fix possible crash on user deletion
[srvx.git] / src / main-common.c
index e5d61161e2ed887f83890106792ed6a25018dd3e..85b9dd34a2dd3395658562eaee9fad9280b4af68 100644 (file)
@@ -1,6 +1,8 @@
 extern FILE *replay_file;
 
-time_t boot_time, burst_begin, now;
+unsigned long boot_time;
+unsigned long burst_begin;
+unsigned long now;
 unsigned long burst_length;
 struct log_type *MAIN_LOG;
 
@@ -51,6 +53,7 @@ static const struct message_entry msgtab[] = {
     { "MSG_STUPID_ACCESS_CHANGE", "Please ask someone $belse$b to demote you." },
     { "MSG_NO_SEARCH_ACCESS", "You do not have enough access to search based on $b%s$b." },
     { "MSG_INVALID_CRITERIA", "$b%s$b is an invalid search criteria." },
+    { "MSG_INVALID_FIELD", "$b%s$b is an invalid search field." },
     { "MSG_MATCH_COUNT", "Found $b%u$b matches." },
     { "MSG_NO_MATCHES", "Nothing matched the criteria of your search." },
     { "MSG_TOPIC_UNKNOWN", "No help on that topic." },
@@ -59,8 +62,8 @@ static const struct message_entry msgtab[] = {
     { "MSG_DB_UNKNOWN", "I do not know of a database named %s." },
     { "MSG_DB_IS_MONDO", "Database %s is in the \"mondo\" database and cannot be written separately." },
     { "MSG_DB_WRITE_ERROR", "Error while writing database %s." },
-    { "MSG_DB_WROTE_DB", "Wrote database %s (in "FMT_TIME_T".%06lu seconds)." },
-    { "MSG_DB_WROTE_ALL", "Wrote all databases (in "FMT_TIME_T".%06lu seconds)." },
+    { "MSG_DB_WROTE_DB", "Wrote database %s (in %lu.%06lu seconds)." },
+    { "MSG_DB_WROTE_ALL", "Wrote all databases (in %lu.%06lu seconds)." },
     { "MSG_AND", "and" },
     { "MSG_0_SECONDS", "0 seconds" },
     { "MSG_YEAR", "year" },
@@ -275,7 +278,7 @@ uplink_select(char *name)
 
             if(max_cycles && (cManager.cycles >= max_cycles))
             {
-                log_module(MAIN_LOG, LOG_FATAL, "Maximum uplink list cycles exceeded; giving up.");
+                log_module(MAIN_LOG, LOG_ERROR, "Maximum uplink list cycles exceeded; giving up.");
                 exit(1);
             }
 
@@ -312,7 +315,7 @@ uplink_select(char *name)
            over. Use the current uplink if possible. */
         if(!cManager.uplink || cManager.uplink->flags & UPLINK_UNAVAILABLE)
         {
-            log_module(MAIN_LOG, LOG_FATAL, "All available uplinks exhausted; giving up.");
+            log_module(MAIN_LOG, LOG_ERROR, "All available uplinks exhausted; giving up.");
             exit(1);
         }
 
@@ -439,6 +442,11 @@ conf_globals(void)
     if (info && (info[0] == '.'))
         info = NULL;
     init_chanserv(info);
+    
+    info = conf_get_data("services/spamserv/nick", RECDB_QSTRING);
+    if (info && (info[0] == '.'))
+        info = NULL;
+    init_spamserv(info);
 
     god_policer_params = policer_params_new();
     if ((dict = conf_get_data("policers/commands-god", RECDB_OBJECT))) {
@@ -529,6 +537,51 @@ conf_rlimits(void)
 
 #endif
 
+static void
+usage(char *exe_name)
+{
+    /* We can assume we have getopt_long(). */
+    printf("Usage: %s [-c config] [-r log] [-d] [-f] [-v|-h]\n"
+           " -c, --config         selects a different configuration file.\n"
+           " -d, --debug          enables debug mode.\n"
+           " -f, --foreground     run srvx in the foreground.\n"
+           " -h, --help           prints this usage message.\n"
+           " -k, --check          checks the configuration file's syntax.\n"
+           " -r, --replay         replay a log file (for debugging).\n"
+           " -v, --version        prints this program's version.\n"
+           , exe_name);
+}
+
+static void
+version()
+{
+    printf("    --------------------------------------------------\n"
+           "    - "PACKAGE_STRING" ("CODENAME"), Built: " __DATE__ ", " __TIME__".\n"
+           "    - Copyright (C) 2000 - 2007, srvx Development Team\n"
+           "    - Version tag %s\n"
+           "    --------------------------------------------------\n",
+           git_version);
+}
+
+static void
+license()
+{
+    printf("\n"
+           "This program is free software; you can redistribute it and/or modify\n"
+           "it under the terms of the GNU General Public License as published by\n"
+           "the Free Software Foundation; either version 2 of the License, or\n"
+           "(at your option) any later version.\n"
+           "\n"
+           "This program is distributed in the hope that it will be useful,\n"
+           "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
+           "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n"
+           "GNU General Public License for more details.\n"
+           "\n"
+           "You should have received a copy of the GNU General Public License\n"
+           "along with this program; if not, write to the Free Software\n"
+           "Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\n\n");
+}
+
 void main_shutdown(void)
 {
     struct uplinkNode *ul, *ul_next;