From: DINH V. H. <ho...@us...> - 2005-01-29 16:19:27
|
Update of /cvsroot/libetpan/etpan-ng/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11388/src Modified Files: etpan-config.c etpan-sender.c Log Message: remove CR when sending mail through command, configuration files for sender changed (we have to put -t explicitely for commands to send mails). Index: etpan-config.c =================================================================== RCS file: /cvsroot/libetpan/etpan-ng/src/etpan-config.c,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- etpan-config.c 16 Dec 2004 12:57:18 -0000 1.21 +++ etpan-config.c 29 Jan 2005 16:19:17 -0000 1.22 @@ -972,6 +972,7 @@ char path[PATH_MAX]; int r; struct etpan_sender_item * item; + char command[PATH_MAX]; snprintf(path, PATH_MAX, "%s/sender", config_path); @@ -1017,8 +1018,10 @@ strncpy(config->default_sender, "sendmail", sizeof(config->default_sender)); + snprintf(command, sizeof(command), "%s -t", ETPAN_DEFAULT_SENDMAIL_PATH); + item = etpan_sender_item_new("sendmail", SENDER_TYPE_COMMAND, - ETPAN_DEFAULT_SENDMAIL_PATH, + command, NULL, 0, NULL, NULL); if (item == NULL) { etpan_sender_config_free(config); Index: etpan-sender.c =================================================================== RCS file: /cvsroot/libetpan/etpan-ng/src/etpan-sender.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- etpan-sender.c 29 Jan 2005 15:46:53 -0000 1.4 +++ etpan-sender.c 29 Jan 2005 16:19:17 -0000 1.5 @@ -490,7 +490,8 @@ char * p; int source_open; int half_close; - + char command[PATH_MAX]; + half_close = 0; r = pipe(fd_input); @@ -514,8 +515,13 @@ dup2(fd_output[1], 1); dup2(fd_output[1], 2); +#if 0 execl(sender->command, sender->command, "-t", NULL); exit(EXIT_FAILURE); +#endif + snprintf(command, sizeof(command), "%s", sender->command); + system(command); + exit(EXIT_SUCCESS); case -1: res = ERROR_COMMAND; @@ -576,8 +582,26 @@ else if (length > 0) { if (FD_ISSET(fd_input[1], &write_fds)) { ssize_t written_bytes; + size_t count; + char * temp_p; - written_bytes = write(fd_input[1], p, length); + /* skip CR if there are CR LF */ + while (* p == '\r') { + p ++; + length --; + } + + count = 0; + temp_p = p; + while (count < length) { + if (* temp_p == '\r') + break; + + temp_p ++; + count ++; + } + + written_bytes = write(fd_input[1], p, count); if (written_bytes < 0) { break; } |