fixed last commits
authorpk910 <philipp@zoelle1.de>
Wed, 17 Aug 2011 05:22:12 +0000 (07:22 +0200)
committerpk910 <philipp@zoelle1.de>
Wed, 17 Aug 2011 05:35:50 +0000 (07:35 +0200)
HandleInfoHandler.c
WHOHandler.c
bot_NeonServ.c
cmd_neonserv_adduser.c
tools.c

index 6673552082fd5992faf8bda1af01e8e492585fd9..537cc459c900e870a4471900b7c92b5d806af0fd 100644 (file)
@@ -8,8 +8,11 @@
 #define AUTHSERV_NICK "AuthServ"
 
 struct HandleInfoQueueEntry {
+    struct ClientSocket *client;
     void *callback;
     void *data;
+    
+    struct HandleInfoQueueEntry *next;
 };
 
 static struct HandleInfoQueueEntry *first_entry = NULL, *last_entry = NULL;
@@ -73,29 +76,29 @@ static void recv_notice(struct UserNode *user, struct UserNode *target, char *me
         if(bot->user == target) break;
     }
     if(!bot) return;
-    char *auth;
-    int match = 0, exists = 0;
+    char *auth = NULL;
+    int do_match = 0, exists = 0;
     char *tmp;
     //messages to parse:
     //  Account * has not been registered.
     //  Account information for Skynet:
     if(!match("Account * has not been registered.", message)) {
-        match = 1;
+        do_match = 1;
         tmp = strstr(message, "\002");
         auth = tmp+1;
         tmp = strstr(auth, "\002");
         *tmp = '\0';
     }
     if(!match("Account information for *", message)) {
-        match = 1;
+        do_match = 1;
         exists = 1;
         tmp = strstr(message, "\002");
         auth = tmp+1;
         tmp = strstr(auth, "\002");
         *tmp = '\0';
     }
-    if(match) {
-        struct HandleInfoQueueEntry* entry = getNextHandleInfoQueueEntry(client, 1);
+    if(do_match) {
+        struct HandleInfoQueueEntry* entry = getNextHandleInfoQueueEntry(bot, 1);
         authlookup_callback_t *callback = entry->callback;
         callback(auth, exists, entry->data);
         free(entry);
index f3da915702ead4f66634790982391896eab614d9..692093e7d4ac882e0b1a7bb146e1a223cf8c2c4c 100644 (file)
@@ -143,7 +143,7 @@ void recv_whohandler_354(struct ClientSocket *client, char **argv, unsigned int
         }
     } else if(type & WHOQUEUETYPE_USERAUTH) {
         //:OGN2.OnlineGamesNet.net 354 Skynet 1 pk910 2001:41d0:2:1d3b::babe Skynet pk910
-        entry->flags |= WHOQUEUETYPE_FOUND;
+        entry->type |= WHOQUEUETYPE_FOUND;
         if(!strcmp(argv[5], "0") && !(entry->user->flags & USERFLAG_ISAUTHED)) {
             strcpy(entry->user->auth, argv[5]);
             entry->user->flags |= USERFLAG_ISAUTHED;
@@ -166,7 +166,7 @@ void recv_whohandler_315(struct ClientSocket *client, char **argv, unsigned int
         userlist_callback_t *callback = entry->callback;
         callback(client, entry->chan, entry->data);
     } else if(type & WHOQUEUETYPE_USERAUTH) {
-        if(!(entry->flags & WHOQUEUETYPE_FOUND)) {
+        if(!(entry->type & WHOQUEUETYPE_FOUND)) {
             userauth_callback_t *callback = entry->callback;
             callback(client, NULL, entry->data);
         }
index e8ced621118fc19356f69c2510c37db208888851..0005492ac0f53d4f02382b3aaf2617dabe8241af 100644 (file)
@@ -8,7 +8,8 @@
 #include "ClientSocket.h"
 #include "mysqlConn.h"
 #include "lang.h"
-#include "HandleInfoHandle.h"
+#include "HandleInfoHandler.h"
+#include "WHOHandler.h"
 
 #define BOTID 1
 #define CLASSNAME "NeonServ"
@@ -22,6 +23,7 @@ INCLUDE ALL CMD's HERE
 */
 #include "cmd_neonserv_users.c"
 #include "cmd_neonserv_modes.c"
+#include "cmd_neonserv_adduser.c"
 
 static void neonserv_bot_ready(struct ClientSocket *client) {
     MYSQL_RES *res;
index 5d3983e35e4a463de0e21f048702bd529258487b..5e01854d170c2d640ecbe4a3007538a915c77d3e 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
-* argv[0] - nick/*auth
+* argv[0] - nick / *auth
 * argv[1] - chan access
 */
 static AUTHLOOKUP_CALLBACK(neonserv_cmd_adduser_auth_lookup);
@@ -16,24 +16,24 @@ struct neonserv_cmd_adduser_cache {
 };
 
 static CMD_BIND(neonserv_cmd_adduser) {
-    int access;
+    int caccess;
     MYSQL_RES *res;
     MYSQL_ROW row;
     check_mysql();
     //check acccess
-    access = atoi(argv[1]);
+    caccess = atoi(argv[1]);
     if(argv[0][0] == '*') {
         //we've got an auth
         argv[0]++;
         printf_mysql_query("SELECT `user_user` FROM `users` WHERE `user_user` = '%s'", escape_string(argv[0]));
         res = mysql_use();
         if ((row = mysql_fetch_row(res)) != NULL) {
-            neonserv_cmd_adduser_async1(client, getTextBot(), user, chan, argv[0], row[0], access);
+            neonserv_cmd_adduser_async1(client, getTextBot(), user, chan, argv[0], row[0], caccess);
         } else {
             //we need to create a new user...
             //but first lookup the auth to check if it really exists
             struct neonserv_cmd_adduser_cache *cache = malloc(sizeof(*cache));
-            if (!user) {
+            if (!cache) {
                 perror("malloc() failed");
                 return;
             }
@@ -41,21 +41,21 @@ static CMD_BIND(neonserv_cmd_adduser) {
             cache->textclient = getTextBot();
             cache->user = user;
             cache->chan = chan;
-            cache->access = access;
+            cache->access = caccess;
             cache->nick = strdup(argv[0]);
             lookup_authname(argv[0], neonserv_cmd_adduser_auth_lookup, cache);
         }
     } else {
-        struct UserNode *user = getUserByNick(argv[0]);
-        if(!user) {
-            user = createTempUser(from);
-            user->flags |= USERFLAG_ISTMPUSER;
+        struct UserNode *cuser = getUserByNick(argv[0]);
+        if(!cuser) {
+            cuser = createTempUser(argv[0]);
+            cuser->flags |= USERFLAG_ISTMPUSER;
         }
-        if(user->flags & USERFLAG_ISAUTHED) {
-            neonserv_cmd_adduser_async1(client, getTextBot(), user, chan, argv[0], user->auth, access);
+        if(cuser->flags & USERFLAG_ISAUTHED) {
+            neonserv_cmd_adduser_async1(client, getTextBot(), user, chan, argv[0], cuser->auth, caccess);
         } else {
             struct neonserv_cmd_adduser_cache *cache = malloc(sizeof(*cache));
-            if (!user) {
+            if (!cache) {
                 perror("malloc() failed");
                 return;
             }
@@ -63,10 +63,9 @@ static CMD_BIND(neonserv_cmd_adduser) {
             cache->textclient = getTextBot();
             cache->user = user;
             cache->chan = chan;
-            cache->access = access;
+            cache->access = caccess;
             cache->nick = strdup(argv[0]);
-            lookup_authname(argv[0], neonserv_cmd_adduser_nick_lookup, cache);
-            get_userauth(user, command_checked_auth, data);
+            get_userauth(cuser, neonserv_cmd_adduser_nick_lookup, cache);
         }
     }
 }
@@ -95,7 +94,7 @@ static USERAUTH_CALLBACK(neonserv_cmd_adduser_nick_lookup) {
     free(cache);
 }
 
-static void neonserv_cmd_adduser_async1(struct ClientSocket *client, struct ClientSocket *textclient, struct UserNode *user, struct ChanNode *chan, char *nick, char *auth, int access) {
+static void neonserv_cmd_adduser_async1(struct ClientSocket *client, struct ClientSocket *textclient, struct UserNode *user, struct ChanNode *chan, char *nick, char *auth, int caccess) {
     //we've got a valid auth now...
-    putsock(client, "PRIVMSG %s :%s: %s   %d", chan->name, nick, auth, access);
+    putsock(client, "PRIVMSG %s :%s: %s   %d", chan->name, nick, auth, caccess);
 }
diff --git a/tools.c b/tools.c
index 19f15218c994bc53f9ddbcece98128b0ac699c23..32d4ab3f26f83d4e30ed5d402125e132ef2b155d 100644 (file)
--- a/tools.c
+++ b/tools.c
@@ -55,14 +55,14 @@ int match(const char *mask, const char *name)
         for (n_tmp = n; *n && *n != *m; n++) ;
       } else {
         m_tmp = m;
-        for (n_tmp = n; *n && ToLower(*n) != ToLower(*m); n++) ;
+        for (n_tmp = n; *n && tolower(*n) != tolower(*m); n++) ;
       }
     }
     /* and fall through */
   default:
     if (!*n)
       return *m != '\0';
-    if (ToLower(*m) != ToLower(*n))
+    if (tolower(*m) != tolower(*n))
       goto backtrack;
     m++;
     n++;