X-Git-Url: http://git.eversberg.eu/gitweb.cgi?p=lcr.git;a=blobdiff_plain;f=mail.c;h=0e34b7719ce73fcd6d41dd247f984d7f0d82cf70;hp=9acd14573a3f98308d80be62f9e43e1214917fbc;hb=79bd731c0db3e3202cfeed2af3fb217ae744b70f;hpb=0efcf371b4a61fa1376e83d2b7404aeb47a36e26 diff --git a/mail.c b/mail.c index 9acd145..0e34b77 100644 --- a/mail.c +++ b/mail.c @@ -11,7 +11,7 @@ #include "main.h" -static char *months[] = { +static const char *months[] = { "January", "February", "March", "April", "Mai", "June", "July", "August", "September", "October", "November", "December" }; @@ -64,13 +64,11 @@ static void *mail_child(void *arg) PDEBUG(DEBUG_EPOINT, "child process started for sending a mail\n"); /* lower priority to keep pbx running fluently */ - if (options.schedule > 0) - { + if (options.schedule > 0) { memset(&schedp, 0, sizeof(schedp)); schedp.sched_priority = 0; ret = sched_setscheduler(0, SCHED_OTHER, &schedp); - if (ret < 0) - { + if (ret < 0) { PERROR("Scheduling to normal priority failed (errno = %d).\nExitting child process...\n", errno); goto done; } @@ -78,8 +76,7 @@ static void *mail_child(void *arg) /* open process */ SPRINT(command, "%s -f%s %s", SENDMAIL, options.email, email); - if ((ph = popen(command, "w")) < 0) - { + if ((ph = popen(command, "w")) < 0) { PERROR("Cannot send mail using command '%s'\n", command); goto done; } @@ -102,9 +99,8 @@ static void *mail_child(void *arg) fprintf(ph, "\n * date: %s %d %d %d:%02d\n\n", months[mon], mday, year+1900, hour, min); /* attach audio file */ - if (filename[0]) - if ((fh = open(filename, O_RDONLY))) - { + if (filename[0]) { + if ((fh = open(filename, O_RDONLY))) { while(strchr(filename, '/')) filename = strchr(filename, '/')+1; fprintf(ph, "--next_part\n"); @@ -114,23 +110,20 @@ static void *mail_child(void *arg) fprintf(ph, "Content-Transfer-Encoding: base64\nContent-Disposition: inline;\n\tfilename=\"%s\"\n\n", filename); /* stream from disk and encode */ - while(42) - { + while(42) { /* read exactly one line */ cnt = read(fh, rbuf, 54); if (cnt <= 0) break; /* encode */ n = cnt; - while (n%3) - { + while (n%3) { rbuf[n] = 0; n++; } n = n/3; i = 0; - while(icallername, callername); SCPY(arg->terminal, terminal); - if ((pthread_create(&tid, NULL, mail_child, arg)<0)) - { + if ((pthread_create(&tid, NULL, mail_child, arg)<0)) { PERROR("failed to create mail-thread.\n"); return; }