Mailing List Archive

svn commit: rev 20520 - incubator/spamassassin/trunk/spamc
Author: mss
Date: Thu May 27 15:36:33 2004
New Revision: 20520

Modified:
incubator/spamassassin/trunk/spamc/spamc.c
Log:
* 'goto finish' is the way to go because else we miss WSACleanup() on Windows
* Removed a FIXME added by me, added a descriptive comment instead.


Modified: incubator/spamassassin/trunk/spamc/spamc.c
==============================================================================
--- incubator/spamassassin/trunk/spamc/spamc.c (original)
+++ incubator/spamassassin/trunk/spamc/spamc.c Thu May 27 15:36:33 2004
@@ -164,6 +164,13 @@
usg("\n");
}

+/**
+ * Does the command line parsing for argv[].
+ *
+ * Returns EX_OK or EX_NOTSPAM if successful. EX_NOTSPAM is a kludge for
+ * the cases where we want in main to return immediately; we can't exit()
+ * because on Windows WSACleanup() needs to be called.
+ */
int
read_args(int argc, char **argv,
int *max_size, char **username,
@@ -202,11 +209,8 @@
{
int i, j;

- /* FIXME: The sizeof on a yet uninitialized value looks
- * strange -- or is this supposed to be sizeof(char)?
- * sizeof(char) is always 1 though so all this does is
- * causing confusion (if I see this correct)
- * -- mss 2004-05-27
+ /* Allocate memory for the necessary pointers needed to
+ * store the remaining arguments.
*/
exec_argv = malloc(sizeof(*exec_argv) * (argc - optind + 2));
if (exec_argv == NULL)
@@ -304,13 +308,15 @@
}
case 'h':
{
+ if (ret == EX_OK)
+ ret = EX_NOTSPAM;
print_usage();
- exit(ret);
+ return(ret);
}
case 'V':
{
print_version();
- exit(ret);
+ return(EX_NOTSPAM);
}
}
}
@@ -463,9 +469,12 @@
/* Now parse the command line arguments. First, set the defaults. */
max_size = 250 * 1024;
username = NULL;
- if ((ret = read_args(argc, argv, &max_size, &username, &trans)) != EX_OK)
- return ret;
-
+ if ((ret = read_args(argc, argv, &max_size, &username, &trans)) != EX_OK) {
+ if (ret == EX_NOTSPAM )
+ ret = EX_OK;
+ goto finish;
+ }
+
if (username == NULL) {
ret = get_current_user(&username);
if ( ret != EX_OK )