#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;
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);
}
} 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;
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);
}
/*
-* argv[0] - nick/*auth
+* argv[0] - nick / *auth
* argv[1] - chan access
*/
static AUTHLOOKUP_CALLBACK(neonserv_cmd_adduser_auth_lookup);
};
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;
}
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;
}
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);
}
}
}
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);
}