mirror of
https://github.com/moparisthebest/curl
synced 2024-11-12 04:25:08 -05:00
OS400/ccsidcurl.c: code style fixes
This commit is contained in:
parent
bccf1dce53
commit
0c56faf43d
@ -94,7 +94,7 @@ iconv_open_CCSID(unsigned int ccsidout, unsigned int ccsidin,
|
|||||||
|
|
||||||
makeOS400IconvCode(fromcode, ccsidin);
|
makeOS400IconvCode(fromcode, ccsidin);
|
||||||
makeOS400IconvCode(tocode, ccsidout);
|
makeOS400IconvCode(tocode, ccsidout);
|
||||||
memset(tocode + 13, 0, sizeof tocode - 13); /* Dest. code id format. */
|
memset(tocode + 13, 0, sizeof(tocode) - 13); /* Dest. code id format. */
|
||||||
|
|
||||||
if(cstr)
|
if(cstr)
|
||||||
fromcode[18] = '1'; /* Set null-terminator flag. */
|
fromcode[18] = '1'; /* Set null-terminator flag. */
|
||||||
@ -104,8 +104,8 @@ iconv_open_CCSID(unsigned int ccsidout, unsigned int ccsidin,
|
|||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
convert(char * d, size_t dlen, int dccsid,
|
convert(char *d, size_t dlen, int dccsid,
|
||||||
const char * s, int slen, int sccsid)
|
const char *s, int slen, int sccsid)
|
||||||
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@ -161,11 +161,11 @@ convert(char * d, size_t dlen, int dccsid,
|
|||||||
|
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
dynconvert(int dccsid, const char * s, int slen, int sccsid)
|
dynconvert(int dccsid, const char *s, int slen, int sccsid)
|
||||||
|
|
||||||
{
|
{
|
||||||
char * d;
|
char *d;
|
||||||
char * cp;
|
char *cp;
|
||||||
size_t dlen;
|
size_t dlen;
|
||||||
int l;
|
int l;
|
||||||
static const char nullbyte = 0;
|
static const char nullbyte = 0;
|
||||||
@ -213,14 +213,14 @@ dynconvert(int dccsid, const char * s, int slen, int sccsid)
|
|||||||
|
|
||||||
|
|
||||||
static struct curl_slist *
|
static struct curl_slist *
|
||||||
slist_convert(int dccsid, struct curl_slist * from, int sccsid)
|
slist_convert(int dccsid, struct curl_slist *from, int sccsid)
|
||||||
|
|
||||||
{
|
{
|
||||||
struct curl_slist * to = (struct curl_slist *) NULL;
|
struct curl_slist *to = (struct curl_slist *) NULL;
|
||||||
|
|
||||||
for(; from; from = from->next) {
|
for(; from; from = from->next) {
|
||||||
struct curl_slist *nl;
|
struct curl_slist *nl;
|
||||||
char * cp = dynconvert(dccsid, from->data, -1, sccsid);
|
char *cp = dynconvert(dccsid, from->data, -1, sccsid);
|
||||||
|
|
||||||
if(!cp) {
|
if(!cp) {
|
||||||
curl_slist_free_all(to);
|
curl_slist_free_all(to);
|
||||||
@ -243,8 +243,8 @@ curl_version_ccsid(unsigned int ccsid)
|
|||||||
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char * aversion;
|
char *aversion;
|
||||||
char * eversion;
|
char *eversion;
|
||||||
|
|
||||||
aversion = curl_version();
|
aversion = curl_version();
|
||||||
|
|
||||||
@ -254,7 +254,8 @@ curl_version_ccsid(unsigned int ccsid)
|
|||||||
i = strlen(aversion) + 1;
|
i = strlen(aversion) + 1;
|
||||||
i *= MAX_CONV_EXPANSION;
|
i *= MAX_CONV_EXPANSION;
|
||||||
|
|
||||||
if(!(eversion = Curl_thread_buffer(LK_CURL_VERSION, i)))
|
eversion = Curl_thread_buffer(LK_CURL_VERSION, i);
|
||||||
|
if(!eversion)
|
||||||
return (char *) NULL;
|
return (char *) NULL;
|
||||||
|
|
||||||
if(convert(eversion, i, ccsid, aversion, -1, ASCII_CCSID) < 0)
|
if(convert(eversion, i, ccsid, aversion, -1, ASCII_CCSID) < 0)
|
||||||
@ -265,12 +266,12 @@ curl_version_ccsid(unsigned int ccsid)
|
|||||||
|
|
||||||
|
|
||||||
char *
|
char *
|
||||||
curl_easy_escape_ccsid(CURL * handle, const char * string, int length,
|
curl_easy_escape_ccsid(CURL *handle, const char *string, int length,
|
||||||
unsigned int sccsid, unsigned int dccsid)
|
unsigned int sccsid, unsigned int dccsid)
|
||||||
|
|
||||||
{
|
{
|
||||||
char * s;
|
char *s;
|
||||||
char * d;
|
char *d;
|
||||||
|
|
||||||
if(!string) {
|
if(!string) {
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
@ -295,13 +296,13 @@ curl_easy_escape_ccsid(CURL * handle, const char * string, int length,
|
|||||||
|
|
||||||
|
|
||||||
char *
|
char *
|
||||||
curl_easy_unescape_ccsid(CURL * handle, const char * string, int length,
|
curl_easy_unescape_ccsid(CURL *handle, const char *string, int length,
|
||||||
int * outlength,
|
int *outlength,
|
||||||
unsigned int sccsid, unsigned int dccsid)
|
unsigned int sccsid, unsigned int dccsid)
|
||||||
|
|
||||||
{
|
{
|
||||||
char * s;
|
char *s;
|
||||||
char * d;
|
char *d;
|
||||||
|
|
||||||
if(!string) {
|
if(!string) {
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
@ -330,11 +331,11 @@ curl_easy_unescape_ccsid(CURL * handle, const char * string, int length,
|
|||||||
|
|
||||||
|
|
||||||
struct curl_slist *
|
struct curl_slist *
|
||||||
curl_slist_append_ccsid(struct curl_slist * list,
|
curl_slist_append_ccsid(struct curl_slist *list,
|
||||||
const char * data, unsigned int ccsid)
|
const char *data, unsigned int ccsid)
|
||||||
|
|
||||||
{
|
{
|
||||||
char * s;
|
char *s;
|
||||||
|
|
||||||
s = (char *) NULL;
|
s = (char *) NULL;
|
||||||
|
|
||||||
@ -353,10 +354,10 @@ curl_slist_append_ccsid(struct curl_slist * list,
|
|||||||
|
|
||||||
|
|
||||||
time_t
|
time_t
|
||||||
curl_getdate_ccsid(const char * p, const time_t * unused, unsigned int ccsid)
|
curl_getdate_ccsid(const char *p, const time_t * unused, unsigned int ccsid)
|
||||||
|
|
||||||
{
|
{
|
||||||
char * s;
|
char *s;
|
||||||
time_t t;
|
time_t t;
|
||||||
|
|
||||||
if(!p)
|
if(!p)
|
||||||
@ -375,7 +376,7 @@ curl_getdate_ccsid(const char * p, const time_t * unused, unsigned int ccsid)
|
|||||||
|
|
||||||
static int
|
static int
|
||||||
convert_version_info_string(const char * * stringp,
|
convert_version_info_string(const char * * stringp,
|
||||||
char * * bufp, int * left, unsigned int ccsid)
|
char * * bufp, int *left, unsigned int ccsid)
|
||||||
|
|
||||||
{
|
{
|
||||||
/* Helper for curl_version_info_ccsid(): convert a string if defined.
|
/* Helper for curl_version_info_ccsid(): convert a string if defined.
|
||||||
@ -403,7 +404,7 @@ curl_version_info_ccsid(CURLversion stamp, unsigned int ccsid)
|
|||||||
|
|
||||||
{
|
{
|
||||||
curl_version_info_data * p;
|
curl_version_info_data * p;
|
||||||
char * cp;
|
char *cp;
|
||||||
int n;
|
int n;
|
||||||
int nproto;
|
int nproto;
|
||||||
curl_version_info_data * id;
|
curl_version_info_data * id;
|
||||||
@ -468,17 +469,17 @@ curl_version_info_ccsid(CURLversion stamp, unsigned int ccsid)
|
|||||||
|
|
||||||
cp = Curl_thread_buffer(LK_VERSION_INFO_DATA, n);
|
cp = Curl_thread_buffer(LK_VERSION_INFO_DATA, n);
|
||||||
id = (curl_version_info_data *) Curl_thread_buffer(LK_VERSION_INFO,
|
id = (curl_version_info_data *) Curl_thread_buffer(LK_VERSION_INFO,
|
||||||
sizeof *id);
|
sizeof(*id));
|
||||||
|
|
||||||
if(!id || !cp)
|
if(!id || !cp)
|
||||||
return (curl_version_info_data *) NULL;
|
return (curl_version_info_data *) NULL;
|
||||||
|
|
||||||
/* Copy data and convert strings. */
|
/* Copy data and convert strings. */
|
||||||
|
|
||||||
memcpy((char *) id, (char *) p, sizeof *p);
|
memcpy((char *) id, (char *) p, sizeof(*p));
|
||||||
|
|
||||||
if(id->protocols) {
|
if(id->protocols) {
|
||||||
int i = nproto * sizeof id->protocols[0];
|
int i = nproto * sizeof(id->protocols[0]);
|
||||||
|
|
||||||
id->protocols = (const char * const *) cp;
|
id->protocols = (const char * const *) cp;
|
||||||
memcpy(cp, (char *) p->protocols, i);
|
memcpy(cp, (char *) p->protocols, i);
|
||||||
@ -521,8 +522,8 @@ curl_easy_strerror_ccsid(CURLcode error, unsigned int ccsid)
|
|||||||
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
const char * s;
|
const char *s;
|
||||||
char * buf;
|
char *buf;
|
||||||
|
|
||||||
s = curl_easy_strerror(error);
|
s = curl_easy_strerror(error);
|
||||||
|
|
||||||
@ -531,7 +532,8 @@ curl_easy_strerror_ccsid(CURLcode error, unsigned int ccsid)
|
|||||||
|
|
||||||
i = MAX_CONV_EXPANSION * (strlen(s) + 1);
|
i = MAX_CONV_EXPANSION * (strlen(s) + 1);
|
||||||
|
|
||||||
if(!(buf = Curl_thread_buffer(LK_EASY_STRERROR, i)))
|
buf = Curl_thread_buffer(LK_EASY_STRERROR, i);
|
||||||
|
if(!buf)
|
||||||
return (const char *) NULL;
|
return (const char *) NULL;
|
||||||
|
|
||||||
if(convert(buf, i, ccsid, s, -1, ASCII_CCSID) < 0)
|
if(convert(buf, i, ccsid, s, -1, ASCII_CCSID) < 0)
|
||||||
@ -546,8 +548,8 @@ curl_share_strerror_ccsid(CURLSHcode error, unsigned int ccsid)
|
|||||||
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
const char * s;
|
const char *s;
|
||||||
char * buf;
|
char *buf;
|
||||||
|
|
||||||
s = curl_share_strerror(error);
|
s = curl_share_strerror(error);
|
||||||
|
|
||||||
@ -556,7 +558,8 @@ curl_share_strerror_ccsid(CURLSHcode error, unsigned int ccsid)
|
|||||||
|
|
||||||
i = MAX_CONV_EXPANSION * (strlen(s) + 1);
|
i = MAX_CONV_EXPANSION * (strlen(s) + 1);
|
||||||
|
|
||||||
if(!(buf = Curl_thread_buffer(LK_SHARE_STRERROR, i)))
|
buf = Curl_thread_buffer(LK_SHARE_STRERROR, i);
|
||||||
|
if(!buf)
|
||||||
return (const char *) NULL;
|
return (const char *) NULL;
|
||||||
|
|
||||||
if(convert(buf, i, ccsid, s, -1, ASCII_CCSID) < 0)
|
if(convert(buf, i, ccsid, s, -1, ASCII_CCSID) < 0)
|
||||||
@ -571,8 +574,8 @@ curl_multi_strerror_ccsid(CURLMcode error, unsigned int ccsid)
|
|||||||
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
const char * s;
|
const char *s;
|
||||||
char * buf;
|
char *buf;
|
||||||
|
|
||||||
s = curl_multi_strerror(error);
|
s = curl_multi_strerror(error);
|
||||||
|
|
||||||
@ -581,7 +584,8 @@ curl_multi_strerror_ccsid(CURLMcode error, unsigned int ccsid)
|
|||||||
|
|
||||||
i = MAX_CONV_EXPANSION * (strlen(s) + 1);
|
i = MAX_CONV_EXPANSION * (strlen(s) + 1);
|
||||||
|
|
||||||
if(!(buf = Curl_thread_buffer(LK_MULTI_STRERROR, i)))
|
buf = Curl_thread_buffer(LK_MULTI_STRERROR, i);
|
||||||
|
if(!buf)
|
||||||
return (const char *) NULL;
|
return (const char *) NULL;
|
||||||
|
|
||||||
if(convert(buf, i, ccsid, s, -1, ASCII_CCSID) < 0)
|
if(convert(buf, i, ccsid, s, -1, ASCII_CCSID) < 0)
|
||||||
@ -610,11 +614,11 @@ curl_certinfo_free_all(struct curl_certinfo *info)
|
|||||||
|
|
||||||
|
|
||||||
CURLcode
|
CURLcode
|
||||||
curl_easy_getinfo_ccsid(CURL * curl, CURLINFO info, ...)
|
curl_easy_getinfo_ccsid(CURL *curl, CURLINFO info, ...)
|
||||||
|
|
||||||
{
|
{
|
||||||
va_list arg;
|
va_list arg;
|
||||||
void * paramp;
|
void *paramp;
|
||||||
CURLcode ret;
|
CURLcode ret;
|
||||||
unsigned int ccsid;
|
unsigned int ccsid;
|
||||||
char * * cpp;
|
char * * cpp;
|
||||||
@ -632,7 +636,7 @@ curl_easy_getinfo_ccsid(CURL * curl, CURLINFO info, ...)
|
|||||||
ret = Curl_getinfo(data, info, paramp);
|
ret = Curl_getinfo(data, info, paramp);
|
||||||
|
|
||||||
if(ret == CURLE_OK)
|
if(ret == CURLE_OK)
|
||||||
switch ((int) info & CURLINFO_TYPEMASK) {
|
switch((int) info & CURLINFO_TYPEMASK) {
|
||||||
|
|
||||||
case CURLINFO_STRING:
|
case CURLINFO_STRING:
|
||||||
ccsid = va_arg(arg, unsigned int);
|
ccsid = va_arg(arg, unsigned int);
|
||||||
@ -649,16 +653,17 @@ curl_easy_getinfo_ccsid(CURL * curl, CURLINFO info, ...)
|
|||||||
|
|
||||||
case CURLINFO_SLIST:
|
case CURLINFO_SLIST:
|
||||||
ccsid = va_arg(arg, unsigned int);
|
ccsid = va_arg(arg, unsigned int);
|
||||||
switch (info) {
|
switch(info) {
|
||||||
case CURLINFO_CERTINFO:
|
case CURLINFO_CERTINFO:
|
||||||
cipf = *(struct curl_certinfo * *) paramp;
|
cipf = *(struct curl_certinfo * *) paramp;
|
||||||
if(cipf) {
|
if(cipf) {
|
||||||
if(!(cipt = (struct curl_certinfo *) malloc(sizeof *cipt)))
|
cipt = (struct curl_certinfo *) malloc(sizeof(*cipt));
|
||||||
|
if(!cipt)
|
||||||
ret = CURLE_OUT_OF_MEMORY;
|
ret = CURLE_OUT_OF_MEMORY;
|
||||||
else {
|
else {
|
||||||
cipt->certinfo = (struct curl_slist * *)
|
cipt->certinfo = (struct curl_slist **)
|
||||||
calloc(cipf->num_of_certs +
|
calloc(cipf->num_of_certs +
|
||||||
1, sizeof(struct curl_slist *));
|
1, sizeof(struct curl_slist *));
|
||||||
if(!cipt->certinfo)
|
if(!cipt->certinfo)
|
||||||
ret = CURLE_OUT_OF_MEMORY;
|
ret = CURLE_OUT_OF_MEMORY;
|
||||||
else {
|
else {
|
||||||
@ -692,10 +697,12 @@ curl_easy_getinfo_ccsid(CURL * curl, CURLINFO info, ...)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
slp = (struct curl_slist * *) paramp;
|
slp = (struct curl_slist **) paramp;
|
||||||
if(*slp)
|
if(*slp) {
|
||||||
if(!(*slp = slist_convert(ccsid, *slp, ASCII_CCSID)))
|
*slp = slist_convert(ccsid, *slp, ASCII_CCSID);
|
||||||
|
if(!*slp)
|
||||||
ret = CURLE_OUT_OF_MEMORY;
|
ret = CURLE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -709,7 +716,7 @@ static int
|
|||||||
Curl_is_formadd_string(CURLformoption option)
|
Curl_is_formadd_string(CURLformoption option)
|
||||||
|
|
||||||
{
|
{
|
||||||
switch (option) {
|
switch(option) {
|
||||||
|
|
||||||
case CURLFORM_FILENAME:
|
case CURLFORM_FILENAME:
|
||||||
case CURLFORM_CONTENTTYPE:
|
case CURLFORM_CONTENTTYPE:
|
||||||
@ -745,8 +752,8 @@ Curl_formadd_convert(struct curl_forms * forms,
|
|||||||
|
|
||||||
{
|
{
|
||||||
int l;
|
int l;
|
||||||
char * cp;
|
char *cp;
|
||||||
char * cp2;
|
char *cp2;
|
||||||
|
|
||||||
if(formx < 0 || !forms[formx].value)
|
if(formx < 0 || !forms[formx].value)
|
||||||
return 0;
|
return 0;
|
||||||
@ -795,7 +802,7 @@ curl_formadd_ccsid(struct curl_httppost * * httppost,
|
|||||||
struct curl_forms * lforms;
|
struct curl_forms * lforms;
|
||||||
struct curl_forms * tforms;
|
struct curl_forms * tforms;
|
||||||
unsigned int lformlen;
|
unsigned int lformlen;
|
||||||
const char * value;
|
const char *value;
|
||||||
unsigned int ccsid;
|
unsigned int ccsid;
|
||||||
int nargs;
|
int nargs;
|
||||||
int namex;
|
int namex;
|
||||||
@ -823,7 +830,7 @@ curl_formadd_ccsid(struct curl_httppost * * httppost,
|
|||||||
/* Allocate the local curl_forms array. */
|
/* Allocate the local curl_forms array. */
|
||||||
|
|
||||||
lformlen = ALLOC_GRANULE;
|
lformlen = ALLOC_GRANULE;
|
||||||
lforms = malloc(lformlen * sizeof *lforms);
|
lforms = malloc(lformlen * sizeof(*lforms));
|
||||||
|
|
||||||
if(!lforms)
|
if(!lforms)
|
||||||
return CURL_FORMADD_MEMORY;
|
return CURL_FORMADD_MEMORY;
|
||||||
@ -845,7 +852,7 @@ curl_formadd_ccsid(struct curl_httppost * * httppost,
|
|||||||
|
|
||||||
if(nargs >= lformlen) {
|
if(nargs >= lformlen) {
|
||||||
lformlen += ALLOC_GRANULE;
|
lformlen += ALLOC_GRANULE;
|
||||||
tforms = realloc(lforms, lformlen * sizeof *lforms);
|
tforms = realloc(lforms, lformlen * sizeof(*lforms));
|
||||||
|
|
||||||
if(!tforms) {
|
if(!tforms) {
|
||||||
result = CURL_FORMADD_MEMORY;
|
result = CURL_FORMADD_MEMORY;
|
||||||
@ -875,7 +882,7 @@ curl_formadd_ccsid(struct curl_httppost * * httppost,
|
|||||||
|
|
||||||
/* Dispatch by option. */
|
/* Dispatch by option. */
|
||||||
|
|
||||||
switch (option) {
|
switch(option) {
|
||||||
|
|
||||||
case CURLFORM_END:
|
case CURLFORM_END:
|
||||||
forms = (struct curl_forms *) NULL; /* Leave array mode. */
|
forms = (struct curl_forms *) NULL; /* Leave array mode. */
|
||||||
@ -1065,11 +1072,11 @@ typedef struct {
|
|||||||
|
|
||||||
|
|
||||||
static size_t
|
static size_t
|
||||||
Curl_formget_callback_ccsid(void * arg, const char * buf, size_t len)
|
Curl_formget_callback_ccsid(void *arg, const char *buf, size_t len)
|
||||||
|
|
||||||
{
|
{
|
||||||
cfcdata * p;
|
cfcdata * p;
|
||||||
char * b;
|
char *b;
|
||||||
int l;
|
int l;
|
||||||
size_t ret;
|
size_t ret;
|
||||||
|
|
||||||
@ -1097,7 +1104,7 @@ Curl_formget_callback_ccsid(void * arg, const char * buf, size_t len)
|
|||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
curl_formget_ccsid(struct curl_httppost * form, void * arg,
|
curl_formget_ccsid(struct curl_httppost *form, void *arg,
|
||||||
curl_formget_callback append, unsigned int ccsid)
|
curl_formget_callback append, unsigned int ccsid)
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -1111,14 +1118,14 @@ curl_formget_ccsid(struct curl_httppost * form, void * arg,
|
|||||||
|
|
||||||
|
|
||||||
CURLcode
|
CURLcode
|
||||||
curl_easy_setopt_ccsid(CURL * curl, CURLoption tag, ...)
|
curl_easy_setopt_ccsid(CURL *curl, CURLoption tag, ...)
|
||||||
|
|
||||||
{
|
{
|
||||||
CURLcode result;
|
CURLcode result;
|
||||||
va_list arg;
|
va_list arg;
|
||||||
struct Curl_easy * data;
|
struct Curl_easy *data;
|
||||||
char * s;
|
char *s;
|
||||||
char * cp;
|
char *cp;
|
||||||
unsigned int ccsid;
|
unsigned int ccsid;
|
||||||
curl_off_t pfsize;
|
curl_off_t pfsize;
|
||||||
static char testwarn = 1;
|
static char testwarn = 1;
|
||||||
@ -1146,7 +1153,7 @@ curl_easy_setopt_ccsid(CURL * curl, CURLoption tag, ...)
|
|||||||
data = (struct Curl_easy *) curl;
|
data = (struct Curl_easy *) curl;
|
||||||
va_start(arg, tag);
|
va_start(arg, tag);
|
||||||
|
|
||||||
switch (tag) {
|
switch(tag) {
|
||||||
|
|
||||||
case CURLOPT_ABSTRACT_UNIX_SOCKET:
|
case CURLOPT_ABSTRACT_UNIX_SOCKET:
|
||||||
case CURLOPT_ALTSVC:
|
case CURLOPT_ALTSVC:
|
||||||
|
Loading…
Reference in New Issue
Block a user