aboutsummaryrefslogtreecommitdiff
path: root/packages
diff options
context:
space:
mode:
authorPatrick Monnerat <pm@datasphere.ch>2013-07-15 18:48:02 +0200
committerPatrick Monnerat <pm@datasphere.ch>2013-07-15 18:48:02 +0200
commit464c8693d2f6f2b45b84951feb9414da698206be (patch)
tree2db09194eccc0e824bd00344a8465b9c8065d6f6 /packages
parent50af17ef240d24572bcbddc5e6b8e9a55adad28f (diff)
OS400: add slist and certinfo EBCDIC support
Diffstat (limited to 'packages')
-rw-r--r--packages/OS400/ccsidcurl.c354
-rw-r--r--packages/OS400/ccsidcurl.h3
-rw-r--r--packages/OS400/curl.inc.in7
3 files changed, 226 insertions, 138 deletions
diff --git a/packages/OS400/ccsidcurl.c b/packages/OS400/ccsidcurl.c
index 1baff3951..a37f79027 100644
--- a/packages/OS400/ccsidcurl.c
+++ b/packages/OS400/ccsidcurl.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2013, 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
@@ -33,6 +33,7 @@
#include "curl.h"
#include "mprintf.h"
+#include "slist.h"
#include "urldata.h"
#include "url.h"
#include "getinfo.h"
@@ -67,7 +68,7 @@ makeOS400IconvCode(char buf[ICONV_ID_SIZE], unsigned int ccsid)
ccsid &= 0xFFFF;
- if (ccsid == NOCONV_CCSID)
+ if(ccsid == NOCONV_CCSID)
ccsid = ASCII_CCSID;
memset(buf, 0, ICONV_ID_SIZE);
@@ -93,7 +94,7 @@ iconv_open_CCSID(unsigned int ccsidout, unsigned int ccsidin, unsigned int cstr)
makeOS400IconvCode(tocode, ccsidout);
memset(tocode + 13, 0, sizeof tocode - 13); /* Dest. code id format. */
- if (cstr)
+ if(cstr)
fromcode[18] = '1'; /* Set null-terminator flag. */
return iconv_open(tocode, fromcode);
@@ -117,23 +118,23 @@ convert(char * d, size_t dlen, int dccsid,
*** Return the converted destination byte count, or -1 if error.
**/
- if (sccsid == 65535)
+ if(sccsid == 65535)
sccsid = ASCII_CCSID;
- if (dccsid == 65535)
+ if(dccsid == 65535)
dccsid = ASCII_CCSID;
- if (sccsid == dccsid) {
+ if(sccsid == dccsid) {
lslen = slen >= 0? slen: strlen(s) + 1;
i = lslen < dlen? lslen: dlen;
- if (s != d && i > 0)
+ if(s != d && i > 0)
memcpy(d, s, i);
return i;
}
- if (slen < 0) {
+ if(slen < 0) {
lslen = 0;
cd = iconv_open_CCSID(dccsid, sccsid, 1);
}
@@ -142,12 +143,12 @@ convert(char * d, size_t dlen, int dccsid,
cd = iconv_open_CCSID(dccsid, sccsid, 0);
}
- if (ICONV_OPEN_ERROR(cd))
+ if(ICONV_OPEN_ERROR(cd))
return -1;
i = dlen;
- if ((int) iconv(cd, (char * *) &s, &lslen, &d, &dlen) < 0)
+ if((int) iconv(cd, (char * *) &s, &lslen, &d, &dlen) < 0)
i = -1;
else
i -= dlen;
@@ -174,24 +175,24 @@ dynconvert(int dccsid, const char * s, int slen, int sccsid)
dlen *= MAX_CONV_EXPANSION; /* Allow some expansion. */
d = malloc(dlen);
- if (!d)
+ if(!d)
return (char *) NULL;
l = convert(d, dlen, dccsid, s, slen, sccsid);
- if (l < 0) {
+ if(l < 0) {
free(d);
return (char *) NULL;
}
- if (slen < 0) {
+ if(slen < 0) {
/* Need to null-terminate even when source length is given.
Since destination code size is unknown, use a conversion to generate
terminator. */
l2 = convert(d + l, dlen - l, dccsid, &nullbyte, -1, ASCII_CCSID);
- if (l2 < 0) {
+ if(l2 < 0) {
free(d);
return (char *) NULL;
}
@@ -199,10 +200,10 @@ dynconvert(int dccsid, const char * s, int slen, int sccsid)
l += l2;
}
- if ((size_t) l < dlen) {
+ if((size_t) l < dlen) {
cp = realloc(d, l); /* Shorten to minimum needed. */
- if (cp)
+ if(cp)
d = cp;
}
@@ -210,6 +211,24 @@ dynconvert(int dccsid, const char * s, int slen, int sccsid)
}
+static struct curl_slist *
+slist_convert(int dccsid, struct curl_slist * from, int sccsid)
+
+{
+ struct curl_slist * to = (struct curl_slist *) NULL;
+ char * cp;
+
+ for (; from; from = from->next) {
+ if(!(cp = dynconvert(dccsid, from->data, -1, sccsid))) {
+ curl_slist_free_all(to);
+ return (struct curl_slist *) NULL;
+ }
+ to = Curl_slist_append_nodup(to, cp);
+ }
+ return to;
+}
+
+
char *
curl_version_ccsid(unsigned int ccsid)
@@ -220,16 +239,16 @@ curl_version_ccsid(unsigned int ccsid)
aversion = curl_version();
- if (!aversion)
+ if(!aversion)
return aversion;
i = strlen(aversion) + 1;
i *= MAX_CONV_EXPANSION;
- if (!(eversion = Curl_thread_buffer(LK_CURL_VERSION, i)))
+ if(!(eversion = Curl_thread_buffer(LK_CURL_VERSION, i)))
return (char *) NULL;
- if (convert(eversion, i, ccsid, aversion, -1, ASCII_CCSID) < 0)
+ if(convert(eversion, i, ccsid, aversion, -1, ASCII_CCSID) < 0)
return (char *) NULL;
return eversion;
@@ -244,20 +263,20 @@ curl_easy_escape_ccsid(CURL * handle, const char * string, int length,
char * s;
char * d;
- if (!string) {
+ if(!string) {
errno = EINVAL;
return (char *) NULL;
}
s = dynconvert(ASCII_CCSID, s, length? length: -1, sccsid);
- if (!s)
+ if(!s)
return (char *) NULL;
d = curl_easy_escape(handle, s, 0);
free(s);
- if (!d)
+ if(!d)
return (char *) NULL;
s = dynconvert(dccsid, d, -1, ASCII_CCSID);
@@ -275,26 +294,26 @@ curl_easy_unescape_ccsid(CURL * handle, const char * string, int length,
char * s;
char * d;
- if (!string) {
+ if(!string) {
errno = EINVAL;
return (char *) NULL;
}
s = dynconvert(ASCII_CCSID, s, length? length: -1, sccsid);
- if (!s)
+ if(!s)
return (char *) NULL;
d = curl_easy_unescape(handle, s, 0, outlength);
free(s);
- if (!d)
+ if(!d)
return (char *) NULL;
s = dynconvert(dccsid, d, -1, ASCII_CCSID);
free(d);
- if (s && outlength)
+ if(s && outlength)
*outlength = strlen(s);
return s;
@@ -310,12 +329,12 @@ curl_slist_append_ccsid(struct curl_slist * list,
s = (char *) NULL;
- if (!data)
+ if(!data)
return curl_slist_append(list, data);
s = dynconvert(ASCII_CCSID, data, -1, ccsid);
- if (!s)
+ if(!s)
return (struct curl_slist *) NULL;
list = curl_slist_append(list, s);
@@ -331,12 +350,12 @@ curl_getdate_ccsid(const char * p, const time_t * unused, unsigned int ccsid)
char * s;
time_t t;
- if (!p)
+ if(!p)
return curl_getdate(p, unused);
s = dynconvert(ASCII_CCSID, p, -1, ccsid);
- if (!s)
+ if(!s)
return (time_t) -1;
t = curl_getdate(s, unused);
@@ -357,10 +376,10 @@ convert_version_info_string(const char * * stringp,
`*bufp' and `*left' are updated accordingly.
Return 0 if ok, else -1. */
- if (*stringp) {
+ if(*stringp) {
l = convert(*bufp, *left, ccsid, *stringp, -1, ASCII_CCSID);
- if (l <= 0)
+ if(l <= 0)
return -1;
*stringp = *bufp;
@@ -393,12 +412,12 @@ curl_version_info_ccsid(CURLversion stamp, unsigned int ccsid)
/* If caller has been compiled with a new version, error. */
- if (stamp > CURLVERSION_NOW)
+ if(stamp > CURLVERSION_NOW)
return (curl_version_info_data *) NULL;
p = curl_version_info(stamp);
- if (!p)
+ if(!p)
return p;
/* Measure thread space needed. */
@@ -406,53 +425,53 @@ curl_version_info_ccsid(CURLversion stamp, unsigned int ccsid)
n = 0;
nproto = 0;
- if (p->protocols) {
+ if(p->protocols) {
while (p->protocols[nproto])
n += strlen(p->protocols[nproto++]);
n += nproto++;
}
- if (p->version)
+ if(p->version)
n += strlen(p->version) + 1;
- if (p->host)
+ if(p->host)
n += strlen(p->host) + 1;
- if (p->ssl_version)
+ if(p->ssl_version)
n += strlen(p->ssl_version) + 1;
- if (p->libz_version)
+ if(p->libz_version)
n += strlen(p->libz_version) + 1;
- if (p->ares)
+ if(p->ares)
n += strlen(p->ares) + 1;
- if (p->libidn)
+ if(p->libidn)
n += strlen(p->libidn) + 1;
- if (p->libssh_version)
+ if(p->libssh_version)
n += strlen(p->libssh_version) + 1;
/* Allocate thread space. */
n *= MAX_CONV_EXPANSION;
- if (nproto)
+ if(nproto)
n += nproto * sizeof(const char *);
cp = Curl_thread_buffer(LK_VERSION_INFO_DATA, n);
id = (curl_version_info_data *) Curl_thread_buffer(LK_VERSION_INFO,
sizeof *id);
- if (!id || !cp)
+ if(!id || !cp)
return (curl_version_info_data *) NULL;
/* Copy data and convert strings. */
memcpy((char *) id, (char *) p, sizeof *p);
- if (id->protocols) {
+ if(id->protocols) {
id->protocols = (const char * const *) cp;
i = nproto * sizeof id->protocols[0];
memcpy(cp, (char *) p->protocols, i);
@@ -460,30 +479,30 @@ curl_version_info_ccsid(CURLversion stamp, unsigned int ccsid)
n -= i;
for (i = 0; id->protocols[i]; i++)
- if (convert_version_info_string(((const char * *) id->protocols) + i,
+ if(convert_version_info_string(((const char * *) id->protocols) + i,
&cp, &n, ccsid))
return (curl_version_info_data *) NULL;
}
- if (convert_version_info_string(&id->version, &cp, &n, ccsid))
+ if(convert_version_info_string(&id->version, &cp, &n, ccsid))
return (curl_version_info_data *) NULL;
- if (convert_version_info_string(&id->host, &cp, &n, ccsid))
+ if(convert_version_info_string(&id->host, &cp, &n, ccsid))
return (curl_version_info_data *) NULL;
- if (convert_version_info_string(&id->ssl_version, &cp, &n, ccsid))
+ if(convert_version_info_string(&id->ssl_version, &cp, &n, ccsid))
return (curl_version_info_data *) NULL;
- if (convert_version_info_string(&id->libz_version, &cp, &n, ccsid))
+ if(convert_version_info_string(&id->libz_version, &cp, &n, ccsid))
return (curl_version_info_data *) NULL;
- if (convert_version_info_string(&id->ares, &cp, &n, ccsid))
+ if(convert_version_info_string(&id->ares, &cp, &n, ccsid))
return (curl_version_info_data *) NULL;
- if (convert_version_info_string(&id->libidn, &cp, &n, ccsid))
+ if(convert_version_info_string(&id->libidn, &cp, &n, ccsid))
return (curl_version_info_data *) NULL;
- if (convert_version_info_string(&id->libssh_version, &cp, &n, ccsid))
+ if(convert_version_info_string(&id->libssh_version, &cp, &n, ccsid))
return (curl_version_info_data *) NULL;
return id;
@@ -500,15 +519,15 @@ curl_easy_strerror_ccsid(CURLcode error, unsigned int ccsid)
s = curl_easy_strerror(error);
- if (!s)
+ if(!s)
return s;
i = MAX_CONV_EXPANSION * (strlen(s) + 1);
- if (!(buf = Curl_thread_buffer(LK_EASY_STRERROR, i)))
+ if(!(buf = Curl_thread_buffer(LK_EASY_STRERROR, i)))
return (const char *) NULL;
- if (convert(buf, i, ccsid, s, -1, ASCII_CCSID) < 0)
+ if(convert(buf, i, ccsid, s, -1, ASCII_CCSID) < 0)
return (const char *) NULL;
return (const char *) buf;
@@ -525,15 +544,15 @@ curl_share_strerror_ccsid(CURLSHcode error, unsigned int ccsid)
s = curl_share_strerror(error);
- if (!s)
+ if(!s)
return s;
i = MAX_CONV_EXPANSION * (strlen(s) + 1);
- if (!(buf = Curl_thread_buffer(LK_SHARE_STRERROR, i)))
+ if(!(buf = Curl_thread_buffer(LK_SHARE_STRERROR, i)))
return (const char *) NULL;
- if (convert(buf, i, ccsid, s, -1, ASCII_CCSID) < 0)
+ if(convert(buf, i, ccsid, s, -1, ASCII_CCSID) < 0)
return (const char *) NULL;
return (const char *) buf;
@@ -550,21 +569,39 @@ curl_multi_strerror_ccsid(CURLMcode error, unsigned int ccsid)
s = curl_multi_strerror(error);
- if (!s)
+ if(!s)
return s;
i = MAX_CONV_EXPANSION * (strlen(s) + 1);
- if (!(buf = Curl_thread_buffer(LK_MULTI_STRERROR, i)))
+ if(!(buf = Curl_thread_buffer(LK_MULTI_STRERROR, i)))
return (const char *) NULL;
- if (convert(buf, i, ccsid, s, -1, ASCII_CCSID) < 0)
+ if(convert(buf, i, ccsid, s, -1, ASCII_CCSID) < 0)
return (const char *) NULL;
return (const char *) buf;
}
+void
+curl_certinfo_free_all(struct curl_certinfo *info)
+
+{
+ int i;
+
+ /* Free all memory used by certificate info. */
+ if(info) {
+ if(info->certinfo) {
+ for (i = 0; i < info->num_of_certs; i++)
+ curl_slist_free_all(info->certinfo[i]);
+ free((char *) info->certinfo);
+ }
+ free((char *) info);
+ }
+}
+
+
CURLcode
curl_easy_getinfo_ccsid(CURL * curl, CURLINFO info, ...)
@@ -577,6 +614,10 @@ curl_easy_getinfo_ccsid(CURL * curl, CURLINFO info, ...)
char * s;
char * d;
struct SessionHandle * data;
+ struct curl_slist * * slp;
+ struct curl_certinfo * cipf;
+ struct curl_certinfo * cipt;
+ int i;
/* WARNING: unlike curl_easy_get_info(), the strings returned by this
procedure have to be free'ed. */
@@ -586,25 +627,66 @@ curl_easy_getinfo_ccsid(CURL * curl, CURLINFO info, ...)
paramp = va_arg(arg, void *);
ret = Curl_getinfo(data, info, paramp);
- if (ret != CURLE_OK || ((int) info & CURLINFO_TYPEMASK) != CURLINFO_STRING) {
- va_end(arg);
- return ret;
- }
+ if(ret == CURLE_OK)
+ switch ((int) info & CURLINFO_TYPEMASK) {
- ccsid = va_arg(arg, unsigned int);
- va_end(arg);
- cpp = (char * *) paramp;
- s = *cpp;
+ case CURLINFO_STRING:
+ ccsid = va_arg(arg, unsigned int);
+ cpp = (char * *) paramp;
+ s = *cpp;
+
+ if(s) {
+ d = dynconvert(ccsid, s, -1, ASCII_CCSID);
+ *cpp = d;
- if (!s)
- return ret;
+ if(!d)
+ ret = CURLE_OUT_OF_MEMORY;
+ }
- d = dynconvert(ccsid, s, -1, ASCII_CCSID);
- *cpp = d;
+ break;
- if (!d)
- return CURLE_OUT_OF_MEMORY;
+ case CURLINFO_SLIST:
+ ccsid = va_arg(arg, unsigned int);
+ if(info == CURLINFO_CERTINFO) {
+ cipf = *(struct curl_certinfo * *) paramp;
+ if(cipf) {
+ if(!(cipt = (struct curl_certinfo *) malloc(sizeof *cipt)))
+ ret = CURLE_OUT_OF_MEMORY;
+ else {
+ cipt->certinfo = (struct curl_slist * *) calloc(cipf->num_of_certs +
+ 1, sizeof(struct curl_slist *));
+ if(!cipt->certinfo)
+ ret = CURLE_OUT_OF_MEMORY;
+ else {
+ cipt->num_of_certs = cipf->num_of_certs;
+ for (i = 0; i < cipf->num_of_certs; i++)
+ if(cipf->certinfo[i])
+ if(!(cipt->certinfo[i] = slist_convert(ccsid,
+ cipf->certinfo[i],
+ ASCII_CCSID))) {
+ ret = CURLE_OUT_OF_MEMORY;
+ break;
+ }
+ }
+ }
+
+ if(ret != CURLE_OK) {
+ curl_certinfo_free_all(cipt);
+ cipt = (struct curl_certinfo *) NULL;
+ }
+
+ *(struct curl_certinfo * *) paramp = cipt;
+ }
+ }
+ else {
+ slp = (struct curl_slist * *) paramp;
+ if(*slp)
+ if(!(*slp = slist_convert(ccsid, *slp, ASCII_CCSID)))
+ ret = CURLE_OUT_OF_MEMORY;
+ }
+ }
+ va_end(arg);
return ret;
}
@@ -615,15 +697,15 @@ Curl_is_formadd_string(CURLformoption option)
{
switch (option) {
- case CURLFORM_FILENAME:
- case CURLFORM_CONTENTTYPE:
- case CURLFORM_BUFFER:
- case CURLFORM_FILE:
- case CURLFORM_FILECONTENT:
- case CURLFORM_COPYCONTENTS:
- case CURLFORM_COPYNAME:
- return 1;
- }
+ case CURLFORM_FILENAME:
+ case CURLFORM_CONTENTTYPE:
+ case CURLFORM_BUFFER:
+ case CURLFORM_FILE:
+ case CURLFORM_FILECONTENT:
+ case CURLFORM_COPYCONTENTS:
+ case CURLFORM_COPYNAME:
+ return 1;
+ }
return 0;
}
@@ -634,9 +716,9 @@ Curl_formadd_release_local(struct curl_forms * forms, int nargs, int skip)
{
while (nargs--)
- if (nargs != skip)
- if (Curl_is_formadd_string(forms[nargs].option))
- if (forms[nargs].value)
+ if(nargs != skip)
+ if(Curl_is_formadd_string(forms[nargs].option))
+ if(forms[nargs].value)
free((char *) forms[nargs].value);
free((char *) forms);
@@ -652,35 +734,35 @@ Curl_formadd_convert(struct curl_forms * forms,
char * cp;
char * cp2;
- if (formx < 0 || !forms[formx].value)
+ if(formx < 0 || !forms[formx].value)
return 0;
- if (lengthx >= 0)
+ if(lengthx >= 0)
l = (int) forms[lengthx].value;
else
l = strlen(forms[formx].value) + 1;
cp = malloc(MAX_CONV_EXPANSION * l);
- if (!cp)
+ if(!cp)
return -1;
l = convert(cp, MAX_CONV_EXPANSION * l, ASCII_CCSID,
forms[formx].value, l, ccsid);
- if (l < 0) {
+ if(l < 0) {
free(cp);
return -1;
}
cp2 = realloc(cp, l); /* Shorten buffer to the string size. */
- if (cp2)
+ if(cp2)
cp = cp2;
forms[formx].value = cp;
- if (lengthx >= 0)
+ if(lengthx >= 0)
forms[lengthx].value = (char *) l; /* Update to length after conversion. */
return l;
@@ -729,7 +811,7 @@ curl_formadd_ccsid(struct curl_httppost * * httppost,
lformlen = ALLOC_GRANULE;
lforms = malloc(lformlen * sizeof *lforms);
- if (!lforms)
+ if(!lforms)
return CURL_FORMADD_MEMORY;
/* Process the arguments, copying them into local array, latching conversion
@@ -747,11 +829,11 @@ curl_formadd_ccsid(struct curl_httppost * * httppost,
for (;;) {
/* Make sure there is still room for an item in local array. */
- if (nargs >= lformlen) {
+ if(nargs >= lformlen) {
lformlen += ALLOC_GRANULE;
tforms = realloc(lforms, lformlen * sizeof *lforms);
- if (!tforms) {
+ if(!tforms) {
result = CURL_FORMADD_MEMORY;
break;
}
@@ -761,7 +843,7 @@ curl_formadd_ccsid(struct curl_httppost * * httppost,
/* Get next option. */
- if (forms) {
+ if(forms) {
/* Get option from array. */
option = forms->option;
@@ -773,7 +855,7 @@ curl_formadd_ccsid(struct curl_httppost * * httppost,
option = va_arg(arg, CURLformoption);
- if (option == CURLFORM_END)
+ if(option == CURLFORM_END)
break;
}
@@ -786,7 +868,7 @@ curl_formadd_ccsid(struct curl_httppost * * httppost,
continue;
case CURLFORM_ARRAY:
- if (!forms) {
+ if(!forms) {
forms = va_arg(arg, struct curl_forms *);
continue;
}
@@ -798,12 +880,12 @@ curl_formadd_ccsid(struct curl_httppost * * httppost,
option = CURLFORM_PTRNAME; /* Static for now. */
case CURLFORM_PTRNAME:
- if (namex >= 0)
+ if(namex >= 0)
result = CURL_FORMADD_OPTION_TWICE;
namex = nargs;
- if (!forms) {
+ if(!forms) {
value = va_arg(arg, char *);
nameccsid = (unsigned int) va_arg(arg, long);
}
@@ -815,12 +897,12 @@ curl_formadd_ccsid(struct curl_httppost * * httppost,
break;
case CURLFORM_COPYCONTENTS:
- if (contentx >= 0)
+ if(contentx >= 0)
result = CURL_FORMADD_OPTION_TWICE;
contentx = nargs;
- if (!forms) {
+ if(!forms) {
value = va_arg(arg, char *);
contentccsid = (unsigned int) va_arg(arg, long);
}
@@ -833,7 +915,7 @@ curl_formadd_ccsid(struct curl_httppost * * httppost,
case CURLFORM_PTRCONTENTS:
case CURLFORM_BUFFERPTR:
- if (!forms)
+ if(!forms)
value = va_arg(arg, char *); /* No conversion. */
break;
@@ -841,7 +923,7 @@ curl_formadd_ccsid(struct curl_httppost * * httppost,
case CURLFORM_CONTENTSLENGTH:
lengthx = nargs;
- if (!forms)
+ if(!forms)
value = (char *) va_arg(arg, long);
break;
@@ -849,25 +931,25 @@ curl_formadd_ccsid(struct curl_httppost * * httppost,
case CURLFORM_NAMELENGTH:
namelengthx = nargs;
- if (!forms)
+ if(!forms)
value = (char *) va_arg(arg, long);
break;
case CURLFORM_BUFFERLENGTH:
- if (!forms)
+ if(!forms)
value = (char *) va_arg(arg, long);
break;
case CURLFORM_CONTENTHEADER:
- if (!forms)
+ if(!forms)
value = (char *) va_arg(arg, struct curl_slist *);
break;
case CURLFORM_STREAM:
- if (!forms)
+ if(!forms)
value = (char *) va_arg(arg, void *);
break;
@@ -875,7 +957,7 @@ curl_formadd_ccsid(struct curl_httppost * * httppost,
case CURLFORM_CONTENTTYPE:
/* If a previous content has been encountered, convert it now. */
- if (Curl_formadd_convert(lforms, contentx, lengthx, contentccsid) < 0) {
+ if(Curl_formadd_convert(lforms, contentx, lengthx, contentccsid) < 0) {
result = CURL_FORMADD_MEMORY;
break;
}
@@ -887,12 +969,12 @@ curl_formadd_ccsid(struct curl_httppost * * httppost,
default:
/* Must be a convertible string. */
- if (!Curl_is_formadd_string(option)) {
+ if(!Curl_is_formadd_string(option)) {
result = CURL_FORMADD_UNKNOWN_OPTION;
break;
}
- if (!forms) {
+ if(!forms) {
value = va_arg(arg, char *);
ccsid = (unsigned int) va_arg(arg, long);
}
@@ -905,7 +987,7 @@ curl_formadd_ccsid(struct curl_httppost * * httppost,
lforms[nargs].value = value;
- if (Curl_formadd_convert(lforms, nargs, -1, ccsid) < 0) {
+ if(Curl_formadd_convert(lforms, nargs, -1, ccsid) < 0) {
result = CURL_FORMADD_MEMORY;
break;
}
@@ -913,7 +995,7 @@ curl_formadd_ccsid(struct curl_httppost * * httppost,
value = lforms[nargs].value;
}
- if (result != CURL_FORMADD_OK)
+ if(result != CURL_FORMADD_OK)
break;
lforms[nargs].value = value;
@@ -924,15 +1006,15 @@ curl_formadd_ccsid(struct curl_httppost * * httppost,
/* Convert the name and the last content, now that we know their lengths. */
- if (result == CURL_FORMADD_OK && namex >= 0) {
- if (Curl_formadd_convert(lforms, namex, namelengthx, nameccsid) < 0)
+ if(result == CURL_FORMADD_OK && namex >= 0) {
+ if(Curl_formadd_convert(lforms, namex, namelengthx, nameccsid) < 0)
result = CURL_FORMADD_MEMORY;
else
lforms[namex].option = CURLFORM_COPYNAME; /* Force copy. */
}
- if (result == CURL_FORMADD_OK) {
- if (Curl_formadd_convert(lforms, contentx, lengthx, contentccsid) < 0)
+ if(result == CURL_FORMADD_OK) {
+ if(Curl_formadd_convert(lforms, contentx, lengthx, contentccsid) < 0)
result = CURL_FORMADD_MEMORY;
else
contentx = -1;
@@ -940,7 +1022,7 @@ curl_formadd_ccsid(struct curl_httppost * * httppost,
/* Do the formadd with our converted parameters. */
- if (result == CURL_FORMADD_OK) {
+ if(result == CURL_FORMADD_OK) {
lforms[nargs].option = CURLFORM_END;
result = curl_formadd(httppost, last_post,
CURLFORM_ARRAY, lforms, CURLFORM_END);
@@ -971,17 +1053,17 @@ Curl_formget_callback_ccsid(void * arg, const char * buf, size_t len)
p = (cfcdata *) arg;
- if ((long) len <= 0)
+ if((long) len <= 0)
return (*p->append)(p->arg, buf, len);
b = malloc(MAX_CONV_EXPANSION * len);
- if (!b)
+ if(!b)
return (size_t) -1;
l = convert(b, MAX_CONV_EXPANSION * len, p->ccsid, buf, len, ASCII_CCSID);
- if (l < 0) {
+ if(l < 0) {
free(b);
return (size_t) -1;
}
@@ -1026,13 +1108,13 @@ curl_easy_setopt_ccsid(CURL * curl, CURLoption tag, ...)
the same message; but since threadsafeness is not handled here,
this may occur (and we don't care!). */
- if (testwarn) {
+ if(testwarn) {
testwarn = 0;
#ifdef USE_TLS_SRP
- if ((int) STRING_LAST != (int) STRING_TLSAUTH_PASSWORD + 1)
+ if((int) STRING_LAST != (int) STRING_TLSAUTH_PASSWORD + 1)
#else
- if ((int) STRING_LAST != (int) STRING_MAIL_AUTH + 1)
+ if((int) STRING_LAST != (int) STRING_MAIL_AUTH + 1)
#endif
curl_mfprintf(stderr,
"*** WARNING: curl_easy_setopt_ccsid() should be reworked ***\n");
@@ -1097,10 +1179,10 @@ curl_easy_setopt_ccsid(CURL * curl, CURLoption tag, ...)
s = va_arg(arg, char *);
ccsid = va_arg(arg, unsigned int);
- if (s) {
+ if(s) {
s = dynconvert(ASCII_CCSID, s, -1, ccsid);
- if (!s) {
+ if(!s) {
result = CURLE_OUT_OF_MEMORY;
break;
}
@@ -1108,7 +1190,7 @@ curl_easy_setopt_ccsid(CURL * curl, CURLoption tag, ...)
result = curl_easy_setopt(curl, tag, s);
- if (s)
+ if(s)
free(s);
break;
@@ -1122,16 +1204,16 @@ curl_easy_setopt_ccsid(CURL * curl, CURLoption tag, ...)
pfsize = data->set.postfieldsize;
- if (!s || !pfsize || ccsid == NOCONV_CCSID || ccsid == ASCII_CCSID) {
+ if(!s || !pfsize || ccsid == NOCONV_CCSID || ccsid == ASCII_CCSID) {
result = curl_easy_setopt(curl, CURLOPT_COPYPOSTFIELDS, s);
break;
}
- if (pfsize == -1) {
+ if(pfsize == -1) {
/* Data is null-terminated. */
s = dynconvert(ASCII_CCSID, s, -1, ccsid);
- if (!s) {
+ if(!s) {
result = CURLE_OUT_OF_MEMORY;
break;
}
@@ -1139,7 +1221,7 @@ curl_easy_setopt_ccsid(CURL * curl, CURLoption tag, ...)
else {
/* Data length specified. */
- if (pfsize < 0 || pfsize > SIZE_MAX) {
+ if(pfsize < 0 || pfsize > SIZE_MAX) {
result = CURLE_OUT_OF_MEMORY;
break;
}
@@ -1147,19 +1229,19 @@ curl_easy_setopt_ccsid(CURL * curl, CURLoption tag, ...)
len = pfsize;
pfsize = len * MAX_CONV_EXPANSION;
- if (pfsize > SIZE_MAX)
+ if(pfsize > SIZE_MAX)
pfsize = SIZE_MAX;
cp = malloc(pfsize);
- if (!cp) {
+ if(!cp) {
result = CURLE_OUT_OF_MEMORY;
break;
}
pfsize = convert(cp, pfsize, ASCII_CCSID, s, len, ccsid);
- if (pfsize < 0) {
+ if(pfsize < 0) {
free(cp);
result = CURLE_OUT_OF_MEMORY;
break;
diff --git a/packages/OS400/ccsidcurl.h b/packages/OS400/ccsidcurl.h
index 96340c921..eaa591f72 100644
--- a/packages/OS400/ccsidcurl.h
+++ b/packages/OS400/ccsidcurl.h
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2008, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2013, 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
@@ -60,5 +60,6 @@ CURL_EXTERN int curl_formget_ccsid(struct curl_httppost * form, void * arg,
curl_formget_callback append,
unsigned int ccsid);
CURL_EXTERN CURLcode curl_easy_setopt_ccsid(CURL * curl, CURLoption tag, ...);
+CURL_EXTERN void curl_certinfo_free_all(struct curl_certinfo *info);
#endif
diff --git a/packages/OS400/curl.inc.in b/packages/OS400/curl.inc.in
index 59ca81756..0c549455f 100644
--- a/packages/OS400/curl.inc.in
+++ b/packages/OS400/curl.inc.in
@@ -2109,14 +2109,19 @@
d code value like(CURLMcode)
d ccsid 10u 0 value
*
+ * May be used for strings and structures.
d curl_easy_getinfo_ccsid...
d pr extproc('curl_easy_getinfo_ccsid')
d like(CURLcode)
d curl * value CURL *
d info value like(CURLINFO)
- d stringarg * options(*nopass) char *
+ d ptrarg * options(*nopass) char *
d ccsid 10u 0 value options(*nopass)
*
+ d curl_certinfo_free_all...
+ d pr extproc('curl_certinfo_free_all')
+ d info * value
+ *
d curl_formadd_ccsid...
d pr extproc('curl_formadd_ccsid')
d like(CURLFORMcode)