X-Git-Url: https://git.exim.org/users/heiko/exim.git/blobdiff_plain/80fea873648ca2ab2e592999a336c59cf054ab55..55e70e76c861b5c45ae93a45d0a5da12aa849999:/src/exim_monitor/em_menu.c diff --git a/src/exim_monitor/em_menu.c b/src/exim_monitor/em_menu.c index 51a952e99..dc24e3dfa 100644 --- a/src/exim_monitor/em_menu.c +++ b/src/exim_monitor/em_menu.c @@ -133,11 +133,12 @@ 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); +uschar * fname; FILE *f = NULL; w = w; /* Keep picky compilers happy */ @@ -147,18 +148,18 @@ call_data = call_data; for (i = 0; i < (spool_is_split? 2:1); i++) { - message_subdir[0] = (i != 0)? ((uschar *)client_data)[5] : 0; - sprintf(CS buffer, "%s/msglog/%s/%s", spool_directory, message_subdir, - (uschar *)client_data); - f = fopen(CS buffer, "r"); - if (f != NULL) break; + message_subdir[0] = i != 0 ? ((uschar *)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)); + 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,10 +170,10 @@ 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); FILE *f = NULL; @@ -181,19 +182,21 @@ call_data = call_data; for (i = 0; i < (spool_is_split? 2:1); i++) { - message_subdir[0] = (i != 0)? ((uschar *)client_data)[5] : 0; - sprintf(CS buffer, "%s/input/%s/%s-D", spool_directory, message_subdir, - (uschar *)client_data); - f = fopen(CS buffer, "r"); - if (f != NULL) break; + uschar * fname; + message_subdir[0] = i != 0 ? ((uschar *)client_data)[5] : 0; + fname = spool_fname(US"input", message_subdir, US client_data, US"-D"); + if ((f = fopen(CS fname, "r"))) + break; } 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);