Ejemplo n.º 1
0
struct ADC_client* ADC_client_create(const char* nickname, const char* description, void* ptr)
{
	ADC_TRACE;
	struct ADC_client* client = (struct ADC_client*) hub_malloc_zero(sizeof(struct ADC_client));

	ADC_client_set_state(client, ps_none);

	client->nick = hub_strdup(nickname);
	client->desc = hub_strdup(description);

	client->send_queue = ioq_send_create();
	client->recv_queue = ioq_recv_create();

	client->ptr = ptr;

	if (!g_adc_client)
	{
		g_adc_client = (struct ADC_client_global*) hub_malloc_zero(sizeof(struct ADC_client_global));
#ifdef SSL_SUPPORT
		g_adc_client->ctx = net_ssl_context_create("1.2", "HIGH");

#endif
	}
	g_adc_client->references++;

	return client;
}
Ejemplo n.º 2
0
Archivo: auth.c Proyecto: Nyogtha/uhub
static int check_cmd_bool(const char* cmd, struct linked_list* list, char* line, int line_count)
{
	char* data;
	char* data_extra;
	
	if (!strncmp(line, cmd, strlen(cmd)))
	{
		data = &line[strlen(cmd)];
		data_extra = 0;
		data[0] = '\0';
		data++;
		
		data = strip_white_space(data);
		if (!*data)
		{
			LOG_FATAL("ACL parse error on line %d", line_count);
			return -1;
		}
		
		list_append(list, hub_strdup(data));
		LOG_DEBUG("ACL: Deny access for: '%s' (%s)", data, cmd);
		return 1;
	}
	return 0;
}
Ejemplo n.º 3
0
int cfg_token_add(struct cfg_tokens* tokens, char* new_token)
{
	if (*new_token)
	{
		list_append(tokens->list, hub_strdup(new_token));
		return 1;
	}
	return 0;
}
Ejemplo n.º 4
0
static int apply_string(const char* key, const char* data, char** target, char* regexp)
{
	(void) regexp;
	// FIXME: Add regexp checks for correct data

	if (*target)
		hub_free(*target);

	*target = hub_strdup(data);
	return 1;
}
Ejemplo n.º 5
0
Archivo: auth.c Proyecto: Nyogtha/uhub
int acl_user_ban_cid(struct acl_handle* handle, const char* cid)
{
	char* data = hub_strdup(cid);
	if (!data)
	{
		LOG_ERROR("ACL error: Out of memory!");
		return -1;
	}

	list_append(handle->cids, data);
	return 0;
}
Ejemplo n.º 6
0
Archivo: auth.c Proyecto: Nyogtha/uhub
int acl_user_ban_nick(struct acl_handle* handle, const char* nick)
{
	char* data = hub_strdup(nick);
	if (!data)
	{
		LOG_ERROR("ACL error: Out of memory!");
		return -1;
	}

	list_append(handle->users_banned, data);
	return 0;
}
Ejemplo n.º 7
0
Archivo: message.c Proyecto: Tilka/uhub
struct adc_message* adc_msg_copy(const struct adc_message* cmd)
{
    char* tmp = 0;
    struct adc_message* copy = (struct adc_message*) msg_malloc_zero(sizeof(struct adc_message));
    if (!copy) return NULL; /* OOM */

    ADC_MSG_ASSERT(cmd);

    /* deep copy */
    copy->cmd                  = cmd->cmd;
    copy->source               = cmd->source;
    copy->target               = cmd->target;
    copy->cache                = 0;
    copy->length               = cmd->length;
    copy->capacity             = 0;
    copy->priority             = cmd->priority;
    copy->references           = 1;
    copy->feature_cast_include = 0;
    copy->feature_cast_exclude = 0;

    if (!adc_msg_grow(copy, copy->length))
    {
        adc_msg_free(copy);
        return NULL; /* OOM */
    }

    if (!copy->cache)
    {
        adc_msg_free(copy);
        return NULL;
    }

    memcpy(copy->cache, cmd->cache, cmd->length);
    copy->cache[copy->length] = 0;

    if (cmd->feature_cast_include)
    {
        copy->feature_cast_include = list_create();
        LIST_FOREACH(char*, tmp, cmd->feature_cast_include,
        {
            list_append(copy->feature_cast_include, hub_strdup(tmp));
        });
Ejemplo n.º 8
0
struct net_connect_handle* net_con_connect(const char* address, uint16_t port, net_connect_cb callback, void* ptr)
{
	struct net_connect_handle* handle = hub_malloc_zero(sizeof(struct net_connect_handle));

	handle->address = hub_strdup(address);
	handle->port = port;
	handle->ptr = ptr;
	handle->callback = callback;

	// FIXME: Check if DNS resolving is necessary ?
	handle->dns = net_dns_gethostbyname(address, AF_UNSPEC, net_con_connect_dns_callback, handle);
	if (!handle->dns)
	{
		LOG_TRACE("net_con_connect(): Unable to create DNS lookup job.");
		hub_free((char*) handle->address);
		hub_free(handle);
		return NULL;
	}

	return handle;
}