4a5aa6682d
This reverts renaming and usage of lib/*.h header files done
28-12-2012, reverting 2 commits:
f871de0... build: make use of 76 lib/*.h renamed files
ffd8e12... build: rename 76 lib/*.h files
This also reverts removal of redundant include guard (redundant thanks
to changes in above commits) done 2-12-2013, reverting 1 commit:
c087374... curl_setup.h: remove redundant include guard
This also reverts renaming and usage of lib/*.c source files done
3-12-2013, reverting 3 commits:
13606bb... build: make use of 93 lib/*.c renamed files
5b6e792... build: rename 93 lib/*.c files
7d83dff... build: commit 13606bbfde
follow-up 1
Start of related discussion thread:
http://curl.haxx.se/mail/lib-2013-01/0012.html
Asking for confirmation on pushing this revertion commit:
http://curl.haxx.se/mail/lib-2013-01/0048.html
Confirmation summary:
http://curl.haxx.se/mail/lib-2013-01/0079.html
NOTICE: The list of 2 files that have been modified by other
intermixed commits, while renamed, and also by at least one
of the 6 commits this one reverts follows below. These 2 files
will exhibit a hole in history unless git's '--follow' option
is used when viewing logs.
lib/curl_imap.h
lib/curl_smtp.h
143 lines
3.3 KiB
C
143 lines
3.3 KiB
C
/***************************************************************************
|
|
* _ _ ____ _
|
|
* Project ___| | | | _ \| |
|
|
* / __| | | | |_) | |
|
|
* | (__| |_| | _ <| |___
|
|
* \___|\___/|_| \_\_____|
|
|
*
|
|
* Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
|
|
*
|
|
* This software is licensed as described in the file COPYING, which
|
|
* you should have received as part of this distribution. The terms
|
|
* are also available at http://curl.haxx.se/docs/copyright.html.
|
|
*
|
|
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
|
* copies of the Software, and permit persons to whom the Software is
|
|
* furnished to do so, under the terms of the COPYING file.
|
|
*
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
* KIND, either express or implied.
|
|
*
|
|
***************************************************************************/
|
|
#include "curlcheck.h"
|
|
|
|
#ifdef HAVE_NETINET_IN_H
|
|
# include <netinet/in.h>
|
|
#endif
|
|
#ifdef HAVE_NETDB_H
|
|
# include <netdb.h>
|
|
#endif
|
|
#ifdef HAVE_ARPA_INET_H
|
|
# include <arpa/inet.h>
|
|
#endif
|
|
|
|
#define ENABLE_CURLX_PRINTF
|
|
#include "curlx.h"
|
|
|
|
#include "hash.h"
|
|
#include "hostip.h"
|
|
|
|
#include "curl_memory.h"
|
|
#include "memdebug.h" /* LAST include file */
|
|
|
|
static struct SessionHandle *data;
|
|
static struct curl_hash *hp;
|
|
static char *data_key;
|
|
static struct Curl_dns_entry *data_node;
|
|
|
|
static CURLcode unit_setup( void )
|
|
{
|
|
data = curl_easy_init();
|
|
if (!data)
|
|
return CURLE_OUT_OF_MEMORY;
|
|
|
|
hp = Curl_mk_dnscache();
|
|
if(!hp) {
|
|
curl_easy_cleanup(data);
|
|
curl_global_cleanup();
|
|
return CURLE_OUT_OF_MEMORY;
|
|
}
|
|
return CURLE_OK;
|
|
}
|
|
|
|
static void unit_stop( void )
|
|
{
|
|
if (data_node) {
|
|
Curl_freeaddrinfo(data_node->addr);
|
|
free(data_node);
|
|
}
|
|
if (data_key)
|
|
free(data_key);
|
|
|
|
Curl_hash_destroy(hp);
|
|
|
|
curl_easy_cleanup(data);
|
|
curl_global_cleanup();
|
|
}
|
|
|
|
static Curl_addrinfo *fake_ai(void)
|
|
{
|
|
static Curl_addrinfo *ai;
|
|
int ss_size;
|
|
|
|
ss_size = sizeof (struct sockaddr_in);
|
|
|
|
if((ai = calloc(1, sizeof(Curl_addrinfo))) == NULL)
|
|
return NULL;
|
|
|
|
if((ai->ai_canonname = strdup("dummy")) == NULL) {
|
|
free(ai);
|
|
return NULL;
|
|
}
|
|
|
|
if((ai->ai_addr = calloc(1, ss_size)) == NULL) {
|
|
free(ai->ai_canonname);
|
|
free(ai);
|
|
return NULL;
|
|
}
|
|
|
|
ai->ai_family = AF_INET;
|
|
ai->ai_addrlen = ss_size;
|
|
|
|
return ai;
|
|
}
|
|
|
|
static CURLcode create_node(void)
|
|
{
|
|
data_key = aprintf("%s:%d", "dummy", 0);
|
|
if (!data_key)
|
|
return CURLE_OUT_OF_MEMORY;
|
|
|
|
data_node = calloc(1, sizeof(struct Curl_dns_entry));
|
|
if (!data_node)
|
|
return CURLE_OUT_OF_MEMORY;
|
|
|
|
data_node->addr = fake_ai();
|
|
if (!data_node->addr)
|
|
return CURLE_OUT_OF_MEMORY;
|
|
|
|
return CURLE_OK;
|
|
}
|
|
|
|
|
|
UNITTEST_START
|
|
|
|
struct Curl_dns_entry *nodep;
|
|
size_t key_len;
|
|
|
|
/* Test 1305 exits without adding anything to the hash */
|
|
if (strcmp(arg, "1305") != 0) {
|
|
CURLcode rc = create_node();
|
|
abort_unless(rc == CURLE_OK, "data node creation failed");
|
|
key_len = strlen(data_key);
|
|
|
|
nodep = Curl_hash_add(hp, data_key, key_len+1, data_node);
|
|
abort_unless(nodep, "insertion into hash failed");
|
|
/* Freeing will now be done by Curl_hash_destroy */
|
|
data_node = NULL;
|
|
|
|
/* To do: test retrieval, deletion, edge conditions */
|
|
}
|
|
|
|
UNITTEST_STOP
|