X-Git-Url: http://git.eversberg.eu/gitweb.cgi?p=lcr.git;a=blobdiff_plain;f=mail.c;h=0e34b7719ce73fcd6d41dd247f984d7f0d82cf70;hp=d4c6441e76815f32fda6414ba840363121fa3047;hb=034d3a91404addedc1c7a3494862c79532b0b878;hpb=2ed0fee489c37a6e2d4473f6185ebbe3e746ac11 diff --git a/mail.c b/mail.c index d4c6441..0e34b77 100644 --- a/mail.c +++ b/mail.c @@ -9,19 +9,9 @@ ** ** \*****************************************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include -//#include #include "main.h" -static char *months[] = { +static const char *months[] = { "January", "February", "March", "April", "Mai", "June", "July", "August", "September", "October", "November", "December" }; @@ -74,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; } @@ -88,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; } @@ -112,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"); @@ -124,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(iemail, vbox_email); @@ -210,8 +187,7 @@ void send_mail(char *filename, char *callerid, char *callerintern, char *callern SCPY(arg->callername, 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; }