From 2fc80ab754daf92c08b1830e0c25ddf312cb433e Mon Sep 17 00:00:00 2001 From: Michiel Broek Date: Sat, 12 Jun 2004 19:09:27 +0000 Subject: [PATCH] A failing post will now return non-zero error --- ChangeLog | 2 ++ mbfido/mbmsg.c | 3 ++- mbfido/post.c | 20 ++++++++++---------- mbfido/post.h | 4 ++-- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3e7a6974..31861da2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -14,6 +14,8 @@ v0.61.0 06-Jun-2004. Added checks in the mbmsg post command if the To parameter has the correct syntax for netmail and all other areas. Fixed parameter count if post is used with the -q option. + Will now return a non-zero error if the post() function + failed. mbout: Prepared for ICM flag (FSP-1033). diff --git a/mbfido/mbmsg.c b/mbfido/mbmsg.c index 6b2cf1a3..0c71753c 100644 --- a/mbfido/mbmsg.c +++ b/mbfido/mbmsg.c @@ -168,7 +168,8 @@ int main(int argc, char **argv) } if (do_post) { - Post(too, tarea, subj, mfile, flavor); + if (Post(too, tarea, subj, mfile, flavor)) + die(MBERR_GENERAL); } die(MBERR_OK); diff --git a/mbfido/post.c b/mbfido/post.c index 2f5a2d18..6a284512 100644 --- a/mbfido/post.c +++ b/mbfido/post.c @@ -41,7 +41,7 @@ extern int do_quiet; /* Suppress screen output */ -void Post(char *To, long Area, char *Subj, char *File, char *Flavor) +int Post(char *To, long Area, char *Subj, char *File, char *Flavor) { int i, rc = FALSE; char *aka, *temp, *sAreas; @@ -63,7 +63,7 @@ void Post(char *To, long Area, char *Subj, char *File, char *Flavor) WriteError("$Can't open %s", File); if (!do_quiet) printf("Can't open \"%s\"\n", File); - return; + return -1; } sAreas = calloc(PATH_MAX, sizeof(char)); @@ -72,7 +72,7 @@ void Post(char *To, long Area, char *Subj, char *File, char *Flavor) WriteError("$Can't open %s", sAreas); free(sAreas); fclose(tp); - return; + return -1; } fread(&msgshdr, sizeof(msgshdr), 1, fp); @@ -90,14 +90,14 @@ void Post(char *To, long Area, char *Subj, char *File, char *Flavor) if (rc == FALSE) { fclose(fp); fclose(tp); - return; + return -1; } if (!msgs.Active) { WriteError("Area %s not active", msgs.Name); fclose(fp); fclose(tp); - return; + return -1; } /* @@ -112,7 +112,7 @@ void Post(char *To, long Area, char *Subj, char *File, char *Flavor) printf("No address in \"%s\" and area is netmail\n", To); fclose(fp); fclose(tp); - return; + return -1; } } else { if ((strchr(To, '@')) || (strstr(To, (char *)".n")) || (strstr(To, (char *)".z"))) { @@ -121,7 +121,7 @@ void Post(char *To, long Area, char *Subj, char *File, char *Flavor) printf("Address present in \"%s\" and area is not netmail\n", To); fclose(fp); fclose(tp); - return; + return -1; } } @@ -129,7 +129,7 @@ void Post(char *To, long Area, char *Subj, char *File, char *Flavor) WriteError("Can't open %s", msgs.Base); fclose(fp); fclose(tp); - return; + return -1; } if (!Msg_Lock(30L)) { @@ -137,7 +137,7 @@ void Post(char *To, long Area, char *Subj, char *File, char *Flavor) Msg_Close(); fclose(fp); fclose(tp); - return; + return -1; } tt = time(NULL); @@ -268,7 +268,7 @@ void Post(char *To, long Area, char *Subj, char *File, char *Flavor) free(temp); Msg_Close(); - return; + return 0; } diff --git a/mbfido/post.h b/mbfido/post.h index abab25f5..440bf7b7 100644 --- a/mbfido/post.h +++ b/mbfido/post.h @@ -1,9 +1,9 @@ #ifndef _POST_H #define _POST_H +/* $Id$ */ -void Post(char *, long, char *, char *, char *); /* Post a Message */ +int Post(char *, long, char *, char *, char *); /* Post a Message */ #endif -