fixed last commits
[NeonServV5.git] / cmd_neonserv_adduser.c
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);
 }