Fix service triggers; allow service hostname configuration; fix glitches
[srvx.git] / src / opserv.c
index fca715be2e54cd0d3dc8303598abcf1522c0c1fa..a7eca7069f7624c3cb73b4669cb5105e8a6912f0 100644 (file)
@@ -1,11 +1,12 @@
 /* opserv.c - IRC Operator assistance service
  * Copyright 2000-2004 srvx Development Team
  *
- * This program is free software; you can redistribute it and/or modify
+ * This file is part of srvx.
+ *
+ * srvx is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.  Important limitations are
- * listed in the COPYING file that accompanies this software.
+ * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -13,7 +14,8 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program; if not, email srvx-maintainers@srvx.net.
+ * along with srvx; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
  */
 
 #include "conf.h"
@@ -918,7 +920,7 @@ static MODCMD_FUNC(cmd_join)
         return 0;
     } else {
         struct mod_chanmode change;
-        change.modes_set = change.modes_clear = 0;
+        mod_chanmode_init(&change);
         change.argc = 1;
         change.args[0].mode = MODE_CHANOP;
         change.args[0].member = AddChannelUser(bot, channel);
@@ -1191,7 +1193,7 @@ static MODCMD_FUNC(cmd_whois)
 #endif
     reply("OSMSG_WHOIS_SERVER", target->uplink->name);
     reply("OSMSG_WHOIS_ACCOUNT", (target->handle_info ? target->handle_info->handle : "Not authenticated"));
-    intervalString(buffer, now - target->timestamp);
+    intervalString(buffer, now - target->timestamp, user->handle_info);
     reply("OSMSG_WHOIS_NICK_AGE", buffer);
     if (target->channels.used <= MAX_CHANNELS_WHOIS)
        opserv_ison(user, target, "OSMSG_WHOIS_CHANNELS");
@@ -1393,8 +1395,9 @@ static MODCMD_FUNC(cmd_stats_network2) {
 #endif
         tbl.contents[nn][1] = buffer;
         ofs = strlen(buffer) + 1;
-        intervalString(buffer + ofs, now - server->link);
-        if (server->self_burst) strcat(buffer + ofs, " Bursting");
+        intervalString(buffer + ofs, now - server->link, user->handle_info);
+        if (server->self_burst)
+            strcat(buffer + ofs, " Bursting");
         tbl.contents[nn][2] = buffer + ofs;
         nn++;
     }
@@ -1426,9 +1429,9 @@ static MODCMD_FUNC(cmd_stats_trusted) {
         th = dict_find(opserv_trusted_hosts, argv[1], NULL);
         if (th) {
             if (th->issued)
-                intervalString(issued, now - th->issued);
+                intervalString(issued, now - th->issued, user->handle_info);
             if (th->expires)
-                intervalString(length, th->expires - now);
+                intervalString(length, th->expires - now, user->handle_info);
             if (th->limit)
                 sprintf(limit, "limit %lu", th->limit);
             reply("OSMSG_HOST_IS_TRUSTED",
@@ -1446,9 +1449,9 @@ static MODCMD_FUNC(cmd_stats_trusted) {
         for (it = dict_first(opserv_trusted_hosts); it; it = iter_next(it)) {
             th = iter_data(it);
             if (th->issued)
-                intervalString(issued, now - th->issued);
+                intervalString(issued, now - th->issued, user->handle_info);
             if (th->expires)
-                intervalString(length, th->expires - now);
+                intervalString(length, th->expires - now, user->handle_info);
             if (th->limit)
                 sprintf(limit, "limit %lu", th->limit);
             reply("OSMSG_HOST_IS_TRUSTED", iter_key(it),
@@ -1489,7 +1492,7 @@ static MODCMD_FUNC(cmd_stats_uptime) {
             clocks_per_sec = CLOCKS_PER_SEC;
         }
     }
-    intervalString(uptime, time(NULL)-boot_time);
+    intervalString(uptime, time(NULL)-boot_time, user->handle_info);
     times(&buf);
     reply("OSMSG_UPTIME_STATS",
           uptime, lines_processed,
@@ -1538,8 +1541,10 @@ static MODCMD_FUNC(cmd_stats_gags) {
     table.contents[0][3] = "Reason";
     for (nn=1, gag=gagList; gag; nn++, gag=gag->next) {
         char expstr[INTERVALLEN];
-        if (gag->expires) intervalString(expstr, gag->expires - now);
-        else strcpy(expstr, "Never");
+        if (gag->expires)
+            intervalString(expstr, gag->expires - now, user->handle_info);
+        else
+            strcpy(expstr, "Never");
         table.contents[nn] = calloc(table.width, sizeof(char*));
         table.contents[nn][0] = gag->mask;
         table.contents[nn][1] = gag->owner;
@@ -2088,7 +2093,7 @@ static MODCMD_FUNC(cmd_addtrust)
     unsigned long interval;
     char *reason, *tmp;
     struct in_addr tmpaddr;
-    int count;
+    unsigned int count;
 
     if (dict_find(opserv_trusted_hosts, argv[1], NULL)) {
         reply("OSMSG_ALREADY_TRUSTED", argv[1]);
@@ -2101,7 +2106,7 @@ static MODCMD_FUNC(cmd_addtrust)
     }
 
     count = strtoul(argv[2], &tmp, 10);
-    if (!count || *tmp != '\0') {
+    if (*tmp != '\0') {
         reply("OSMSG_BAD_NUMBER", argv[2]);
         return 0;
     }
@@ -2123,7 +2128,7 @@ static MODCMD_FUNC(cmd_edittrust)
     unsigned long interval;
     struct trusted_host *th;
     char *reason, *tmp;
-    int count;
+    unsigned int count;
 
     th = dict_find(opserv_trusted_hosts, argv[1], NULL);
     if (!th) {
@@ -4015,7 +4020,7 @@ init_opserv(const char *nick)
 {
     OS_LOG = log_register_type("OpServ", "file:opserv.log");
     if (nick)
-        opserv = AddService(nick, "Oper Services");
+        opserv = AddService(nick, "Oper Services", NULL);
     conf_register_reload(opserv_conf_read);
 
     memset(level_strings, 0, sizeof(level_strings));
@@ -4126,7 +4131,7 @@ init_opserv(const char *nick)
     opserv_db_init();
     saxdb_register("OpServ", opserv_saxdb_read, opserv_saxdb_write);
     if (nick)
-        service_register(opserv, '?');
+        service_register(opserv)->trigger = '?';
 
     reg_exit_func(opserv_db_cleanup);
     message_register_table(msgtab);