1
0
mirror of https://github.com/moparisthebest/curl synced 2024-11-12 04:25:08 -05:00

packages/OS400: make the source code-style compliant

... and make sure 'make checksrc' in the root dir also verifies the
packages/OS400 sources.

Closes https://github.com/curl/curl/pull/6085
This commit is contained in:
Daniel Stenberg 2020-10-15 10:07:00 +02:00 committed by Jay Satiro
parent 3bcd81df92
commit f3b7d72c57
6 changed files with 228 additions and 341 deletions

View File

@ -328,6 +328,7 @@ checksrc:
(cd tests && $(MAKE) checksrc) (cd tests && $(MAKE) checksrc)
(cd include/curl && $(MAKE) checksrc) (cd include/curl && $(MAKE) checksrc)
(cd docs/examples && $(MAKE) checksrc) (cd docs/examples && $(MAKE) checksrc)
(cd packages && $(MAKE) checksrc)
.PHONY: vc-ide .PHONY: vc-ide

View File

@ -41,3 +41,11 @@ EXTRA_DIST = README \
TPF/maketpf.env_curl \ TPF/maketpf.env_curl \
TPF/maketpf.env_curllib \ TPF/maketpf.env_curllib \
Android/Android.mk Android/Android.mk
CHECKSRC = $(CS_$(V))
CS_0 = @echo " RUN " $@;
CS_1 =
CS_ = $(CS_0)
checksrc:
$(CHECKSRC)(@PERL@ $(top_srcdir)/lib/checksrc.pl -D$(srcdir) $(srcdir)/OS400/*.[ch])

View File

@ -57,7 +57,6 @@
static void static void
makeOS400IconvCode(char buf[ICONV_ID_SIZE], unsigned int ccsid) makeOS400IconvCode(char buf[ICONV_ID_SIZE], unsigned int ccsid)
{ {
/** /**
*** Convert a CCSID to the corresponding IBM iconv_open() character *** Convert a CCSID to the corresponding IBM iconv_open() character
@ -80,7 +79,6 @@ makeOS400IconvCode(char buf[ICONV_ID_SIZE], unsigned int ccsid)
static iconv_t static iconv_t
iconv_open_CCSID(unsigned int ccsidout, unsigned int ccsidin, iconv_open_CCSID(unsigned int ccsidout, unsigned int ccsidin,
unsigned int cstr) unsigned int cstr)
{ {
char fromcode[ICONV_ID_SIZE]; char fromcode[ICONV_ID_SIZE];
char tocode[ICONV_ID_SIZE]; char tocode[ICONV_ID_SIZE];
@ -106,7 +104,6 @@ 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;
iconv_t cd; iconv_t cd;
@ -160,9 +157,7 @@ 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;
@ -214,7 +209,6 @@ 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;
@ -238,9 +232,7 @@ slist_convert(int dccsid, struct curl_slist *from, int sccsid)
} }
char * char *curl_version_ccsid(unsigned int ccsid)
curl_version_ccsid(unsigned int ccsid)
{ {
int i; int i;
char *aversion; char *aversion;
@ -268,7 +260,6 @@ 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;
@ -299,7 +290,6 @@ 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;
@ -333,7 +323,6 @@ 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;
@ -355,7 +344,6 @@ 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;
@ -377,7 +365,6 @@ 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.
Result is stored in the `*left'-byte buffer at `*bufp'. Result is stored in the `*left'-byte buffer at `*bufp'.
@ -401,7 +388,6 @@ convert_version_info_string(const char * * stringp,
curl_version_info_data * curl_version_info_data *
curl_version_info_ccsid(CURLversion stamp, unsigned int ccsid) curl_version_info_ccsid(CURLversion stamp, unsigned int ccsid)
{ {
curl_version_info_data *p; curl_version_info_data *p;
char *cp; char *cp;
@ -519,7 +505,6 @@ curl_version_info_ccsid(CURLversion stamp, unsigned int ccsid)
const char * const char *
curl_easy_strerror_ccsid(CURLcode error, unsigned int ccsid) curl_easy_strerror_ccsid(CURLcode error, unsigned int ccsid)
{ {
int i; int i;
const char *s; const char *s;
@ -545,7 +530,6 @@ curl_easy_strerror_ccsid(CURLcode error, unsigned int ccsid)
const char * const char *
curl_share_strerror_ccsid(CURLSHcode error, unsigned int ccsid) curl_share_strerror_ccsid(CURLSHcode error, unsigned int ccsid)
{ {
int i; int i;
const char *s; const char *s;
@ -571,7 +555,6 @@ curl_share_strerror_ccsid(CURLSHcode error, unsigned int ccsid)
const char * const char *
curl_multi_strerror_ccsid(CURLMcode error, unsigned int ccsid) curl_multi_strerror_ccsid(CURLMcode error, unsigned int ccsid)
{ {
int i; int i;
const char *s; const char *s;
@ -597,7 +580,6 @@ curl_multi_strerror_ccsid(CURLMcode error, unsigned int ccsid)
void void
curl_certinfo_free_all(struct curl_certinfo *info) curl_certinfo_free_all(struct curl_certinfo *info)
{ {
/* Free all memory used by certificate info. */ /* Free all memory used by certificate info. */
if(info) { if(info) {
@ -615,7 +597,6 @@ 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;
@ -716,7 +697,6 @@ curl_easy_getinfo_ccsid(CURL *curl, CURLINFO info, ...)
static int static int
Curl_is_formadd_string(CURLformoption option) Curl_is_formadd_string(CURLformoption option)
{ {
switch(option) { switch(option) {
@ -736,7 +716,6 @@ Curl_is_formadd_string(CURLformoption option)
static void static void
Curl_formadd_release_local(struct curl_forms *forms, int nargs, int skip) Curl_formadd_release_local(struct curl_forms *forms, int nargs, int skip)
{ {
while(nargs--) while(nargs--)
if(nargs != skip) if(nargs != skip)
@ -751,7 +730,6 @@ Curl_formadd_release_local(struct curl_forms * forms, int nargs, int skip)
static int static int
Curl_formadd_convert(struct curl_forms *forms, Curl_formadd_convert(struct curl_forms *forms,
int formx, int lengthx, unsigned int ccsid) int formx, int lengthx, unsigned int ccsid)
{ {
int l; int l;
char *cp; char *cp;
@ -795,7 +773,6 @@ Curl_formadd_convert(struct curl_forms * forms,
CURLFORMcode CURLFORMcode
curl_formadd_ccsid(struct curl_httppost * * httppost, curl_formadd_ccsid(struct curl_httppost * * httppost,
struct curl_httppost * * last_post, ...) struct curl_httppost * * last_post, ...)
{ {
va_list arg; va_list arg;
CURLformoption option; CURLformoption option;
@ -1066,18 +1043,17 @@ curl_formadd_ccsid(struct curl_httppost * * httppost,
} }
typedef struct { struct cfcdata {
curl_formget_callback append; curl_formget_callback append;
void * arg; void * arg;
unsigned int ccsid; unsigned int ccsid;
} cfcdata; };
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; struct cfcdata *p;
char *b; char *b;
int l; int l;
size_t ret; size_t ret;
@ -1108,7 +1084,6 @@ 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)
{ {
cfcdata lcfc; cfcdata lcfc;
@ -1121,7 +1096,6 @@ 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;
@ -1309,7 +1283,6 @@ curl_easy_setopt_ccsid(CURL *curl, CURLoption tag, ...)
char * char *
curl_form_long_value(long value) curl_form_long_value(long value)
{ {
/* ILE/RPG cannot cast an integer to a pointer. This procedure does it. */ /* ILE/RPG cannot cast an integer to a pointer. This procedure does it. */
@ -1320,7 +1293,6 @@ curl_form_long_value(long value)
char * char *
curl_pushheader_bynum_cssid(struct curl_pushheaders *h, curl_pushheader_bynum_cssid(struct curl_pushheaders *h,
size_t num, unsigned int ccsid) size_t num, unsigned int ccsid)
{ {
char *d = (char *) NULL; char *d = (char *) NULL;
char *s = curl_pushheader_bynum(h, num); char *s = curl_pushheader_bynum(h, num);
@ -1335,7 +1307,6 @@ curl_pushheader_bynum_cssid(struct curl_pushheaders *h,
char * char *
curl_pushheader_byname_ccsid(struct curl_pushheaders *h, const char *header, curl_pushheader_byname_ccsid(struct curl_pushheaders *h, const char *header,
unsigned int ccsidin, unsigned int ccsidout) unsigned int ccsidin, unsigned int ccsidout)
{ {
char *d = (char *) NULL; char *d = (char *) NULL;
@ -1357,7 +1328,6 @@ curl_pushheader_byname_ccsid(struct curl_pushheaders *h, const char *header,
static CURLcode static CURLcode
mime_string_call(curl_mimepart *part, const char *string, unsigned int ccsid, mime_string_call(curl_mimepart *part, const char *string, unsigned int ccsid,
CURLcode (*mimefunc)(curl_mimepart *part, const char *string)) CURLcode (*mimefunc)(curl_mimepart *part, const char *string))
{ {
char *s = (char *) NULL; char *s = (char *) NULL;
CURLcode result; CURLcode result;
@ -1375,7 +1345,6 @@ mime_string_call(curl_mimepart *part, const char *string, unsigned int ccsid,
CURLcode CURLcode
curl_mime_name_ccsid(curl_mimepart *part, const char *name, unsigned int ccsid) curl_mime_name_ccsid(curl_mimepart *part, const char *name, unsigned int ccsid)
{ {
return mime_string_call(part, name, ccsid, curl_mime_name); return mime_string_call(part, name, ccsid, curl_mime_name);
} }
@ -1383,7 +1352,6 @@ curl_mime_name_ccsid(curl_mimepart *part, const char *name, unsigned int ccsid)
CURLcode CURLcode
curl_mime_filename_ccsid(curl_mimepart *part, curl_mime_filename_ccsid(curl_mimepart *part,
const char *filename, unsigned int ccsid) const char *filename, unsigned int ccsid)
{ {
return mime_string_call(part, filename, ccsid, curl_mime_filename); return mime_string_call(part, filename, ccsid, curl_mime_filename);
} }
@ -1391,7 +1359,6 @@ curl_mime_filename_ccsid(curl_mimepart *part,
CURLcode CURLcode
curl_mime_type_ccsid(curl_mimepart *part, curl_mime_type_ccsid(curl_mimepart *part,
const char *mimetype, unsigned int ccsid) const char *mimetype, unsigned int ccsid)
{ {
return mime_string_call(part, mimetype, ccsid, curl_mime_type); return mime_string_call(part, mimetype, ccsid, curl_mime_type);
} }
@ -1399,7 +1366,6 @@ curl_mime_type_ccsid(curl_mimepart *part,
CURLcode CURLcode
curl_mime_encoder_ccsid(curl_mimepart *part, curl_mime_encoder_ccsid(curl_mimepart *part,
const char *encoding, unsigned int ccsid) const char *encoding, unsigned int ccsid)
{ {
return mime_string_call(part, encoding, ccsid, curl_mime_encoder); return mime_string_call(part, encoding, ccsid, curl_mime_encoder);
} }
@ -1407,7 +1373,6 @@ curl_mime_encoder_ccsid(curl_mimepart *part,
CURLcode CURLcode
curl_mime_filedata_ccsid(curl_mimepart *part, curl_mime_filedata_ccsid(curl_mimepart *part,
const char *filename, unsigned int ccsid) const char *filename, unsigned int ccsid)
{ {
return mime_string_call(part, filename, ccsid, curl_mime_filedata); return mime_string_call(part, filename, ccsid, curl_mime_filedata);
} }
@ -1415,7 +1380,6 @@ curl_mime_filedata_ccsid(curl_mimepart *part,
CURLcode CURLcode
curl_mime_data_ccsid(curl_mimepart *part, curl_mime_data_ccsid(curl_mimepart *part,
const char *data, size_t datasize, unsigned int ccsid) const char *data, size_t datasize, unsigned int ccsid)
{ {
char *s = (char *) NULL; char *s = (char *) NULL;
CURLcode result; CURLcode result;
@ -1434,7 +1398,6 @@ curl_mime_data_ccsid(curl_mimepart *part,
CURLUcode CURLUcode
curl_url_get_ccsid(CURLU *handle, CURLUPart what, char **part, curl_url_get_ccsid(CURLU *handle, CURLUPart what, char **part,
unsigned int flags, unsigned int ccsid) unsigned int flags, unsigned int ccsid)
{ {
char *s = (char *)NULL; char *s = (char *)NULL;
CURLUcode result; CURLUcode result;
@ -1459,7 +1422,6 @@ curl_url_get_ccsid(CURLU *handle, CURLUPart what, char **part,
CURLUcode CURLUcode
curl_url_set_ccsid(CURLU *handle, CURLUPart what, const char *part, curl_url_set_ccsid(CURLU *handle, CURLUPart what, const char *part,
unsigned int flags, unsigned int ccsid) unsigned int flags, unsigned int ccsid)
{ {
char *s = (char *)NULL; char *s = (char *)NULL;
CURLUcode result; CURLUcode result;

View File

@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms

View File

@ -25,11 +25,12 @@
#include "curl_setup.h" #include "curl_setup.h"
#include "urldata.h" #include "urldata.h"
/* The following defines indicate the expected dupstring enum values /* The following defines indicate the expected dupstring enum values in
* in curl_easy_setopt_ccsid() in packages/OS400/ccsidcurl.c. If a * curl_easy_setopt_ccsid() in packages/OS400/ccsidcurl.c. If a mismatch is
* mismatch is flagged during the build, it indicates that curl_easy_setopt_ccsid() * flagged during the build, it indicates that curl_easy_setopt_ccsid() may
* may need updating to perform data EBCDIC to ASCII data conversion on * need updating to perform data EBCDIC to ASCII data conversion on the
* the string. * string.
*
* Once any applicable changes to curl_easy_setopt_ccsid() have been * Once any applicable changes to curl_easy_setopt_ccsid() have been
* made, the EXPECTED_STRING_LASTZEROTERMINATED/EXPECTED_STRING_LAST * made, the EXPECTED_STRING_LASTZEROTERMINATED/EXPECTED_STRING_LAST
* values can be updated to match the latest enum values in urldata.h. * values can be updated to match the latest enum values in urldata.h.
@ -41,22 +42,21 @@ int main(int argc, char *argv[])
{ {
int rc = 0; int rc = 0;
if (STRING_LASTZEROTERMINATED != EXPECTED_STRING_LASTZEROTERMINATED) if(STRING_LASTZEROTERMINATED != EXPECTED_STRING_LASTZEROTERMINATED) {
{ fprintf(stderr,
fprintf(stderr,"STRING_LASTZEROTERMINATED(%d) is not expected value(%d).\n", "STRING_LASTZEROTERMINATED(%d) is not expected value(%d).\n",
STRING_LASTZEROTERMINATED, EXPECTED_STRING_LASTZEROTERMINATED); STRING_LASTZEROTERMINATED, EXPECTED_STRING_LASTZEROTERMINATED);
rc += 1; rc += 1;
} }
if (STRING_LAST != EXPECTED_STRING_LAST) if(STRING_LAST != EXPECTED_STRING_LAST) {
{
fprintf(stderr, "STRING_LAST(%d) is not expected value(%d).\n", fprintf(stderr, "STRING_LAST(%d) is not expected value(%d).\n",
STRING_LAST, EXPECTED_STRING_LAST); STRING_LAST, EXPECTED_STRING_LAST);
rc += 2; rc += 2;
} }
if (rc != 0) if(rc) {
{
fprintf(stderr, "curl_easy_setopt_ccsid() in packages/OS400/ccsidcurl.c" fprintf(stderr, "curl_easy_setopt_ccsid() in packages/OS400/ccsidcurl.c"
" may need updating if new strings are provided as input via the curl API.\n"); " may need updating if new strings are provided as"
" input via the curl API.\n");
} }
return rc; return rc;
} }

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -60,23 +60,20 @@
#include "os400sys.h" #include "os400sys.h"
/** /**
*** QADRT OS/400 ASCII runtime defines only the most used procedures, but *** QADRT OS/400 ASCII runtime defines only the most used procedures, but a
*** but a lot of them are not supported. This module implements *** lot of them are not supported. This module implements ASCII wrappers for
*** ASCII wrappers for those that are used by libcurl, but not *** those that are used by libcurl, but not defined by QADRT.
*** defined by QADRT.
**/ **/
#pragma convert(0) /* Restore EBCDIC. */ #pragma convert(0) /* Restore EBCDIC. */
#define MIN_BYTE_GAIN 1024 /* Minimum gain when shortening a buffer. */ #define MIN_BYTE_GAIN 1024 /* Minimum gain when shortening a buffer. */
typedef struct { struct buffer_t {
unsigned long size; /* Buffer size. */ unsigned long size; /* Buffer size. */
char *buf; /* Buffer address. */ char *buf; /* Buffer address. */
} buffer_t; };
static char *buffer_undef(localkey_t key, long size); static char *buffer_undef(localkey_t key, long size);
@ -85,17 +82,14 @@ static char * buffer_unthreaded(localkey_t key, long size);
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_key_t thdkey; static pthread_key_t thdkey;
static buffer_t * locbufs; static struct buffer_t *locbufs;
char *(*Curl_thread_buffer)(localkey_t key, long size) = buffer_undef; char *(*Curl_thread_buffer)(localkey_t key, long size) = buffer_undef;
static void thdbufdestroy(void *private)
static void
thdbufdestroy(void * private)
{ {
if(private) { if(private) {
buffer_t * p = (buffer_t *) private; struct buffer_t *p = (struct buffer_t *) private;
localkey_t i; localkey_t i;
for(i = (localkey_t) 0; i < LK_LAST; i++) { for(i = (localkey_t) 0; i < LK_LAST; i++) {
@ -110,7 +104,6 @@ thdbufdestroy(void * private)
static void static void
terminate(void) terminate(void)
{ {
if(Curl_thread_buffer == buffer_threaded) { if(Curl_thread_buffer == buffer_threaded) {
locbufs = pthread_getspecific(thdkey); locbufs = pthread_getspecific(thdkey);
@ -120,7 +113,7 @@ terminate(void)
if(Curl_thread_buffer != buffer_undef) { if(Curl_thread_buffer != buffer_undef) {
thdbufdestroy((void *) locbufs); thdbufdestroy((void *) locbufs);
locbufs = (buffer_t *) NULL; locbufs = (struct buffer_t *) NULL;
} }
Curl_thread_buffer = buffer_undef; Curl_thread_buffer = buffer_undef;
@ -128,8 +121,7 @@ terminate(void)
static char * static char *
get_buffer(buffer_t * buf, long size) get_buffer(struct buffer_t *buf, long size)
{ {
char *cp; char *cp;
@ -171,7 +163,6 @@ get_buffer(buffer_t * buf, long size)
static char * static char *
buffer_unthreaded(localkey_t key, long size) buffer_unthreaded(localkey_t key, long size)
{ {
return get_buffer(locbufs + key, size); return get_buffer(locbufs + key, size);
} }
@ -179,15 +170,14 @@ buffer_unthreaded(localkey_t key, long size)
static char * static char *
buffer_threaded(localkey_t key, long size) buffer_threaded(localkey_t key, long size)
{ {
buffer_t * bufs; struct buffer_t *bufs;
/* Get the buffer for the given local key in the current thread, and /* Get the buffer for the given local key in the current thread, and
make sure it is at least `size'-byte long. Set `size' to < 0 to get make sure it is at least `size'-byte long. Set `size' to < 0 to get
its address only. */ its address only. */
bufs = (buffer_t *) pthread_getspecific(thdkey); bufs = (struct buffer_t *) pthread_getspecific(thdkey);
if(!bufs) { if(!bufs) {
if(size < 0) if(size < 0)
@ -211,7 +201,6 @@ buffer_threaded(localkey_t key, long size)
static char * static char *
buffer_undef(localkey_t key, long size) buffer_undef(localkey_t key, long size)
{ {
/* Define the buffer system, get the buffer for the given local key in /* Define the buffer system, get the buffer for the given local key in
the current thread, and make sure it is at least `size'-byte long. the current thread, and make sure it is at least `size'-byte long.
@ -224,12 +213,15 @@ buffer_undef(localkey_t key, long size)
if(Curl_thread_buffer == buffer_undef) { /* If unchanged during lock. */ if(Curl_thread_buffer == buffer_undef) { /* If unchanged during lock. */
if(!pthread_key_create(&thdkey, thdbufdestroy)) if(!pthread_key_create(&thdkey, thdbufdestroy))
Curl_thread_buffer = buffer_threaded; Curl_thread_buffer = buffer_threaded;
else if(!(locbufs = calloc((size_t) LK_LAST, sizeof(*locbufs)))) { else {
locbufs = calloc((size_t) LK_LAST, sizeof(*locbufs));
if(!locbufs) {
pthread_mutex_unlock(&mutex); pthread_mutex_unlock(&mutex);
return (char *) NULL; return (char *) NULL;
} }
else else
Curl_thread_buffer = buffer_unthreaded; Curl_thread_buffer = buffer_unthreaded;
}
atexit(terminate); atexit(terminate);
} }
@ -241,7 +233,6 @@ buffer_undef(localkey_t key, long size)
static char * static char *
set_thread_string(localkey_t key, const char *s) set_thread_string(localkey_t key, const char *s)
{ {
int i; int i;
char *cp; char *cp;
@ -266,7 +257,6 @@ Curl_getnameinfo_a(const struct sockaddr * sa, curl_socklen_t salen,
char *nodename, curl_socklen_t nodenamelen, char *nodename, curl_socklen_t nodenamelen,
char *servname, curl_socklen_t servnamelen, char *servname, curl_socklen_t servnamelen,
int flags) int flags)
{ {
char *enodename = NULL; char *enodename = NULL;
char *eservname = NULL; char *eservname = NULL;
@ -309,12 +299,10 @@ Curl_getnameinfo_a(const struct sockaddr * sa, curl_socklen_t salen,
return status; return status;
} }
int int
Curl_getaddrinfo_a(const char *nodename, const char *servname, Curl_getaddrinfo_a(const char *nodename, const char *servname,
const struct addrinfo *hints, const struct addrinfo *hints,
struct addrinfo **res) struct addrinfo **res)
{ {
char *enodename; char *enodename;
char *eservname; char *eservname;
@ -354,7 +342,6 @@ Curl_getaddrinfo_a(const char * nodename, const char * servname,
return status; return status;
} }
#ifdef USE_GSKIT #ifdef USE_GSKIT
/* ASCII wrappers for the GSKit procedures. */ /* ASCII wrappers for the GSKit procedures. */
@ -380,10 +367,7 @@ struct Curl_gsk_descriptor {
struct gskstrlist *strlist; struct gskstrlist *strlist;
}; };
int Curl_gsk_environment_open(gsk_handle *my_env_handle)
int
Curl_gsk_environment_open(gsk_handle * my_env_handle)
{ {
struct Curl_gsk_descriptor *p; struct Curl_gsk_descriptor *p;
int rc; int rc;
@ -402,11 +386,8 @@ Curl_gsk_environment_open(gsk_handle * my_env_handle)
return rc; return rc;
} }
int Curl_gsk_secure_soc_open(gsk_handle my_env_handle,
int
Curl_gsk_secure_soc_open(gsk_handle my_env_handle,
gsk_handle *my_session_handle) gsk_handle *my_session_handle)
{ {
struct Curl_gsk_descriptor *p; struct Curl_gsk_descriptor *p;
gsk_handle h; gsk_handle h;
@ -429,10 +410,7 @@ Curl_gsk_secure_soc_open(gsk_handle my_env_handle,
return rc; return rc;
} }
static void gsk_free_handle(struct Curl_gsk_descriptor *p)
static void
gsk_free_handle(struct Curl_gsk_descriptor * p)
{ {
struct gskstrlist *q; struct gskstrlist *q;
@ -444,10 +422,7 @@ gsk_free_handle(struct Curl_gsk_descriptor * p)
free(p); free(p);
} }
int Curl_gsk_environment_close(gsk_handle *my_env_handle)
int
Curl_gsk_environment_close(gsk_handle * my_env_handle)
{ {
struct Curl_gsk_descriptor *p; struct Curl_gsk_descriptor *p;
int rc; int rc;
@ -466,9 +441,7 @@ Curl_gsk_environment_close(gsk_handle * my_env_handle)
} }
int int Curl_gsk_secure_soc_close(gsk_handle *my_session_handle)
Curl_gsk_secure_soc_close(gsk_handle * my_session_handle)
{ {
struct Curl_gsk_descriptor *p; struct Curl_gsk_descriptor *p;
int rc; int rc;
@ -486,10 +459,7 @@ Curl_gsk_secure_soc_close(gsk_handle * my_session_handle)
return rc; return rc;
} }
int Curl_gsk_environment_init(gsk_handle my_env_handle)
int
Curl_gsk_environment_init(gsk_handle my_env_handle)
{ {
struct Curl_gsk_descriptor *p; struct Curl_gsk_descriptor *p;
@ -500,9 +470,7 @@ Curl_gsk_environment_init(gsk_handle my_env_handle)
} }
int int Curl_gsk_secure_soc_init(gsk_handle my_session_handle)
Curl_gsk_secure_soc_init(gsk_handle my_session_handle)
{ {
struct Curl_gsk_descriptor *p; struct Curl_gsk_descriptor *p;
@ -516,7 +484,6 @@ Curl_gsk_secure_soc_init(gsk_handle my_session_handle)
int int
Curl_gsk_attribute_set_buffer_a(gsk_handle my_gsk_handle, GSK_BUF_ID bufID, Curl_gsk_attribute_set_buffer_a(gsk_handle my_gsk_handle, GSK_BUF_ID bufID,
const char *buffer, int bufSize) const char *buffer, int bufSize)
{ {
struct Curl_gsk_descriptor *p; struct Curl_gsk_descriptor *p;
char *ebcdicbuf; char *ebcdicbuf;
@ -545,7 +512,6 @@ Curl_gsk_attribute_set_buffer_a(gsk_handle my_gsk_handle, GSK_BUF_ID bufID,
int int
Curl_gsk_attribute_set_enum(gsk_handle my_gsk_handle, GSK_ENUM_ID enumID, Curl_gsk_attribute_set_enum(gsk_handle my_gsk_handle, GSK_ENUM_ID enumID,
GSK_ENUM_VALUE enumValue) GSK_ENUM_VALUE enumValue)
{ {
struct Curl_gsk_descriptor *p; struct Curl_gsk_descriptor *p;
@ -559,7 +525,6 @@ Curl_gsk_attribute_set_enum(gsk_handle my_gsk_handle, GSK_ENUM_ID enumID,
int int
Curl_gsk_attribute_set_numeric_value(gsk_handle my_gsk_handle, Curl_gsk_attribute_set_numeric_value(gsk_handle my_gsk_handle,
GSK_NUM_ID numID, int numValue) GSK_NUM_ID numID, int numValue)
{ {
struct Curl_gsk_descriptor *p; struct Curl_gsk_descriptor *p;
@ -574,7 +539,6 @@ int
Curl_gsk_attribute_set_callback(gsk_handle my_gsk_handle, Curl_gsk_attribute_set_callback(gsk_handle my_gsk_handle,
GSK_CALLBACK_ID callBackID, GSK_CALLBACK_ID callBackID,
void *callBackAreaPtr) void *callBackAreaPtr)
{ {
struct Curl_gsk_descriptor *p; struct Curl_gsk_descriptor *p;
@ -588,7 +552,6 @@ Curl_gsk_attribute_set_callback(gsk_handle my_gsk_handle,
static int static int
cachestring(struct Curl_gsk_descriptor *p, cachestring(struct Curl_gsk_descriptor *p,
const char *ebcdicbuf, int bufsize, const char **buffer) const char *ebcdicbuf, int bufsize, const char **buffer)
{ {
int rc; int rc;
char *asciibuf; char *asciibuf;
@ -621,7 +584,6 @@ cachestring(struct Curl_gsk_descriptor * p,
int int
Curl_gsk_attribute_get_buffer_a(gsk_handle my_gsk_handle, GSK_BUF_ID bufID, Curl_gsk_attribute_get_buffer_a(gsk_handle my_gsk_handle, GSK_BUF_ID bufID,
const char **buffer, int *bufSize) const char **buffer, int *bufSize)
{ {
struct Curl_gsk_descriptor *p; struct Curl_gsk_descriptor *p;
int rc; int rc;
@ -646,7 +608,6 @@ Curl_gsk_attribute_get_buffer_a(gsk_handle my_gsk_handle, GSK_BUF_ID bufID,
int int
Curl_gsk_attribute_get_enum(gsk_handle my_gsk_handle, GSK_ENUM_ID enumID, Curl_gsk_attribute_get_enum(gsk_handle my_gsk_handle, GSK_ENUM_ID enumID,
GSK_ENUM_VALUE *enumValue) GSK_ENUM_VALUE *enumValue)
{ {
struct Curl_gsk_descriptor *p; struct Curl_gsk_descriptor *p;
@ -660,7 +621,6 @@ Curl_gsk_attribute_get_enum(gsk_handle my_gsk_handle, GSK_ENUM_ID enumID,
int int
Curl_gsk_attribute_get_numeric_value(gsk_handle my_gsk_handle, Curl_gsk_attribute_get_numeric_value(gsk_handle my_gsk_handle,
GSK_NUM_ID numID, int *numValue) GSK_NUM_ID numID, int *numValue)
{ {
struct Curl_gsk_descriptor *p; struct Curl_gsk_descriptor *p;
@ -676,7 +636,6 @@ Curl_gsk_attribute_get_cert_info(gsk_handle my_gsk_handle,
GSK_CERT_ID certID, GSK_CERT_ID certID,
const gsk_cert_data_elem **certDataElem, const gsk_cert_data_elem **certDataElem,
int *certDataElementCount) int *certDataElementCount)
{ {
struct Curl_gsk_descriptor *p; struct Curl_gsk_descriptor *p;
@ -691,7 +650,6 @@ Curl_gsk_attribute_get_cert_info(gsk_handle my_gsk_handle,
int int
Curl_gsk_secure_soc_misc(gsk_handle my_session_handle, GSK_MISC_ID miscID) Curl_gsk_secure_soc_misc(gsk_handle my_session_handle, GSK_MISC_ID miscID)
{ {
struct Curl_gsk_descriptor *p; struct Curl_gsk_descriptor *p;
@ -705,7 +663,6 @@ Curl_gsk_secure_soc_misc(gsk_handle my_session_handle, GSK_MISC_ID miscID)
int int
Curl_gsk_secure_soc_read(gsk_handle my_session_handle, char *readBuffer, Curl_gsk_secure_soc_read(gsk_handle my_session_handle, char *readBuffer,
int readBufSize, int *amtRead) int readBufSize, int *amtRead)
{ {
struct Curl_gsk_descriptor *p; struct Curl_gsk_descriptor *p;
@ -719,7 +676,6 @@ Curl_gsk_secure_soc_read(gsk_handle my_session_handle, char * readBuffer,
int int
Curl_gsk_secure_soc_write(gsk_handle my_session_handle, char *writeBuffer, Curl_gsk_secure_soc_write(gsk_handle my_session_handle, char *writeBuffer,
int writeBufSize, int *amtWritten) int writeBufSize, int *amtWritten)
{ {
struct Curl_gsk_descriptor *p; struct Curl_gsk_descriptor *p;
@ -732,7 +688,6 @@ Curl_gsk_secure_soc_write(gsk_handle my_session_handle, char * writeBuffer,
const char * const char *
Curl_gsk_strerror_a(int gsk_return_value) Curl_gsk_strerror_a(int gsk_return_value)
{ {
return set_thread_string(LK_GSK_ERROR, gsk_strerror(gsk_return_value)); return set_thread_string(LK_GSK_ERROR, gsk_strerror(gsk_return_value));
} }
@ -741,7 +696,6 @@ int
Curl_gsk_secure_soc_startInit(gsk_handle my_session_handle, Curl_gsk_secure_soc_startInit(gsk_handle my_session_handle,
int IOCompletionPort, int IOCompletionPort,
Qso_OverlappedIO_t *communicationsArea) Qso_OverlappedIO_t *communicationsArea)
{ {
struct Curl_gsk_descriptor *p; struct Curl_gsk_descriptor *p;
@ -753,15 +707,12 @@ Curl_gsk_secure_soc_startInit(gsk_handle my_session_handle,
#endif /* USE_GSKIT */ #endif /* USE_GSKIT */
#ifdef HAVE_GSSAPI #ifdef HAVE_GSSAPI
/* ASCII wrappers for the GSSAPI procedures. */ /* ASCII wrappers for the GSSAPI procedures. */
static int static int
Curl_gss_convert_in_place(OM_uint32 *minor_status, gss_buffer_t buf) Curl_gss_convert_in_place(OM_uint32 *minor_status, gss_buffer_t buf)
{ {
unsigned int i = buf->length; unsigned int i = buf->length;
@ -791,7 +742,6 @@ Curl_gss_convert_in_place(OM_uint32 * minor_status, gss_buffer_t buf)
OM_uint32 OM_uint32
Curl_gss_import_name_a(OM_uint32 *minor_status, gss_buffer_t in_name, Curl_gss_import_name_a(OM_uint32 *minor_status, gss_buffer_t in_name,
gss_OID in_name_type, gss_name_t *out_name) gss_OID in_name_type, gss_name_t *out_name)
{ {
int rc; int rc;
unsigned int i; unsigned int i;
@ -818,12 +768,11 @@ Curl_gss_import_name_a(OM_uint32 * minor_status, gss_buffer_t in_name,
return rc; return rc;
} }
OM_uint32 OM_uint32
Curl_gss_display_status_a(OM_uint32 *minor_status, OM_uint32 status_value, Curl_gss_display_status_a(OM_uint32 *minor_status, OM_uint32 status_value,
int status_type, gss_OID mech_type, int status_type, gss_OID mech_type,
gss_msg_ctx_t * message_context, gss_buffer_t status_string) gss_msg_ctx_t *message_context,
gss_buffer_t status_string)
{ {
int rc; int rc;
@ -844,7 +793,6 @@ Curl_gss_display_status_a(OM_uint32 * minor_status, OM_uint32 status_value,
return rc; return rc;
} }
OM_uint32 OM_uint32
Curl_gss_init_sec_context_a(OM_uint32 *minor_status, Curl_gss_init_sec_context_a(OM_uint32 *minor_status,
gss_cred_id_t cred_handle, gss_cred_id_t cred_handle,
@ -856,7 +804,6 @@ Curl_gss_init_sec_context_a(OM_uint32 * minor_status,
gss_OID *actual_mech_type, gss_OID *actual_mech_type,
gss_buffer_t output_token, gss_flags_t *ret_flags, gss_buffer_t output_token, gss_flags_t *ret_flags,
OM_uint32 *time_rec) OM_uint32 *time_rec)
{ {
int rc; int rc;
gss_buffer_desc in; gss_buffer_desc in;
@ -909,7 +856,6 @@ OM_uint32
Curl_gss_delete_sec_context_a(OM_uint32 *minor_status, Curl_gss_delete_sec_context_a(OM_uint32 *minor_status,
gss_ctx_id_t *context_handle, gss_ctx_id_t *context_handle,
gss_buffer_t output_token) gss_buffer_t output_token)
{ {
int rc; int rc;
@ -931,14 +877,12 @@ Curl_gss_delete_sec_context_a(OM_uint32 * minor_status,
#endif /* HAVE_GSSAPI */ #endif /* HAVE_GSSAPI */
#ifndef CURL_DISABLE_LDAP #ifndef CURL_DISABLE_LDAP
/* ASCII wrappers for the LDAP procedures. */ /* ASCII wrappers for the LDAP procedures. */
void * void *
Curl_ldap_init_a(char *host, int port) Curl_ldap_init_a(char *host, int port)
{ {
unsigned int i; unsigned int i;
char *ehost; char *ehost;
@ -960,10 +904,8 @@ Curl_ldap_init_a(char * host, int port)
return result; return result;
} }
int int
Curl_ldap_simple_bind_s_a(void *ld, char *dn, char *passwd) Curl_ldap_simple_bind_s_a(void *ld, char *dn, char *passwd)
{ {
int i; int i;
char *edn; char *edn;
@ -1002,11 +944,9 @@ Curl_ldap_simple_bind_s_a(void * ld, char * dn, char * passwd)
return i; return i;
} }
int int
Curl_ldap_search_s_a(void *ld, char *base, int scope, char *filter, Curl_ldap_search_s_a(void *ld, char *base, int scope, char *filter,
char **attrs, int attrsonly, LDAPMessage **res) char **attrs, int attrsonly, LDAPMessage **res)
{ {
int i; int i;
int j; int j;
@ -1087,7 +1027,6 @@ Curl_ldap_search_s_a(void * ld, char * base, int scope, char * filter,
struct berval ** struct berval **
Curl_ldap_get_values_len_a(void *ld, LDAPMessage *entry, const char *attr) Curl_ldap_get_values_len_a(void *ld, LDAPMessage *entry, const char *attr)
{ {
char *cp; char *cp;
struct berval **result; struct berval **result;
@ -1117,18 +1056,14 @@ Curl_ldap_get_values_len_a(void * ld, LDAPMessage * entry, const char * attr)
return result; return result;
} }
char * char *
Curl_ldap_err2string_a(int error) Curl_ldap_err2string_a(int error)
{ {
return set_thread_string(LK_LDAP_ERROR, ldap_err2string(error)); return set_thread_string(LK_LDAP_ERROR, ldap_err2string(error));
} }
char * char *
Curl_ldap_get_dn_a(void *ld, LDAPMessage *entry) Curl_ldap_get_dn_a(void *ld, LDAPMessage *entry)
{ {
int i; int i;
char *cp; char *cp;
@ -1157,11 +1092,9 @@ Curl_ldap_get_dn_a(void * ld, LDAPMessage * entry)
return cp; return cp;
} }
char * char *
Curl_ldap_first_attribute_a(void *ld, Curl_ldap_first_attribute_a(void *ld,
LDAPMessage *entry, BerElement **berptr) LDAPMessage *entry, BerElement **berptr)
{ {
int i; int i;
char *cp; char *cp;
@ -1190,11 +1123,9 @@ Curl_ldap_first_attribute_a(void * ld,
return cp; return cp;
} }
char * char *
Curl_ldap_next_attribute_a(void *ld, Curl_ldap_next_attribute_a(void *ld,
LDAPMessage *entry, BerElement *berptr) LDAPMessage *entry, BerElement *berptr)
{ {
int i; int i;
char *cp; char *cp;
@ -1225,7 +1156,6 @@ Curl_ldap_next_attribute_a(void * ld,
#endif /* CURL_DISABLE_LDAP */ #endif /* CURL_DISABLE_LDAP */
static int static int
sockaddr2ebcdic(struct sockaddr_storage *dstaddr, sockaddr2ebcdic(struct sockaddr_storage *dstaddr,
const struct sockaddr *srcaddr, int srclen) const struct sockaddr *srcaddr, int srclen)
@ -1303,7 +1233,6 @@ sockaddr2ascii(struct sockaddr *dstaddr, int dstlen,
return srclen; return srclen;
} }
int int
Curl_os400_connect(int sd, struct sockaddr *destaddr, int addrlen) Curl_os400_connect(int sd, struct sockaddr *destaddr, int addrlen)
{ {
@ -1318,7 +1247,6 @@ Curl_os400_connect(int sd, struct sockaddr * destaddr, int addrlen)
return connect(sd, (struct sockaddr *) &laddr, i); return connect(sd, (struct sockaddr *) &laddr, i);
} }
int int
Curl_os400_bind(int sd, struct sockaddr *localaddr, int addrlen) Curl_os400_bind(int sd, struct sockaddr *localaddr, int addrlen)
{ {
@ -1333,7 +1261,6 @@ Curl_os400_bind(int sd, struct sockaddr * localaddr, int addrlen)
return bind(sd, (struct sockaddr *) &laddr, i); return bind(sd, (struct sockaddr *) &laddr, i);
} }
int int
Curl_os400_sendto(int sd, char *buffer, int buflen, int flags, Curl_os400_sendto(int sd, char *buffer, int buflen, int flags,
struct sockaddr *dstaddr, int addrlen) struct sockaddr *dstaddr, int addrlen)
@ -1349,7 +1276,6 @@ Curl_os400_sendto(int sd, char * buffer, int buflen, int flags,
return sendto(sd, buffer, buflen, flags, (struct sockaddr *) &laddr, i); return sendto(sd, buffer, buflen, flags, (struct sockaddr *) &laddr, i);
} }
int int
Curl_os400_recvfrom(int sd, char *buffer, int buflen, int flags, Curl_os400_recvfrom(int sd, char *buffer, int buflen, int flags,
struct sockaddr *fromaddr, int *addrlen) struct sockaddr *fromaddr, int *addrlen)
@ -1379,7 +1305,6 @@ Curl_os400_recvfrom(int sd, char * buffer, int buflen, int flags,
return rcvlen; return rcvlen;
} }
int int
Curl_os400_getpeername(int sd, struct sockaddr *addr, int *addrlen) Curl_os400_getpeername(int sd, struct sockaddr *addr, int *addrlen)
{ {
@ -1397,7 +1322,6 @@ Curl_os400_getpeername(int sd, struct sockaddr *addr, int *addrlen)
return retcode; return retcode;
} }
int int
Curl_os400_getsockname(int sd, struct sockaddr *addr, int *addrlen) Curl_os400_getsockname(int sd, struct sockaddr *addr, int *addrlen)
{ {
@ -1419,7 +1343,6 @@ Curl_os400_getsockname(int sd, struct sockaddr *addr, int *addrlen)
#ifdef HAVE_LIBZ #ifdef HAVE_LIBZ
const char * const char *
Curl_os400_zlibVersion(void) Curl_os400_zlibVersion(void)
{ {
return set_thread_string(LK_ZLIB_VERSION, zlibVersion()); return set_thread_string(LK_ZLIB_VERSION, zlibVersion());
} }
@ -1427,7 +1350,6 @@ Curl_os400_zlibVersion(void)
int int
Curl_os400_inflateInit_(z_streamp strm, const char *version, int stream_size) Curl_os400_inflateInit_(z_streamp strm, const char *version, int stream_size)
{ {
z_const char *msgb4 = strm->msg; z_const char *msgb4 = strm->msg;
int ret; int ret;
@ -1440,11 +1362,9 @@ Curl_os400_inflateInit_(z_streamp strm, const char * version, int stream_size)
return ret; return ret;
} }
int int
Curl_os400_inflateInit2_(z_streamp strm, int windowBits, Curl_os400_inflateInit2_(z_streamp strm, int windowBits,
const char *version, int stream_size) const char *version, int stream_size)
{ {
z_const char *msgb4 = strm->msg; z_const char *msgb4 = strm->msg;
int ret; int ret;
@ -1457,10 +1377,8 @@ Curl_os400_inflateInit2_(z_streamp strm, int windowBits,
return ret; return ret;
} }
int int
Curl_os400_inflate(z_streamp strm, int flush) Curl_os400_inflate(z_streamp strm, int flush)
{ {
z_const char *msgb4 = strm->msg; z_const char *msgb4 = strm->msg;
int ret; int ret;
@ -1473,10 +1391,8 @@ Curl_os400_inflate(z_streamp strm, int flush)
return ret; return ret;
} }
int int
Curl_os400_inflateEnd(z_streamp strm) Curl_os400_inflateEnd(z_streamp strm)
{ {
z_const char *msgb4 = strm->msg; z_const char *msgb4 = strm->msg;
int ret; int ret;