| verzia 1.16, 2001/10/02 14:46:14 |
verzia 1.17, 2001/10/02 16:24:47 |
|
|
| /* |
/* |
| * Author: rajo <host8@kepler.fmph.uniba.sk> |
* Author: rajo <host8@kepler.fmph.uniba.sk> |
| * $Log$ |
* $Log$ |
| |
* Revision 1.17 2001/10/02 16:24:47 jombik9 |
| |
* Added suport for Subject header. |
| |
* Removed white characters in SMS message. |
| |
* Minor bugfixies & lots of improvements. |
| |
* Unneccessary files removed from CVS repository. |
| |
* |
| * Revision 1.16 2001/10/02 14:46:14 host8 |
* Revision 1.16 2001/10/02 14:46:14 host8 |
| * Patched syntax bug (bad global substitution). |
* Patched syntax bug (bad global substitution). |
| * |
* |
| Riadok 149 void analyze_mail(char *str) |
|
| Riadok 155 void analyze_mail(char *str) |
|
| |
|
| if (str == NULL) return; |
if (str == NULL) return; |
| if (str == strstr(str, "> ")) return; // reply part |
if (str == strstr(str, "> ")) return; // reply part |
| if (str == strstr(str, "From ")) { |
|
| j=-1; |
if (str == strstr(str, "From:") && ! g.skipped_header) { |
| while (++j,str[j]!=' '&&str[j]!='\0'); |
strncat(g.text, |
| while (++j,str[j]!=' '&&str[j]!='\0'); |
compress_str(str + strlen("From:")), |
| strncat(g.text, str, j+1); |
SMS_LEN - strlen(g.text)); |
| g.is_header=1; |
strncat(g.text, SMS_SEPARATOR, SMS_LEN - strlen(g.text)); |
| g.skipped_header=0; |
g.text[SMS_LEN] = '\0'; |
| |
|
| |
g.skipped_header = 0; |
| |
g.is_header = 1; |
| return; |
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)); |
pom = (char *) malloc((strlen(str)+1)*sizeof(char)); |
| strcpy(pom, str); |
strcpy(pom, str); |
| strtolower(pom); |
strtolower(pom); |
| if (pom == strstr(pom, "content-transfer-encoding: ") && |
if (pom == strstr(pom, "content-transfer-encoding: ") |
| g.is_header&&1) { |
&& g.is_header) { |
| if (pom == strstr(pom, "content-transfer-encoding: 8bit") || |
if (pom == strstr(pom, "content-transfer-encoding: 8bit") |
| pom == strstr(pom, "content-transfer-encoding:" |
|| pom == strstr(pom, "content-transfer-encoding:" |
| " 7bit")) { |
" 7bit")) { |
| } |
} |
| else { |
else { |
| Riadok 174 void analyze_mail(char *str) |
|
| Riadok 196 void analyze_mail(char *str) |
|
| exit(0); |
exit(0); |
| } |
} |
| } |
} |
| |
|
| if (pom == strstr(pom, "content-type: ") && g.is_header&&1) { |
if (pom == strstr(pom, "content-type: ") && g.is_header&&1) { |
| if (pom != strstr(pom, "content-type: text/plain;")) { |
if (pom != strstr(pom, "content-type: text/plain;")) { |
| fprintf(stderr, "NO SMS SEND: '%s'\n", str); |
fprintf(stderr, "NO SMS SEND: '%s'\n", str); |
| Riadok 182 void analyze_mail(char *str) |
|
| Riadok 205 void analyze_mail(char *str) |
|
| exit(0); |
exit(0); |
| } |
} |
| } |
} |
| |
|
| free(pom); |
free(pom); |
| |
|
| if (str == strstr(str, "---------- Forwarded message ----------")) { |
if (str == strstr(str, "---------- Forwarded message ----------")) { |
| g.is_header=1; |
g.is_header=1; |
| g.skipped_header=0; |
g.skipped_header=0; |
| g.is_forwarded=1; |
g.is_forwarded=1; |
| return; |
return; |
| } |
} |
| if ((! strcmp(str,"\n")) && g.is_header&&1) { |
|
| |
if ((! strcmp(str,"\n")) && g.is_header) { |
| fprintf(stderr, "END OF HEADER\n"); |
fprintf(stderr, "END OF HEADER\n"); |
| g.is_header=0; |
g.is_header=0; |
| g.skipped_header=1; |
g.skipped_header=1; |
| return; |
return; |
| } |
} |
| |
|
| if (g.skipped_header) { |
if (g.skipped_header) { |
| add_str_to_sms(str); |
add_str_to_sms(str); |
| /* compress_str(str); |
|
| if (strlen(g.text) < SMS_LEN) { |
|
| j=0; |
|
| while (strlen(g.text)<SMS_LEN && *(str+j)!='\0') { |
|
| if (isalnum(*(str+j))) { |
|
| strncat(g.text, (str+j), 1); |
|
| } |
|
| else { |
|
| if ((SMS_LEN-strlen(g.text)) > 2) { |
|
| strcat(g.text, "%"); |
|
| pom = hexa(*(str+j)); |
|
| strcat(g.text, pom); |
|
| free(pom); |
|
| } |
|
| else return; |
|
| } |
|
| j++; |
|
| } |
|
| } |
|
| */ |
|
| return; |
return; |
| } |
} |
| |
|
| return; |
return; |
| } // }}} |
} // }}} |
| // Function print_usage() {{{ |
// Function print_usage() {{{ |