#include #include #include #include "config.h" #include "mail2sms.h" #include "http.h" #include "strings.h" // Function analyze_mail() {{{ void analyze_mail(char *str) { char *pom; if (str == NULL) return; if (str == strstr(str, "> ")) return; // reply part if (str == strstr(str, "From:") && ! g.skipped_header) { strncat(g.text, compress_str(str + strlen("From:")), SMS_LEN - strlen(g.text)); strncat(g.text, SMS_SEPARATOR, SMS_LEN - strlen(g.text)); g.text[SMS_LEN] = '\0'; g.skipped_header = 0; g.is_header = 1; return; } if (str == strstr(str, "Subject:") && ! g.skipped_header) { strncat(g.text, compress_str(str + strlen("Subject:")), SMS_LEN - strlen(g.text)); strncat(g.text, SMS_SEPARATOR, SMS_LEN - strlen(g.text)); g.text[SMS_LEN] = '\0'; g.skipped_header = 0; g.is_header = 1; return; } pom = (char *) malloc((strlen(str)+1)*sizeof(char)); strcpy(pom, str); strtolower(pom); if (pom == strstr(pom, "content-transfer-encoding: ") && g.is_header) { if (pom == strstr(pom, "content-transfer-encoding: 8bit") || pom == strstr(pom, "content-transfer-encoding:" " 7bit")) { } else { fprintf(stderr, "NO SMS SEND: '%s'\n", str); my_free(pom); void_read_at_exit(); exit(0); } } if (pom == strstr(pom, "content-type: ") && g.is_header&&1) { if (pom != strstr(pom, "content-type: text/plain;")) { fprintf(stderr, "NO SMS SEND: '%s'\n", str); my_free(pom); void_read_at_exit(); exit(0); } } my_free(pom); if (str == strstr(str, "---------- Forwarded message ----------")) { g.is_header=1; g.skipped_header=0; g.is_forwarded=1; return; } if ((! strcmp(str,"\n")) && g.is_header) { fprintf(stderr, "END OF HEADER\n"); g.is_header=0; g.skipped_header=1; return; } if (g.skipped_header) { add_str_to_sms(str); return; } return; } // }}} /* Modeline for ViM {{{1 * vim:set ts=4: * vim600:fdm=marker fdl=0 fdc=3: * }}}1 */