diff options
author | Patrick Monnerat <Patrick.Monnerat@datasphere.ch> | 2007-08-23 14:30:24 +0000 |
---|---|---|
committer | Patrick Monnerat <Patrick.Monnerat@datasphere.ch> | 2007-08-23 14:30:24 +0000 |
commit | 557cc55f6f398c0cd02571c077d5c73156820513 (patch) | |
tree | cf56aa36be857b932eb1d15805ccc29dcfaed1b3 /packages/OS400 | |
parent | 2d8dba388bf9089cd53e8046825a07f935e6611e (diff) |
Porting library to OS/400
Diffstat (limited to 'packages/OS400')
-rw-r--r-- | packages/OS400/README.OS400 | 245 | ||||
-rw-r--r-- | packages/OS400/ccsidcurl.c | 1099 | ||||
-rw-r--r-- | packages/OS400/ccsidcurl.h | 65 | ||||
-rw-r--r-- | packages/OS400/curl.inc.in | 1518 | ||||
-rw-r--r-- | packages/OS400/initscript.sh | 171 | ||||
-rw-r--r-- | packages/OS400/make-include.sh | 48 | ||||
-rw-r--r-- | packages/OS400/make-lib.sh | 207 | ||||
-rw-r--r-- | packages/OS400/make-src.sh | 5 | ||||
-rw-r--r-- | packages/OS400/make-tests.sh | 102 | ||||
-rw-r--r-- | packages/OS400/makefile.sh | 26 | ||||
-rw-r--r-- | packages/OS400/os400sys.c | 957 | ||||
-rw-r--r-- | packages/OS400/os400sys.h | 53 |
12 files changed, 4496 insertions, 0 deletions
diff --git a/packages/OS400/README.OS400 b/packages/OS400/README.OS400 new file mode 100644 index 000000000..8b46b2c99 --- /dev/null +++ b/packages/OS400/README.OS400 @@ -0,0 +1,245 @@ +$Id$ + +Implementation notes: + + This is a true OS/400 implementation, not a PASE implementation (for PASE, +use AIX implementation). + + The biggest problem with OS/400 is EBCDIC. Libcurl implements an internal +conversion mechanism, but it has been designed for computers that have a +single native character set. OS/400 default native character set varies +depending on the country for which it has been localized. And more, a job +may dynamically alter its "native" character set. + Several characters that do not have fixed code in EBCDIC variants are +used in libcurl strings. As a consequence, using the existing conversion +mechanism would have lead in a localized binary library - not portable across +countries. + For this reason, and because libcurl was originally designed for ASCII based +operating systems, the current OS/400 implementation uses ASCII as internal +character set. This has been accomplished using the QADRT library and +include files, a C and system procedures ASCII wrapper library. See IBM QADRT +description for more information. + This then results in libcurl being an ASCII library: any function string +argument is taken/returned in ASCII and a C/C++ calling program built around +QADRT may use libcurl functions as on any other platform. + QADRT does not define ASCII wrappers for all C/system procedures: the +OS/400 configuration header file and an additional module (os400sys.c) define +some more of them, that are used by libcurl and that QADRT left out. + To support all the different variants of EBCDIC, non-standard wrapper +procedures have been added to libcurl on OS/400: they provide an additional +CCSID (numeric Coded Character Set ID specific to OS/400) parameter for each +string argument. String values passed to callback procedures are NOT converted, +so text gathered this way is (probably !) ASCII. + + Another OS/400 problem comes from the fact that the last fixed argument of a +vararg procedure may not be of type char, unsigned char, short or unsigned +short. Enums that are internally implemented by the C compiler as one of these +types are also forbidden. Libcurl uses enums as vararg procedure tagfields... +Happily, there is a pragma forcing enums to type "int". The original libcurl +header files are thus altered during build process to use this pragma, in +order to force libcurl enums of being type int (the pragma disposition in use +before inclusion is restored before resuming the including unit compilation). + + Three SSL implementations were present in libcurl. Nevertheless, none of them +is available on OS/400. To support SSL on OS/400, a fourth implementation has +been added (qssl.[ch]). There is no way to have different certificate stores +for CAs and for personal/application certificates/key. More, the SSL context +may be defined as an application identifier in the main certificate store, +or as a keyring file. As a consequence, the meaning of some fields have been +slightly altered: +_ The "certificate identifier" is taken from CURLOPT_SSLCERT if defined, else +from CURLOPT_CAINFO. +_ The certificate identifier is then used as an application identifier in the +main certificate store. If successful, this context is used. +_ If the previous step failed, the certificate identifier is used as the file +name of a keyring. CURLOPT_SSLKEYPASSWD is used here as the keyring password. +_ The default ca-bundle (CURLOPT_CAINFO) is set to the main certificate store's +keyring file name: this allows to use the system global CAs by default. (In that +case, the keyring password is safely recovered from the system... IBM dixit!) + + Non-standard EBCDIC wrapper prototypes are defined in an additional header +file: ccsidcurl.h. These should be self-explanatory to an OS/400-aware +designer. CCSID 0 can be used to select the current job's CCSID. + Wrapper procedures with variable arguments are described below: + +_ curl_easy_setopt_ccsid() + Variable arguments are a string pointer and a CCSID (unsigned int) for +options: + CURLOPT_CAINFO + CURLOPT_CAPATH + CURLOPT_COOKIE + CURLOPT_COOKIEFILE + CURLOPT_COOKIEJAR + CURLOPT_COOKIELIST + CURLOPT_CUSTOMREQUEST + CURLOPT_EGDSOCKET + CURLOPT_ENCODING + CURLOPT_FTPPORT + CURLOPT_FTP_ACCOUNT + CURLOPT_FTP_ALTERNATIVE_TO_USER + CURLOPT_INTERFACE + CURLOPT_KRBLEVEL + CURLOPT_NETRC_FILE + CURLOPT_POSTFIELDS + CURLOPT_PROXY + CURLOPT_PROXYUSERPWD + CURLOPT_RANDOM_FILE + CURLOPT_RANGE + CURLOPT_REFERER + CURLOPT_SSH_PRIVATE_KEYFILE + CURLOPT_SSH_PUBLIC_KEYFILE + CURLOPT_SSLCERT + CURLOPT_SSLCERTTYPE + CURLOPT_SSLENGINE + CURLOPT_SSLKEY + CURLOPT_SSLKEYPASSWD + CURLOPT_SSLKEYTYPE + CURLOPT_SSL_CIPHER_LIST + CURLOPT_URL + CURLOPT_USERAGENT + CURLOPT_USERPWD + Else it is the same as for curl_easy_setopt(). + Note that CURLOPT_ERRORBUFFER is not in the list above, since it gives the +address of an (empty) character buffer, not the address of a string. + +_ curl_formadd_ccsid() + In the variable argument list, string pointers should be followed by a (long) +CCSID for the following options: + CURLFORM_FILENAME + CURLFORM_CONTENTTYPE + CURLFORM_BUFFER + CURLFORM_FILE + CURLFORM_FILECONTENT + CURLFORM_COPYCONTENTS + CURLFORM_COPYNAME + CURLFORM_PTRNAME + If taken from an argument array, an additional array entry must follow each +entry containing one of the above option. This additional entry holds the CCSID +in its value field, and the option field is meaningless. + It is not possible to have a string pointer and its CCSID across a function +parameter/array boundary. + Please note that CURLFORM_PTRCONTENTS and CURLFORM_BUFFERPTR are considered +unconvertible strings and thus are NOT followed by a CCSID. + +_ curl_easy_getinfo_ccsid + The following options are followed by a 'char * *' and a CCSID. Unlike +curl_easy_getinfo(), the value returned in the pointer should be freed after +use: + CURLINFO_EFFECTIVE_URL + CURLINFO_CONTENT_TYPE + CURLINFO_FTP_ENTRY_PATH + Other options are processed like in curl_easy_getinfo(). + + Standard compilation environment does support neither autotools nor make; +in fact, very few common utilities are available. As a consequence, the +config-os400.h has been coded manually and the compilation scripts are +a set of shell scripts stored in subdirectory packages/OS400. + + The "curl" command and the test environment are currently not supported on +OS/400. + + +Protocols currently implemented on OS/400: +_ HTTP +_ HTTPS +_ FTP +_ FTPS +_ FTP with secure transmission. +_ LDAP +_ DICT +_ TELNET + + + +Compiling on OS/400: + + These instructions targets people who knows about OS/400, compiling, IFS and +archive extraction. Do not ask questions about these subjects if you're not +familiar with. + +_ As a prerequisite, QADRT development environment must be installed. +_ Install the curl source directory in IFS. +_ Enter shell (QSH) +_ Change current directory to the curl installation directory +_ Change current directory to ./packages/OS400 +_ Edit file iniscript.sh. You may want to change tunable configuration + parameters, like debug info generation, optimisation level, listing option, + target library, etc. +_ Copy any file in the current directory to makelog (i.e.: + cp initscript.sh makelog): this is intended to create the makelog file with + an ASCII CCSID! +_ Enter the command "sh makefile.sh > makelog 2>&1' +_ Examine the makelog file to check for compilation errors. + + Leaving file initscript.sh unchanged, this will produce the following OS/400 +objects: +_ Library CURL. All other objects will be stored in this library. +_ Modules for all libcurl units. +_ Binding directory CURL_A, to be used at calling program link time for + statically binding the modules (specify BNDSRVPGM(QADRTTS) when creating a + program using CURL_A). +_ Service program CURL, to be used at calling program run-time when this program + has dynamically bound curl at link time. +_ Binding directory CURL. To be used to dynamically bind libcurl when linking a + calling program. +_ Source file H. It contains all the include members needed to compile a C/C++ + module using libcurl, and an ILE/RPG /copy member for support in this + language. +_ Standard C/C++ libcurl include members in file H. +_ CCSIDCURL member in file H. This defines the non-standard EBCDIC wrappers for + C and C++. +_ CURL.INC member in file H. This defines everything needed by an ILE/RPG + program using libcurl. +_ LIBxxx modules and programs. Although the test environment is not supported + on OS/400, the libcurl test programs are compiled for manual tests. + + + +Special programming consideration: + +QADRT being used, the following points must be considered: +_ If static binding is used, service program QADRTTS must be linked too. +_ The EBCDIC CCSID used by QADRT is 37 by default, NOT THE JOB'S CCSID. If + another EBCDIC CCSID is required, it must be set via a locale through a call + to setlocale_a (QADRT's setlocale() ASCII wrapper) with category LC_ALL or + LC_CTYPE, or by setting environment variable QADRT_ENV_LOCALE to the locale + object path before executing the program. +_ Do not use original source include files unless you know what you are doing. + Use the installed members instead (in /QSYS.LIB/CURL.LIB/H.FILE). + + + +ILE/RPG support: + + Since 95% of the OS/400 programmers use ILE/RPG exclusively, a definition + /COPY member is provided for this language. To include all libcurl + definitions in an ILE/RPG module, line + + h bnddir('CURL/CURL') + +must figure in the program header, and line + + d/copy curl/h,curl.inc + +in the global data section of the module's source code. + + No vararg procedure support exists in ILE/RPG: for this reason, the following +considerations apply: +_ Procedures curl_easy_setopt_long(), curl_easy_setopt_object(), + curl_easy_setopt_function() and curl_easy_setopt_offset() are all alias + prototypes to curl_easy_setopt(), but with different parameter lists. +_ Procedures curl_easy_getinfo_string(), curl_easy_getinfo_long(), + curl_easy_getinfo_double() and curl_easy_getinfo_slist() are all alias + prototypes to curl_easy_getinfo(), but with different parameter lists. +_ Procedures curl_multi_setopt_long(), curl_multi_setopt_object(), + curl_multi_setopt_function() and curl_multi_setopt_offset() are all alias + prototypes to curl_multi_setopt(), but with different parameter lists. +_ The prototype of procedure curl_formadd() allows specifying a pointer option + and the CURLFORM_END option. This makes possible to use an option array + without any additional definition. If some specific incompatible argument + list is used in the ILE/RPG program, the latter must define a specialised + alias. The same applies to curl_formadd_ccsid() too. + + Since RPG cannot cast a long to a pointer, procedure curl_form_long_value() +is provided for that purpose: this allows storing a long value in the curl_forms +array. diff --git a/packages/OS400/ccsidcurl.c b/packages/OS400/ccsidcurl.c new file mode 100644 index 000000000..978458f59 --- /dev/null +++ b/packages/OS400/ccsidcurl.c @@ -0,0 +1,1099 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2007, 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 + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id$ + * + ***************************************************************************/ + +/* CCSID API wrappers for OS/400. */ + +#include <iconv.h> +#include <string.h> +#include <stdlib.h> +#include <errno.h> +#include <stdarg.h> + +#pragma enum(int) + +#include <curl/curl.h> +#include "urldata.h" +#include "url.h" +#include "getinfo.h" +#include "ccsidcurl.h" + +#include "os400sys.h" + + +#define ASCII_CCSID 819 /* Use ISO-8859-1 as ASCII. */ +#define ICONV_ID_SIZE 32 /* Size of iconv_open() code identifier. */ +#define ICONV_OPEN_ERROR(t) ((t).return_value == -1) + +#define ALLOC_GRANULE 8 /* Alloc. granule for curl_formadd_ccsid(). */ + + +static void +makeOS400IconvCode(char buf[ICONV_ID_SIZE], unsigned int ccsid) + +{ + /** + *** Convert a CCSID to the corresponding IBM iconv_open() character + *** code identifier. + *** This code is specific to the OS400 implementation of the iconv library. + *** CCSID 65535 (no conversion) is replaced by the ASCII CCSID. + *** CCSID 0 is interpreted by the OS400 as the job's CCSID. + **/ + + ccsid &= 0xFFFF; + + if (ccsid == 65535) + ccsid = ASCII_CCSID; + + memset(buf, 0, ICONV_ID_SIZE); + curl_msprintf(buf, "IBMCCSID%05u0000000", ccsid); +} + + +static iconv_t +iconv_open_CCSID(unsigned int ccsidout, unsigned int ccsidin, unsigned int cstr) + +{ + char fromcode[ICONV_ID_SIZE]; + char tocode[ICONV_ID_SIZE]; + + /** + *** Like iconv_open(), but character codes are given as CCSIDs. + *** If `cstr' is non-zero, conversion is set up to stop whenever a + *** null character is encountered. + *** See iconv_open() IBM description in "National Language Support API". + **/ + + makeOS400IconvCode(fromcode, ccsidin); + makeOS400IconvCode(tocode, ccsidout); + memset(tocode + 13, 0, sizeof tocode - 13); /* Dest. code id format. */ + + if (cstr) + fromcode[18] = '1'; /* Set null-terminator flag. */ + + return iconv_open(tocode, fromcode); +} + + +static int +convert(char * d, size_t dlen, int dccsid, + const char * s, int slen, int sccsid) + +{ + int i; + iconv_t cd; + size_t lslen; + + /** + *** Convert `sccsid'-coded `slen'-data bytes at `s' into `dccsid'-coded + *** data stored in the `dlen'-byte buffer at `d'. + *** If `slen' < 0, source string is null-terminated. + *** CCSID 65535 (no conversion) is replaced by the ASCII CCSID. + *** Return the converted destination byte count, or -1 if error. + **/ + + if (sccsid == 65535) + sccsid = ASCII_CCSID; + + if (dccsid == 65535) + dccsid = ASCII_CCSID; + + if (sccsid == dccsid) { + lslen = slen >= 0? slen: strlen(s) + 1; + i = lslen < dlen? lslen: dlen; + + if (s != d && i > 0) + memcpy(d, s, i); + + return i; + } + + if (slen < 0) { + lslen = 0; + cd = iconv_open_CCSID(dccsid, sccsid, 1); + } + else { + lslen = (size_t) slen; + cd = iconv_open_CCSID(dccsid, sccsid, 0); + } + + if (ICONV_OPEN_ERROR(cd)) + return -1; + + i = dlen; + + if ((int) iconv(cd, (char * *) &s, &lslen, &d, &dlen) < 0) + i = -1; + else + i -= dlen; + + iconv_close(cd); + return i; +} + + +static char * +dynconvert(int dccsid, const char * s, int slen, int sccsid) + +{ + char * d; + char * cp; + size_t dlen; + int l; + int l2; + static const char nullbyte = 0; + + /* Like convert, but the destination is allocated and returned. */ + + dlen = (size_t) (slen < 0? strlen(s): slen) + 1; + dlen *= MAX_CONV_EXPANSION; /* Allow some expansion. */ + d = malloc(dlen); + + if (!d) + return (char *) NULL; + + l = convert(d, dlen, dccsid, s, slen, sccsid); + + if (l < 0) { + free(d); + return (char *) NULL; + } + + 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) { + free(d); + return (char *) NULL; + } + + l += l2; + } + + if ((size_t) l < dlen) { + cp = realloc(d, l); /* Shorten to minimum needed. */ + + if (cp) + d = cp; + } + + return d; +} + + +char * +curl_version_ccsid(unsigned int ccsid) + +{ + int i; + char * aversion; + char * eversion; + + aversion = curl_version(); + + if (!aversion) + return aversion; + + i = strlen(aversion) + 1; + i *= MAX_CONV_EXPANSION; + + if (!(eversion = Curl_thread_buffer(LK_CURL_VERSION, i))) + return (char *) NULL; + + if (convert(eversion, i, ccsid, aversion, -1, ASCII_CCSID) < 0) + return (char *) NULL; + + return eversion; +} + + +char * +curl_easy_escape_ccsid(CURL * handle, const char * string, int length, + unsigned int sccsid, unsigned int dccsid) + +{ + char * s; + char * d; + + if (!string) { + errno = EINVAL; + return (char *) NULL; + } + + s = dynconvert(ASCII_CCSID, s, length? length: -1, sccsid); + + if (!s) + return (char *) NULL; + + d = curl_easy_escape(handle, s, 0); + free(s); + + if (!d) + return (char *) NULL; + + s = dynconvert(dccsid, d, -1, ASCII_CCSID); + free(d); + return s; +} + + +char * +curl_easy_unescape_ccsid(CURL * handle, const char * string, int length, + int * outlength, + unsigned int sccsid, unsigned int dccsid) + +{ + char * s; + char * d; + + if (!string) { + errno = EINVAL; + return (char *) NULL; + } + + s = dynconvert(ASCII_CCSID, s, length? length: -1, sccsid); + + if (!s) + return (char *) NULL; + + d = curl_easy_unescape(handle, s, 0, outlength); + free(s); + + if (!d) + return (char *) NULL; + + s = dynconvert(dccsid, d, -1, ASCII_CCSID); + free(d); + + if (s && outlength) + *outlength = strlen(s); + + return s; +} + + +struct curl_slist * +curl_slist_append_ccsid(struct curl_slist * list, + const char * data, unsigned int ccsid) + +{ + char * s; + + s = (char *) NULL; + + if (!data) + return curl_slist_append(list, data); + + s = dynconvert(ASCII_CCSID, data, -1, ccsid); + + if (!s) + return (struct curl_slist *) NULL; + + list = curl_slist_append(list, s); + free(s); + return list; +} + + +time_t +curl_getdate_ccsid(const char * p, const time_t * unused, unsigned int ccsid) + +{ + char * s; + time_t t; + + if (!p) + return curl_getdate(p, unused); + + s = dynconvert(ASCII_CCSID, p, -1, ccsid); + + if (!s) + return (time_t) -1; + + t = curl_getdate(s, unused); + free(s); + return t; +} + + +static int +convert_version_info_string(const char * * stringp, + char * * bufp, int * left, unsigned int ccsid) + +{ + int l; + + /* Helper for curl_version_info_ccsid(): convert a string if defined. + Result is stored in the `*left'-byte buffer at `*bufp'. + `*bufp' and `*left' are updated accordingly. + Return 0 if ok, else -1. */ + + if (*stringp) { + l = convert(*bufp, *left, ccsid, *stringp, -1, ASCII_CCSID); + + if (l <= 0) + return -1; + + *stringp = *bufp; + *bufp += l; + *left -= l; + } + + return 0; +} + + +curl_version_info_data * +curl_version_info_ccsid(CURLversion stamp, unsigned int ccsid) + +{ + curl_version_info_data * p; + char * cp; + int n; + int nproto; + int i; + curl_version_info_data * id; + + /* The assertion below is possible, because although the second operand + is an enum member, the first is a #define. In that case, the OS/400 C + compiler seems to compare string values after substitution. */ + +#if CURLVERSION_NOW != CURLVERSION_FOURTH +#error curl_version_info_data structure has changed: upgrade this procedure too. +#endif + + /* If caller has been compiled with a new version, error. */ + + if (stamp > CURLVERSION_NOW) + return (curl_version_info_data *) NULL; + + p = curl_version_info(stamp); + + if (!p) + return p; + + /* Measure thread space needed. */ + + n = 0; + nproto = 0; + + if (p->protocols) { + while (p->protocols[nproto]) + n += strlen(p->protocols[nproto++]); + + n += nproto++; + } + + if (p->version) + n += strlen(p->version) + 1; + + if (p->host) + n += strlen(p->host) + 1; + + if (p->ssl_version) + n += strlen(p->ssl_version) + 1; + + if (p->libz_version) + n += strlen(p->libz_version) + 1; + + if (p->ares) + n += strlen(p->ares) + 1; + + if (p->libidn) + n += strlen(p->libidn) + 1; + + if (p->libssh_version) + n += strlen(p->libssh_version) + 1; + + /* Allocate thread space. */ + + n *= MAX_CONV_EXPANSION; + + 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) + return (curl_version_info_data *) NULL; + + /* Copy data and convert strings. */ + + memcpy((char *) id, (char *) p, sizeof *p); + + if (id->protocols) { + id->protocols = (const char * const *) cp; + i = nproto * sizeof id->protocols[0]; + memcpy(cp, (char *) p->protocols, i); + cp += i; + n -= i; + + for (i = 0; id->protocols[i]; 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)) + return (curl_version_info_data *) NULL; + + 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)) + return (curl_version_info_data *) NULL; + + 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)) + return (curl_version_info_data *) NULL; + + 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)) + return (curl_version_info_data *) NULL; + + return id; +} + + +const char * +curl_easy_strerror_ccsid(CURLcode error, unsigned int ccsid) + +{ + int i; + const char * s; + char * buf; + + s = curl_easy_strerror(error); + + if (!s) + return s; + + i = MAX_CONV_EXPANSION * (strlen(s) + 1); + + if (!(buf = Curl_thread_buffer(LK_EASY_STRERROR, i))) + return (const char *) NULL; + + if (convert(buf, i, ccsid, s, -1, ASCII_CCSID) < 0) + return (const char *) NULL; + + return (const char *) buf; +} + + +const char * +curl_share_strerror_ccsid(CURLSHcode error, unsigned int ccsid) + +{ + int i; + const char * s; + char * buf; + + s = curl_share_strerror(error); + + if (!s) + return s; + + i = MAX_CONV_EXPANSION * (strlen(s) + 1); + + if (!(buf = Curl_thread_buffer(LK_SHARE_STRERROR, i))) + return (const char *) NULL; + + if (convert(buf, i, ccsid, s, -1, ASCII_CCSID) < 0) + return (const char *) NULL; + + return (const char *) buf; +} + + +const char * +curl_multi_strerror_ccsid(CURLMcode error, unsigned int ccsid) + +{ + int i; + const char * s; + char * buf; + + s = curl_multi_strerror(error); + + if (!s) + return s; + + i = MAX_CONV_EXPANSION * (strlen(s) + 1); + + if (!(buf = Curl_thread_buffer(LK_MULTI_STRERROR, i))) + return (const char *) NULL; + + if (convert(buf, i, ccsid, s, -1, ASCII_CCSID) < 0) + return (const char *) NULL; + + return (const char *) buf; +} + + +CURLcode +curl_easy_getinfo_ccsid(CURL * curl, CURLINFO info, ...) + +{ + va_list arg; + void * paramp; + CURLcode ret; + unsigned int ccsid; + char * * cpp; + char * s; + char * d; + struct SessionHandle * data; + + /* WARNING: unlike curl_easy_get_info(), the strings returned by this + procedure have to be free'ed. */ + + data = (struct SessionHandle *) curl; + va_start(arg, 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; + } + + ccsid = va_arg(arg, unsigned int); + va_end(arg); + cpp = (char * *) paramp; + s = *cpp; + + if (!s) + return ret; + + d = dynconvert(ccsid, s, -1, ASCII_CCSID); + *cpp = d; + + if (!d) + return CURLE_OUT_OF_MEMORY; + + return ret; +} + + +static int +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; + } + + return 0; +} + + +static void +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) + free((char *) forms[nargs].value); + + free((char *) forms); +} + + +static int +Curl_formadd_convert(struct curl_forms * forms, + int formx, int lengthx, unsigned int ccsid) + +{ + int l; + char * cp; + char * cp2; + + if (formx < 0 || !forms[formx].value) + return 0; + + if (lengthx >= 0) + l = (int) forms[lengthx].value; + else + l = strlen(forms[formx].value) + 1; + + cp = malloc(MAX_CONV_EXPANSION * l); + + if (!cp) + return -1; + + l = convert(cp, MAX_CONV_EXPANSION * l, ASCII_CCSID, + forms[formx].value, l, ccsid); + + if (l < 0) { + free(cp); + return -1; + } + + cp2 = realloc(cp, l); /* Shorten buffer to the string size. */ + + if (cp2) + cp = cp2; + + forms[formx].value = cp; + + if (lengthx >= 0) + forms[lengthx].value = (char *) l; /* Update to length after conversion. */ + + return l; +} + + +CURLFORMcode +curl_formadd_ccsid(struct curl_httppost * * httppost, + struct curl_httppost * * last_post, ...) + +{ + va_list arg; + CURLformoption option; + CURLFORMcode result; + struct curl_forms * forms; + struct curl_forms * lforms; + struct curl_forms * tforms; + unsigned int lformlen; + const char * value; + unsigned int ccsid; + int nargs; + int namex; + int namelengthx; + int contentx; + int lengthx; + unsigned int contentccsid; + unsigned int nameccsid; + + /* A single curl_formadd() call cannot be splitted in several calls to deal + with all parameters: the original parameters are thus copied to a local + curl_forms array and converted to ASCII when needed. + CURLFORM_PTRNAME is processed as if it were CURLFORM_COPYNAME. + CURLFORM_COPYNAME and CURLFORM_NAMELENGTH occurrence order in + parameters is not defined; for this reason, the actual conversion is + delayed to the end of parameter processing. The same applies to + CURLFORM_COPYCONTENTS/CURLFORM_CONTENTSLENGTH, but these may appear + several times in the parameter list; the problem resides here in knowing + which CURLFORM_CONTENTSLENGTH applies to which CURLFORM_COPYCONTENTS and + when we can be sure to have both info for conversion: end of parameter + list is such a point, but CURLFORM_CONTENTTYPE is also used here as a + natural separator between content data definitions; this seems to be + in accordance with FormAdd() behavior. */ + + /* Allocate the local curl_forms array. */ + + lformlen = ALLOC_GRANULE; + lforms = (struct curl_forms *) malloc(lformlen * sizeof * lforms); + + if (!lforms) + return CURL_FORMADD_MEMORY; + + /* Process the arguments, copying them into local array, latching conversion + indexes and converting when needed. */ + + result = CURL_FORMADD_OK; + nargs = 0; + contentx = -1; + lengthx = -1; + namex = -1; + namelengthx = -1; + forms = (struct curl_forms *) NULL; + va_start(arg, last_post); + + for (;;) { + /* Make sure there is still room for an item in local array. */ + + if (nargs >= lformlen) { + lformlen += ALLOC_GRANULE; + tforms = (struct curl_forms *) realloc((char *) lforms, + lformlen * sizeof *lforms); + + if (!tforms) { + result = CURL_FORMADD_MEMORY; + break; + } + + lforms = tforms; + } + + /* Get next option. */ + + if (forms) { + /* Get option from array. */ + + option = forms->option; + value = forms->value; + forms++; + } + else { + /* Get option from arguments. */ + + option = va_arg(arg, CURLformoption); + + if (option == CURLFORM_END) + break; + } + + /* Dispatch by option. */ + + switch (option) { + + case CURLFORM_END: + forms = (struct curl_forms *) NULL; /* Leave array mode. */ + continue; + + case CURLFORM_ARRAY: + if (!forms) { + forms = va_arg(arg, struct curl_forms *); + continue; + } + + result = CURL_FORMADD_ILLEGAL_ARRAY; + break; + + case CURLFORM_COPYNAME: + option = CURLFORM_PTRNAME; /* Static for now. */ + + case CURLFORM_PTRNAME: + if (namex >= 0) + result = CURL_FORMADD_OPTION_TWICE; + + namex = nargs; + + if (!forms) { + value = va_arg(arg, char *); + nameccsid = (unsigned int) va_arg(arg, long); + } + else { + nameccsid = (unsigned int) forms->value; + forms++; + } + + break; + + case CURLFORM_COPYCONTENTS: + if (contentx >= 0) + result = CURL_FORMADD_OPTION_TWICE; + + contentx = nargs; + + if (!forms) { + value = va_arg(arg, char *); + contentccsid = (unsigned int) va_arg(arg, long); + } + else { + contentccsid = (unsigned int) forms->value; + forms++; + } + + break; + + case CURLFORM_PTRCONTENTS: + case CURLFORM_BUFFERPTR: + if (!forms) + value = va_arg(arg, char *); /* No conversion. */ + + break; + + case CURLFORM_CONTENTSLENGTH: + lengthx = nargs; + + if (!forms) + value = (char *) va_arg(arg, long); + + break; + + case CURLFORM_NAMELENGTH: + namelengthx = nargs; + + if (!forms) + value = (char *) va_arg(arg, long); + + break; + + case CURLFORM_BUFFERLENGTH: + if (!forms) + value = (char *) va_arg(arg, long); + + break; + + case CURLFORM_CONTENTHEADER: + if (!forms) + value = (char *) va_arg(arg, struct curl_slist *); + + break; + + case CURLFORM_CONTENTTYPE: + /* If a previous content has been encountered, convert it now. */ + + if (Curl_formadd_convert(lforms, contentx, lengthx, contentccsid) < 0) { + result = CURL_FORMADD_MEMORY; + break; + } + + contentx = -1; + lengthx = -1; + /* Fall into default. */ + + default: + /* Must be a convertible string. */ + + if (!Curl_is_formadd_string(option)) { + result = CURL_FORMADD_UNKNOWN_OPTION; + break; + } + + if (!forms) { + value = va_arg(arg, char *); + ccsid = (unsigned int) va_arg(arg, long); + } + else { + ccsid = (unsigned int) forms->value; + forms++; + } + + /* Do the conversion. */ + + lforms[nargs].value = value; + + if (Curl_formadd_convert(lforms, nargs, -1, ccsid) < 0) { + result = CURL_FORMADD_MEMORY; + break; + } + + value = lforms[nargs].value; + } + + if (result != CURL_FORMADD_OK) + break; + + lforms[nargs].value = value; + lforms[nargs++].option = option; + } + + va_end(arg); + + /* 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) + 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) + result = CURL_FORMADD_MEMORY; + else + contentx = -1; + } + + /* Do the formadd with our converted parameters. */ + + if (result == CURL_FORMADD_OK) { + lforms[nargs].option = CURLFORM_END; + result = curl_formadd(httppost, last_post, + CURLFORM_ARRAY, lforms, CURLFORM_END); + } + + /* Terminate. */ + + Curl_formadd_release_local(lforms, nargs, contentx); + return result; +} + + +typedef struct { + curl_formget_callback append; + void * arg; + unsigned int ccsid; +} cfcdata; + + +static size_t +Curl_formget_callback_ccsid(void * arg, const char * buf, size_t len) + +{ + cfcdata * p; + char * b; + int l; + size_t ret; + + p = (cfcdata *) arg; + + if ((long) len <= 0) + return (*p->append)(p->arg, buf, len); + + b = malloc(MAX_CONV_EXPANSION * len); + + if (!b) + return (size_t) -1; + + l = convert(b, MAX_CONV_EXPANSION * len, p->ccsid, buf, len, ASCII_CCSID); + + if (l < 0) { + free(b); + return (size_t) -1; + } + + ret = (*p->append)(p->arg, b, l); + free(b); + return ret == l? len: -1; +} + + +int +curl_formget_ccsid(struct curl_httppost * form, void * arg, + curl_formget_callback append, unsigned int ccsid) + +{ + cfcdata lcfc; + + lcfc.append = append; + lcfc.arg = arg; + lcfc.ccsid = ccsid; + return curl_formget(form, (void *) &lcfc, Curl_formget_callback_ccsid); +} + + +CURLcode +curl_easy_setopt_ccsid(CURL * curl, CURLoption tag, ...) + +{ + CURLcode result; + va_list arg; + struct SessionHandle * data; + char * s; + unsigned int ccsid; + static char testwarn = 1; + + /* Warns if this procedure has not been updated when the dupstring enum + changes. + We (try to) do it only once: there is no need to issue several times + the same message; but since threadsafeness is not handled here, + this may occur (and we don't care!). */ + + if (testwarn) { + testwarn = 0; + + if ((int) STRING_LAST != (int) STRING_USERPWD + 1) + curl_mfprintf(stderr, + "*** WARNING: curl_easy_setopt_ccsid() should be reworked ***\n"); + } + + data = (struct SessionHandle *) curl; + va_start(arg, tag); + + switch (tag) { + + case CURLOPT_CAINFO: + case CURLOPT_CAPATH: + case CURLOPT_COOKIE: + case CURLOPT_COOKIEFILE: + case CURLOPT_COOKIEJAR: + case CURLOPT_COOKIELIST: + case CURLOPT_CUSTOMREQUEST: + case CURLOPT_EGDSOCKET: + case CURLOPT_ENCODING: + case CURLOPT_FTPPORT: + case CURLOPT_FTP_ACCOUNT: + case CURLOPT_FTP_ALTERNATIVE_TO_USER: + case CURLOPT_INTERFACE: + case CURLOPT_KRBLEVEL: + case CURLOPT_NETRC_FILE: + case CURLOPT_POSTFIELDS: + case CURLOPT_PROXY: + case CURLOPT_PROXYUSERPWD: + case CURLOPT_RANDOM_FILE: + case CURLOPT_RANGE: + case CURLOPT_REFERER: + case CURLOPT_SSH_PRIVATE_KEYFILE: + case CURLOPT_SSH_PUBLIC_KEYFILE: + case CURLOPT_SSLCERT: + case CURLOPT_SSLCERTTYPE: + case CURLOPT_SSLENGINE: + case CURLOPT_SSLKEY: + case CURLOPT_SSLKEYPASSWD: + case CURLOPT_SSLKEYTYPE: + case CURLOPT_SSL_CIPHER_LIST: + case CURLOPT_URL: + case CURLOPT_USERAGENT: + case CURLOPT_USERPWD: + s = va_arg(arg, char *); + ccsid = va_arg(arg, unsigned int); + + if (s) { + s = dynconvert(ASCII_CCSID, s, -1, ccsid); + + if (!s) { + result = CURLE_OUT_OF_MEMORY; + break; + } + } + + result = curl_easy_setopt(curl, tag, s); + + if (s) + free(s); + + break; + + case CURLOPT_ERRORBUFFER: /* This is an output buffer. */ + default: + result = Curl_setopt(data, tag, arg); + break; + } + + va_end(arg); + return result; +} + + +char * +curl_form_long_value(long value) + +{ + /* ILE/RPG cannot cast an integer to a pointer. This procedure does it. */ + + return (char *) value; +} diff --git a/packages/OS400/ccsidcurl.h b/packages/OS400/ccsidcurl.h new file mode 100644 index 000000000..e964793c9 --- /dev/null +++ b/packages/OS400/ccsidcurl.h @@ -0,0 +1,65 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2007, 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 + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id$ + * + ***************************************************************************/ + +#ifndef __CURL_CCSIDCURL_H +#define __CURL_CCSIDCURL_H + +#include <curl.h> +#include <easy.h> +#include <multi.h> + + +CURL_EXTERN char * curl_version_ccsid(unsigned int ccsid); +CURL_EXTERN char * curl_easy_escape_ccsid(CURL * handle, + const char * string, int length, + unsigned int sccsid, + unsigned int dccsid); +CURL_EXTERN char * curl_easy_unescape_ccsid(CURL * handle, const char * string, + int length, int * outlength, + unsigned int sccsid, + unsigned int dccsid); +CURL_EXTERN struct curl_slist * curl_slist_append_ccsid(struct curl_slist * lst, + const char * data, + unsigned int ccsid); +CURL_EXTERN time_t curl_getdate_ccsid(const char * p, const time_t * unused, + unsigned int ccsid); +CURL_EXTERN curl_version_info_data * curl_version_info_ccsid(CURLversion stamp, + unsigned int csid); +CURL_EXTERN const char * curl_easy_strerror_ccsid(CURLcode error, + unsigned int ccsid); +CURL_EXTERN const char * curl_share_strerror_ccsid(CURLSHcode error, + unsigned int ccsid); +CURL_EXTERN const char * curl_multi_strerror_ccsid(CURLMcode error, + unsigned int ccsid); +CURL_EXTERN CURLcode curl_easy_getinfo_ccsid(CURL * curl, CURLINFO info, ...); +CURL_EXTERN CURLFORMcode curl_formadd_ccsid(struct curl_httppost * * httppost, + struct curl_httppost * * last_post, + ...); +CURL_EXTERN char * curl_form_long_value(long value); +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, ...); + +#endif diff --git a/packages/OS400/curl.inc.in b/packages/OS400/curl.inc.in new file mode 100644 index 000000000..4d84d8616 --- /dev/null +++ b/packages/OS400/curl.inc.in @@ -0,0 +1,1518 @@ + ************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2007, 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 + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF + * ANY KIND, either express or implied. + * + * $Id$ + * + ************************************************************************** + * + /if not defined(CURL_CURL_INC_) + /define CURL_CURL_INC_ + * + * WARNING: this file should be kept in sync with C include files. + * + ************************************************************************** + * Constants + ************************************************************************** + * + d LIBCURL_VERSION... + d c '@LIBCURL_VERSION@' + d LIBCURL_VERSION_MAJOR... + d c @LIBCURL_VERSION_MAJOR@ + d LIBCURL_VERSION_MINOR... + d c @LIBCURL_VERSION_MINOR@ + d LIBCURL_VERSION_PATCH... + d c @LIBCURL_VERSION_PATCH@ + d LIBCURL_VERSION_NUM... + d c X'00@LIBCURL_VERSION_NUM@' + d LIBCURL_TIMESTAMP... + d c '@LIBCURL_TIMESTAMP@' + * + d CURL_SOCKET_BAD... + d c -1 + d CURL_SOCKET_TIMEOUT... + d c -1 + * + d CURLINFO_STRING... + d c X'00100000' + d CURLINFO_LONG c X'00200000' + d CURLINFO_DOUBLE... + d c X'00300000' + d CURLINFO_SLIST c X'00400000' + d CURLINFO_MASK c X'000FFFFF' + d CURLINFO_TYPEMASK... + d c X'00F00000' + * + d CURL_GLOBAL_SSL... + d c X'00000001' + d CURL_GLOBAL_WIN32... + d c X'00000002' + d CURL_GLOBAL_ALL... + d c X'00000003' + d CURL_GLOBAL_NOTHING... + d c X'00000000' + d CURL_GLOBAL_DEFAULT... + d c X'00000003' + * + d CURL_VERSION_IPV6... + d c X'00000001' + d CURL_VERSION_KERBEROS4... + d c X'00000002' + d CURL_VERSION_SSL... + d c X'00000004' + d CURL_VERSION_LIBZ... + d c X'00000008' + d CURL_VERSION_NTLM... + d c X'00000010' + d CURL_VERSION_GSSNEGOTIATE... + d c X'00000020' + d CURL_VERSION_DEBUG... + d c X'00000040' + d CURL_VERSION_ASYNCHDNS... + d c X'00000080' + d CURL_VERSION_SPNEGO... + d c X'00000100' + d CURL_VERSION_LARGEFILE... + d c X'00000200' + d CURL_VERSION_IDN... + d c X'00000400' + d CURL_VERSION_SSPI... + d c X'00000800' + d CURL_VERSION_CONV... + d c X'00001000' + * + d HTTPPOST_FILENAME... + d c X'00000001' + d HTTPPOST_READFILE... + d c X'00000002' + d HTTPPOST_PTRNAME... + d c X'00000004' + d HTTPPOST_PTRCONTENTS... + d c X'00000008' + d HTTPPOST_BUFFER... + d c X'00000010' + d HTTPPOST_PTRBUFFER... + d c X'00000020' + * + d CURL_READFUNC_ABORT... + d c X'10000000' + * + d CURLAUTH_NONE c X'00000000' + d CURLAUTH_BASIC c X'00000001' + d CURLAUTH_DIGEST... + d c X'00000002' + d CURLAUTH_GSSNEGOTIATE... + d c X'00000004' + d CURLAUTH_NTLM c X'00000008' + d CURLAUTH_ANY c X'7FFFFFFF' + d CURLAUTH_ANYSAFE... + d c X'7FFFFFFE' ~CURLAUTH_BASIC + * + d CURLSSH_AUTH_ANY... + d c X'7FFFFFFF' + d CURLSSH_AUTH_NONE... + d c X'00000000' + d CURLSSH_AUTH_PUBLICKEY... + d c X'00000001' + d CURLSSH_AUTH_PASSWORD... + d c X'00000002' + d CURLSSH_AUTH_HOST... + d c X'00000004' + d CURLSSH_AUTH_KEYBOARD... + d c X'00000008' + d CURLSSH_AUTH_DEFAULT... + d c X'7FFFFFFF' CURLSSH_AUTH_ANY + * + d CURL_ERROR_SIZE... + d c 256 + * + d CURLOPTTYPE_LONG... + d c 0 + d CURLOPTTYPE_OBJECTPOINT... + d c 10000 + d CURLOPTTYPE_FUNCTIONPOINT... + d c 20000 + d CURLOPTTYPE_OFF_T... + d c 30000 + * + d CURL_IPRESOLVE_WHATEVER... + d c 0 + d CURL_IPRESOLVE_V4... + d c 1 + d CURL_IPRESOLVE_V6... + d c 2 + * + d CURL_HTTP_VERSION_NONE... + d c 0 + d CURL_HTTP_VERSION_1_0... + d c 1 + d CURL_HTTP_VERSION_1_1... + d c 2 + * + d CURL_NETRC_IGNORED... + d c 0 + d CURL_NETRC_OPTIONAL... + d c 1 + d CURL_NETRC_REQUIRED... + d c 2 + * + d CURL_SSLVERSION_DEFAULT... + d c 0 + d CURL_SSLVERSION_TLSv1... + d c 1 + d CURL_SSLVERSION_SSLv2... + d c 2 + d CURL_SSLVERSION_SSLv3... + d c 3 + * + d CURL_POLL_NONE c 0 + d CURL_POLL_IN c 1 + d CURL_POLL_OUT c 2 + d CURL_POLL_INOUT... + d c 3 + d CURL_POLL_REMOVE... + d c 4 + * + d CURL_CSELECT_IN... + d c X'00000001' + d CURL_CSELECT_OUT... + d c X'00000002' + d CURL_CSELECT_ERR... + d c X'00000004' + * + ************************************************************************** + * Types + ************************************************************************** + * + d curl_socket_t s 10i 0 based(######ptr######) + * + d curl_off_t s 20i 0 based(######ptr######) + * + d CURLcode s 10i 0 based(######ptr######) Enum + d CURLE_OK c 0 + d CURLE_UNSUPPORTED_PROTOCOL... + d c 1 + d CURLE_FAILED_INIT... + d c 2 + d CURLE_URL_MALFORMAT... + d c 3 + d CURLE_URL_MALFORMAT_USER... + d c 4 + d CURLE_COULDNT_RESOLVE_PROXY... + d c 5 + d CURLE_COULDNT_RESOLVE_HOST... + d c 6 + d CURLE_COULDNT_CONNECT... + d c 7 + d CURLE_FTP_WEIRD_SERVER_REPLY... + d c 8 + d CURLE_FTP_ACCESS_DENIED... + d c 9 + d CURLE_FTP_USER_PASSWORD_INCORRECT... + d c 10 + d CURLE_FTP_WEIRD_PASS_REPLY... + d c 11 + d CURLE_FTP_WEIRD_USER_REPLY... + d c 12 + d CURLE_FTP_WEIRD_PASV_REPLY... + d c 13 + d CURLE_FTP_WEIRD_227_FORMAT... + d c 14 + d CURLE_FTP_CANT_GET_HOST... + d c 15 + d CURLE_FTP_CANT_RECONNECT... + d c 16 + d CURLE_FTP_COULDNT_SET_BINARY... + d c 17 + d CURLE_PARTIAL_FILE... + d c 18 + d CURLE_FTP_COULDNT_RETR_FILE... + d c 19 + d CURLE_FTP_WRITE_ERROR... + d c 20 + d CURLE_FTP_QUOTE_ERROR... + d c 21 + d CURLE_HTTP_RETURNED_ERROR... + d c 22 + d CURLE_WRITE_ERROR... + d c 23 + d CURLE_MALFORMAT_USER... + d c 24 + d CURLE_UPLOAD_FAILED... + d c 25 + d CURLE_READ_ERROR... + d c 26 + d CURLE_OUT_OF_MEMORY... + d c 27 + d CURLE_OPERATION_TIMEOUTED... + d c 28 + d CURLE_OPERATION_TIMEDOUT... + d c 28 + d CURLE_FTP_COULDNT_SET_ASCII... + d c 29 + d CURLE_FTP_PORT_FAILED... + d c 30 + d CURLE_FTP_COULDNT_USE_REST... + d c 31 + d CURLE_FTP_COULDNT_GET_SIZE... + d c 32 + d CURLE_HTTP_RANGE_ERROR... + d c 33 + d CURLE_HTTP_POST_ERROR... + d c 34 + d CURLE_SSL_CONNECT_ERROR... + d c 35 + d CURLE_BAD_DOWNLOAD_RESUME... + d c 36 + d CURLE_FILE_COULDNT_READ_FILE... + d c 37 + d CURLE_LDAP_CANNOT_BIND... + d c 38 + d CURLE_LDAP_SEARCH_FAILED... + d c 39 + d CURLE_LIBRARY_NOT_FOUND... + d c 40 + d CURLE_FUNCTION_NOT_FOUND... + d c 41 + d CURLE_ABORTED_BY_CALLBACK... + d c 42 + d CURLE_BAD_FUNCTION_ARGUMENT... + d c 43 + d CURLE_BAD_CALLING_ORDER... + d c 44 + d CURLE_INTERFACE_FAILED... + d c 45 + d CURLE_BAD_PASSWORD_ENTERED... + d c 46 + d CURLE_TOO_MANY_REDIRECTS... + d c 47 + d CURLE_UNKNOWN_TELNET_OPTION... + d c 48 + d CURLE_TELNET_OPTION_SYNTAX... + d c 49 + d CURLE_OBSOLETE... + d c 50 + d CURLE_SSL_PEER_CERTIFICATE... + d c 51 + d CURLE_GOT_NOTHING... + d c 52 + d CURLE_SSL_ENGINE_NOTFOUND... + d c 53 + d CURLE_SSL_ENGINE_SETFAILED... + d c 54 + d CURLE_SEND_ERROR... + d c 55 + d CURLE_RECV_ERROR... + d c 56 + d CURLE_SHARE_IN_USE... + d c 57 + d CURLE_SSL_CERTPROBLEM... + d c 58 + d CURLE_SSL_CIPHER... + d c 59 + d CURLE_SSL_CACERT... + d c 60 + d CURLE_BAD_CONTENT_ENCODING... + d c 61 + d CURLE_LDAP_INVALID_URL... + d c 62 + d CURLE_FILESIZE_EXCEEDED... + d c 63 + d CURLE_FTP_SSL_FAILED... + d c 64 + d CURLE_SEND_FAIL_REWIND... + d c 65 + d CURLE_SSL_ENGINE_INITFAILED... + d c 66 + d CURLE_LOGIN_DENIED... + d c 67 + d CURLE_TFTP_NOTFOUND... + d c 68 + d CURLE_TFTP_PERM... + d c 69 + d CURLE_TFTP_DISKFULL... + d c 70 + d CURLE_TFTP_ILLEGAL... + d c 71 + d CURLE_TFTP_UNKNOWNID... + d c 72 + d CURLE_TFTP_EXISTS... + d c 73 + d CURLE_TFTP_NOSUCHUSER... + d c 74 + d CURLE_CONV_FAILED... + d c 75 + d CURLE_CONV_REQD... + d c 76 + d CURLE_SSL_CACERT_BADFILE... + d c 77 + d CURLE_REMOTE_FILE_NOT_FOUND... + d c 78 + d CURLE_SSH... + d c 79 + d CURLE_SSL_SHUTDOWN_FAILED... + d c 80 + * + d curlioerr s 10i 0 based(######ptr######) Enum + d CURLIOE_OK c 0 + d CURLIOE_UNKNOWNCMD... + d c 1 + d CURLIOE_FAILRESTART... + d c 2 + * + d curliocmd s 10i 0 based(######ptr######) Enum + d CURLIOCMD_NOP c 0 + d CURLIOCMD_RESTARTREAD... + d c 1 + * + d curl_infotype s 10i 0 based(######ptr######) Enum + d CURLINFO_TEXT... + d c 0 + d CURLINFO_HEADER_IN... + d c 1 + d CURLINFO_HEADER_OUT... + d c 2 + d CURLINFO_DATA_IN... + d c 3 + d CURLINFO_DATA_OUT... + d c 4 + d CURLINFO_SSL_DATA_IN... + d c 5 + d CURLINFO_SSL_DATA_OUT... + d c 6 + d CURLINFO_END... + d c 7 + * + d curl_proxytype s 10i 0 based(######ptr######) Enum + d CURLPROXY_HTTP... + d c 0 + d CURLPROXY_SOCKS4... + d c 4 + d CURLPROXY_SOCKS5... + d c 5 + * + d curl_ftpssl s 10i 0 based(######ptr######) Enum + d CURLFTPSSL_NONE... + d c 0 + d CURLFTPSSL_TRY... + d c 1 + d CURLFTPSSL_CONTROL... + d c 2 + d CURLFTPSSL_ALL... + d c 3 + * + d curl_ftpccc s 10i 0 based(######ptr######) Enum + d CURLFTPSSL_CCC_NONE... + d c 0 + d CURLFTPSSL_CCC_PASSIVE... + d c 1 + d CURLFTPSSL_CCC_ACTIVE... + d c 2 + * + d curl_ftpauth s 10i 0 based(######ptr######) Enum + d CURLFTPAUTH_DEFAULT... + d c 0 + d CURLFTPAUTH_SSL... + d c 1 + d CURLFTPAUTH_TLS... + d c 2 + * + d curl_ftpmethod s 10i 0 based(######ptr######) Enum + d CURLFTPMETHOD_DEFAULT... + d c 0 + d CURLFTPMETHOD_MULTICWD... + d c 1 + d CURLFTPMETHOD_NOCWD... + d c 2 + d CURLFTPMETHOD_SINGLECWD... + d c 3 + * + d CURLoption s 10i 0 based(######ptr######) Enum + d CURLOPT_FILE c 10001 + d CURLOPT_WRITEDATA... + d c 10001 + d CURLOPT_URL c 10002 + d CURLOPT_PORT c 00003 + d CURLOPT_PROXY c 10004 + d CURLOPT_USERPWD... + d c 10005 + d CURLOPT_PROXYUSERPWD... + d c 10006 + d CURLOPT_RANGE c 10007 + d CURLOPT_INFILE... + d c 10009 + d CURLOPT_READDATA... + d c 10009 + d CURLOPT_ERRORBUFFER... + d c 10010 + d CURLOPT_WRITEFUNCTION... + d c 20011 + d CURLOPT_READFUNCTION... + d c 20012 + d CURLOPT_TIMEOUT... + d c 00013 + d CURLOPT_INFILESIZE... + d c 00014 + d CURLOPT_POSTFIELDS... + d c 10015 + d CURLOPT_REFERER... + d c 10016 + d CURLOPT_FTPPORT... + d c 10017 + d CURLOPT_USERAGENT... + d c 10018 + d CURLOPT_LOW_SPEED_LIMIT... + d c 00019 + d CURLOPT_LOW_SPEED_TIME... + d c 00020 + d CURLOPT_RESUME_FROM... + d c 00021 + d CURLOPT_COOKIE... + d c 10022 + d CURLOPT_HTTPHEADER... + d c 10023 + d CURLOPT_HTTPPOST... + d c 10024 + d CURLOPT_SSLCERT... + d c 10025 + d CURLOPT_SSLCERTPASSWD... + d c 10026 + d CURLOPT_SSLKEYPASSWD... + d c 10026 + d CURLOPT_CRLF c 00027 + d CURLOPT_QUOTE c 10028 + d CURLOPT_WRITEHEADER... + d c 10029 + d CURLOPT_HEADERDATA... + d c 10029 + d CURLOPT_COOKIEFILE... + d c 10031 + d CURLOPT_SSLVERSION... + d c 00032 + d CURLOPT_TIMECONDITION... + d c 00033 + d CURLOPT_TIMEVALUE... + d c 00034 + d CURLOPT_CUSTOMREQUEST... + d c 10036 + d CURLOPT_STDERR... + d c 10037 + d CURLOPT_POSTQUOTE... + d c 10039 + d CURLOPT_WRITEINFO... + d c 10040 + d CURLOPT_VERBOSE... + d c 00041 + d CURLOPT_HEADER... + d c 00042 + d CURLOPT_NOPROGRESS... + d c 00043 + d CURLOPT_NOBODY... + d c 00044 + d CURLOPT_FAILONERROR... + d c 00045 + d CURLOPT_UPLOAD... + d c 00046 + d CURLOPT_POST c 00047 + d CURLOPT_FTPLISTONLY... + d c 00048 + d CURLOPT_FTPAPPEND... + d c 00050 + d CURLOPT_NETRC c 00051 + d CURLOPT_FOLLOWLOCATION... + d c 00052 + d CURLOPT_TRANSFERTEXT... + d c 00053 + d CURLOPT_PUT c 00054 + d CURLOPT_PROGRESSFUNCTION... + d c 20056 + d CURLOPT_PROGRESSDATA... + d c 10057 + d CURLOPT_AUTOREFERER... + d c 00058 + d CURLOPT_PROXYPORT... + d c 00059 + d CURLOPT_POSTFIELDSIZE... + d c 00060 + d CURLOPT_HTTPPROXYTUNNEL... + d c 00061 + d CURLOPT_INTERFACE... + d c 10062 + d CURLOPT_KRB4LEVEL... + d c 10063 + d CURLOPT_SSL_VERIFYPEER... + d c 00064 + d CURLOPT_CAINFO... + d c 10065 + d CURLOPT_MAXREDIRS... + d c 00068 + d CURLOPT_FILETIME... + d c 00069 + d CURLOPT_TELNETOPTIONS... + d c 10070 + d CURLOPT_MAXCONNECTS... + d c 00071 + d CURLOPT_CLOSEPOLICY... + d c 00072 + d CURLOPT_FRESH_CONNECT... + d c 00074 + d CURLOPT_FORBID_REUSE... + d c 00075 + d CURLOPT_RANDOM_FILE... + d c 10076 + d CURLOPT_EGDSOCKET... + d c 10077 + d CURLOPT_CONNECTTIMEOUT... + d c 00078 + d CURLOPT_HEADERFUNCTION... + d c 20079 + d CURLOPT_HTTPGET... + d c 00080 + d CURLOPT_SSL_VERIFYHOST... + d c 00081 + d CURLOPT_COOKIEJAR... + d c 10082 + d CURLOPT_SSL_CIPHER_LIST... + d c 10083 + d CURLOPT_HTTP_VERSION... + d c 00084 + d CURLOPT_FTP_USE_EPSV... + d c 00085 + d CURLOPT_SSLCERTTYPE... + d c 10086 + d CURLOPT_SSLKEY... + d c 10087 + d CURLOPT_SSLKEYTYPE... + d c 10088 + d CURLOPT_SSLENGINE... + d c 10089 + d CURLOPT_SSLENGINE_DEFAULT... + d c 00090 + d CURLOPT_DNS_USE_GLOBAL_CACHE... + d c 00091 + d CURLOPT_DNS_CACHE_TIMEOUT... + d c 00092 + d CURLOPT_PREQUOTE... + d c 10093 + d CURLOPT_DEBUGFUNCTION... + d c 20094 + d CURLOPT_DEBUGDATA... + d c 10095 + d CURLOPT_COOKIESESSION... + d c 00096 + d CURLOPT_CAPATH... + d c 10097 + d CURLOPT_BUFFERSIZE... + d c 00098 + d CURLOPT_NOSIGNAL... + d c 00099 + d CURLOPT_SHARE c 10100 + d CURLOPT_PROXYTYPE... + d c 00101 + d CURLOPT_ENCODING... + d c 10102 + d CURLOPT_PRIVATE... + d c 10103 + d CURLOPT_HTTP200ALIASES... + d c 10104 + d CURLOPT_UNRESTRICTED_AUTH... + d c 00105 + d CURLOPT_FTP_USE_EPRT... + d c 00106 + d CURLOPT_HTTPAUTH... + d c 00107 + d CURLOPT_SSL_CTX_FUNCTION... + d c 20108 + d CURLOPT_SSL_CTX_DATA... + d c 10109 + d CURLOPT_FTP_CREATE_MISSING_DIRS... + d c 00110 + d CURLOPT_PROXYAUTH... + d c 00111 + d CURLOPT_FTP_RESPONSE_TIMEOUT... + d c 00112 + d CURLOPT_IPRESOLVE... + d c 00113 + d CURLOPT_MAXFILESIZE... + d c 00114 + d CURLOPT_INFILESIZE_LARGE... + d c 30115 + d CURLOPT_RESUME_FROM_LARGE... + d c 30116 + d CURLOPT_MAXFILESIZE_LARGE... + d c 30117 + d CURLOPT_NETRC_FILE... + d c 10118 + d CURLOPT_FTP_SSL... + d c 00119 + d CURLOPT_POSTFIELDSIZE_LARGE... + d c 30120 + d CURLOPT_TCP_NODELAY... + d c 00121 + d CURLOPT_FTPSSLAUTH... + d c 00129 + d CURLOPT_IOCTLFUNCTION... + d c 20130 + d CURLOPT_IOCTLDATA... + d c 10131 + d CURLOPT_FTP_ACCOUNT... + d c 10134 + d CURLOPT_COOKIELIST... + d c 10135 + d CURLOPT_IGNORE_CONTENT_LENGTH... + d c 00136 + d CURLOPT_FTP_SKIP_PASV_IP... + d c 00137 + d CURLOPT_FTP_FILEMETHOD... + d c 00138 + d CURLOPT_LOCALPORT... + d c 00139 + d CURLOPT_LOCALPORTRANGE... + d c 00140 + d CURLOPT_CONNECT_ONLY... + d c 00141 + d CURLOPT_CONV_FROM_NETWORK_FUNCTION... + d c 20142 + d CURLOPT_CONV_TO_NETWORK_FUNCTION... + d c 20143 + d CURLOPT_CONV_FROM_UTF8_FUNCTION... + d c 20144 + d CURLOPT_MAX_SEND_SPEED_LARGE... + d c 30145 + d CURLOPT_MAX_RECV_SPEED_LARGE... + d c 30146 + d CURLOPT_FTP_ALTERNATIVE_TO_USER... + d c 10147 + d CURLOPT_SOCKOPTFUNCTION... + d c 20148 + d CURLOPT_SOCKOPTDATA... + d c 10149 + d CURLOPT_SSL_SESSIONID_CACHE... + d c 00150 + d CURLOPT_SSH_AUTH_TYPES... + d c 00151 + d CURLOPT_SSH_PUBLIC_KEYFILE... + d c 10152 + d CURLOPT_SSH_PRIVATE_KEYFILE... + d c 10153 + d CURLOPT_FTP_SSL_CCC... + d c 00154 + d CURLOPT_TIMEOUT_MS... + d c 00155 + d CURLOPT_CONNECTTIMEOUT_MS... + d c 00156 + d CURLOPT_HTTP_TRANSFER_DECODING... + d c 00157 + d CURLOPT_HTTP_CONTENT_DECODING... + d c 00158 + d CURLOPT_NEW_FILE_PERMS... + d c 00159 + d CURLOPT_NEW_DIRECTORY_PERMS... + d c 00160 + * + d CURLFORMcode s 10i 0 based(######ptr######) Enum + d CURL_FORMADD_OK... + d c 0 + d CURL_FORMADD_MEMORY... + d c 1 + d CURL_FORMADD_OPTION_TWICE... + d c 2 + d CURL_FORMADD_NULL... + d c 3 + d CURL_FORMADD_UNKNOWN_OPTION... + d c 4 + d CURL_FORMADD_INCOMPLETE... + d c 5 + d CURL_FORMADD_ILLEGAL_ARRAY... + d c 6 + d CURL_FORMADD_DISABLED... + d c 7 + * + d CURLformoption s 10i 0 based(######ptr######) Enum + d CURLFORM_NOTHING... + d c 0 + d CURLFORM_COPYNAME... + d c 1 + d CURLFORM_PTRNAME... + d c 2 + d CURLFORM_NAMELENGTH... + d c 3 + d CURLFORM_COPYCONTENTS... + d c 4 + d CURLFORM_PTRCONTENTS... + d c 5 + d CURLFORM_CONTENTSLENGTH... + d c 6 + d CURLFORM_FILECONTENT... + d c 7 + d CURLFORM_ARRAY... + d c 8 + d CURLFORM_OBSOLETE... + d c 9 + d CURLFORM_FILE... + d c 10 + d CURLFORM_BUFFER... + d c 11 + d CURLFORM_BUFFERPTR... + d c 12 + d CURLFORM_BUFFERLENGTH... + d c 13 + d CURLFORM_CONTENTTYPE... + d c 14 + d CURLFORM_CONTENTHEADER... + d c 15 + d CURLFORM_FILENAME... + d c 16 + d CURLFORM_END... + d c 17 + d CURLFORM_OBSOLETE2... + d c 18 + * + d CURLINFO s 10i 0 based(######ptr######) Enum + d CURLINFO_EFFECTIVE_URL... CURLINFO_STRING + 1 + d c X'00100001' + d CURLINFO_RESPONSE_CODE... CURLINFO_LONG + 2 + d c X'00200002' + d CURLINFO_TOTAL_TIME... CURLINFO_DOUBLE + 3 + d c X'00300003' + d CURLINFO_NAMELOOKUP_TIME... CURLINFO_DOUBLE + 4 + d c X'00300004' + d CURLINFO_CONNECT_TIME... CURLINFO_DOUBLE + 5 + d c X'00300005' + d CURLINFO_PRETRANSFER_TIME... CURLINFO_DOUBLE + 6 + d c X'00300006' + d CURLINFO_SIZE_UPLOAD... CURLINFO_DOUBLE + 7 + d c X'00300007' + d CURLINFO_SIZE_DOWNLOAD... CURLINFO_DOUBLE + 8 + d c X'00300008' + d CURLINFO_SPEED_DOWNLOAD... CURLINFO_DOUBLE + 9 + d c X'00300009' + d CURLINFO_SPEED_UPLOAD... CURLINFO_DOUBLE + 10 + d c X'0030000A' + d CURLINFO_HEADER_SIZE... CURLINFO_LONG + 11 + d c X'0020000B' + d CURLINFO_REQUEST_SIZE... CURLINFO_LONG + 12 + d c X'0020000C' + d CURLINFO_SSL_VERIFYRESULT... CURLINFO_LONG + 13 + d c X'0020000D' + d CURLINFO_FILETIME... CURLINFO_LONG + 14 + d c X'0020000E' + d CURLINFO_CONTENT_LENGTH_DOWNLOAD... CURLINFO_DOUBLE + 15 + d c X'0030000F' + d CURLINFO_CONTENT_LENGTH_UPLOAD... CURLINFO_DOUBLE + 16 + d c X'00300010' + d CURLINFO_STARTTRANSFER_TIME... CURLINFO_DOUBLE + 17 + d c X'00300011' + d CURLINFO_CONTENT_TYPE... CURLINFO_STRING + 18 + d c X'00100012' + d CURLINFO_REDIRECT_TIME... CURLINFO_DOUBLE + 19 + d c X'00300013' + d CURLINFO_REDIRECT_COUNT... CURLINFO_LONG + 20 + d c X'00200014' + d CURLINFO_PRIVATE... CURLINFO_STRING + 21 + d c X'00100015' + d CURLINFO_HTTP_CONNECTCODE... CURLINFO_LONG + 22 + d c X'00200016' + d CURLINFO_HTTPAUTH_AVAIL... CURLINFO_LONG + 23 + d c X'00200017' + d CURLINFO_PROXYAUTH_AVAIL... CURLINFO_LONG + 24 + d c X'00200018' + d CURLINFO_OS_ERRNO... CURLINFO_LONG + 25 + d c X'00200019' + d CURLINFO_NUM_CONNECTS... CURLINFO_LONG + 26 + d c X'00200020' + d CURLINFO_SSL_ENGINES... CURLINFO_SLIST + 27 + d c X'00400021' + d CURLINFO_COOKIELIST... CURLINFO_SLIST + 28 + d c X'00400022' + d CURLINFO_LASTSOCKET... CURLINFO_LONG + 29 + d c X'00200023' + d CURLINFO_FTP_ENTRY_PATH... CURLINFO_STRING + 30 + d c X'00100024' + d CURLINFO_HTTP_CODE... Old ...RESPONSE_CODE + d c X'00200002' + * + d curl_closepolicy... + d s 10i 0 based(######ptr######) Enum + d CURLCLOSEPOLICY_OLDEST... + d c 1 + d CURLCLOSEPOLICY_LEAST_RECENTLY_USED... + d c 2 + d CURLCLOSEPOLICY_LEAST_TRAFFIC... + d c 3 + d CURLCLOSEPOLICY_SLOWEST... + d c 4 + d CURLCLOSEPOLICY_CALLBACK... + d c 5 + * + d curl_lock_data... + d s 10i 0 based(######ptr######) Enum + d CURL_LOCK_DATA_NONE... + d c 0 + d CURL_LOCK_DATA_SHARE... + d c 1 + d CURL_LOCK_DATA_COOKIE... + d c 2 + d CURL_LOCK_DATA_DNS... + d c 3 + d CURL_LOCK_DATA_SSL_SESSION... + d c 4 + d CURL_LOCK_DATA_CONNECT... + d c 5 + d CURL_LOCK_DATA_LAST... + d c 6 + * + d curl_lock_access... + d s 10i 0 based(######ptr######) Enum + d CURL_LOCK_ACCESS_NONE... + d c 0 + d CURL_LOCK_ACCESS_SHARED... + d c 1 + d CURL_LOCK_ACCESS_SINGLE... + d c 2 + * + d curl_TimeCond s 10i 0 based(######ptr######) Enum + d CURL_TIMECOND_NONE... + d c 0 + d CURL_TIMECOND_IFMODSINCE... + d c 1 + d CURL_TIMECOND_LASTMOD... + d c 2 + d CURL_TIMECOND_LAST... + d c 3 + * + d CURLSHcode s 10i 0 based(######ptr######) Enum + d CURLSHE_OK c 0 + d CURLSHE_BAD_OPTION... + d c 1 + d CURLSHE_IN_USE... + d c 2 + d CURLSHE_INVALID... + d c 3 + d CURLSHE_NOMEM... + d c 4 + * + d CURLSHoption... + d s 10i 0 based(######ptr######) Enum + d CURLSHOPT_SHARE... + d c 1 + d CURLSHOPT_UNSHARE... + d c 2 + d CURLSHOPT_LOCKFUNC... + d c 3 + d CURLSHOPT_UNLOCKFUNC... + d c 4 + d CURLSHOPT_USERDATA... + d c 5 + * + d CURLversion s 10i 0 based(######ptr######) Enum + d CURLVERSION_FIRST... + d c 0 + d CURLVERSION_SECOND... + d c 1 + d CURLVERSION_THIRD... + d c 2 + d CURLVERSION_FOURTH... + d c 3 + d CURLVERSION_NOW... + d c 3 CURLVERSION_FOURTH + * + d curlsocktype s 10i 0 based(######ptr######) Enum + d CURLSOCKTYPE_IPCXN... + d c 0 + * + d CURLMcode s 10i 0 based(######ptr######) Enum + d CURLM_CALL_MULTI_PERFORM... + d c -1 + d CURLM_CALL_MULTI_SOCKET... + d c -1 + d CURLM_OK c 0 + d CURLM_BAD_HANDLE... + d c 1 + d CURLM_BAD_EASY_HANDLE... + d c 2 + d CURLM_OUT_OF_MEMORY... + d c 3 + d CURLM_INTERNAL_ERROR... + d c 4 + d CURLM_BAD_SOCKET... + d c 5 + d CURLM_UNKNOWN_OPTION... + d c 6 + d CURLM_LAST c 7 + * + d CURLMSG s 10i 0 based(######ptr######) Enum + d CURLMSG_NONE c 0 + d CURLMSG_DONE c 1 + * + d CURLMoption s 10i 0 based(######ptr######) Enum + d CURLMOPT_SOCKETFUNCTION... + d c 20001 + d CURLMOPT_SOCKETDATA... + d c 10002 + d CURLMOPT_PIPELINING... + d c 00003 + d CURLMOPT_TIMERFUNCTION... + d c 20004 + d CURLMOPT_TIMERDATA... + d c 10005 + d CURLMOPT_MAXCONNECTS... + d c 00006 + * + * Renaming CURLMsg to CURL_Msg to avoid case-insensivity name clash. + * + d CURL_Msg ds based(######ptr######) + d qualified + d msg like(CURLMSG) + d easy_handle * CURL * + d data * + d whatever * overlay(data) void * + d result overlay(data) like(CURLcode) + * + d curl_http_post... + d ds based(######ptr######) + d qualified + d next * curl_httppost * + d name * char * + d namelength 10i 0 long + d contents * char * + d contentslength... + d 10i 0 long + d buffer * char * + d bufferlength... + d 10i 0 long + d contenttype * char * + d contentheader... + d * curl_slist * + d more * curl_httppost * + d flags 10i 0 long + d showfilename * char * + * + d curl_forms ds based(######ptr######) + d qualified + d option like(CURLformoption) + d value * const char * + d value_ptr * overlay(value) + d value_procptr... + d * overlay(value) procptr + * + d curl_slist ds based(######ptr######) + d qualified + d data * char * + d next * struct curl_slist * + * + d curl_version_info_data... + d ds based(######ptr######) + d qualified + d age like(CURLversion) + d version * const char * + d version_num 10u 0 + d host * const char * + d features 10i 0 + d ssl_version * const char * + d ssl_version_num... + d 10i 0 long + d libz_version * const char * + d protocols * const char * const * + d ares * const char * + d ares_num 10i 0 + d libidn * const char * + d iconv_ver_num... + d 10i 0 + d libssh_version... + d * const char * + * + d curl_formget_callback... + d s * based(######ptr######) procptr + * + d curl_malloc_callback... + d s * based(######ptr######) procptr + * + d curl_free_callback... + d s * based(######ptr######) procptr + * + d curl_realloc_callback... + d s * based(######ptr######) procptr + * + d curl_strdup_callback... + d s * based(######ptr######) procptr + * + d curl_calloc_callback... + d s * based(######ptr######) procptr + * + d curl_lock_function... + d s * based(######ptr######) procptr + * + d curl_unlock_function... + d s * based(######ptr######) procptr + * + d curl_progress_callback... + d s * based(######ptr######) procptr + * + d curl_read_callback... + d s * based(######ptr######) procptr + * + d curl_sockopt_callback... + d s * based(######ptr######) procptr + * + d curl_ioctl_callback... + d s * based(######ptr######) procptr + * + d curl_debug_callback... + d s * based(######ptr######) procptr + * + d curl_conv_callback... + d s * based(######ptr######) procptr + * + d curl_ssl_ctx_callback... + d s * based(######ptr######) procptr + * + d curl_socket_callback... + d s * based(######ptr######) procptr + * + ************************************************************************** + * Prototypes + ************************************************************************** + * + * This procedure as a variable parameter list. + * This prototype allows use of an option array, or a single "object" + * option. Other argument lists may be implemented by alias procedure + * prototype definitions. + * + d curl_formadd pr extproc('curl_formadd') + d like(CURLFORMcode) + d httppost * curl_httppost * + d lastpost * curl_httppost * + d option1 value like(CURLFORMoption) CURLFORM_ARRAY + d options(*nopass) + d object1 * value options(*string: *nopass) + d option2 value like(CURLFORMoption) CURLFORM_END + d options(*nopass) + * + * + d curl_strequal pr 10i 0 extproc('curl_strequal') + d s1 * value options(*string) + d s2 * value options(*string) + * + d curl_strnequal pr 10i 0 extproc('curl_strnequal') + d s1 * value options(*string) + d s2 * value options(*string) + d n 10i 0 value + * + d curl_formget pr 10i 0 extproc('curl_formget') + d form * value curl_httppost * + d arg * value + d append value like(curl_formget_callback) + * + d curl_formfree pr extproc('curl_formfree') + d form * value curl_httppost * + * + d curl_getenv pr * extproc('curl_getenv') + d variable * value options(*string) + * + d curl_version pr * extproc('curl_version') + * + d curl_easy_escape... + d pr * extproc('curl_easy_escape') char * + d handle * value CURL * + d string * value options(*string) + d length 10i 0 value + * + d curl_escape pr * extproc('curl_escape') char * + d string * value options(*string) + d length 10i 0 value + * + d curl_easy_unescape... + d pr * extproc('curl_easy_unescape') char * + d handle * value CURL * + d string * value options(*string) + d length 10i 0 value + d outlength 10i 0 options(*omit) + * + d curl_unescape pr * extproc('curl_unescape') char * + d string * value options(*string) + d length 10i 0 value + * + d curl_free pr extproc('curl_free') + d p * value + * + d curl_global_init... + d pr extproc('curl_global_init') + d like(CURLcode) + d flags 10i 0 value + * + d curl_global_init_mem... + d pr extproc('curl_global_init_mem') + d like(CURLcode) + d m value like(curl_malloc_callback) + d f value like(curl_free_callback) + d r value like(curl_realloc_callback) + d s value like(curl_strdup_callback) + d c value like(curl_calloc_callback) + * + d curl_global_cleanup... + d pr extproc('curl_global_cleanup') + * + d curl_slist_append... + d pr * extproc('curl_slist_append') struct curl_slist * + d list * value struct curl_slist * + d data * value options(*string) const char * + * + d curl_slist_free_all... + d pr extproc('curl_slist_free_all') + d list * value struct curl_slist * + * + d curl_getdate pr 10i 0 extproc('curl_getdate') time_t + d p * value options(*string) const char * + d unused 10i 0 const options(*omit) time_t + * + d curl_share_init... + d pr * extproc('curl_share_init') CURLSH * (= void *) + * + * Variable argument type procedure. + * Multiply prototyped to support all possible types. + * + d curl_share_setopt_int... + d pr extproc('curl_share_setopt') + d like(CURLSHcode) + d share * value CURLSH * (= void *) + d option value like(CURLSHoption) + d intarg 10i 0 value options(*nopass) + * + d curl_share_setopt_ptr... + d pr extproc('curl_share_setopt') + d like(CURLSHcode) + d share * value CURLSH * (= void *) + d option value like(CURLSHoption) + d ptrarg * value options(*nopass) + * + d curl_share_setopt_proc... + d pr extproc('curl_share_setopt') + d like(CURLSHcode) + d share * value CURLSH * (= void *) + d option value like(CURLSHoption) + d procarg * value procptr options(*nopass) + * + d curl_share_cleanup... + d pr extproc('curl_share_cleanup') + d like(CURLSHcode) + d share * value CURLSH * (= void *) + * + d curl_version_info... + d pr * extproc('curl_version_info') c_i_version_data * + d version value like(CURLversion) + * + d curl_easy_strerror... + d pr * extproc('curl_easy_strerror') const char * + d code value like(CURLcode) + * + d curl_share_strerror... + d pr * extproc('curl_share_strerror') const char * + d code value like(CURLSHcode) + * + d curl_easy_init pr * extproc('curl_easy_init') CURL * + * + * Multiple prototypes for vararg procedure curl_easy_setopt. + * + d curl_easy_setopt_long... + d pr extproc('curl_easy_setopt') + d like(CURLcode) + d curl * value CURL * + d option value like(CURLoption) + d longarg 10i 0 value options(*nopass) + * + d curl_easy_setopt_object... + d pr extproc('curl_easy_setopt') + d like(CURLcode) + d curl * value CURL * + d option value like(CURLoption) + d objectarg * value options(*string: *nopass) + * + d curl_easy_setopt_function... + d pr extproc('curl_easy_setopt') + d like(CURLcode) + d curl * value CURL * + d option value like(CURLoption) + d functionarg * value procptr options(*nopass) + * + d curl_easy_setopt_offset... + d pr extproc('curl_easy_setopt') + d like(CURLcode) + d curl * value CURL * + d option value like(CURLoption) + d offsetarg value like(curl_off_t) + d options(*nopass) + * + * + d curl_easy_perform... + d pr extproc('curl_easy_perform') + d like(CURLcode) + d curl * value CURL * + * + d curl_easy_cleanup... + d pr extproc('curl_easy_cleanup') + d curl * value CURL * + * + * Multiple prototypes for vararg procedure curl_easy_getinfo. + * + d curl_easy_getinfo_string... + d pr extproc('curl_easy_getinfo') + d like(CURLcode) + d curl * value CURL * + d info value like(CURLINFO) + d stringarg * options(*nopass) char * + * + d curl_easy_getinfo_long... + d pr extproc('curl_easy_getinfo') + d like(CURLcode) + d curl * value CURL * + d info value like(CURLINFO) + d longarg 10i 0 options(*nopass) + * + d curl_easy_getinfo_double... + d pr extproc('curl_easy_getinfo') + d like(CURLcode) + d curl * value CURL * + d info value like(CURLINFO) + d doublearg 8f options(*nopass) + * + d curl_easy_getinfo_slist... + d pr extproc('curl_easy_getinfo') + d like(CURLcode) + d curl * value CURL * + d info value like(CURLINFO) + d slistarg * options(*nopass) struct curl_slist * + * + * + d curl_easy_duphandle... + d pr * extproc('curl_easy_duphandle') CURL * + d curl * value CURL * + * + d curl_easy_reset... + d pr extproc('curl_easy_reset') + d curl * value CURL * + * + d curl_multi_init... + d pr * extproc('curl_multi_init') CURLM * + * + d curl_multi_add_handle... + d pr extproc('curl_multi_add_handle') + d like(CURLMcode) + d multi_handle * value CURLM * + d curl_handle * value CURL * + * + d curl_multi_remove_handle... + d pr extproc('curl_multi_remove_handle') + d like(CURLMcode) + d multi_handle * value CURLM * + d curl_handle * value CURL * + * + d curl_multi_fdset... + d pr extproc('curl_multi_fdset') + d like(CURLMcode) + d multi_handle * value CURLM * + d read_fd_set 65535 options(*varsize) fd_set + d write_fd_set 65535 options(*varsize) fd_set + d exc_fd_set 65535 options(*varsize) fd_set + d max_fd 10i 0 + * + d curl_multi_perform... + d pr extproc('curl_multi_perform') + d like(CURLMcode) + d multi_handle * value CURLM * + d running_handles... + d 10i 0 + * + d curl_multi_cleanup... + d pr extproc('curl_multi_cleanup') + d like(CURLMcode) + d multi_handle * value CURLM * + * + d curl_multi_info_read... + d pr * extproc('curl_multi_info_read') CURL_Msg * + d multi_handle * value CURLM * + d msgs_in_queue 10i 0 + * + d curl_multi_strerror... + d pr * extproc('curl_multi_strerror') char * + d code value like(CURLMcode) + * + d curl_multi_socket... + d pr extproc('curl_multi_socket') + d like(CURLMcode) + d multi_handle * value CURLM * + d s value like(curl_socket_t) + d running_handles... + d 10i 0 + * + d curl_multi_socket_action... + d pr extproc('curl_multi_socket_action') + d like(CURLMcode) + d multi_handle * value CURLM * + d s value like(curl_socket_t) + d ev_bitmask 10i 0 value + d running_handles... + d 10i 0 + * + d curl_multi_socket_all... + d pr extproc('curl_multi_socket_all') + d like(CURLMcode) + d multi_handle * value CURLM * + d running_handles... + d 10i 0 + * + d curl_multi_timeout... + d pr extproc('curl_multi_timeout') + d like(CURLMcode) + d multi_handle * value CURLM * + d milliseconds 10i 0 + * + * Multiple prototypes for vararg procedure curl_multi_setopt. + * + d curl_multi_setopt_long... + d pr extproc('curl_multi_setopt') + d like(CURLMcode) + d multi_handle * value CURLM * + d option value like(CURLMoption) + d longarg 10i 0 value options(*nopass) + * + d curl_multi_setopt_object... + d pr extproc('curl_multi_setopt') + d like(CURLMcode) + d multi_handle * value CURLM * + d option value like(CURLMoption) + d objectarg * value options(*string: *nopass) + * + d curl_multi_setopt_function... + d pr extproc('curl_multi_setopt') + d like(CURLMcode) + d multi_handle * value CURLM * + d option value like(CURLMoption) + d functionarg * value procptr options(*nopass) + * + d curl_multi_setopt_offset... + d pr extproc('curl_multi_setopt') + d like(CURLMcode) + d multi_handle * value CURLM * + d option value like(CURLMoption) + d offsetarg value like(curl_off_t) + d options(*nopass) + * + * + d curl_multi_assign... + d pr extproc('curl_multi_assign') + d like(CURLMcode) + d multi_handle * value CURLM * + d sockfd value like(curl_socket_t) + d sockp * value void * + * + ************************************************************************** + * CCSID wrapper procedure prototypes + ************************************************************************** + * + d curl_version_ccsid... + d pr * extproc('curl_version_ccsid') + d ccsid 10u 0 value + * + d curl_easy_escape_ccsid... + d pr * extproc('curl_easy_escape_ccsid') char * + d handle * value CURL * + d string * value options(*string) + d length 10i 0 value + d ccsid 10u 0 value + * + d curl_easy_unescape_ccsid... + d pr * extproc('curl_easy_unescape_ccsid') char * + d handle * value CURL * + d string * value options(*string) + d length 10i 0 value + d outlength 10i 0 options(*omit) + d ccsid 10u 0 value + * + d curl_slist_append_ccsid... + d pr * extproc('curl_slist_append_ccsid') struct curl_slist * + d list * value struct curl_slist * + d data * value options(*string) const char * + d ccsid 10u 0 value + * + d curl_getdate_ccsid... + d pr 10i 0 extproc('curl_getdate_ccsid') time_t + d p * value options(*string) const char * + d unused 10i 0 const options(*omit) time_t + d ccsid 10u 0 value + * + d curl_version_info_ccsid... + d pr * extproc('curl_version_info_ccsid') c_i_version_data * + d version value like(CURLversion) + d ccsid 10u 0 value + * + d curl_easy_strerror_ccsid... + d pr * extproc('curl_easy_strerror_ccsid') const char * + d code value like(CURLcode) + d ccsid 10u 0 value + * + d curl_share_strerror_ccsid... + d pr * extproc('curl_share_strerror_ccsid') const char * + d code value like(CURLSHcode) + d ccsid 10u 0 value + * + d curl_multi_strerror_ccsid... + d pr * extproc('curl_multi_strerror_ccsid') char * + d code value like(CURLMcode) + d ccsid 10u 0 value + * + 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 ccsid 10u 0 value options(*nopass) + * + d curl_formadd_ccsid... + d pr extproc('curl_formadd_ccsid') + d like(CURLFORMcode) + d httppost * curl_httppost * + d lastpost * curl_httppost * + d option1 value like(CURLFORMoption) CURLFORM_ARRAY + d options(*nopass) + d object1 * value options(*string: *nopass) + d option2 value like(CURLFORMoption) CURLFORM_END + d options(*nopass) + * + d curl_formget_ccsid... + d pr 10i 0 extproc('curl_formget_ccsid') + d form * value curl_httppost * + d arg * value + d append value like(curl_formget_callback) + d ccsid 10u 0 value + * + d curl_form_long_value... + d pr * extproc('curl_form_long_value') + d value 10i 0 value curl_httppost * + * + d curl_easy_setopt_ccsid... + d pr extproc('curl_easy_setopt_ccsid') + d like(CURLcode) + d curl * value CURL * + d option value like(CURLoption) + d objectarg * value options(*string: *nopass) + d ccsid 10u 0 value options(*nopass) + * + /endif diff --git a/packages/OS400/initscript.sh b/packages/OS400/initscript.sh new file mode 100644 index 000000000..60d7de229 --- /dev/null +++ b/packages/OS400/initscript.sh @@ -0,0 +1,171 @@ +#!/bin/sh + +# $Id$ + +case "${SCRIPTDIR}" in +/*) ;; +*) SCRIPTDIR="`pwd`/${SCRIPTDIR}" +esac + +while true +do case "${SCRIPTDIR}" in + */.) SCRIPTDIR="${SCRIPTDIR%/.}";; + *) break;; + esac +done + +# The script directory is supposed to be in $TOPDIR/packages/os400. + +TOPDIR=`dirname "${SCRIPTDIR}"` +TOPDIR=`dirname "${TOPDIR}"` +export SCRIPTDIR TOPDIR + + +################################################################################ +# +# Tunable configuration parameters. +# +################################################################################ + +TARGETLIB='CURL' # Target OS/400 program library +STATBNDDIR='CURL_A' # Static binding directory. +DYNBNDDIR='CURL' # Dynamic binding directory. +SRVPGM='CURL' # Service program. +TGTCCSID='500' # Target CCSID of objects +DEBUG='*ALL' # Debug level +OPTIMIZE='10' # Optimisation level +OUTPUT='*NONE' # Compilation output option. +TGTRLS='V5R1M0' # Target OS release + +export TARGETLIB STATBNDDIR DYNBNDDIR SRVPGM TGTCCSID DEBUG OPTIMIZE OUTPUTC +export TGTRLS + + +################################################################################ + +# Need to get the version definitions. + +LIBCURL_VERSION=`grep '^#define *LIBCURL_VERSION ' \ + "${TOPDIR}/include/curl/curlver.h" | + sed 's/.*"\(.*\)".*/\1/'` +LIBCURL_VERSION_MAJOR=`grep '^#define *LIBCURL_VERSION_MAJOR ' \ + "${TOPDIR}/include/curl/curlver.h" | + sed 's/^#define *LIBCURL_VERSION_MAJOR *\([^ ]*\).*/\1/'` +LIBCURL_VERSION_MINOR=`grep '^#define *LIBCURL_VERSION_MINOR ' \ + "${TOPDIR}/include/curl/curlver.h" | + sed 's/^#define *LIBCURL_VERSION_MINOR *\([^ ]*\).*/\1/'` +LIBCURL_VERSION_PATCH=`grep '^#define *LIBCURL_VERSION_PATCH ' \ + "${TOPDIR}/include/curl/curlver.h" | + sed 's/^#define *LIBCURL_VERSION_PATCH *\([^ ]*\).*/\1/'` +LIBCURL_VERSION_NUM=`grep '^#define *LIBCURL_VERSION_NUM ' \ + "${TOPDIR}/include/curl/curlver.h" | + sed 's/^#define *LIBCURL_VERSION_NUM *0x\([^ ]*\).*/\1/'` +LIBCURL_TIMESTAMP=`grep '^#define *LIBCURL_TIMESTAMP ' \ + "${TOPDIR}/include/curl/curlver.h" | + sed 's/.*"\(.*\)".*/\1/'` +export LIBCURL_VERSION +export LIBCURL_VERSION_MAJOR LIBCURL_VERSION_MINOR LIBCURL_VERSION_PATCH +export LIBCURL_VERSION_NUM LIBCURL_TIMESTAMP + +################################################################################ +# +# OS/400 specific definitions. +# +################################################################################ + +LIBIFSNAME="/QSYS.LIB/${TARGETLIB}.LIB" + + +################################################################################ +# +# Procedures. +# +################################################################################ + +# action_needed dest [src] +# +# dest is an object to build +# if specified, src is an object on which dest depends. +# +# exit 0 (succeeds) if some action has to be taken, else 1. + +action_needed() + +{ + [ ! -e "${1}" ] && return 0 + [ "${2}" ] || return 1 + [ "${1}" -ot "${2}" ] && return 0 + return 1 +} + + +# make_module module_name source_name [additional_definitions] +# +# Compile source name into ASCII module if needed. +# As side effect, append the module name to variable MODULES. +# Set LINK to "YES" if the module has been compiled. + +make_module() + +{ + MODULES="${MODULES} ${1}" + MODIFSNAME="${LIBIFSNAME}/${1}.MODULE" + action_needed "${MODIFSNAME}" "${2}" || return 0; + + # #pragma convert has to be in the source file itself, i.e. + # putting it in an include file makes it only active + # for that include file. + # Thus we build a temporary file with the pragma prepended to + # the source file and we compile that themporary file. + + echo "#line 1 \"${2}\"" > __tmpsrcf.c + echo "#pragma convert(819)" >> __tmpsrcf.c + echo "#line 1" >> __tmpsrcf.c + cat "${2}" >> __tmpsrcf.c + CMD="CRTCMOD MODULE(${TARGETLIB}/${1}) SRCSTMF('__tmpsrcf.c')" +# CMD="${CMD} SYSIFCOPT(*IFS64IO) OPTION(*INCDIRFIRST *SHOWINC *SHOWSYS)" + CMD="${CMD} SYSIFCOPT(*IFS64IO) OPTION(*INCDIRFIRST)" + CMD="${CMD} LOCALETYPE(*LOCALE)" + CMD="${CMD} INCDIR('/qibm/proddata/qadrt/include'" + CMD="${CMD} '${TOPDIR}/include/curl' '${TOPDIR}/include'" + CMD="${CMD} '${TOPDIR}/packages/OS400' ${INCLUDES})" + CMD="${CMD} TGTCCSID(${TGTCCSID}) TGTRLS(${TGTRLS})" + CMD="${CMD} OUTPUT(${OUTPUT})" + CMD="${CMD} OPTIMIZE(${OPTIMIZE})" + CMD="${CMD} DBGVIEW(${DEBUG})" + + if [ "${3}" ] + then CMD="${CMD} DEFINE(${3})" + fi + + system "${CMD}" + rm -f __tmpsrcf.c + LINK=YES +} + + +# Determine DB2 object name from IFS name. + +db2_name() + +{ + basename "${1}" | + tr '[a-z]' '[A-Z]' | + sed -e 's/\..*//' \ + -e 's/^\(..........\).*/\1/' +} + + +# Copy IFS file replacing version info. + +versioned_copy() + +{ + sed -e "s/@LIBCURL_VERSION@/${LIBCURL_VERSION}/g" \ + -e "s/@LIBCURL_VERSION_MAJOR@/${LIBCURL_VERSION_MAJOR}/g" \ + -e "s/@LIBCURL_VERSION_MINOR@/${LIBCURL_VERSION_MINOR}/g" \ + -e "s/@LIBCURL_VERSION_PATCH@/${LIBCURL_VERSION_PATCH}/g" \ + -e "s/@LIBCURL_VERSION_NUM@/${LIBCURL_VERSION_NUM}/g" \ + -e "s/@LIBCURL_TIMESTAMP@/${LIBCURL_TIMESTAMP}/g" \ + < "${1}" > "${2}" +} diff --git a/packages/OS400/make-include.sh b/packages/OS400/make-include.sh new file mode 100644 index 000000000..a752028e0 --- /dev/null +++ b/packages/OS400/make-include.sh @@ -0,0 +1,48 @@ +#!/bin/sh +# +# Installation of the include files in the OS/400 library. +# +# $Id$ + +SCRIPTDIR=`dirname "${0}"` +. "${SCRIPTDIR}/initscript.sh" +cd "${TOPDIR}/include" + + +# Create the OS/400 source program file for the include files. + +SRCPF="${LIBIFSNAME}/H.FILE" + +if action_needed "${SRCPF}" +then CMD="CRTSRCPF FILE(${TARGETLIB}/H) RCDLEN(112)" + CMD="${CMD} TEXT('curl: Header files')" + system "${CMD}" +fi + + +# Enumeration values are used as va_arg tagfields, so they MUST be +# integers. + +copy_hfile() + +{ + sed -e '1i\ +#pragma enum(int)\ +' -e '$a\ +#pragma enum(pop)\ +' < "${2}" > "${1}" +} + +# Copy the header files. + +for HFILE in curl/*.h ${SCRIPTDIR}/ccsidcurl.h +do DEST="${SRCPF}/`db2_name \"${HFILE}\"`.MBR" + if action_needed "${DEST}" "${HFILE}" + then copy_hfile "${DEST}" "${HFILE}" + fi +done + + +# Copy the ILE/RPG include file, setting-up version number. + + versioned_copy "${SCRIPTDIR}/curl.inc.in" "${SRCPF}/CURL.INC.MBR" diff --git a/packages/OS400/make-lib.sh b/packages/OS400/make-lib.sh new file mode 100644 index 000000000..c41e68f1f --- /dev/null +++ b/packages/OS400/make-lib.sh @@ -0,0 +1,207 @@ +#!/bin/sh +# +# libcurl compilation script for the OS/400. +# +# $Id$ + +SCRIPTDIR=`dirname "${0}"` +. "${SCRIPTDIR}/initscript.sh" +cd "${TOPDIR}/lib" + + +# Create ca-bundle.h file. + +if action_needed "ca-bundle.h" +then echo "/* This file is generated automatically */" > ca-bundle.h + echo "#ifndef CURL_CA_BUNDLE" >> ca-bundle.h + + if [ "${CABUNDLE}" ] + then echo '#define CURL_CA_BUNDLE @CURL_CA_BUNDLE@' >> ca-bundle.h + else echo '#undef CURL_CA_BUNDLE /* unknown */' >> ca-bundle.h + fi + + echo "#endif" >> ca-bundle.h +fi + + +# Create and compile the identification source file. + +echo '#pragma comment(user, "libcurl version '"${LIBCURL_VERSION}"'")' > os400.c +echo '#pragma comment(date)' >> os400.c +echo '#pragma comment(copyright, "Copyright (C) 1998-2007 Daniel Stenberg et al. OS/400 version by P. Monnerat")' >> os400.c +make_module OS400 os400.c +LINK= # No need to rebuild service program yet. +MODULES= + + +# Get source list. + +CSOURCES() + +{ + shift # Drop the equal sign. + CSOURCES="$*" # Get the file names. +} + +HHEADERS() + +{ + shift # Drop the equal sign. + HHEADERS="$*" # Get the file names. +} + +. Makefile.inc + + +# Compile the sources into modules. + +INCLUDES="'`pwd`'" + +make_module OS400SYS "${SCRIPTDIR}/os400sys.c" +make_module CCSIDCURL "${SCRIPTDIR}/ccsidcurl.c" + +for SRC in ${CSOURCES} +do MODULE=`basename "${SRC}" .c | + tr '[a-z]' '[A-Z]' | + sed -e 's/^\(..........\).*/\1/'` + make_module "${MODULE}" "${SRC}" +done + + +# If needed, (re)create the static binding directory. + +if action_needed "${LIBIFSNAME}/${STATBNDDIR}.BNDDIR" +then LINK=YES +fi + +if [ "${LINK}" ] +then rm -rf "${LIBIFSNAME}/${STATBNDDIR}.BNDDIR" + CMD="CRTBNDDIR BNDDIR(${TARGETLIB}/${STATBNDDIR})" + CMD="${CMD} TEXT('LibCurl API static binding directory')" + system "${CMD}" + + for MODULE in ${MODULES} + do CMD="ADDBNDDIRE BNDDIR(${TARGETLIB}/${STATBNDDIR})" + CMD="${CMD} OBJ((${TARGETLIB}/${MODULE} *MODULE))" + system "${CMD}" + done +fi + + +# The exportation file for service program creation must be in a DB2 +# source file, so make sure it exists. + +if action_needed "${LIBIFSNAME}/TOOLS.FILE" +then CMD="CRTSRCPF FILE(${TARGETLIB}/TOOLS) RCDLEN(112)" + CMD="${CMD} TEXT('curl: build tools')" + system "${CMD}" +fi + + +# Gather the list of symbols to export. + +EXPORTS=`grep '^CURL_EXTERN[ ]' \ + "${TOPDIR}"/include/curl/*.h \ + "${SCRIPTDIR}/ccsidcurl.h" | + sed -e 's/^.*CURL_EXTERN[ ]\(.*\)(.*$/\1/' \ + -e 's/[ ]*$//' \ + -e 's/^.*[ ][ ]*//' \ + -e 's/^\*//' \ + -e 's/(\(.*\))/\1/'` + +# Create the service program exportation file in DB2 member if needed. + +BSF="${LIBIFSNAME}/TOOLS.FILE/BNDSRC.MBR" + +if action_needed "${BSF}" +then LINK=YES +fi + +if [ "${LINK}" ] +then echo " STRPGMEXP PGMLVL(*CURRENT) SIGNATURE('LIBCURL')" > "${BSF}" + for EXPORT in ${EXPORTS} + do echo ' EXPORT SYMBOL("'"${EXPORT}"'")' >> "${BSF}" + done + + echo ' ENDPGMEXP' >> "${BSF}" +fi + + +# Build the service program if needed. + +if action_needed "${LIBIFSNAME}/${SRVPGM}.SRVPGM" +then LINK=YES +fi + +if [ "${LINK}" ] +then CMD="CRTSRVPGM SRVPGM(${TARGETLIB}/${SRVPGM})" + CMD="${CMD} SRCFILE(${TARGETLIB}/TOOLS) SRCMBR(BNDSRC)" + CMD="${CMD} MODULE(${TARGETLIB}/OS400)" + CMD="${CMD} BNDDIR(${TARGETLIB}/${STATBNDDIR})" + CMD="${CMD} BNDSRVPGM(QADRTTS)" + CMD="${CMD} TEXT('curl API library')" + CMD="${CMD} TGTRLS(${TGTRLS})" + system "${CMD}" + LINK=YES +fi + + +# If needed, (re)create the dynamic binding directory. + +if action_needed "${LIBIFSNAME}/${DYNBNDDIR}.BNDDIR" +then LINK=YES +fi + +if [ "${LINK}" ] +then rm -rf "${LIBIFSNAME}/${DYNBNDDIR}.BNDDIR" + CMD="CRTBNDDIR BNDDIR(${TARGETLIB}/${DYNBNDDIR})" + CMD="${CMD} TEXT('LibCurl API dynamic binding directory')" + system "${CMD}" + CMD="ADDBNDDIRE BNDDIR(${TARGETLIB}/${DYNBNDDIR})" + CMD="${CMD} OBJ((*LIBL/${SRVPGM} *SRVPGM))" + system "${CMD}" +fi + + +# Rebuild the formdata test if needed. + +if [ "${TEST_FORMDATA}" ] +then MODULES= + make_module TFORMDATA formdata.c "'_FORM_DEBUG' 'CURLDEBUG'" + make_module TSTREQUAL strequal.c "'_FORM_DEBUG' 'CURLDEBUG'" + make_module TMEMDEBUG memdebug.c "'_FORM_DEBUG' 'CURLDEBUG'" + make_module TMPRINTF mprintf.c "'_FORM_DEBUG' 'CURLDEBUG'" + make_module TSTRERROR strerror.c "'_FORM_DEBUG' 'CURLDEBUG'" + # The following modules should not be needed (see comment in + # formdata.c. However, there are some unsatisfied + # external references leading in the following + # modules to be (recursively) needed. + MODULES="${MODULES} EASY STRDUP SSLGEN QSSL HOSTIP HOSTIP4 HOSTIP6" + MODULES="${MODULES} URL HASH TRANSFER GETINFO COOKIE SENDF SELECT" + MODULES="${MODULES} INET_NTOP SHARE HOSTTHRE MULTI LLIST FTP HTTP" + MODULES="${MODULES} HTTP_DIGES HTTP_CHUNK HTTP_NEGOT TIMEVAL HOSTSYN" + MODULES="${MODULES} CONNECT SOCKS PROGRESS ESCAPE INET_PTON GETENV" + MODULES="${MODULES} DICT LDAP TELNET FILE TFTP NETRC PARSEDATE" + MODULES="${MODULES} SPEEDCHECK SPLAY BASE64 SECURITY IF2IP MD5" + MODULES="${MODULES} KRB5 OS400SYS" + + PGMIFSNAME="${LIBIFSNAME}/TFORMDATA.PGM" + + if action_needed "${PGMIFSNAME}" + then LINK=YES + fi + + if [ "${LINK}" ] + then CMD="CRTPGM PGM(${TARGETLIB}/TFORMDATA)" + CMD="${CMD} ENTMOD(QADRT/QADRTMAIN2)" + CMD="${CMD} MODULE(" + + for MODULE in ${MODULES} + do CMD="${CMD} ${TARGETLIB}/${MODULE}" + done + + CMD="${CMD} ) BNDSRVPGM(QADRTTS)" + CMD="${CMD} TGTRLS(${TGTRLS})" + system "${CMD}" + fi +fi diff --git a/packages/OS400/make-src.sh b/packages/OS400/make-src.sh new file mode 100644 index 000000000..ba7115322 --- /dev/null +++ b/packages/OS400/make-src.sh @@ -0,0 +1,5 @@ +#!/bin/sh +# +# $Id$ +# +# Not implemented yet on OS/400. diff --git a/packages/OS400/make-tests.sh b/packages/OS400/make-tests.sh new file mode 100644 index 000000000..6ef6af914 --- /dev/null +++ b/packages/OS400/make-tests.sh @@ -0,0 +1,102 @@ +#!/bin/sh +# +# tests compilation script for the OS/400. +# +# $Id$ + + +SCRIPTDIR=`dirname "${0}"` +. "${SCRIPTDIR}/initscript.sh" +cd "${TOPDIR}/tests" + + +# tests directory not implemented yet. + + +# Process the libtest subdirectory. + +cd libtest + +# Get definitions from the Makefile.am file. +# The `sed' statement works as follows: +# _ Join \nl-separated lines. +# _ Retain only lines that begins with "identifier =". +# _ Turn these lines into shell variable assignments. + +eval "`sed -e ': begin' \ + -e '/\\\\$/{' \ + -e 'N' \ + -e 's/\\\\\\n/ /' \ + -e 'b begin' \ + -e '}' \ + -e '/^[A-Za-z_][A-Za-z0-9_]*[ ]*[=]/b keep' \ + -e 'd' \ + -e ': keep' \ + -e 's/[ ]*=[ ]*/=/' \ + -e 's/=\\(.*[^ ]\\)[ ]*$/=\\"\\1\\"/' \ + -e 's/\\$(\\([^)]*\\))/${\\1}/g' \ + < Makefile.am`" + +# Compile all programs. +# The list is found in variable "noinst_PROGRAMS" + +INCLUDES="'${TOPDIR}/tests/libtest' '${TOPDIR}/lib'" + +for PGM in ${noinst_PROGRAMS} +do DB2PGM=`db2_name "${PGM}"` + PGMIFSNAME="${LIBIFSNAME}/${DB2PGM}.PGM" + + # Extract preprocessor symbol definitions from compilation + # options for the program. + + PGMCFLAGS="`eval echo \"\\${${PGM}_CFLAGS}\"`" + PGMDEFINES= + + for FLAG in ${PGMCFLAGS} + do case "${FLAG}" in + -D?*) DEFINE="`echo \"${FLAG}\" | sed 's/^..//'`" + PGMDEFINES="${PGMDEFINES} '${DEFINE}'" + ;; + esac + done + + # Compile all C sources for the program into modules. + + PGMSOURCES="`eval echo \"\\${${PGM}_SOURCES}\"`" + LINK= + MODULES= + + for SOURCE in ${PGMSOURCES} + do case "${SOURCE}" in + *.c) # Special processing for libxxx.c files: their + # module name is determined by the target + # PROGRAM name. + + case "${SOURCE}" in + lib*.c) MODULE="${DB2PGM}" + ;; + *) MODULE=`db2_name "${SOURCE}"` + ;; + esac + + make_module "${MODULE}" "${SOURCE}" "${PGMDEFINES}" + if action_needed "${PGMIFSNAME}" "${MODIFSNAME}" + then LINK=yes + fi + ;; + esac + done + + # Link program if needed. + + if [ "${LINK}" ] + then MODULES="`echo \"${MODULES}\" | + sed \"s/[^ ][^ ]*/${TARGETLIB}\/&/g\"`" + CMD="CRTPGM PGM(${TARGETLIB}/${DB2PGM})" + CMD="${CMD} ENTMOD(QADRT/QADRTMAIN2)" + CMD="${CMD} MODULE(${MODULES})" + CMD="${CMD} BNDSRVPGM(${TARGETLIB}/${SRVPGM} QADRTTS)" + CMD="${CMD} TGTRLS(${TGTRLS})" + system "${CMD}" + fi +done diff --git a/packages/OS400/makefile.sh b/packages/OS400/makefile.sh new file mode 100644 index 000000000..a3d657f1b --- /dev/null +++ b/packages/OS400/makefile.sh @@ -0,0 +1,26 @@ +#!/bin/sh +# +# curl compilation script for the OS/400. +# +# $Id$ +# +# This is a shell script since make is not a standard component of OS/400. + +SCRIPTDIR=`dirname "${0}"` +. "${SCRIPTDIR}/initscript.sh" +cd "${TOPDIR}" + + +# Create the OS/400 library if it does not exist. + +if action_needed "${LIBIFSNAME}" +then CMD="CRTLIB LIB(${TARGETLIB}) TEXT('curl: multiprotocol support API')" + system "${CMD}" +fi + + +# Build in each directory. + +for SUBDIR in include lib src tests +do "${SCRIPTDIR}/make-${SUBDIR}.sh" +done diff --git a/packages/OS400/os400sys.c b/packages/OS400/os400sys.c new file mode 100644 index 000000000..7464e0fb1 --- /dev/null +++ b/packages/OS400/os400sys.c @@ -0,0 +1,957 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2007, 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 + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id$ + * + ***************************************************************************/ + +/* OS/400 additional support. */ + +#include <sys/types.h> +#include <sys/socket.h> + +#include <stdlib.h> +#include <string.h> +#include <pthread.h> +#include <netdb.h> +#include <qadrt.h> +#include <errno.h> +#include <qsossl.h> +#include <gssapi.h> +#include <ldap.h> + +#include <netinet/in.h> +#include <arpa/inet.h> + +#include "config-os400.h" /* Not config.h: need only some defines. */ +#include "os400sys.h" + + +/** +*** QADRT OS/400 ASCII runtime defines only the most used procedures, but +*** but a lot of them are not supported. This module implements +*** ASCII wrappers for those that are used by libcurl, but not +*** defined by QADRT. +**/ + +#pragma convert(0) /* Restore EBCDIC. */ + + +#define MIN_BYTE_GAIN 1024 /* Minimum gain when shortening a buffer. */ + +typedef struct { + unsigned long size; /* Buffer size. */ + char * buf; /* Buffer address. */ +} buffer_t; + + +static char * buffer_undef(localkey_t key, long size); +static char * buffer_threaded(localkey_t key, long size); +static char * buffer_unthreaded(localkey_t key, long size); + +static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; +static pthread_key_t thdkey; +static buffer_t * locbufs; + +char * (* Curl_thread_buffer)(localkey_t key, long size) = buffer_undef; + + +static void +thdbufdestroy(void * private) + +{ + localkey_t i; + buffer_t * p; + + if (private) { + p = (buffer_t *) private; + + for (i = (localkey_t) 0; i < LK_LAST; i++) { + if (p->buf) + free(p->buf); + + p++; + } + + free(private); + } +} + + +static void +terminate(void) + +{ + if (Curl_thread_buffer == buffer_threaded) { + locbufs = pthread_getspecific(thdkey); + pthread_setspecific(thdkey, (void *) NULL); + pthread_key_delete(thdkey); + } + + if (Curl_thread_buffer != buffer_undef) { + thdbufdestroy((void *) locbufs); + locbufs = (buffer_t *) NULL; + } + + Curl_thread_buffer = buffer_undef; +} + + +static char * +get_buffer(buffer_t * buf, long size) + +{ + char * cp; + + /* If `size' >= 0, make sure buffer at `buf' is at least `size'-byte long. + Return the buffer address. */ + + if (size < 0) + return buf->buf; + + if (!buf->buf) { + if ((buf->buf = malloc(size))) + buf->size = size; + + return buf->buf; + } + + if ((unsigned long) size <= buf->size) { + /* Shorten the buffer only if it frees a significant byte count. This + avoids some realloc() overhead. */ + + if (buf->size - size < MIN_BYTE_GAIN) + return buf->buf; + } + + /* Resize the buffer. */ + + if ((cp = realloc(buf->buf, size))) { + buf->buf = cp; + buf->size = size; + } + else if (size <= buf->size) + cp = buf->buf; + + return cp; +} + + +static char * +buffer_unthreaded(localkey_t key, long size) + +{ + return get_buffer(locbufs + key, size); +} + + +static char * +buffer_threaded(localkey_t key, long size) + +{ + buffer_t * bufs; + + /* 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 + its address only. */ + + bufs = (buffer_t *) pthread_getspecific(thdkey); + + if (!bufs) { + if (size < 0) + return (char *) NULL; /* No buffer yet. */ + + /* Allocate buffer descriptors for the current thread. */ + + if (!(bufs = (buffer_t *) calloc((size_t) LK_LAST, sizeof *bufs))) + return (char *) NULL; + + if (pthread_setspecific(thdkey, (void *) bufs)) { + free(bufs); + return (char *) NULL; + } + } + + return get_buffer(bufs + key, size); +} + + +static char * +buffer_undef(localkey_t key, long size) + +{ + /* 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. + Set `size' to < 0 to get its address only. */ + + pthread_mutex_lock(&mutex); + + /* Determine if we can use pthread-specific data. */ + + if (Curl_thread_buffer == buffer_undef) { /* If unchanged during lock. */ + if (!pthread_key_create(&thdkey, thdbufdestroy)) + Curl_thread_buffer = buffer_threaded; + else if (!(locbufs = (buffer_t *) calloc((size_t) LK_LAST, + sizeof *locbufs))) { + pthread_mutex_unlock(&mutex); + return (char *) NULL; + } + else + Curl_thread_buffer = buffer_unthreaded; + + atexit(terminate); + } + + pthread_mutex_unlock(&mutex); + return Curl_thread_buffer(key, size); +} + + +int +Curl_getnameinfo_a(const struct sockaddr * sa, socklen_t salen, + char * nodename, socklen_t nodenamelen, + char * servname, socklen_t servnamelen, + int flags) + +{ + char * enodename; + char * eservname; + int status; + int i; + + enodename = (char *) NULL; + eservname = (char *) NULL; + + if (nodename && nodenamelen) + if (!(enodename = malloc(nodenamelen))) + return EAI_MEMORY; + + if (servname && servnamelen) + if (!(eservname = malloc(servnamelen))) { + if (enodename) + free(enodename); + + return EAI_MEMORY; + } + + status = getnameinfo(sa, salen, enodename, nodenamelen, + eservname, servnamelen, flags); + + if (!status) { + if (enodename) { + i = QadrtConvertE2A(nodename, enodename, + nodenamelen - 1, strlen(enodename)); + nodename[i] = '\0'; + } + + if (eservname) { + i = QadrtConvertE2A(servname, eservname, + servnamelen - 1, strlen(eservname)); + servname[i] = '\0'; + } + } + + if (enodename) + free(enodename); + + if (eservname) + free(eservname); + + return status; +} + + +int +Curl_getaddrinfo_a(const char * nodename, const char * servname, + const struct addrinfo * hints, + struct addrinfo * * res) + +{ + char * enodename; + char * eservname; + int status; + int i; + + enodename = (char *) NULL; + eservname = (char *) NULL; + + if (nodename) { + i = strlen(nodename); + + if (!(enodename = malloc(i + 1))) + return EAI_MEMORY; + + i = QadrtConvertA2E(enodename, nodename, i, i); + enodename[i] = '\0'; + } + + if (servname) { + i = strlen(servname); + + if (!(eservname = malloc(i + 1))) { + if (enodename) + free(enodename); + + return EAI_MEMORY; + } + + QadrtConvertA2E(eservname, servname, i, i); + eservname[i] = '\0'; + } + + status = getaddrinfo(enodename, eservname, hints, res); + + if (enodename) + free(enodename); + + if (eservname) + free(eservname); + + return status; +} + + +int +Curl_inet_ntoa_r_a(struct in_addr internet_address, + char * output_buffer, int output_buffer_length) + +{ + int rc; + int i; + char * cp; + + if (!output_buffer || output_buffer_length < 16) + return inet_ntoa_r(internet_address, output_buffer, output_buffer_length); + + if (!(cp = malloc(output_buffer_length + 1))) + return -1; + + rc = inet_ntoa_r(internet_address, cp, output_buffer_length); + + if (rc) { + free(cp); + return rc; + } + + cp[output_buffer_length - 1] = '\0'; + i = strlen(cp); + QadrtConvertE2A(output_buffer, cp, i, i); + output_buffer[i] = '\0'; + free(cp); + return rc; +} + + +#ifdef USE_QSOSSL + +/* ASCII wrappers for the SSL procedures. */ + +int +Curl_SSL_Init_Application_a(SSLInitApp * init_app) + +{ + int rc; + unsigned int i; + SSLInitApp ia; + + if (!init_app || !init_app->applicationID || !init_app->applicationIDLen) + return SSL_Init_Application(init_app); + + memcpy((char *) &ia, (char *) init_app, sizeof ia); + i = ia.applicationIDLen; + + if (!(ia.applicationID = malloc(i + 1))) { + errno = ENOMEM; + return SSL_ERROR_IO; + } + + QadrtConvertA2E(ia.applicationID, init_app->applicationID, i, i); + ia.applicationID[i] = '\0'; + rc = SSL_Init_Application(&ia); + free(ia.applicationID); + init_app->localCertificateLen = ia.localCertificateLen; + init_app->sessionType = ia.sessionType; + return rc; +} + + +int +Curl_SSL_Init_a(SSLInit * init) + +{ + int rc; + unsigned int i; + SSLInit ia; + + if (!init || (!init->keyringFileName && !init->keyringPassword)) + return SSL_Init(init); + + memcpy((char *) &ia, (char *) init, sizeof ia); + + if (ia.keyringFileName) { + i = strlen(ia.keyringFileName); + + if (!(ia.keyringFileName = malloc(i + 1))) { + errno = ENOMEM; + return SSL_ERROR_IO; + } + + QadrtConvertA2E(ia.keyringFileName, init->keyringFileName, i, i); + ia.keyringFileName[i] = '\0'; + } + + if (ia.keyringPassword) { + i = strlen(ia.keyringPassword); + + if (!(ia.keyringPassword = malloc(i + 1))) { + if (ia.keyringFileName) + free(ia.keyringFileName); + + errno = ENOMEM; + return SSL_ERROR_IO; + } + + QadrtConvertA2E(ia.keyringPassword, init->keyringPassword, i, i); + ia.keyringPassword[i] = '\0'; + } + + rc = SSL_Init(&ia); + + if (ia.keyringFileName) + free(ia.keyringFileName); + + if (ia.keyringPassword) + free(ia.keyringPassword); + + return rc; +} + + +char * +Curl_SSL_Strerror_a(int sslreturnvalue, SSLErrorMsg * serrmsgp) + +{ + int i; + char * cp; + char * cp2; + + cp = SSL_Strerror(sslreturnvalue, serrmsgp); + + if (!cp) + return cp; + + i = strlen(cp); + + if (!(cp2 = Curl_thread_buffer(LK_SSL_ERROR, MAX_CONV_EXPANSION * i + 1))) + return cp2; + + i = QadrtConvertE2A(cp2, cp, MAX_CONV_EXPANSION * i, i); + cp2[i] = '\0'; + return cp2; +} + +#endif /* USE_QSOSSL */ + + +#ifdef HAVE_GSSAPI + +/* ASCII wrappers for the GSSAPI procedures. */ + +static int +Curl_gss_convert_in_place(OM_uint32 * minor_status, gss_buffer_t buf) + +{ + unsigned int i; + char * t; + + /* Convert `buf' in place, from EBCDIC to ASCII. + If error, release the buffer and return -1. Else return 0. */ + + i = buf->length; + + if (i) { + if (!(t = malloc(i))) { + gss_release_buffer(minor_status, buf); + + if (minor_status) + *minor_status = ENOMEM; + + return -1; + } + + QadrtConvertE2A(t, buf->value, i, i); + memcpy(buf->value, t, i); + free(t); + } + + return 0; +} + + +OM_uint32 +Curl_gss_import_name_a(OM_uint32 * minor_status, gss_buffer_t in_name, + gss_OID in_name_type, gss_name_t * out_name) + +{ + int rc; + unsigned int i; + gss_buffer_desc in; + + if (!in_name || !in_name->value || !in_name->length) + return gss_import_name(minor_status, in_name, in_name_type, out_name); + + memcpy((char *) &in, (char *) in_name, sizeof in); + i = in.length; + + if (!(in.value = malloc(i + 1))) { + if (minor_status) + *minor_status = ENOMEM; + + return GSS_S_FAILURE; + } + + QadrtConvertA2E(in.value, in_name->value, i, i); + ((char *) in.value)[i] = '\0'; + rc = gss_import_name(minor_status, &in, in_name_type, out_name); + free(in.value); + return rc; +} + + +OM_uint32 +Curl_gss_display_status_a(OM_uint32 * minor_status, OM_uint32 status_value, + int status_type, gss_OID mech_type, + gss_msg_ctx_t * message_context, gss_buffer_t status_string) + +{ + int rc; + + rc = gss_display_status(minor_status, status_value, status_type, + mech_type, message_context, status_string); + + if (rc != GSS_S_COMPLETE || !status_string || + !status_string->length || !status_string->value) + return rc; + + /* No way to allocate a buffer here, because it will be released by + gss_release_buffer(). The solution is to overwrite the EBCDIC buffer + with ASCII to return it. */ + + if (Curl_gss_convert_in_place(minor_status, status_string)) + return GSS_S_FAILURE; + + return rc; +} + + +OM_uint32 +Curl_gss_init_sec_context_a(OM_uint32 * minor_status, gss_cred_id_t cred_handle, + gss_ctx_id_t * context_handle, + gss_name_t target_name, gss_OID mech_type, + gss_flags_t req_flags, OM_uint32 time_req, + gss_channel_bindings_t input_chan_bindings, + gss_buffer_t input_token, + gss_OID * actual_mech_type, + gss_buffer_t output_token, gss_flags_t * ret_flags, + OM_uint32 * time_rec) + +{ + int rc; + unsigned int i; + gss_buffer_desc in; + gss_buffer_t inp; + + in.value = NULL; + + if ((inp = input_token)) + if (inp->length && inp->value) { + i = inp->length; + + if (!(in.value = malloc(i + 1))) { + if (minor_status) + *minor_status = ENOMEM; + + return GSS_S_FAILURE; + } + + QadrtConvertA2E(in.value, input_token->value, i, i); + ((char *) in.value)[i] = '\0'; + in.length = i; + inp = ∈ + } + + rc = gss_init_sec_context(minor_status, cred_handle, context_handle, + target_name, mech_type, req_flags, time_req, + input_chan_bindings, inp, actual_mech_type, + output_token, ret_flags, time_rec); + + if (in.value) + free(in.value); + + if (rc != GSS_S_COMPLETE || !output_token || + !output_token->length || !output_token->value) + return rc; + + /* No way to allocate a buffer here, because it will be released by + gss_release_buffer(). The solution is to overwrite the EBCDIC buffer + with ASCII to return it. */ + + if (Curl_gss_convert_in_place(minor_status, output_token)) + return GSS_S_FAILURE; + + return rc; +} + + +OM_uint32 +Curl_gss_delete_sec_context_a(OM_uint32 * minor_status, + gss_ctx_id_t * context_handle, + gss_buffer_t output_token) + +{ + int rc; + + rc = gss_delete_sec_context(minor_status, context_handle, output_token); + + if (rc != GSS_S_COMPLETE || !output_token || + !output_token->length || !output_token->value) + return rc; + + /* No way to allocate a buffer here, because it will be released by + gss_release_buffer(). The solution is to overwrite the EBCDIC buffer + with ASCII to return it. */ + + if (Curl_gss_convert_in_place(minor_status, output_token)) + return GSS_S_FAILURE; + + return rc; +} + +#endif /* HAVE_GSSAPI */ + + +#ifndef CURL_DISABLE_LDAP + +/* ASCII wrappers for the LDAP procedures. */ + +void * +Curl_ldap_init_a(char * host, int port) + +{ + unsigned int i; + char * ehost; + void * result; + + if (!host) + return (void *) ldap_init(host, port); + + i = strlen(host); + + if (!(ehost = malloc(i + 1))) + return (void *) NULL; + + QadrtConvertA2E(ehost, host, i, i); + ehost[i] = '\0'; + result = (void *) ldap_init(ehost, port); + free(ehost); + return result; +} + + +int +Curl_ldap_simple_bind_s_a(void * ld, char * dn, char * passwd) + +{ + int i; + char * edn; + char * epasswd; + + edn = (char *) NULL; + epasswd = (char *) NULL; + + if (dn) { + i = strlen(dn); + + if (!(edn = malloc(i + 1))) + return LDAP_NO_MEMORY; + + QadrtConvertA2E(edn, dn, i, i); + edn[i] = '\0'; + } + + if (passwd) { + i = strlen(passwd); + + if (!(epasswd = malloc(i + 1))) { + if (edn) + free(edn); + + return LDAP_NO_MEMORY; + } + + QadrtConvertA2E(epasswd, passwd, i, i); + epasswd[i] = '\0'; + } + + i = ldap_simple_bind_s(ld, edn, epasswd); + + if (epasswd) + free(epasswd); + + if (edn) + free(edn); + + return i; +} + + +int +Curl_ldap_search_s_a(void * ld, char * base, int scope, char * filter, + char * * attrs, int attrsonly, LDAPMessage * * res) + +{ + int i; + int j; + char * ebase; + char * efilter; + char * * eattrs; + int status; + + ebase = (char *) NULL; + efilter = (char *) NULL; + eattrs = (char * *) NULL; + status = LDAP_SUCCESS; + + if (base) { + i = strlen(base); + + if (!(ebase = malloc(i + 1))) + status = LDAP_NO_MEMORY; + else { + QadrtConvertA2E(ebase, base, i, i); + ebase[i] = '\0'; + } + } + + if (filter && status == LDAP_SUCCESS) { + i = strlen(filter); + + if (!(efilter = malloc(i + 1))) + status = LDAP_NO_MEMORY; + else { + QadrtConvertA2E(efilter, filter, i, i); + efilter[i] = '\0'; + } + } + + if (attrs && status == LDAP_SUCCESS) { + for (i = 0; attrs[i++];) + ; + + if (!(eattrs = (char * *) calloc(i, sizeof *eattrs))) + status = LDAP_NO_MEMORY; + else { + for (j = 0; attrs[j]; j++) { + i = strlen(attrs[j]); + + if (!(eattrs[j] = malloc(i + 1))) { + status = LDAP_NO_MEMORY; + break; + } + + QadrtConvertA2E(eattrs[j], attrs[j], i, i); + eattrs[j][i] = '\0'; + } + } + } + + if (status == LDAP_SUCCESS) + status = ldap_search_s(ld, ebase? ebase: "", scope, + efilter? efilter: "(objectclass=*)", + eattrs, attrsonly, res); + + if (eattrs) { + for (j = 0; eattrs[j]; j++) + free(eattrs[j]); + + free(eattrs); + } + + if (efilter) + free(efilter); + + if (ebase) + free(ebase); + + return status; +} + + +struct berval * * +Curl_ldap_get_values_len_a(void * ld, LDAPMessage * entry, const char * attr) + +{ + int i; + char * cp; + struct berval * * result; + + cp = (char *) NULL; + + if (attr) { + i = strlen(attr); + + if (!(cp = malloc(i + 1))) { + ldap_set_lderrno(ld, LDAP_NO_MEMORY, NULL, + ldap_err2string(LDAP_NO_MEMORY)); + return (struct berval * *) NULL; + } + + QadrtConvertA2E(cp, attr, i, i); + cp[i] = '\0'; + } + + result = ldap_get_values_len(ld, entry, cp); + + if (cp) + free(cp); + + /* Result data are binary in nature, so they haven't been converted to EBCDIC. + Therefore do not convert. */ + + return result; +} + + +char * +Curl_ldap_err2string_a(int error) + +{ + int i; + char * cp; + char * cp2; + + cp = ldap_err2string(error); + + if (!cp) + return cp; + + i = strlen(cp); + + if (!(cp2 = Curl_thread_buffer(LK_LDAP_ERROR, MAX_CONV_EXPANSION * i + 1))) + return cp2; + + i = QadrtConvertE2A(cp2, cp, MAX_CONV_EXPANSION * i, i); + cp2[i] = '\0'; + return cp2; +} + + +char * +Curl_ldap_get_dn_a(void * ld, LDAPMessage * entry) + +{ + int i; + char * cp; + char * cp2; + + cp = ldap_get_dn(ld, entry); + + if (!cp) + return cp; + + i = strlen(cp); + + if (!(cp2 = malloc(i + 1))) + return cp2; + + QadrtConvertE2A(cp2, cp, i, i); + + /* No way to allocate a buffer here, because it will be released by + ldap_memfree() and ldap_memalloc() does not exist. The solution is to + overwrite the EBCDIC buffer with ASCII to return it. */ + + strcpy(cp, cp2); + free(cp2); + return cp; +} + + +char * +Curl_ldap_first_attribute_a(void * ld, + LDAPMessage * entry, BerElement * * berptr) + +{ + int i; + char * cp; + char * cp2; + + cp = ldap_first_attribute(ld, entry, berptr); + + if (!cp) + return cp; + + i = strlen(cp); + + if (!(cp2 = malloc(i + 1))) + return cp2; + + QadrtConvertE2A(cp2, cp, i, i); + + /* No way to allocate a buffer here, because it will be released by + ldap_memfree() and ldap_memalloc() does not exist. The solution is to + overwrite the EBCDIC buffer with ASCII to return it. */ + + strcpy(cp, cp2); + free(cp2); + return cp; +} + + +char * +Curl_ldap_next_attribute_a(void * ld, + LDAPMessage * entry, BerElement * berptr) + +{ + int i; + char * cp; + char * cp2; + + cp = ldap_next_attribute(ld, entry, berptr); + + if (!cp) + return cp; + + i = strlen(cp); + + if (!(cp2 = malloc(i + 1))) + return cp2; + + QadrtConvertE2A(cp2, cp, i, i); + + /* No way to allocate a buffer here, because it will be released by + ldap_memfree() and ldap_memalloc() does not exist. The solution is to + overwrite the EBCDIC buffer with ASCII to return it. */ + + strcpy(cp, cp2); + free(cp2); + return cp; +} + +#endif /* CURL_DISABLE_LDAP */ diff --git a/packages/OS400/os400sys.h b/packages/OS400/os400sys.h new file mode 100644 index 000000000..6da99d416 --- /dev/null +++ b/packages/OS400/os400sys.h @@ -0,0 +1,53 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2007, 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 + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id$ + * + ***************************************************************************/ + +/* OS/400 additional definitions. */ + +#ifndef __OS400_SYS_ +#define __OS400_SYS_ + + +/* Per-thread item identifiers. */ + +typedef enum { + LK_SSL_ERROR, + LK_LDAP_ERROR, + LK_CURL_VERSION, + LK_VERSION_INFO, + LK_VERSION_INFO_DATA, + LK_EASY_STRERROR, + LK_SHARE_STRERROR, + LK_MULTI_STRERROR, + LK_LAST +} localkey_t; + + +extern char * (* Curl_thread_buffer)(localkey_t key, long size); + + +/* Maximum string expansion factor due to character code conversion. */ + +#define MAX_CONV_EXPANSION 4 /* Can deal with UTF-8. */ + +#endif |