mirror of https://github.com/moparisthebest/curl
add debug messages for fopen() failures
This commit is contained in:
parent
a1d5983991
commit
4dc453c087
|
@ -216,9 +216,26 @@ static int file_lookup(union ares_addr *addr, int family, struct hostent **host)
|
||||||
return ARES_ENOTFOUND;
|
return ARES_ENOTFOUND;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
int error;
|
||||||
|
|
||||||
fp = fopen(PATH_HOSTS, "r");
|
fp = fopen(PATH_HOSTS, "r");
|
||||||
if (!fp)
|
if (!fp)
|
||||||
|
{
|
||||||
|
error = ERRNO;
|
||||||
|
switch(error)
|
||||||
|
{
|
||||||
|
case ENOENT:
|
||||||
return ARES_ENOTFOUND;
|
return ARES_ENOTFOUND;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
DEBUGF(fprintf(stderr, "fopen() failed with error: %d %s\n",
|
||||||
|
error, strerror(error)));
|
||||||
|
DEBUGF(fprintf(stderr, "Error opening file: %s\n",
|
||||||
|
PATH_HOSTS));
|
||||||
|
*host = NULL;
|
||||||
|
return ARES_EFILE;
|
||||||
|
}
|
||||||
|
}
|
||||||
while ((status = ares__get_hostent(fp, family, host)) == ARES_SUCCESS)
|
while ((status = ares__get_hostent(fp, family, host)) == ARES_SUCCESS)
|
||||||
{
|
{
|
||||||
if (family != (*host)->h_addrtype)
|
if (family != (*host)->h_addrtype)
|
||||||
|
|
|
@ -216,6 +216,7 @@ static int single_domain(ares_channel channel, const char *name, char **s)
|
||||||
char *line = NULL;
|
char *line = NULL;
|
||||||
int linesize, status;
|
int linesize, status;
|
||||||
const char *p, *q;
|
const char *p, *q;
|
||||||
|
int error;
|
||||||
|
|
||||||
/* If the name contains a trailing dot, then the single query is the name
|
/* If the name contains a trailing dot, then the single query is the name
|
||||||
* sans the trailing dot.
|
* sans the trailing dot.
|
||||||
|
@ -265,6 +266,22 @@ static int single_domain(ares_channel channel, const char *name, char **s)
|
||||||
if (status != ARES_SUCCESS)
|
if (status != ARES_SUCCESS)
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
error = ERRNO;
|
||||||
|
switch(error)
|
||||||
|
{
|
||||||
|
case ENOENT:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
DEBUGF(fprintf(stderr, "fopen() failed with error: %d %s\n",
|
||||||
|
error, strerror(error)));
|
||||||
|
DEBUGF(fprintf(stderr, "Error opening file: %s\n",
|
||||||
|
hostaliases));
|
||||||
|
*s = NULL;
|
||||||
|
return ARES_EFILE;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,7 @@ int test(char *URL)
|
||||||
int hd ;
|
int hd ;
|
||||||
struct_stat file_info;
|
struct_stat file_info;
|
||||||
struct curl_slist *hl;
|
struct curl_slist *hl;
|
||||||
|
int error;
|
||||||
|
|
||||||
struct curl_slist *headerlist=NULL;
|
struct curl_slist *headerlist=NULL;
|
||||||
const char *buf_1 = "RNFR 505";
|
const char *buf_1 = "RNFR 505";
|
||||||
|
@ -57,6 +58,9 @@ int test(char *URL)
|
||||||
hd = stat(arg2, &file_info);
|
hd = stat(arg2, &file_info);
|
||||||
if(hd == -1) {
|
if(hd == -1) {
|
||||||
/* can't open file, bail out */
|
/* can't open file, bail out */
|
||||||
|
error = ERRNO;
|
||||||
|
fprintf(stderr, "stat() failed with error: %d %s\n",
|
||||||
|
error, strerror(error));
|
||||||
fprintf(stderr, "WARNING: cannot open file %s\n", arg2);
|
fprintf(stderr, "WARNING: cannot open file %s\n", arg2);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -71,6 +75,10 @@ int test(char *URL)
|
||||||
an example! */
|
an example! */
|
||||||
hd_src = fopen(arg2, "rb");
|
hd_src = fopen(arg2, "rb");
|
||||||
if(NULL == hd_src) {
|
if(NULL == hd_src) {
|
||||||
|
error = ERRNO;
|
||||||
|
fprintf(stderr, "fopen() failed with error: %d %s\n",
|
||||||
|
error, strerror(error));
|
||||||
|
fprintf(stderr, "Error opening file: %s\n", arg2);
|
||||||
return -2; /* if this happens things are major weird */
|
return -2; /* if this happens things are major weird */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@ int test(char *URL)
|
||||||
CURL *curl;
|
CURL *curl;
|
||||||
FILE *hd_src ;
|
FILE *hd_src ;
|
||||||
int hd ;
|
int hd ;
|
||||||
|
int error;
|
||||||
struct_stat file_info;
|
struct_stat file_info;
|
||||||
int running;
|
int running;
|
||||||
char done=FALSE;
|
char done=FALSE;
|
||||||
|
@ -48,6 +49,13 @@ int test(char *URL)
|
||||||
fdopen() from the previous descriptor, but hey this is just
|
fdopen() from the previous descriptor, but hey this is just
|
||||||
an example! */
|
an example! */
|
||||||
hd_src = fopen(arg2, "rb");
|
hd_src = fopen(arg2, "rb");
|
||||||
|
if(NULL == hd_src) {
|
||||||
|
error = ERRNO;
|
||||||
|
fprintf(stderr, "fopen() failed with error: %d %s\n",
|
||||||
|
error, strerror(error));
|
||||||
|
fprintf(stderr, "Error opening file: %s\n", arg2);
|
||||||
|
return TEST_ERR_MAJOR_BAD;
|
||||||
|
}
|
||||||
|
|
||||||
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
|
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
|
||||||
fprintf(stderr, "curl_global_init() failed\n");
|
fprintf(stderr, "curl_global_init() failed\n");
|
||||||
|
|
Loading…
Reference in New Issue