]> code.citadel.org Git - citadel.git/blobdiff - citadel/internetmail.c
fix all the <time.h> vs. <sys/time.h> issues, hopefully
[citadel.git] / citadel / internetmail.c
index d0471d664eca9b32019adefd22ec25b75e64ba4b..c2aba231d83a60b7ccca6cdb2bbb12e27c48ef4e 100644 (file)
@@ -1,4 +1,6 @@
 /*
+ * $Id$
+ *
  * Internet mail configurator for Citadel/UX
  * see copyright.doc for copyright information
  *
@@ -8,7 +10,18 @@
 #include <unistd.h>
 #include <stdio.h>
 #include <fcntl.h>
-#include <time.h>
+
+#if TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# if HAVE_SYS_TIME_H
+#  include <sys/time.h>
+# else
+#  include <time.h>
+# endif
+#endif
+
 #include <string.h>
 #include <ctype.h>
 #include <syslog.h>
@@ -27,14 +40,19 @@ extern char GW_DOMAIN[128];
 extern char TABLEFILE[128];
 extern int RUN_NETPROC;
 
-void StripLeadingAndTrailingWhitespace(char *str) {
-       if (strlen(str) == 0) return;
-       while (isspace(str[0])) strcpy(str, &str[1]);
-       while (isspace(str[strlen(str)-1])) str[strlen(str)-1] = 0;
-       }
+void StripLeadingAndTrailingWhitespace(char *str)
+{
+       if (strlen(str) == 0)
+               return;
+       while (isspace(str[0]))
+               strcpy(str, &str[1]);
+       while (isspace(str[strlen(str) - 1]))
+               str[strlen(str) - 1] = 0;
+}
 
-void LoadInternetConfig() {
-       char ParamName[256], ParamValue[256], buf[256];
+void LoadInternetConfig(void)
+{
+       char ParamName[SIZ], ParamValue[SIZ], buf[SIZ];
        FILE *conf;
        int a, eqpos;
 
@@ -43,23 +61,23 @@ void LoadInternetConfig() {
        if (conf == NULL) {
                syslog(LOG_NOTICE, "Couldn't load internetmail.config");
                exit(1);
-               }
-
-       while (fgets(buf, 256, conf) != NULL) {
-               if (strlen(buf) > 0) buf[strlen(buf) - 1] = 0;
+       }
+       while (fgets(buf, sizeof buf, conf) != NULL) {
+               if (strlen(buf) > 0)
+                       buf[strlen(buf) - 1] = 0;
                strcpy(ParamName, "");
                strcpy(ParamValue, "");
                if (buf[0] != '#') {
                        eqpos = (-1);
-                       for (a=strlen(buf); a>=0; --a) {
-                               if (buf[a] == '=') eqpos = a;
-                               }
+                       for (a = strlen(buf); a >= 0; --a) {
+                               if (buf[a] == '=')
+                                       eqpos = a;
+                       }
                        if (eqpos >= 0) {
                                strcpy(ParamName, buf);
                                ParamName[eqpos] = 0;
-                               strcpy(ParamValue, &buf[eqpos+1]);
-                               }
-
+                               strcpy(ParamValue, &buf[eqpos + 1]);
+                       }
                        StripLeadingAndTrailingWhitespace(ParamName);
                        StripLeadingAndTrailingWhitespace(ParamValue);
 
@@ -77,27 +95,29 @@ void LoadInternetConfig() {
                                strcpy(TABLEFILE, ParamValue);
                        if (!strcasecmp(ParamName, "deliver local"))
                                strcpy(metoo[mecount++], ParamValue);
-                       if (!strcasecmp(ParamName, "run netproc")) 
+                       if (!strcasecmp(ParamName, "run netproc"))
                                RUN_NETPROC = atoi(ParamValue);
-                       }
                }
-       fclose(conf);
        }
+       fclose(conf);
+}
 
 
 /* 
  * returns nonzero if the specified host is listed as local
  */
-int IsHostLocal(char *WhichHost) {
+int IsHostLocal(char *WhichHost)
+{
        int a;
 
-       if (!strcasecmp(WhichHost, FQDN)) return(1);
+       if (!strcasecmp(WhichHost, FQDN))
+               return (1);
 
        if (mecount > 0) {
-               for (a=0; a<mecount; ++a) {
-                       if (!strcasecmp(WhichHost, metoo[a])) return(1);
-                       }
+               for (a = 0; a < mecount; ++a) {
+                       if (!strcasecmp(WhichHost, metoo[a]))
+                               return (1);
                }
-       
-       return(0);
        }
+       return (0);
+}