1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-21 23:58:49 -05:00

use the new lib/curlx.h header and modified the code to use all to-become-

curlx_-functions with the new prefix to prepare this code for the future
removal of several curl_-functions from the public libcurl API.
This commit is contained in:
Daniel Stenberg 2004-04-30 08:23:50 +00:00
parent 913e1570bd
commit ec113aefb9

View File

@ -35,9 +35,6 @@
#include <curl/curl.h> #include <curl/curl.h>
#define _MPRINTF_REPLACE /* we want curl-functions instead of native ones */
#include <curl/mprintf.h>
#include "urlglob.h" #include "urlglob.h"
#include "writeout.h" #include "writeout.h"
#include "getpass.h" #include "getpass.h"
@ -103,8 +100,10 @@
#include <sys/poll.h> #include <sys/poll.h>
#endif #endif
#include <strtoofft.h> /* header from the libcurl directory */ #define ENABLE_CURLX_PRINTF
#include <timeval.h> /* header from the libcurl directory */ /* make the curlx header define all printf() functions to use the curlx_*
versions instead */
#include <curlx.h> /* header from the libcurl directory */
/* The last #include file should be: */ /* The last #include file should be: */
#ifdef CURLDEBUG #ifdef CURLDEBUG
@ -811,7 +810,7 @@ static int formparse(char *input,
while(isspace((int)*ptr)) while(isspace((int)*ptr))
ptr++; ptr++;
if(curl_strnequal("type=", ptr, 5)) { if(curlx_strnequal("type=", ptr, 5)) {
/* set type pointer */ /* set type pointer */
type = &ptr[5]; type = &ptr[5];
@ -831,7 +830,7 @@ static int formparse(char *input,
ptr=sep+1; ptr=sep+1;
} }
else if(curl_strnequal("filename=", ptr, 9)) { else if(curlx_strnequal("filename=", ptr, 9)) {
filename = &ptr[9]; filename = &ptr[9];
ptr=strchr(filename, FORM_TYPE_SEPARATOR); ptr=strchr(filename, FORM_TYPE_SEPARATOR);
if(!ptr) { if(!ptr) {
@ -898,9 +897,9 @@ static int formparse(char *input,
} }
forms[count].option = CURLFORM_END; forms[count].option = CURLFORM_END;
FreeMultiInfo (multi_start); FreeMultiInfo (multi_start);
if (curl_formadd (httppost, last_post, if (curl_formadd(httppost, last_post,
CURLFORM_COPYNAME, name, CURLFORM_COPYNAME, name,
CURLFORM_ARRAY, forms, CURLFORM_END) != 0) { CURLFORM_ARRAY, forms, CURLFORM_END) != 0) {
fprintf(stderr, "curl_formadd failed!\n"); fprintf(stderr, "curl_formadd failed!\n");
free(forms); free(forms);
free(contents); free(contents);
@ -911,18 +910,18 @@ static int formparse(char *input,
} }
else { else {
if( contp[0]=='<' ) { if( contp[0]=='<' ) {
if (curl_formadd (httppost, last_post, if (curl_formadd(httppost, last_post,
CURLFORM_COPYNAME, name, CURLFORM_COPYNAME, name,
CURLFORM_FILECONTENT, contp+1, CURLFORM_END) != 0) { CURLFORM_FILECONTENT, contp+1, CURLFORM_END) != 0) {
fprintf(stderr, "curl_formadd failed!\n"); fprintf(stderr, "curl_formadd failed!\n");
free(contents); free(contents);
return 6; return 6;
} }
} }
else { else {
if (curl_formadd (httppost, last_post, if (curl_formadd(httppost, last_post,
CURLFORM_COPYNAME, name, CURLFORM_COPYNAME, name,
CURLFORM_COPYCONTENTS, contp, CURLFORM_END) != 0) { CURLFORM_COPYCONTENTS, contp, CURLFORM_END) != 0) {
fprintf(stderr, "curl_formadd failed!\n"); fprintf(stderr, "curl_formadd failed!\n");
free(contents); free(contents);
return 7; return 7;
@ -1059,7 +1058,7 @@ static void checkpasswd(const char *kind, /* for what purpose */
char *passptr; char *passptr;
/* build a nice-looking prompt */ /* build a nice-looking prompt */
curl_msnprintf(prompt, sizeof(prompt), curlx_msnprintf(prompt, sizeof(prompt),
"Enter %s password for user '%s':", "Enter %s password for user '%s':",
kind, *userpwd); kind, *userpwd);
@ -1218,10 +1217,10 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */
size_t fnam=strlen(word); size_t fnam=strlen(word);
int numhits=0; int numhits=0;
for(j=0; j< sizeof(aliases)/sizeof(aliases[0]); j++) { for(j=0; j< sizeof(aliases)/sizeof(aliases[0]); j++) {
if(curl_strnequal(aliases[j].lname, word, fnam)) { if(curlx_strnequal(aliases[j].lname, word, fnam)) {
longopt = TRUE; longopt = TRUE;
numhits++; numhits++;
if(curl_strequal(aliases[j].lname, word)) { if(curlx_strequal(aliases[j].lname, word)) {
parse = aliases[j].letter; parse = aliases[j].letter;
hit = j; hit = j;
numhits = 1; /* a single unique hit */ numhits = 1; /* a single unique hit */
@ -1528,7 +1527,7 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */
break; break;
case 'C': case 'C':
/* This makes us continue an ftp transfer at given position */ /* This makes us continue an ftp transfer at given position */
if(!curl_strequal(nextarg, "-")) { if(!curlx_strequal(nextarg, "-")) {
if(str2offset(&config->resume_from, nextarg)) if(str2offset(&config->resume_from, nextarg))
return PARAM_BAD_NUMERIC; return PARAM_BAD_NUMERIC;
config->resume_from_current = FALSE; config->resume_from_current = FALSE;
@ -1551,7 +1550,7 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */
nextarg++; /* pass the @ */ nextarg++; /* pass the @ */
if(curl_strequal("-", nextarg)) if(curlx_strequal("-", nextarg))
file = stdin; file = stdin;
else else
file = fopen(nextarg, "rb"); file = fopen(nextarg, "rb");
@ -1944,7 +1943,7 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */
or - (stdin) follows */ or - (stdin) follows */
FILE *file; FILE *file;
nextarg++; /* pass the @ */ nextarg++; /* pass the @ */
if(curl_strequal("-", nextarg)) if(curlx_strequal("-", nextarg))
file = stdin; file = stdin;
else else
file = fopen(nextarg, "r"); file = fopen(nextarg, "r");
@ -2452,7 +2451,7 @@ void progressbarinit(struct ProgressData *bar,
/* 20000318 mgs /* 20000318 mgs
* OS/2 users most likely won't have this env var set, and besides that * OS/2 users most likely won't have this env var set, and besides that
* we're using our own way to determine screen width */ * we're using our own way to determine screen width */
colp = curl_getenv("COLUMNS"); colp = curlx_getenv("COLUMNS");
if (colp != NULL) { if (colp != NULL) {
bar->width = atoi(colp); bar->width = atoi(colp);
curl_free(colp); curl_free(colp);
@ -2534,7 +2533,7 @@ int my_trace(CURL *handle, curl_infotype type,
if(!config->trace_stream) { if(!config->trace_stream) {
/* open for append */ /* open for append */
if(curl_strequal("-", config->trace_dump)) if(curlx_strequal("-", config->trace_dump))
config->trace_stream = stdout; config->trace_stream = stdout;
else { else {
config->trace_stream = fopen(config->trace_dump, "w"); config->trace_stream = fopen(config->trace_dump, "w");
@ -2690,12 +2689,12 @@ operate(struct Configurable *config, int argc, char *argv[])
char *env; char *env;
#ifdef CURLDEBUG #ifdef CURLDEBUG
/* this sends all memory debug messages to a logfile named memdump */ /* this sends all memory debug messages to a logfile named memdump */
env = curl_getenv("CURL_MEMDEBUG"); env = curlx_getenv("CURL_MEMDEBUG");
if(env) { if(env) {
curl_free(env); curl_free(env);
curl_memdebug("memdump"); curl_memdebug("memdump");
} }
env = curl_getenv("CURL_MEMLIMIT"); env = curlx_getenv("CURL_MEMLIMIT");
if(env) { if(env) {
curl_memlimit(atoi(env)); curl_memlimit(atoi(env));
curl_free(env); curl_free(env);
@ -2722,7 +2721,7 @@ operate(struct Configurable *config, int argc, char *argv[])
config->lastsendtime = curlx_tvnow(); config->lastsendtime = curlx_tvnow();
if(argc>1 && if(argc>1 &&
(!curl_strnequal("--", argv[1], 2) && (argv[1][0] == '-')) && (!curlx_strnequal("--", argv[1], 2) && (argv[1][0] == '-')) &&
strchr(argv[1], 'q')) { strchr(argv[1], 'q')) {
/* /*
* The first flag, that is not a verbose name, but a shortname * The first flag, that is not a verbose name, but a shortname
@ -2749,7 +2748,7 @@ operate(struct Configurable *config, int argc, char *argv[])
char *flag = argv[i]; char *flag = argv[i];
if(curl_strequal("--", argv[i])) if(curlx_strequal("--", argv[i]))
/* this indicates the end of the flags and thus enables the /* this indicates the end of the flags and thus enables the
following (URL) argument to start with -. */ following (URL) argument to start with -. */
stillflags=FALSE; stillflags=FALSE;
@ -2804,7 +2803,7 @@ operate(struct Configurable *config, int argc, char *argv[])
if (!config->cacert && if (!config->cacert &&
!config->capath && !config->capath &&
!config->insecure_ok) { !config->insecure_ok) {
env = curl_getenv("CURL_CA_BUNDLE"); env = curlx_getenv("CURL_CA_BUNDLE");
if(env) { if(env) {
GetStr(&config->cacert, env); GetStr(&config->cacert, env);
curl_free(env); curl_free(env);
@ -2925,7 +2924,7 @@ operate(struct Configurable *config, int argc, char *argv[])
urlnum = 1; /* without globbing, this is a single URL */ urlnum = 1; /* without globbing, this is a single URL */
/* if multiple files extracted to stdout, insert separators! */ /* if multiple files extracted to stdout, insert separators! */
separator= ((!outfiles || curl_strequal(outfiles, "-")) && urlnum > 1); separator= ((!outfiles || curlx_strequal(outfiles, "-")) && urlnum > 1);
/* Here's looping around each globbed URL */ /* Here's looping around each globbed URL */
for(i = 0; for(i = 0;
@ -2935,7 +2934,7 @@ operate(struct Configurable *config, int argc, char *argv[])
outfile = outfiles?strdup(outfiles):NULL; outfile = outfiles?strdup(outfiles):NULL;
if((urlnode->flags&GETOUT_USEREMOTE) || if((urlnode->flags&GETOUT_USEREMOTE) ||
(outfile && !curl_strequal("-", outfile)) ) { (outfile && !curlx_strequal("-", outfile)) ) {
/* /*
* We have specified a file name to store the result in, or we have * We have specified a file name to store the result in, or we have
@ -3026,7 +3025,7 @@ operate(struct Configurable *config, int argc, char *argv[])
} }
} }
infdfopen=FALSE; infdfopen=FALSE;
if(uploadfile && !curl_strequal(uploadfile, "-")) { if(uploadfile && !curlx_strequal(uploadfile, "-")) {
/* /*
* We have specified a file to upload and it isn't "-". * We have specified a file to upload and it isn't "-".
*/ */
@ -3103,7 +3102,7 @@ operate(struct Configurable *config, int argc, char *argv[])
uploadfilesize=fileinfo.st_size; uploadfilesize=fileinfo.st_size;
} }
else if(uploadfile && curl_strequal(uploadfile, "-")) { else if(uploadfile && curlx_strequal(uploadfile, "-")) {
infd = stdin; infd = stdin;
} }
@ -3425,7 +3424,7 @@ operate(struct Configurable *config, int argc, char *argv[])
} }
#endif #endif
if (outfile && !curl_strequal(outfile, "-") && outs.stream) if (outfile && !curlx_strequal(outfile, "-") && outs.stream)
fclose(outs.stream); fclose(outs.stream);
#ifdef HAVE_UTIME #ifdef HAVE_UTIME