Пример #1
0
HttpResponse* http_response_new()
{
	HttpResponse* ret = (HttpResponse*)calloc(1, sizeof(HttpResponse));

	if (!ret)
		return NULL;

	ret->Authenticates = ListDictionary_New(FALSE);
	ListDictionary_KeyObject(ret->Authenticates)->fnObjectEquals = strings_equals_nocase;
	ListDictionary_KeyObject(ret->Authenticates)->fnObjectFree = string_free;
	ListDictionary_ValueObject(ret->Authenticates)->fnObjectEquals = strings_equals_nocase;
	ListDictionary_ValueObject(ret->Authenticates)->fnObjectFree = string_free;
	return ret;
}
Пример #2
0
void add_callback_by_name(const char *name, void *fkt, void *context)
{
	struct cb_value *value = calloc(1, sizeof(struct cb_value));

	if (!value)
	{
		DEBUG_WARN("calloc failed %s (%d)!", strerror(errno), errno);
		assert(FALSE);
		return;
	}

	if (!cb_dict)
	{
		DEBUG_DVC("Function list is empty, allocating new.");
		cb_dict = ListDictionary_New(TRUE);
		ListDictionary_KeyObject(cb_dict)->fnObjectEquals = callback_key_cmp;
	}

	value->fkt = fkt;
	value->context = context;
	DEBUG_DVC("Adding '%s'=%p to function list.", name, fkt);
	ListDictionary_Add(cb_dict, (void *)name, value);
	dump_callbacks();
}
Пример #3
0
HttpResponse* http_response_new(void)
{
	HttpResponse* response = (HttpResponse*) calloc(1, sizeof(HttpResponse));

	if (!response)
		return NULL;

	response->Authenticates = ListDictionary_New(FALSE);

	if (!response->Authenticates)
		goto fail;

	response->data = Stream_New(NULL, 2048);

	if (!response->data)
		goto fail;

	ListDictionary_KeyObject(response->Authenticates)->fnObjectEquals = strings_equals_nocase;
	ListDictionary_ValueObject(response->Authenticates)->fnObjectEquals = strings_equals_nocase;
	return response;
fail:
	http_response_free(response);
	return NULL;
}