-/* HandleInfoHandler.c - NeonServ v5.3
+/* HandleInfoHandler.c - NeonServ v5.6
* Copyright (C) 2011-2012 Philipp Kreil (pk910)
*
* This program is free software: you can redistribute it and/or modify
#include "ChanNode.h"
#include "IRCEvents.h"
#include "tools.h"
+#include "modules.h"
+#include "log.h"
#define AUTHSERV_NICK "AuthServ"
struct HandleInfoQueueEntry {
char *auth;
void *callback[MAXCALLBACKS];
+ int module_id[MAXCALLBACKS];
void *data[MAXCALLBACKS];
struct HandleInfoQueueEntry *next;
struct HandleInfoQueueEntry *entry = malloc(sizeof(*entry));
if (!entry)
{
- perror("malloc() failed");
+ printf_log("main", LOG_ERROR, "%s:%d malloc() failed", __FILE__, __LINE__);
return NULL;
}
SYNCHRONIZE(cache_sync);
DESYNCHRONIZE(cache_sync);
}
-void lookup_authname(char *auth, authlookup_callback_t callback, void *data) {
+void lookup_authname(char *auth, int module_id, authlookup_callback_t callback, void *data) {
struct ClientSocket *bot;
struct HandleInfoQueueEntry* entry;
for(bot = getBots(SOCKET_FLAG_READY, NULL); bot; bot = getBots(SOCKET_FLAG_READY, bot)) {
for(i = 1; i < MAXCALLBACKS; i++) {
if(!entry->callback[i]) {
entry->callback[i] = callback;
+ entry->module_id[i] = module_id;
entry->data[i] = data;
return;
}
int i;
entry->auth = strdup(auth);
entry->callback[0] = callback;
+ entry->module_id[0] = module_id;
for(i = 1; i < MAXCALLBACKS; i++)
entry->callback[i] = NULL;
entry->data[0] = data;
if(do_match) {
#ifdef HAVE_THREADS
- unsigned long tid = syscall(SYS_gettid);
+ unsigned int tid = (unsigned int) pthread_self_tid();
while(!clientsocket_parseorder_top(tid)) {
usleep(1000); //1ms
}
for(i = 0; i < MAXCALLBACKS; i++) {
callback = entry->callback[i];
if(!callback) break;
- callback(entry->auth, exists, registered, entry->data[i]);
+ if(!entry->module_id[i] || module_loaded(entry->module_id[i]))
+ callback(entry->auth, exists, registered, entry->data[i]);
}
free(entry->auth);
free(entry);
}
void init_handleinfohandler() {
- bind_privnotice(recv_notice);
+ bind_privnotice(recv_notice, 0);
}
void free_handleinfohandler() {