]> jfr.im git - irc/evilnet/x3.git/blobdiff - src/mod-memoserv.c
Finally fixed all those pesky warnings
[irc/evilnet/x3.git] / src / mod-memoserv.c
index 58d1c01c4749266cb6ed8506417a7f8b1e9be4c9..036902a1616fd06e58fd33f5999d8a906a352979 100644 (file)
@@ -44,7 +44,7 @@
 #include "nickserv.h"
 #include "opserv.h"
 #include "saxdb.h"
-#include "sendmail.h"
+#include "mail.h"
 #include "timeq.h"
 
 #define KEY_MAIN_ACCOUNTS "accounts"
@@ -147,9 +147,9 @@ struct userNode *memoserv;
                                      return 0; }
 
 DECLARE_LIST(memoList, struct memo*);
-DEFINE_LIST(memoList, struct memo*);
+DEFINE_LIST(memoList, struct memo*)
 DECLARE_LIST(historyList, struct history*);
-DEFINE_LIST(historyList, struct history*);
+DEFINE_LIST(historyList, struct history*)
 
 /* memo_account.flags fields */
 #define MEMO_NOTIFY_NEW      0x00000001
@@ -185,7 +185,9 @@ extern struct string_list *autojoin_channels;
 const char *memoserv_module_deps[] = { NULL };
 static struct module *memoserv_module;
 static struct log_type *MS_LOG;
-static unsigned long memosSent, memosExpired;
+static unsigned long memoCount;
+static unsigned long memosSent;
+static unsigned long memosExpired;
 static struct dict *memos; /* memo_account->handle->handle -> memo_account */
 static struct dict *historys;
 static dict_t memoserv_opt_dict; /* contains option_func_t* */
@@ -217,6 +219,7 @@ delete_memo(struct memo *memo)
     memoList_remove(&memo->sender->sent, memo);
     free(memo->message);
     free(memo);
+    memoCount--;
 }
 
 static void
@@ -253,10 +256,10 @@ do_expire(void)
 {
     dict_iterator_t it;
     for (it = dict_first(memos); it; it = iter_next(it)) {
-        struct memo_account *acct = iter_data(it);
+        struct memo_account *account = iter_data(it);
         unsigned int ii;
-        for (ii = 0; ii < acct->sent.used; ++ii) {
-            struct memo *memo = acct->sent.list[ii];
+        for (ii = 0; ii < account->sent.used; ++ii) {
+            struct memo *memo = account->sent.list[ii];
             if ((now - memo->sent) > memoserv_conf.message_expiry) {
                 delete_memo(memo);
                 memosExpired++;
@@ -266,10 +269,10 @@ do_expire(void)
     }
 
     for (it = dict_first(historys); it; it = iter_next(it)) {
-        struct memo_account *acct = iter_data(it);
+        struct memo_account *account = iter_data(it);
         unsigned int ii;
-        for (ii = 0; ii < acct->hsent.used; ++ii) {
-            struct history *history = acct->hsent.list[ii];
+        for (ii = 0; ii < account->hsent.used; ++ii) {
+            struct history *history = account->hsent.list[ii];
             if ((now - history->sent) > memoserv_conf.message_expiry) {
                 delete_history(history);
                 memosExpired++;
@@ -312,7 +315,6 @@ static struct memo*
 add_memo(time_t sent, struct memo_account *recipient, struct memo_account *sender, char *message, int nfrom_read)
 {
     struct memo *memo;
-    struct history *history;
 
     memo = calloc(1, sizeof(*memo));
     if (!memo)
@@ -330,9 +332,10 @@ add_memo(time_t sent, struct memo_account *recipient, struct memo_account *sende
     memo->sent = sent;
     memo->message = strdup(message);
     memosSent++;
+    memoCount++;
 
     if (nfrom_read)
-        history = add_history(sent, recipient, sender, memo->id);
+        add_history(sent, recipient, sender, memo->id);
 
     return memo;
 }
@@ -360,7 +363,7 @@ memoserv_can_send(struct userNode *bot, struct userNode *user, struct memo_accou
 
     if (acct->handle->ignores->used) {
         for (i=0; i < acct->handle->ignores->used; i++) {
-            if (user_matches_glob(user, acct->handle->ignores->list[i], MATCH_USENICK)) {
+            if (user_matches_glob(user, acct->handle->ignores->list[i], MATCH_USENICK, 0)) {
                 match = 1;
                 break;
             }
@@ -473,7 +476,7 @@ static MODCMD_FUNC(cmd_send)
         fmt = handle_find_message(hi, "MSEMAIL_NEWMEMO_BODY");
         snprintf(body, sizeof(body), fmt, user->nick, memoserv->nick, message, memoserv->nick, memo_id, netname);
 
-        sendmail(memoserv, hi, subject, body, 0);
+        mail_send(memoserv, hi, subject, body, 0);
     }
 
     reply("MSMSG_MEMO_SENT", ma->handle->handle, memo_id);
@@ -778,7 +781,7 @@ static MODCMD_FUNC(cmd_oset)
 
     MEMOSERV_MIN_PARAMS(2);
 
-    if (!(hi = get_victim_oper(cmd, user, argv[1])))
+    if (!(hi = get_victim_oper(user, argv[1])))
         return 0;
 
     if (argc < 3) {
@@ -976,7 +979,7 @@ static MODCMD_FUNC(cmd_status)
     }
 
     reply("MSMSG_STATUS_HIST_TOTAL", hc);
-    reply("MSMSG_STATUS_TOTAL", mc);
+    reply("MSMSG_STATUS_TOTAL", memoCount);
     reply("MSMSG_STATUS_EXPIRED", memosExpired);
     reply("MSMSG_STATUS_SENT", memosSent);
     return 1;
@@ -1109,7 +1112,6 @@ memoserv_history_read(const char *key, struct record_data *hir)
 {
     char *str;
     struct handle_info *sender, *recipient;
-    struct history *history;
     unsigned long id;
     time_t sent;
 
@@ -1147,7 +1149,7 @@ memoserv_history_read(const char *key, struct record_data *hir)
         return 0;
     }
 
-    history = add_history(sent, memoserv_get_account(recipient), memoserv_get_account(sender), id);
+    add_history(sent, memoserv_get_account(recipient), memoserv_get_account(sender), id);
 
     return 0;
 }
@@ -1269,14 +1271,14 @@ memoserv_saxdb_write(struct saxdb_context *ctx)
 }
 
 static void
-memoserv_cleanup(void)
+memoserv_cleanup(UNUSED_ARG(void *extra))
 {
     dict_delete(memos);
     dict_delete(historys);
 }
 
 static void
-memoserv_check_messages(struct userNode *user, UNUSED_ARG(struct handle_info *old_handle))
+memoserv_check_messages(struct userNode *user, UNUSED_ARG(struct handle_info *old_handle), UNUSED_ARG(void *extra))
 {
     unsigned int ii, unseen;
     struct memo_account *ma;
@@ -1297,7 +1299,7 @@ memoserv_check_messages(struct userNode *user, UNUSED_ARG(struct handle_info *ol
 }
 
 static void
-memoserv_rename_account(struct handle_info *hi, const char *old_handle)
+memoserv_rename_account(struct handle_info *hi, const char *old_handle, UNUSED_ARG(void *extra))
 {
     struct memo_account *ma;
     if (!(ma = dict_find(memos, old_handle, NULL)))
@@ -1310,7 +1312,7 @@ memoserv_rename_account(struct handle_info *hi, const char *old_handle)
 }
 
 static void
-memoserv_unreg_account(UNUSED_ARG(struct userNode *user), struct handle_info *handle)
+memoserv_unreg_account(UNUSED_ARG(struct userNode *user), struct handle_info *handle, UNUSED_ARG(void *extra))
 {
     dict_remove(memos, handle->handle);
     dict_remove(historys, handle->handle);
@@ -1323,11 +1325,11 @@ memoserv_init(void)
     memos = dict_new();
     historys = dict_new();
     dict_set_free_data(memos, delete_memo_account);
-    reg_auth_func(memoserv_check_messages);
-    reg_handle_rename_func(memoserv_rename_account);
-    reg_unreg_func(memoserv_unreg_account);
+    reg_auth_func(memoserv_check_messages, NULL);
+    reg_handle_rename_func(memoserv_rename_account, NULL);
+    reg_unreg_func(memoserv_unreg_account, NULL);
     conf_register_reload(memoserv_conf_read);
-    reg_exit_func(memoserv_cleanup);
+    reg_exit_func(memoserv_cleanup, NULL);
     saxdb_register("MemoServ", memoserv_saxdb_read, memoserv_saxdb_write);
 
     memoserv_module = module_register("MemoServ", MS_LOG, "mod-memoserv.help", NULL);
@@ -1377,8 +1379,8 @@ memoserv_finalize(void) {
     if (str) {
         memoserv = memoserv_conf.bot;
         const char *modes = conf_get_data("modules/memoserv/modes", RECDB_QSTRING);
-        memoserv = AddService(str, modes ? modes : NULL, "User-User Memorandum Services", NULL);
-
+        memoserv = AddLocalUser(str, str, NULL, "User-User Memorandum Services", modes);
+        service_register(memoserv);
     } else {
         log_module(MS_LOG, LOG_ERROR, "database_get_data for memoserv_conf.bot failed!");
         exit(1);