X-Git-Url: http://git.pk910.de/?p=NeonServV5.git;a=blobdiff_plain;f=src%2FHandleInfoHandler.c;h=0508e07413448c82c7dc22f2661b364d333db646;hp=99d19658b73c33d6b24abb729988eecbc44cc746;hb=c32e8254ec4ed0d77757e32f8aa5aabcdb494057;hpb=77b1c3e45f25e5a000b06a551e3b2329ad2db8a0 diff --git a/src/HandleInfoHandler.c b/src/HandleInfoHandler.c index 99d1965..0508e07 100644 --- a/src/HandleInfoHandler.c +++ b/src/HandleInfoHandler.c @@ -121,6 +121,8 @@ static void recv_notice(struct UserNode *user, struct UserNode *target, char *me char *auth = NULL; int do_match = 0, exists = 0; char *tmp; + time_t registered = time(0); + struct tm *timeinfo; //messages to parse: // Account * has not been registered. // Account information for Skynet: @@ -130,24 +132,99 @@ static void recv_notice(struct UserNode *user, struct UserNode *target, char *me auth = tmp+1; tmp = strstr(auth, "\002"); *tmp = '\0'; - } - if(!match("Account information for *", message)) { - do_match = 1; + } else if(!match("Account information for *", message)) { + do_match = 2; exists = 1; tmp = strstr(message, "\002"); auth = tmp+1; tmp = strstr(auth, "\002"); *tmp = '\0'; + } else if(!match(" Registered on: *", message)) { + do_match = 1; + exists = 1; + tmp = strstr(message, ": "); + tmp += 2; + timeinfo = localtime(®istered); + timeinfo->tm_year = 0; + //parse time + //Sat Nov 19 14:52:57 2011 + tmp = strchr(tmp, ' '); + if(!tmp) goto errparse; + tmp++; + char *tmp2 = strchr(tmp, ' '); + if(!tmp2) goto errparse; + *tmp2 = '\0'; + if(!stricmp(tmp, "Jan")) + timeinfo->tm_mon = 0; + else if(!stricmp(tmp, "Feb")) + timeinfo->tm_mon = 1; + else if(!stricmp(tmp, "Mar")) + timeinfo->tm_mon = 2; + else if(!stricmp(tmp, "Apr")) + timeinfo->tm_mon = 3; + else if(!stricmp(tmp, "May")) + timeinfo->tm_mon = 4; + else if(!stricmp(tmp, "Jun")) + timeinfo->tm_mon = 5; + else if(!stricmp(tmp, "Jul")) + timeinfo->tm_mon = 6; + else if(!stricmp(tmp, "Aug")) + timeinfo->tm_mon = 7; + else if(!stricmp(tmp, "Sep")) + timeinfo->tm_mon = 8; + else if(!stricmp(tmp, "Oct")) + timeinfo->tm_mon = 9; + else if(!stricmp(tmp, "Nov")) + timeinfo->tm_mon = 10; + else if(!stricmp(tmp, "Dec")) + timeinfo->tm_mon = 11; + tmp = tmp2 + 1; + tmp2 = strchr(tmp, ' '); + if(!tmp2) goto errparse; + *tmp2 = '\0'; + timeinfo->tm_mday = atoi(tmp); + tmp = tmp2 + 1; + if(*tmp == ' ') tmp++; + tmp2 = strchr(tmp, ':'); + if(!tmp2) goto errparse; + *tmp2 = '\0'; + timeinfo->tm_hour = atoi(tmp); + tmp = tmp2 + 1; + tmp2 = strchr(tmp, ':'); + if(!tmp2) goto errparse; + *tmp2 = '\0'; + timeinfo->tm_min = atoi(tmp); + tmp = tmp2 + 1; + tmp2 = strchr(tmp, ' '); + if(!tmp2) goto errparse; + *tmp2 = '\0'; + timeinfo->tm_sec = atoi(tmp); + tmp = tmp2 + 1; + timeinfo->tm_year = atoi(tmp) - 1900; + registered = mktime(timeinfo); } + errparse: + if(do_match) { - struct HandleInfoQueueEntry* entry = getNextHandleInfoQueueEntry(bot, 1); + #ifdef HAVE_THREADS + unsigned long tid = syscall(SYS_gettid); + while(!clientsocket_parseorder_top(tid)) { + usleep(1000); //1ms + } + #endif + struct HandleInfoQueueEntry* entry = getNextHandleInfoQueueEntry(bot, ((do_match != 2) ? 1 : 0)); if(entry) { + if(do_match == 2) { + free(entry->auth); + entry->auth = strdup(auth); + return; + } authlookup_callback_t *callback; int i; for(i = 0; i < MAXCALLBACKS; i++) { callback = entry->callback[i]; if(!callback) break; - callback(auth, exists, entry->data[i]); + callback(entry->auth, exists, registered, entry->data[i]); } free(entry->auth); free(entry);