X-Git-Url: https://git.exim.org/users/heiko/exim.git/blobdiff_plain/a2da3176aa39ec9aa5ae495e5a6d533477f871aa..f9fc9427579982838daf3e50c1d14b69bf59a43e:/src/exim_monitor/em_menu.c?ds=sidebyside diff --git a/src/exim_monitor/em_menu.c b/src/exim_monitor/em_menu.c index ccdfa05ba..31ce1a371 100644 --- a/src/exim_monitor/em_menu.c +++ b/src/exim_monitor/em_menu.c @@ -2,7 +2,7 @@ * Exim Monitor * *************************************************/ -/* Copyright (c) University of Cambridge 1995 - 2016 */ +/* Copyright (c) University of Cambridge 1995 - 2018 */ /* See the file NOTICE for conditions of use and distribution. */ @@ -133,32 +133,33 @@ menu_is_up = FALSE; * Display the message log * *************************************************/ -static void msglogAction(Widget w, XtPointer client_data, XtPointer call_data) +static void +msglogAction(Widget w, XtPointer client_data, XtPointer call_data) { int i; -uschar buffer[256]; -Widget text = text_create((uschar *)client_data, text_depth); -FILE *f = NULL; +Widget text = text_create(US client_data, text_depth); +uschar * fname = NULL; +FILE * f = NULL; w = w; /* Keep picky compilers happy */ call_data = call_data; /* End up with the split version, so message looks right when non-exist */ -for (i = 0; i < (spool_is_split? 2:1); i++) +for (i = 0; i < (spool_is_split ? 2:1); i++) { - message_subdir[0] = (i != 0)? ((uschar *)client_data)[5] : 0; - snprintf(CS buffer, sizeof(buffer), "%s/msglog/%s/%s/%s", - spool_directory, queue_name, message_subdir, (uschar *)client_data); - if ((f = fopen(CS buffer, "r"))) + message_subdir[0] = i != 0 ? (US client_data)[5] : 0; + fname = spool_fname(US"msglog", message_subdir, US client_data, US""); + if ((f = fopen(CS fname, "r"))) break; } -if (f == NULL) - text_showf(text, "%s: %s\n", buffer, strerror(errno)); +if (!f) + text_showf(text, "%s: %s\n", fname, strerror(errno)); else { - while (Ufgets(buffer, 256, f) != NULL) text_show(text, buffer); + uschar buffer[256]; + while (Ufgets(buffer, sizeof(buffer), f) != NULL) text_show(text, buffer); fclose(f); } } @@ -169,11 +170,11 @@ else * Display the message body * *************************************************/ -static void bodyAction(Widget w, XtPointer client_data, XtPointer call_data) +static void +bodyAction(Widget w, XtPointer client_data, XtPointer call_data) { int i; -uschar buffer[256]; -Widget text = text_create((uschar *)client_data, text_depth); +Widget text = text_create(US client_data, text_depth); FILE *f = NULL; w = w; /* Keep picky compilers happy */ @@ -181,10 +182,10 @@ call_data = call_data; for (i = 0; i < (spool_is_split? 2:1); i++) { - message_subdir[0] = i != 0 ? ((uschar *)client_data)[5] : 0; - snprintf(CS buffer, sizeof(buffer), "%s/input/%s/%s/%s-D", - spool_directory, queue_name, message_subdir, (uschar *)client_data); - if ((f = fopen(CS buffer, "r"))) + uschar * fname; + message_subdir[0] = i != 0 ? (US client_data)[5] : 0; + fname = spool_fname(US"input", message_subdir, US client_data, US"-D"); + if ((f = fopen(CS fname, "r"))) break; } @@ -192,8 +193,10 @@ if (f == NULL) text_showf(text, "Failed to open file: %s\n", strerror(errno)); else { + uschar buffer[256]; int count = 0; - while (Ufgets(buffer, 256, f) != NULL) + + while (Ufgets(buffer, sizeof(buffer), f) != NULL) { text_show(text, buffer); count += Ustrlen(buffer); @@ -331,9 +334,9 @@ if (!delivery) if (rc == 0 && Ustrcmp(action + Ustrlen(action) - 4, "-Mes") == 0) { queue_item *q = find_queue(id, queue_noop, 0); - if (q != NULL) + if (q) { - if (q->sender != NULL) store_free(q->sender); + if (q->sender) store_free(q->sender); q->sender = store_malloc(Ustrlen(address_arg) + 1); Ustrcpy(q->sender, address_arg); } @@ -408,7 +411,7 @@ static void deliverAction(Widget w, XtPointer client_data, XtPointer call_data) { w = w; /* Keep picky compilers happy */ call_data = call_data; -ActOnMessage((uschar *)client_data, US"-v -M", US""); +ActOnMessage(US client_data, US"-v -M", US""); } @@ -421,7 +424,7 @@ static void freezeAction(Widget w, XtPointer client_data, XtPointer call_data) { w = w; /* Keep picky compilers happy */ call_data = call_data; -ActOnMessage((uschar *)client_data, US"-Mf", US""); +ActOnMessage(US client_data, US"-Mf", US""); } @@ -434,7 +437,7 @@ static void thawAction(Widget w, XtPointer client_data, XtPointer call_data) { w = w; /* Keep picky compilers happy */ call_data = call_data; -ActOnMessage((uschar *)client_data, US"-Mt", US""); +ActOnMessage(US client_data, US"-Mt", US""); } @@ -621,7 +624,7 @@ static void giveupAction(Widget w, XtPointer client_data, XtPointer call_data) { w = w; /* Keep picky compilers happy */ call_data = call_data; -ActOnMessage((uschar *)client_data, US"-v -Mg", US""); +ActOnMessage(US client_data, US"-v -Mg", US""); } @@ -634,7 +637,7 @@ static void removeAction(Widget w, XtPointer client_data, XtPointer call_data) { w = w; /* Keep picky compilers happy */ call_data = call_data; -ActOnMessage((uschar *)client_data, US"-Mrm", US""); +ActOnMessage(US client_data, US"-Mrm", US""); } @@ -647,7 +650,7 @@ static void headersAction(Widget w, XtPointer client_data, XtPointer call_data) { uschar buffer[256]; header_line *h, *next; -Widget text = text_create((uschar *)client_data, text_depth); +Widget text = text_create(US client_data, text_depth); void *reset_point; w = w; /* Keep picky compilers happy */ @@ -658,7 +661,7 @@ Then use Exim's function to read the header. */ reset_point = store_get(0); -sprintf(CS buffer, "%s-H", (uschar *)client_data); +sprintf(CS buffer, "%s-H", US client_data); if (spool_read_header(buffer, TRUE, FALSE) != spool_read_OK) { if (errno == ERRNO_SPOOLFORMAT) @@ -677,7 +680,7 @@ if (spool_read_header(buffer, TRUE, FALSE) != spool_read_OK) if (sender_address != NULL) { - text_showf(text, "%s sender: <%s>\n", sender_local? "Local" : "Remote", + text_showf(text, "%s sender: <%s>\n", f.sender_local ? "Local" : "Remote", sender_address); }