Ejemplo n.º 1
0
USERS *adduser(unsigned int fdclient, char *host, acetables *g_ape)
{
	USERS *nuser = NULL;

	/* Calling module */
	FIRE_EVENT(adduser, nuser, fdclient, host, g_ape);
	

	nuser = init_user(g_ape);
	
	nuser->type = (fdclient ? HUMAN : BOT);
		
	g_ape->uHead = nuser;
	
	nuser->pipe = init_pipe(nuser, USER_PIPE, g_ape);

	hashtbl_append(g_ape->hSessid, nuser->sessid, (void *)nuser);
	
	g_ape->nConnected++;
	
	addsubuser(fdclient, host, nuser, g_ape);

	return nuser;
	
}
Ejemplo n.º 2
0
CHANNEL *mkchan(char *chan, acetables *g_ape)
{
	CHANNEL *new_chan = NULL;


	FIRE_EVENT(mkchan, new_chan, chan, g_ape);

	
	if (!isvalidchan(chan)) {
		return NULL;
	}
	
	new_chan = (CHANNEL *) xmalloc(sizeof(*new_chan));
		
	memcpy(new_chan->name, chan, strlen(chan)+1);
	
	new_chan->head = NULL;
	new_chan->banned = NULL;
	new_chan->properties = NULL;
	
	new_chan->interactive = (*new_chan->name == '*' ? 0 : 1);

	//memcpy(new_chan->topic, topic, strlen(topic)+1);

	new_chan->pipe = init_pipe(new_chan, CHANNEL_PIPE, g_ape);
	
	hashtbl_append(g_ape->hLusers, chan, (void *)new_chan);
	
	/* just to test */
	//proxy_attach(proxy_init("olol", "localhost", 1337, g_ape), new_chan->pipe->pubid, 0, g_ape);
	
	return new_chan;
	
}
Ejemplo n.º 3
0
USERS *adduser(ape_socket *client, const char *host, const char *ip, USERS *allocated, acetables *g_ape)
{
	USERS *nuser = NULL;

	/* Calling module */
	if (allocated == NULL) {
		FIRE_EVENT(allocateuser, nuser, client, host, ip, g_ape);
		
		nuser = init_user(g_ape);
		strncpy(nuser->ip, ip, 16);
		
		nuser->pipe = init_pipe(nuser, USER_PIPE, g_ape);
		nuser->type = (client != NULL ? HUMAN : BOT);
		
		nuser->istmp = 1;
		
		hashtbl_append(g_ape->hSessid, nuser->sessid, (void *)nuser);

		addsubuser(client, host, nuser, g_ape);
	} else {
		FIRE_EVENT(adduser, nuser, allocated, g_ape);
		
		nuser = allocated;
		nuser->istmp = 0;
		
		g_ape->nConnected++;
		
		//ape_log(APE_INFO, __FILE__, __LINE__, g_ape, 
		//	"New user - (ip : %s)", nuser->ip);
	}

	return nuser;
	
}
Ejemplo n.º 4
0
/* Init a pipe (user, channel, proxy) */
transpipe *init_pipe(void *pipe, int type, acetables *g_ape)
{
	transpipe *npipe = NULL;
	
	npipe = xmalloc(sizeof(*npipe));
	npipe->pipe = pipe;
	npipe->type = type;
	npipe->link = NULL;
	
	gen_sessid_new(npipe->pubid, g_ape);
	hashtbl_append(g_ape->hPubid, npipe->pubid, (void *)npipe);
	return npipe;
}
Ejemplo n.º 5
0
void register_cmd(const char *cmd, unsigned int (*func)(callbackp *), unsigned int need, acetables *g_ape)
{
	callback *new_cmd, *old_cmd;
	
	new_cmd = (callback *) xmalloc(sizeof(*new_cmd));

	new_cmd->func = func;
	new_cmd->need = need;
	
	/* Unregister old cmd if exists */
	if ((old_cmd = (callback *)hashtbl_seek(g_ape->hCallback, cmd)) != NULL) {
		hashtbl_erase(g_ape->hCallback, cmd);
	}
	
	hashtbl_append(g_ape->hCallback, cmd, (void *)new_cmd);
	
}