changed Makefile; build all commands as an own file
[NeonServV5.git] / cmd_neonserv_ban.c
index e51934d4a38d98224ce879ac013868ad1ac72b3c..eec73264dceac76143ec0fbdf2074e9f8722b1b0 100644 (file)
@@ -1,17 +1,20 @@
 
+#include "cmd_neonserv.h"
+
 /*
 * argv[0-*]    nick[,*auth[,*!*@mask[...]]]
 */
 static USERLIST_CALLBACK(neonserv_cmd_ban_userlist_lookup);
-static void neonserv_cmd_ban_async1(struct ClientSocket *client, struct ClientSocket *textclient, struct UserNode *user, struct ChanNode *chan, char *masks);
+static void neonserv_cmd_ban_async1(struct ClientSocket *client, struct ClientSocket *textclient, struct UserNode *user, struct ChanNode *chan, struct Event *event, char *masks);
 
 struct neonserv_cmd_ban_cache {
     struct ClientSocket *client, *textclient;
     struct UserNode *user;
+    struct Event *event;
     char *masks;
 };
 
-static CMD_BIND(neonserv_cmd_ban) {
+CMD_BIND(neonserv_cmd_ban) {
     struct neonserv_cmd_ban_cache *cache = malloc(sizeof(*cache));
     if (!cache) {
         perror("malloc() failed");
@@ -20,18 +23,19 @@ static CMD_BIND(neonserv_cmd_ban) {
     cache->client = client;
     cache->textclient = getTextBot();
     cache->user = user;
+    cache->event = event;
     cache->masks = strdup(merge_argv_char(argv, 0, argc, ','));
-    get_userlist(chan, neonserv_cmd_ban_userlist_lookup, cache);
+    get_userlist_with_invisible(chan, neonserv_cmd_ban_userlist_lookup, cache);
 }
 
 static USERLIST_CALLBACK(neonserv_cmd_ban_userlist_lookup) {
     struct neonserv_cmd_ban_cache *cache = data;
-    neonserv_cmd_ban_async1(cache->client, cache->textclient, cache->user, chan, cache->masks);
+    neonserv_cmd_ban_async1(cache->client, cache->textclient, cache->user, chan, cache->event, cache->masks);
     free(cache->masks);
     free(cache);
 }
 
-static void neonserv_cmd_ban_async1(struct ClientSocket *client, struct ClientSocket *textclient, struct UserNode *user, struct ChanNode *chan, char *masks) {
+static void neonserv_cmd_ban_async1(struct ClientSocket *client, struct ClientSocket *textclient, struct UserNode *user, struct ChanNode *chan, struct Event *event, char *masks) {
     int done_masks = 0, provided_masks = 0, skip, match_count, total_match;
     char *mask, *nextmask;
     char hostmask_buffer[NICKLEN+USERLEN+HOSTLEN+3];
@@ -41,7 +45,6 @@ static void neonserv_cmd_ban_async1(struct ClientSocket *client, struct ClientSo
     struct ModeBuffer *modeBuf;
     modeBuf = initModeBuffer(client, chan);
     nextmask = masks;
-    check_mysql();
     while((mask = nextmask)) {
         nextmask = strstr(mask, ",");
         if(nextmask) {
@@ -93,4 +96,6 @@ static void neonserv_cmd_ban_async1(struct ClientSocket *client, struct ClientSo
         reply(getTextBot(), user, "NS_BAN_DONE", done_masks, chan->name, total_match);
     else
         reply(getTextBot(), user, "NS_BAN_FAIL", client->user->nick);
+    if(done_masks)
+        logEvent(event);
 }