diff options
Diffstat (limited to 'blasms.c')
-rw-r--r-- | blasms.c | 36 |
1 files changed, 36 insertions, 0 deletions
@@ -145,6 +145,8 @@ void settelnum(char* telnum, char* sms, int *offsetptr) { int main(int argc, char *argv[]) { /* Telephone number (may contain name)*/ char telnum[100]; + /* Unmodified telephone number length */ + int telnumlen; /* SMS content */ char sms[500]; /* SMS command */ @@ -297,6 +299,40 @@ int main(int argc, char *argv[]) { } replacestr(systemcmd, i, 2, telnum); break; + case 'M': + strcpy(telnum, "pending/"); + strcat(telnum, sms + offset + 1); + + fp = fopen(telnum, "r"); + + if (fp == NULL) { + printf("Error opening message file.\n"); + return 1; + } + + if (fgets(line, 1024, fp) == NULL) { + printf("Error reading message file.\n"); + return 1; + } + + fclose(fp); + + if ((strchrp = strchr(line + offset, ' ')) != NULL) { + remtrailn(line); + strncpy(telnum, line, strchrp - line); + telnum[strchrp - line] = '\0'; + telnumlen = strlen(telnum); + setname(telnum); + } else { + printf("Error, malformed message file.\n"); + return 1; + } + + replacestr(systemcmd, i, 2, telnum); + replacestr(systemcmd, strlen(systemcmd) - 1, 0, ":"); + replacestr(systemcmd, strlen(systemcmd) - 1, 0, line + telnumlen); + + break; } } } |