A failing post will now return non-zero error

This commit is contained in:
Michiel Broek 2004-06-12 19:09:27 +00:00
parent 9accf392ed
commit 2fc80ab754
4 changed files with 16 additions and 13 deletions

View File

@ -14,6 +14,8 @@ v0.61.0 06-Jun-2004.
Added checks in the mbmsg post command if the To parameter has Added checks in the mbmsg post command if the To parameter has
the correct syntax for netmail and all other areas. the correct syntax for netmail and all other areas.
Fixed parameter count if post is used with the -q option. Fixed parameter count if post is used with the -q option.
Will now return a non-zero error if the post() function
failed.
mbout: mbout:
Prepared for ICM flag (FSP-1033). Prepared for ICM flag (FSP-1033).

View File

@ -168,7 +168,8 @@ int main(int argc, char **argv)
} }
if (do_post) { if (do_post) {
Post(too, tarea, subj, mfile, flavor); if (Post(too, tarea, subj, mfile, flavor))
die(MBERR_GENERAL);
} }
die(MBERR_OK); die(MBERR_OK);

View File

@ -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; int i, rc = FALSE;
char *aka, *temp, *sAreas; 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); WriteError("$Can't open %s", File);
if (!do_quiet) if (!do_quiet)
printf("Can't open \"%s\"\n", File); printf("Can't open \"%s\"\n", File);
return; return -1;
} }
sAreas = calloc(PATH_MAX, sizeof(char)); 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); WriteError("$Can't open %s", sAreas);
free(sAreas); free(sAreas);
fclose(tp); fclose(tp);
return; return -1;
} }
fread(&msgshdr, sizeof(msgshdr), 1, fp); 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) { if (rc == FALSE) {
fclose(fp); fclose(fp);
fclose(tp); fclose(tp);
return; return -1;
} }
if (!msgs.Active) { if (!msgs.Active) {
WriteError("Area %s not active", msgs.Name); WriteError("Area %s not active", msgs.Name);
fclose(fp); fclose(fp);
fclose(tp); 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); printf("No address in \"%s\" and area is netmail\n", To);
fclose(fp); fclose(fp);
fclose(tp); fclose(tp);
return; return -1;
} }
} else { } else {
if ((strchr(To, '@')) || (strstr(To, (char *)".n")) || (strstr(To, (char *)".z"))) { 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); printf("Address present in \"%s\" and area is not netmail\n", To);
fclose(fp); fclose(fp);
fclose(tp); 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); WriteError("Can't open %s", msgs.Base);
fclose(fp); fclose(fp);
fclose(tp); fclose(tp);
return; return -1;
} }
if (!Msg_Lock(30L)) { if (!Msg_Lock(30L)) {
@ -137,7 +137,7 @@ void Post(char *To, long Area, char *Subj, char *File, char *Flavor)
Msg_Close(); Msg_Close();
fclose(fp); fclose(fp);
fclose(tp); fclose(tp);
return; return -1;
} }
tt = time(NULL); tt = time(NULL);
@ -268,7 +268,7 @@ void Post(char *To, long Area, char *Subj, char *File, char *Flavor)
free(temp); free(temp);
Msg_Close(); Msg_Close();
return; return 0;
} }

View File

@ -1,9 +1,9 @@
#ifndef _POST_H #ifndef _POST_H
#define _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 #endif