[Global]: loading init

This commit is contained in:
JerryALT
2024-03-12 22:41:56 +03:00
commit f6f27d419a
7509 changed files with 1423218 additions and 0 deletions

View File

@ -0,0 +1,6 @@
# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
#
# SPDX-License-Identifier: curl
# OS400 .cmd files are not windows scripts.
*.cmd text eol=auto

391
deps/curl/packages/OS400/README.OS400 vendored Normal file
View File

@ -0,0 +1,391 @@
Implementation notes:
This is a true OS/400 ILE 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. Callback procedures arguments giving access to strings 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).
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_ABSTRACT_UNIX_SOCKET
CURLOPT_ACCEPT_ENCODING
CURLOPT_ALTSVC
CURLOPT_AWS_SIGV4
CURLOPT_CAINFO
CURLOPT_CAPATH
CURLOPT_COOKIE
CURLOPT_COOKIEFILE
CURLOPT_COOKIEJAR
CURLOPT_COOKIELIST
CURLOPT_CRLFILE
CURLOPT_CUSTOMREQUEST
CURLOPT_DEFAULT_PROTOCOL
CURLOPT_DNS_INTERFACE
CURLOPT_DNS_LOCAL_IP4
CURLOPT_DNS_LOCAL_IP6
CURLOPT_DNS_SERVERS
CURLOPT_DOH_URL
CURLOPT_EGDSOCKET
CURLOPT_FTPPORT
CURLOPT_FTP_ACCOUNT
CURLOPT_FTP_ALTERNATIVE_TO_USER
CURLOPT_HAPROXY_CLIENT_IP
CURLOPT_HSTS
CURLOPT_INTERFACE
CURLOPT_ISSUERCERT
CURLOPT_KEYPASSWD
CURLOPT_KRBLEVEL
CURLOPT_LOGIN_OPTIONS
CURLOPT_MAIL_AUTH
CURLOPT_MAIL_FROM
CURLOPT_NETRC_FILE
CURLOPT_NOPROXY
CURLOPT_PASSWORD
CURLOPT_PINNEDPUBLICKEY
CURLOPT_PRE_PROXY
CURLOPT_PROTOCOLS_STR
CURLOPT_PROXY
CURLOPT_PROXYPASSWORD
CURLOPT_PROXYUSERNAME
CURLOPT_PROXYUSERPWD
CURLOPT_PROXY_CAINFO
CURLOPT_PROXY_CAPATH
CURLOPT_PROXY_CRLFILE
CURLOPT_PROXY_ISSUERCERT
CURLOPT_PROXY_KEYPASSWD
CURLOPT_PROXY_PINNEDPUBLICKEY
CURLOPT_PROXY_SERVICE_NAME
CURLOPT_PROXY_SSLCERT
CURLOPT_PROXY_SSLCERTTYPE
CURLOPT_PROXY_SSLKEY
CURLOPT_PROXY_SSLKEYTYPE
CURLOPT_PROXY_SSL_CIPHER_LIST
CURLOPT_PROXY_TLS13_CIPHERS
CURLOPT_PROXY_TLSAUTH_PASSWORD
CURLOPT_PROXY_TLSAUTH_TYPE
CURLOPT_PROXY_TLSAUTH_USERNAME
CURLOPT_RANDOM_FILE
CURLOPT_RANGE
CURLOPT_REDIR_PROTOCOLS_STR
CURLOPT_REFERER
CURLOPT_REQUEST_TARGET
CURLOPT_RTSP_SESSION_ID
CURLOPT_RTSP_STREAM_URI
CURLOPT_RTSP_TRANSPORT
CURLOPT_SASL_AUTHZID
CURLOPT_SERVICE_NAME
CURLOPT_SOCKS5_GSSAPI_SERVICE
CURLOPT_SSH_HOST_PUBLIC_KEY_MD5
CURLOPT_SSH_HOST_PUBLIC_KEY_SHA256
CURLOPT_SSH_KNOWNHOSTS
CURLOPT_SSH_PRIVATE_KEYFILE
CURLOPT_SSH_PUBLIC_KEYFILE
CURLOPT_SSLCERT
CURLOPT_SSLCERTTYPE
CURLOPT_SSLENGINE
CURLOPT_SSLKEY
CURLOPT_SSLKEYTYPE
CURLOPT_SSL_CIPHER_LIST
CURLOPT_SSL_EC_CURVES
CURLOPT_TLS13_CIPHERS
CURLOPT_TLSAUTH_PASSWORD
CURLOPT_TLSAUTH_TYPE
CURLOPT_TLSAUTH_USERNAME
CURLOPT_UNIX_SOCKET_PATH
CURLOPT_URL
CURLOPT_USERAGENT
CURLOPT_USERNAME
CURLOPT_USERPWD
CURLOPT_XOAUTH2_BEARER
All blob options are also supported.
In all other cases, it ignores the ccsid parameter and behaves as
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.
CURLOPT_POSTFIELDS stores the address of static binary data (of type void *)
and thus is not converted. If CURLOPT_COPYPOSTFIELDS is issued after
CURLOPT_POSTFIELDSIZE != -1, the data size is adjusted according to the
CCSID conversion result length.
_ curl_formadd_ccsid()
In the variable argument list, string pointers should be followed by a (long)
CCSID for the following options:
CURLFORM_BUFFER
CURLFORM_CONTENTTYPE
CURLFORM_COPYCONTENTS
CURLFORM_COPYNAME
CURLFORM_FILE
CURLFORM_FILECONTENT
CURLFORM_FILENAME
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 released with
curl_free() after use:
CURLINFO_CONTENT_TYPE
CURLINFO_EFFECTIVE_URL
CURLINFO_FTP_ENTRY_PATH
CURLINFO_LOCAL_IP
CURLINFO_PRIMARY_IP
CURLINFO_REDIRECT_URL
CURLINFO_REFERER
CURLINFO_RTSP_SESSION_ID
CURLINFO_SCHEME
Likewise, the following options are followed by a struct curl_slist * * and a
CCSID.
CURLINFO_COOKIELIST
CURLINFO_SSL_ENGINES
Lists returned should be released with curl_slist_free_all() after use.
Option CURLINFO_CERTINFO is followed by a struct curl_certinfo * * and a
CCSID. Returned structures should be freed with curl_certinfo_free_all()
after use.
Other options are processed like in curl_easy_getinfo().
_ curl_easy_strerror_ccsid(), curl_multi_strerror_ccsid(),
curl_share_strerror_ccsid() and curl_url_strerror_ccsid() work as their
non-ccsid version and return a string encoded in the additional ccsid
parameter. These strings belong to libcurl and may not be freed by the caller.
A subsequent call to the same procedure in the same thread invalidates the
previous result.
_ curl_pushheader_bynum_cssid() and curl_pushheader_byname_ccsid()
Although the prototypes are self-explanatory, the returned string pointer
should be released with curl_free() after use, as opposite to the non-ccsid
versions of these procedures.
Please note that HTTP2 is not (yet) implemented on OS/400, thus these
functions will always return NULL.
_ curl_easy_option_by_name_ccsid() returns a pointer to an untranslated option
metadata structure. As each curl_easyoption structure holds the option name in
ASCII, the curl_easy_option_get_name_ccsid() function allows getting it in any
supported ccsid. However the caller should release the returned pointer with
curl_free() after use.
_ curl_easy_header_ccsid() works as its non-CCSID counterpart but requires an
additional ccsid parameter specifying the name parameter encoding. The output
hout parameter is kept in libcurl's encoding and should not be altered.
_ curl_from_ccsid() and curl_to_ccsid() are string encoding conversion
functions between ASCII (latin1) and the given CCSID. The first parameter is
the source string, the second is the CCSID and the returned value is a pointer
to the dynamically allocated string. These functions do not impact on Curl's
behavior and are only provided for user convenience. After use, returned values
must be released with curl_free().
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:
_ DICT
_ FILE
_ FTP
_ FTPS
_ FTP with secure transmission
_ GOPHER
_ HTTP
_ HTTPS
_ IMAP
_ IMAPS
_ IMAP with secure transmission
_ LDAP
_ POP3
_ POP3S
_ POP3 with secure transmission
_ RTSP
_ SCP if libssh2 is enabled
_ SFTP if libssh2 is enabled
_ SMTP
_ SMTPS
_ SMTP with secure transmission
_ TELNET
_ TFTP
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.
For more information on downloading and installing the QADRT development kit,
please see https://www.ibm.com/support/pages/node/6258183
_ If data compression has to be supported, ZLIB development environment must
be installed.
_ Likewise, if SCP and SFTP protocols have to be compiled in, LIBSSH2
developent environment must be installed.
_ Install the curl source directory in IFS. Do NOT install it in the
installation target directory (which defaults to /curl).
_ Enter Qshell (QSH, not PASE)
_ Change current directory to the curl installation directory
_ Change current directory to ./packages/OS400
- If you want to change the default configuration parameters like debug info
generation, optimization level, listing option, target library, ZLIB/LIBSSH2
availability and location, etc., copy file config400.default to
config400.override and edit the latter. Do not edit the original default file
as it might be overwritten by a subsequent source installation.
_ 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. CZM0383 warnings on
C or system standard API come from QADRT inlining and can safely be ignored.
Without configuration parameters override, 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 QGLDCLNT QGLDBRDR)
when creating a program using CURL_A).
_ Service program CURL.<soname>, where <soname> is extracted from the
lib/Makefile.am VERSION variable. 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.
- CLI tool bound program CURL.
- CLI command CURL.
_ 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.
_ IFS directory /curl/include/curl containing the C header files for IFS source
C/C++ compilation and curl.inc.rpgle for IFS source ILE/RPG compilation.
- IFS link /curl/bin/curl to CLI tool program.
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 and
/curl/include/curl).
ILE/RPG support:
Since most of the ILE OS/400 programmers use ILE/RPG exclusively, a
definition /INCLUDE 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/include 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(), curl_easy_setopt_offset() and
curl_easy_setopt_blob() 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(), curl_easy_getinfo_slist(),
curl_easy_getinfo_ptr(), curl_easy_getinfo_socket() and
curl_easy_getinfo_off_t() 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.
_ Procedures curl_share_setopt_int(), curl_share_setopt_ptr() and
curl_share_setopt_proc() are all alias prototypes to curl_share_setopt,
but with different parameter lists.
_ Procedure curl_easy_setopt_blob_ccsid() is an alias of
curl_easy_setopt_ccsid() supporting blob encoding conversion.
_ 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 V7R4M0, procedure overloading is used to emulate limited "vararg-like"
definitions of curl_easy_setopt(), curl_multi_setopt(), curl_share_setopt()
and curl_easy_getinfo(). Blob and CCSID alternatives are NOT included in
overloading.
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. Please note the form API is deprecated and the MIME API
should be used instead.
CLI tool:
The build system provides it as a bound program, an IFS link to it and a
simple CL command. The latter however is not able to provide a different
parameter for each option since there are too many of those; instead,
parameters are entered in a single field subject to quoting and escaping, in
the same form as expected by the standard CLI program.
Care must be taken about the program output encoding: by default, it is sent
to the standard output and is thus subject to transcoding. It is therefore
recommended to use option "--output" to redirect output to a specific IFS file.
Similar problems may occur about the standard input encoding.

1527
deps/curl/packages/OS400/ccsidcurl.c vendored Normal file

File diff suppressed because it is too large Load Diff

113
deps/curl/packages/OS400/ccsidcurl.h vendored Normal file
View File

@ -0,0 +1,113 @@
#ifndef CURLINC_CCSIDCURL_H
#define CURLINC_CCSIDCURL_H
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 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 https://curl.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.
*
* SPDX-License-Identifier: curl
*
*
***************************************************************************/
#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 *l,
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 cid);
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, ...);
CURL_EXTERN void curl_certinfo_free_all(struct curl_certinfo *info);
CURL_EXTERN char *curl_pushheader_bynum_cssid(struct curl_pushheaders *h,
size_t num, unsigned int ccsid);
CURL_EXTERN char *curl_pushheader_byname_ccsid(struct curl_pushheaders *h,
const char *header,
unsigned int ccsidin,
unsigned int ccsidout);
CURL_EXTERN CURLcode curl_mime_name_ccsid(curl_mimepart *part,
const char *name,
unsigned int ccsid);
CURL_EXTERN CURLcode curl_mime_filename_ccsid(curl_mimepart *part,
const char *filename,
unsigned int ccsid);
CURL_EXTERN CURLcode curl_mime_type_ccsid(curl_mimepart *part,
const char *mimetype,
unsigned int ccsid);
CURL_EXTERN CURLcode curl_mime_encoder_ccsid(curl_mimepart *part,
const char *encoding,
unsigned int ccsid);
CURL_EXTERN CURLcode curl_mime_filedata_ccsid(curl_mimepart *part,
const char *filename,
unsigned int ccsid);
CURL_EXTERN CURLcode curl_mime_data_ccsid(curl_mimepart *part,
const char *data, size_t datasize,
unsigned int ccsid);
CURL_EXTERN CURLUcode curl_url_get_ccsid(CURLU *handle, CURLUPart what,
char **part, unsigned int flags,
unsigned int ccsid);
CURL_EXTERN CURLUcode curl_url_set_ccsid(CURLU *handle, CURLUPart what,
const char *part, unsigned int flags,
unsigned int ccsid);
CURL_EXTERN const struct curl_easyoption *curl_easy_option_by_name_ccsid(
const char *name, unsigned int ccsid);
CURL_EXTERN const char *curl_easy_option_get_name_ccsid(
const struct curl_easyoption *option,
unsigned int ccsid);
CURL_EXTERN const char *curl_url_strerror_ccsid(CURLUcode error,
unsigned int ccsid);
CURL_EXTERN CURLHcode curl_easy_header_ccsid(CURL *easy, const char *name,
size_t index, unsigned int origin,
int request,
struct curl_header **hout,
unsigned int ccsid);
CURL_EXTERN const char *curl_from_ccsid(const char *s, unsigned int ccsid);
CURL_EXTERN const char *curl_to_ccsid(const char *s, unsigned int ccsid);
CURL_EXTERN CURLcode curl_easy_setopt_RPGnum_(CURL *easy,
CURLoption tag, curl_off_t arg);
CURL_EXTERN CURLcode curl_multi_setopt_RPGnum_(CURLM *multi, CURLMoption tag,
curl_off_t arg);
#endif

View File

@ -0,0 +1,55 @@
#!/bin/sh
#***************************************************************************
# _ _ ____ _
# Project ___| | | | _ \| |
# / __| | | | |_) | |
# | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____|
#
# Copyright (C) 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 https://curl.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.
#
# SPDX-License-Identifier: curl
#
###########################################################################
# Tunable configuration parameters.
setenv TARGETLIB 'CURL' # Target OS/400 program library.
setenv STATBNDDIR 'CURL_A' # Static binding directory.
setenv DYNBNDDIR 'CURL' # Dynamic binding directory.
setenv SRVPGM "CURL.${SONAME}" # Service program.
setenv CURLPGM 'CURL' # CLI tool bound program.
setenv CURLCMD 'CURL' # CL command name.
setenv CURLCLI 'CURLCL' # CL interface program.
setenv TGTCCSID '500' # Target CCSID of objects.
setenv DEBUG '*ALL' # Debug level.
setenv OPTIMIZE '10' # Optimization level
setenv OUTPUT '*NONE' # Compilation output option.
setenv TGTRLS '*CURRENT' # Target OS release.
setenv IFSDIR '/curl' # Installation IFS directory.
setenv QADRTDIR '/QIBM/ProdData/qadrt' # QADRT IFS directory.
# Define ZLIB availability and locations.
setenv WITH_ZLIB 0 # Define to 1 to enable.
setenv ZLIB_INCLUDE '/zlib/include' # ZLIB include IFS directory.
setenv ZLIB_LIB 'ZLIB' # ZLIB library.
setenv ZLIB_BNDDIR 'ZLIB_A' # ZLIB binding directory.
# Define LIBSSH2 availability and locations.
setenv WITH_LIBSSH2 0 # Define to 1 to enable.
setenv LIBSSH2_INCLUDE '/libssh2/include' # LIBSSH2 include IFS directory.
setenv LIBSSH2_LIB 'LIBSSH2' # LIBSSH2 library.
setenv LIBSSH2_BNDDIR 'LIBSSH2_A' # LIBSSH2 binding directory.

32
deps/curl/packages/OS400/curl.cmd vendored Normal file
View File

@ -0,0 +1,32 @@
/*****************************************************************************/
/* _ _ ____ _ */
/* Project ___| | | | _ \| | */
/* / __| | | | |_) | | */
/* | (__| |_| | _ <| |___ */
/* \___|\___/|_| \_\_____| */
/* */
/* Copyright (C) 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 https://curl.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. */
/* */
/* SPDX-License-Identifier: curl */
/* */
/* */
/*****************************************************************************/
/* Use program CURLCL as interface to the curl command line tool */
CMD PROMPT('File transfer utility')
PARM KWD(CMDARGS) TYPE(*CHAR) LEN(5000) VARY(*YES *INT2) +
CASE(*MIXED) EXPR(*YES) MIN(1) +
PROMPT('Curl command arguments')

3425
deps/curl/packages/OS400/curl.inc.in vendored Normal file

File diff suppressed because it is too large Load Diff

177
deps/curl/packages/OS400/curlcl.c vendored Normal file
View File

@ -0,0 +1,177 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 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 https://curl.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.
*
* SPDX-License-Identifier: curl
*
*
***************************************************************************/
/* CL interface program to curl cli tool. */
#include <stdio.h>
#include <stdlib.h>
#include <milib.h>
#include <miptrnam.h>
#include <mih/callpgmv.h>
#ifndef CURLPGM
#define CURLPGM "CURL"
#endif
/* Variable-length string, with 16-bit length. */
struct vary2 {
short len;
char string[5000];
};
/* Arguments from CL command. */
struct arguments {
char *pgm; /* Program name. */
struct vary2 *cmdargs; /* Command line arguments. */
};
static int
is_ifs(char c)
{
return c == ' ' || c == '\t' || c == '\r' || c == '\n';
}
static int
parse_command_line(const char *cmdargs, size_t len,
size_t *argc, char **argv,
size_t *argsize, char *argbuf)
{
const char *endline = cmdargs + len;
char quote = '\0';
int inarg = 0;
*argc = 0;
*argsize = 0;
while(cmdargs < endline) {
char c = *cmdargs++;
if(!inarg) {
/* Skip argument separator. */
if(is_ifs(c))
continue;
/* Start a new argument. */
++*argc;
if(argv)
*argv++ = argbuf;
inarg = 1;
}
/* Check for quoting end. */
if(quote && quote == c) {
quote = '\0';
continue;
}
/* Check for backslash-escaping. */
if(quote != '\'' && c == '\\') {
if(cmdargs >= endline) {
fputs("Trailing backslash in command\n", stderr);
return -1;
}
c = *cmdargs++;
}
else if(!quote && is_ifs(c)) { /* Check for end of argument. */
inarg = 0;
c = '\0'; /* Will store a string terminator. */
}
/* Store argument character and count it. */
if(argbuf)
*argbuf++ = c;
++*argsize;
}
if(quote) {
fprintf(stderr, "Unterminated quote: %c\n", quote);
return -1;
}
/* Terminate last argument. */
if(inarg) {
if(argbuf)
*argbuf = '\0';
++*argsize;
}
/* Terminate argument list. */
if(argv)
*argv = NULL;
return 0;
}
int
main(int argsc, struct arguments *args)
{
size_t argc;
char **argv;
size_t argsize;
int i;
int exitcode;
char library[11];
/* Extract current program library name. */
for(i = 0; i < 10; i++) {
char c = args->pgm[i];
if(!c || c == '/')
break;
library[i] = c;
}
library[i] = '\0';
/* Measure arguments size. */
exitcode = parse_command_line(args->cmdargs->string, args->cmdargs->len,
&argc, NULL, &argsize, NULL);
if(!exitcode) {
/* Allocate space for parsed arguments. */
argv = (char **) malloc((argc + 1) * sizeof(*argv) + argsize);
if(!argv) {
fputs("Memory allocation error\n", stderr);
exitcode = -2;
}
else {
_SYSPTR pgmptr = rslvsp(WLI_PGM, (char *) CURLPGM, library, _AUTH_NONE);
_LU_Work_Area_T *luwrka = (_LU_Work_Area_T *) _LUWRKA();
parse_command_line(args->cmdargs->string, args->cmdargs->len,
&argc, argv, &argsize, (char *) (argv + argc + 1));
/* Call program. */
_CALLPGMV((void *) &pgmptr, argv, argc);
exitcode = luwrka->LU_RC;
free(argv);
}
}
return exitcode;
}

121
deps/curl/packages/OS400/curlmain.c vendored Normal file
View File

@ -0,0 +1,121 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 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 https://curl.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.
*
* SPDX-License-Identifier: curl
*
*
***************************************************************************/
/*
* QADRT/QADRTMAIN2 substitution program.
* This is needed because the IBM-provided QADRTMAIN2 does not
* properly translate arguments by default or if no locale is provided.
*/
#include <stdlib.h>
#include <string.h>
#include <iconv.h>
#include <errno.h>
#include <locale.h>
/* Do not use qadrt.h since it defines unneeded static procedures. */
extern void QadrtInit(void);
extern int QadrtFreeConversionTable(void);
extern int QadrtFreeEnviron(void);
extern char * setlocale_a(int, const char *);
/* The ASCII main program. */
extern int main_a(int argc, char * * argv);
/* Global values of original EBCDIC arguments. */
int ebcdic_argc;
char ** ebcdic_argv;
int main(int argc, char **argv)
{
int i;
int j;
iconv_t cd;
size_t bytecount = 0;
char *inbuf;
char *outbuf;
size_t inbytesleft;
size_t outbytesleft;
char dummybuf[128];
char tocode[32];
char fromcode[32];
ebcdic_argc = argc;
ebcdic_argv = argv;
/* Build the encoding converter. */
strncpy(tocode, "IBMCCSID01208", sizeof(tocode)); /* Use UTF-8. */
strncpy(fromcode, "IBMCCSID000000000010", sizeof(fromcode));
cd = iconv_open(tocode, fromcode);
/* Measure the arguments. */
for(i = 0; i < argc; i++) {
inbuf = argv[i];
do {
inbytesleft = 0;
outbuf = dummybuf;
outbytesleft = sizeof(dummybuf);
j = iconv(cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft);
bytecount += outbuf - dummybuf;
} while(j == -1 && errno == E2BIG);
/* Reset the shift state. */
iconv(cd, NULL, &inbytesleft, &outbuf, &outbytesleft);
}
/* Allocate memory for the ASCII arguments and vector. */
argv = (char **) malloc((argc + 1) * sizeof(*argv) + bytecount);
/* Build the vector and convert argument encoding. */
outbuf = (char *) (argv + argc + 1);
outbytesleft = bytecount;
for(i = 0; i < argc; i++) {
argv[i] = outbuf;
inbuf = ebcdic_argv[i];
inbytesleft = 0;
iconv(cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft);
iconv(cd, NULL, &inbytesleft, &outbuf, &outbytesleft);
}
iconv_close(cd);
argv[argc] = NULL;
/* Try setting the locale regardless of QADRT_ENV_LOCALE. */
setlocale_a(LC_ALL, "");
/* Call the program. */
i = main_a(argc, argv);
/* Clean-up allocated items. */
free((char *) argv);
QadrtFreeConversionTable();
QadrtFreeEnviron();
/* Terminate. */
return i;
}

287
deps/curl/packages/OS400/initscript.sh vendored Normal file
View File

@ -0,0 +1,287 @@
#!/bin/sh
#***************************************************************************
# _ _ ____ _
# Project ___| | | | _ \| |
# / __| | | | |_) | |
# | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____|
#
# Copyright (C) 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 https://curl.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.
#
# SPDX-License-Identifier: curl
#
###########################################################################
CLcommand()
{
/usr/bin/system "${@}" || exit 1
}
setenv()
{
# Define and export.
eval ${1}="${2}"
export ${1}
}
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
# Extract the SONAME from the library makefile.
SONAME=`sed -e '/^VERSIONCHANGE=/!d;s/^.*=\([0-9]*\).*/\1/' \
< "${TOPDIR}/lib/Makefile.soname"`
export SONAME
# Get OS/400 configuration parameters.
. "${SCRIPTDIR}/config400.default"
if [ -f "${SCRIPTDIR}/config400.override" ]
then . "${SCRIPTDIR}/config400.override"
fi
# 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
}
# canonicalize_path path
#
# Return canonicalized path as:
# - Absolute
# - No . or .. component.
canonicalize_path()
{
if expr "${1}" : '^/' > /dev/null
then P="${1}"
else P="`pwd`/${1}"
fi
R=
IFSSAVE="${IFS}"
IFS="/"
for C in ${P}
do IFS="${IFSSAVE}"
case "${C}" in
.) ;;
..) R=`expr "${R}" : '^\(.*/\)..*'`
;;
?*) R="${R}${C}/"
;;
*) ;;
esac
done
IFS="${IFSSAVE}"
echo "/`expr "${R}" : '^\(.*\)/'`"
}
# 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;
SRCDIR=`dirname \`canonicalize_path "${2}"\``
# #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 temporary 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 *ASYNCSIGNAL)"
# CMD="${CMD} OPTION(*INCDIRFIRST *SHOWINC *SHOWSYS)"
CMD="${CMD} OPTION(*INCDIRFIRST)"
CMD="${CMD} LOCALETYPE(*LOCALE) FLAG(10)"
CMD="${CMD} INCDIR('${QADRTDIR}/include'"
CMD="${CMD} '${TOPDIR}/include/curl' '${TOPDIR}/include' '${SRCDIR}'"
CMD="${CMD} '${TOPDIR}/packages/OS400'"
if [ "${WITH_ZLIB}" != "0" ]
then CMD="${CMD} '${ZLIB_INCLUDE}'"
fi
if [ "${WITH_LIBSSH2}" != "0" ]
then CMD="${CMD} '${LIBSSH2_INCLUDE}'"
fi
CMD="${CMD} ${INCLUDES})"
CMD="${CMD} TGTCCSID(${TGTCCSID}) TGTRLS(${TGTRLS})"
CMD="${CMD} OUTPUT(${OUTPUT})"
CMD="${CMD} OPTIMIZE(${OPTIMIZE})"
CMD="${CMD} DBGVIEW(${DEBUG})"
DEFINES="${3} 'qadrt_use_inline'"
if [ "${WITH_ZLIB}" != "0" ]
then DEFINES="${DEFINES} HAVE_LIBZ"
fi
if [ "${WITH_LIBSSH2}" != "0" ]
then DEFINES="${DEFINES} USE_LIBSSH2"
fi
if [ "${DEFINES}" ]
then CMD="${CMD} DEFINE(${DEFINES})"
fi
CLcommand "${CMD}"
rm -f __tmpsrcf.c
LINK=YES
}
# Determine DB2 object name from IFS name.
db2_name()
{
if [ "${2}" = 'nomangle' ]
then basename "${1}" |
tr 'a-z-' 'A-Z_' |
sed -e 's/\..*//' \
-e 's/^\(.\).*\(.........\)$/\1\2/'
else basename "${1}" |
tr 'a-z-' 'A-Z_' |
sed -e 's/\..*//' \
-e 's/^CURL_*/C/' \
-e 's/^TOOL_*/T/' \
-e 's/^\(.\).*\(.........\)$/\1\2/'
fi
}
# 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}"
}
# Get definitions from a make file.
# The `sed' statement works as follows:
# - Join \nl-separated lines.
# - Retain only lines that begins with "identifier =".
# - Replace @...@ substitutions by shell variable references.
# - Turn these lines into shell variable assignments.
get_make_vars()
{
eval "`sed -e ': begin' \
-e '/\\\\$/{' \
-e 'N' \
-e 's/\\\\\\n/ /' \
-e 'b begin' \
-e '}' \
-e '/^[A-Za-z_][A-Za-z0-9_]*[[:space:]]*=/!d' \
-e 's/@\\([A-Za-z0-9_]*\\)@/${\\1}/g' \
-e 's/[[:space:]]*=[[:space:]]*/=/' \
-e 's/=\\(.*[^[:space:]]\\)[[:space:]]*$/=\\"\\1\\"/' \
-e 's/\\\$(\\([^)]*\\))/\${\\1}/g' \
< \"${1}\"`"
}

106
deps/curl/packages/OS400/make-include.sh vendored Normal file
View File

@ -0,0 +1,106 @@
#!/bin/sh
#***************************************************************************
# _ _ ____ _
# Project ___| | | | _ \| |
# / __| | | | |_) | |
# | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____|
#
# Copyright (C) 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 https://curl.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.
#
# SPDX-License-Identifier: curl
#
###########################################################################
#
# Installation of the header files in the OS/400 library.
#
SCRIPTDIR=`dirname "${0}"`
. "${SCRIPTDIR}/initscript.sh"
cd "${TOPDIR}/include"
# Create the OS/400 source program file for the header files.
SRCPF="${LIBIFSNAME}/H.FILE"
if action_needed "${SRCPF}"
then CMD="CRTSRCPF FILE(${TARGETLIB}/H) RCDLEN(112)"
CMD="${CMD} CCSID(${TGTCCSID}) TEXT('curl: Header files')"
CLcommand "${CMD}"
fi
# Create the IFS directory for the header files.
IFSINCLUDE="${IFSDIR}/include/curl"
if action_needed "${IFSINCLUDE}"
then mkdir -p "${IFSINCLUDE}"
fi
# Enumeration values are used as va_arg tagfields, so they MUST be
# integers.
copy_hfile()
{
destfile="${1}"
srcfile="${2}"
shift
shift
sed -e '1i\
#pragma enum(int)\
' "${@}" -e '$a\
#pragma enum(pop)\
' < "${srcfile}" > "${destfile}"
}
# Copy the header files.
for HFILE in curl/*.h ${SCRIPTDIR}/ccsidcurl.h
do case "`basename \"${HFILE}\" .h`" in
stdcheaders|typecheck-gcc)
continue;;
esac
DEST="${SRCPF}/`db2_name \"${HFILE}\" nomangle`.MBR"
if action_needed "${DEST}" "${HFILE}"
then copy_hfile "${DEST}" "${HFILE}"
IFSDEST="${IFSINCLUDE}/`basename \"${HFILE}\"`"
rm -f "${IFSDEST}"
ln -s "${DEST}" "${IFSDEST}"
fi
done
# Copy the ILE/RPG header file, setting-up version number.
versioned_copy "${SCRIPTDIR}/curl.inc.in" "${SRCPF}/CURL.INC.MBR"
rm -f "${IFSINCLUDE}/curl.inc.rpgle"
ln -s "${SRCPF}/CURL.INC.MBR" "${IFSINCLUDE}/curl.inc.rpgle"
# Duplicate file H as CURL to support more include path forms.
if action_needed "${LIBIFSNAME}/CURL.FILE"
then :
else CLcommand "DLTF FILE(${TARGETLIB}/CURL)"
fi
CMD="CRTDUPOBJ OBJ(H) FROMLIB(${TARGETLIB}) OBJTYPE(*FILE) TOLIB(*FROMLIB)"
CMD="${CMD} NEWOBJ(CURL) DATA(*YES)"
CLcommand "${CMD}"

178
deps/curl/packages/OS400/make-lib.sh vendored Normal file
View File

@ -0,0 +1,178 @@
#!/bin/sh
#***************************************************************************
# _ _ ____ _
# Project ___| | | | _ \| |
# / __| | | | |_) | |
# | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____|
#
# Copyright (C) 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 https://curl.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.
#
# SPDX-License-Identifier: curl
#
###########################################################################
#
# libcurl compilation script for the OS/400.
#
SCRIPTDIR=`dirname "${0}"`
. "${SCRIPTDIR}/initscript.sh"
cd "${TOPDIR}/lib"
# Need to have IFS access to the mih/cipher header file.
if action_needed cipher.mih '/QSYS.LIB/QSYSINC.LIB/MIH.FILE/CIPHER.MBR'
then rm -f cipher.mih
ln -s '/QSYS.LIB/QSYSINC.LIB/MIH.FILE/CIPHER.MBR' cipher.mih
fi
# Create and compile the identification source file.
echo '#pragma comment(user, "libcurl version '"${LIBCURL_VERSION}"'")' > os400.c
echo '#pragma comment(user, __DATE__)' >> os400.c
echo '#pragma comment(user, __TIME__)' >> os400.c
echo '#pragma comment(copyright, "Copyright (C) Daniel Stenberg et al. OS/400 version by P. Monnerat")' >> os400.c
make_module OS400 os400.c BUILDING_LIBCURL
LINK= # No need to rebuild service program yet.
MODULES=
# Get source list (CSOURCES variable).
get_make_vars Makefile.inc
# Compile the sources into modules.
INCLUDES="'`pwd`'"
make_module OS400SYS "${SCRIPTDIR}/os400sys.c" BUILDING_LIBCURL
make_module CCSIDCURL "${SCRIPTDIR}/ccsidcurl.c" BUILDING_LIBCURL
for SRC in ${CSOURCES}
do MODULE=`db2_name "${SRC}"`
make_module "${MODULE}" "${SRC}" BUILDING_LIBCURL
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')"
CLcommand "${CMD}"
for MODULE in ${MODULES}
do CMD="ADDBNDDIRE BNDDIR(${TARGETLIB}/${STATBNDDIR})"
CMD="${CMD} OBJ((${TARGETLIB}/${MODULE} *MODULE))"
CLcommand "${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')"
CLcommand "${CMD}"
fi
# Gather the list of symbols to export.
# - Unfold lines from the header files so that they contain a semicolon.
# - Keep only CURL_EXTERN definitions.
# - Remove the CURL_DEPRECATED and CURL_TEMP_PRINTF macro calls.
# - Drop the parenthesized function arguments and what follows.
# - Keep the trailing function name only.
EXPORTS=`cat "${TOPDIR}"/include/curl/*.h "${SCRIPTDIR}/ccsidcurl.h" |
sed -e 'H;s/.*//;x;s/\n//;s/.*/& /' \
-e '/^CURL_EXTERN[[:space:]]/!d' \
-e '/\;/!{x;d;}' \
-e 's/ CURL_DEPRECATED([^)]*)//g' \
-e 's/ CURL_TEMP_PRINTF([^)]*)//g' \
-e 's/[[:space:]]*(.*$//' \
-e 's/^.*[^A-Za-z0-9_]\([A-Za-z0-9_]*\)$/\1/'`
# Create the service program exportation file in DB2 member if needed.
BSF="${LIBIFSNAME}/TOOLS.FILE/BNDSRC.MBR"
if action_needed "${BSF}" Makefile.am
then LINK=YES
fi
if [ "${LINK}" ]
then echo " STRPGMEXP PGMLVL(*CURRENT) SIGNATURE('LIBCURL_${SONAME}')" \
> "${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}"
if [ "${WITH_ZLIB}" != 0 ]
then CMD="${CMD} ${ZLIB_LIB}/${ZLIB_BNDDIR}"
liblist -a "${ZLIB_LIB}"
fi
if [ "${WITH_LIBSSH2}" != 0 ]
then CMD="${CMD} ${LIBSSH2_LIB}/${LIBSSH2_BNDDIR}"
liblist -a "${LIBSSH2_LIB}"
fi
CMD="${CMD})"
CMD="${CMD} BNDSRVPGM(QADRTTS QGLDCLNT QGLDBRDR)"
CMD="${CMD} TEXT('curl API library')"
CMD="${CMD} TGTRLS(${TGTRLS})"
CLcommand "${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')"
CLcommand "${CMD}"
CMD="ADDBNDDIRE BNDDIR(${TARGETLIB}/${DYNBNDDIR})"
CMD="${CMD} OBJ((*LIBL/${SRVPGM} *SRVPGM))"
CLcommand "${CMD}"
fi

99
deps/curl/packages/OS400/make-src.sh vendored Normal file
View File

@ -0,0 +1,99 @@
#!/bin/sh
#***************************************************************************
# _ _ ____ _
# Project ___| | | | _ \| |
# / __| | | | |_) | |
# | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____|
#
# Copyright (C) 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 https://curl.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.
#
# SPDX-License-Identifier: curl
#
###########################################################################
#
# Command line interface tool compilation script for the OS/400.
SCRIPTDIR=`dirname "${0}"`
. "${SCRIPTDIR}/initscript.sh"
cd "${TOPDIR}/src"
# Get source lists.
# CURL_CFILES are in the current directory.
# CURLX_CFILES are in the lib directory and need to be recompiled because
# some function names change using macros.
get_make_vars Makefile.inc
# Compile the sources into modules.
LINK=
MODULES=
INCLUDES="'${TOPDIR}/lib'"
for SRC in ${CURLX_CFILES}
do MODULE=`db2_name "${SRC}"`
MODULE=`db2_name "X${MODULE}"`
make_module "${MODULE}" "${SRC}"
done
for SRC in ${CURL_CFILES}
do MODULE=`db2_name "${SRC}"`
make_module "${MODULE}" "${SRC}"
done
# Link modules into program.
MODULES="`echo \"${MODULES}\" | sed \"s/[^ ][^ ]*/${TARGETLIB}\/&/g\"`"
CMD="CRTPGM PGM(${TARGETLIB}/${CURLPGM})"
CMD="${CMD} ENTMOD(${TARGETLIB}/CURLMAIN)"
CMD="${CMD} MODULE(${MODULES})"
CMD="${CMD} BNDSRVPGM(${TARGETLIB}/${SRVPGM} QADRTTS)"
CMD="${CMD} TGTRLS(${TGTRLS})"
CLcommand "${CMD}"
# Create the IFS command.
IFSBIN="${IFSDIR}/bin"
if action_needed "${IFSBIN}"
then mkdir -p "${IFSBIN}"
fi
rm -f "${IFSBIN}/curl"
ln -s "/QSYS.LIB/${TARGETLIB}.LIB/${CURLPGM}.PGM" "${IFSBIN}/curl"
# Create the CL interface program.
if action_needed "${LIBIFSNAME}/CURLCL.PGM" "${SCRIPTDIR}/curlcl.c"
then CMD="CRTBNDC PGM(${TARGETLIB}/${CURLCLI})"
CMD="${CMD} SRCSTMF('${SCRIPTDIR}/curlcl.c')"
CMD="${CMD} DEFINE('CURLPGM=\"${CURLPGM}\"')"
CMD="${CMD} TGTCCSID(${TGTCCSID})"
CLcommand "${CMD}"
fi
# Create the CL command.
if action_needed "${LIBIFSNAME}/${CURLCMD}.CMD" "${SCRIPTDIR}/curl.cmd"
then CMD="CRTCMD CMD(${TARGETLIB}/${CURLCMD}) PGM(${TARGETLIB}/${CURLCLI})"
CMD="${CMD} SRCSTMF('${SCRIPTDIR}/curl.cmd')"
CLcommand "${CMD}"
fi

145
deps/curl/packages/OS400/make-tests.sh vendored Normal file
View File

@ -0,0 +1,145 @@
#!/bin/sh
#***************************************************************************
# _ _ ____ _
# Project ___| | | | _ \| |
# / __| | | | |_) | |
# | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____|
#
# Copyright (C) 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 https://curl.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.
#
# SPDX-License-Identifier: curl
#
###########################################################################
#
# tests compilation script for the OS/400.
#
SCRIPTDIR=`dirname "${0}"`
. "${SCRIPTDIR}/initscript.sh"
cd "${TOPDIR}/tests"
# Build programs in a directory.
build_all_programs()
{
# Compile all programs.
# The list is found in variable "noinst_PROGRAMS"
INCLUDES="'`pwd`' '${TOPDIR}/lib' '${TOPDIR}/src'"
MODS="${1}"
SRVPGMS="${2}"
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}\"`"
PGMDFNS=
for FLAG in ${PGMCFLAGS}
do case "${FLAG}" in
-D?*) DEFINE="`echo \"${FLAG}\" | sed 's/^..//'`"
PGMDFNS="${PGMDFNS} '${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
# If source is in a sibling directory,
# prefix module name with 'X'.
case "${SOURCE}" in
../*) MODULE=`db2_name "X${MODULE}"`
;;
esac
make_module "${MODULE}" "${SOURCE}" "${PGMDFNS}"
if action_needed "${PGMIFSNAME}" "${MODIFSNAME}"
then LINK=yes
fi
;;
esac
done
# Link program if needed.
if [ "${LINK}" ]
then PGMLDADD="`eval echo \"\\${${PGM}_LDADD}\"`"
for ARG in ${PGMLDADD}
do case "${ARG}" in
-*) ;; # Ignore non-module.
*) MODULES="${MODULES} "`db2_name "${ARG}"`
;;
esac
done
MODULES="`echo \"${MODULES}\" |
sed \"s/[^ ][^ ]*/${TARGETLIB}\/&/g\"`"
CMD="CRTPGM PGM(${TARGETLIB}/${DB2PGM})"
CMD="${CMD} ENTMOD(${TARGETLIB}/CURLMAIN)"
CMD="${CMD} MODULE(${MODULES} ${MODS})"
CMD="${CMD} BNDSRVPGM(${SRVPGMS} QADRTTS)"
CMD="${CMD} TGTRLS(${TGTRLS})"
CLcommand "${CMD}"
fi
done
}
# Build programs in the server directory.
(
cd server
get_make_vars Makefile.inc
build_all_programs "${TARGETLIB}/OS400SYS"
)
# Build all programs in the libtest subdirectory.
(
cd libtest
get_make_vars Makefile.inc
# Special case: redefine chkhostname compilation parameters.
chkhostname_SOURCES=chkhostname.c
chkhostname_LDADD=curl_gethostname.o
build_all_programs "" "${TARGETLIB}/${SRVPGM}"
)

123
deps/curl/packages/OS400/makefile.sh vendored Normal file
View File

@ -0,0 +1,123 @@
#!/bin/sh
#***************************************************************************
# _ _ ____ _
# Project ___| | | | _ \| |
# / __| | | | |_) | |
# | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____|
#
# Copyright (C) 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 https://curl.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.
#
# SPDX-License-Identifier: curl
#
###########################################################################
#
# curl compilation script for the OS/400.
#
#
# 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')"
CLcommand "${CMD}"
fi
# Create the DOCS source file if it does not exist.
if action_needed "${LIBIFSNAME}/DOCS.FILE"
then CMD="CRTSRCPF FILE(${TARGETLIB}/DOCS) RCDLEN(240)"
CMD="${CMD} CCSID(${TGTCCSID}) TEXT('Documentation texts')"
CLcommand "${CMD}"
fi
# Copy some documentation files if needed.
for TEXT in "${TOPDIR}/COPYING" "${SCRIPTDIR}/README.OS400" \
"${TOPDIR}/CHANGES" "${TOPDIR}/docs/THANKS" "${TOPDIR}/docs/FAQ" \
"${TOPDIR}/docs/FEATURES" "${TOPDIR}/docs/SSLCERTS.md" \
"${TOPDIR}/docs/RESOURCES" "${TOPDIR}/docs/VERSIONS.md" \
"${TOPDIR}/docs/HISTORY.md"
do MEMBER="`basename \"${TEXT}\" .OS400`"
MEMBER="`basename \"${MEMBER}\" .md`"
MEMBER="${LIBIFSNAME}/DOCS.FILE/`db2_name \"${MEMBER}\"`.MBR"
[ -e "${TEXT}" ] || continue
if action_needed "${MEMBER}" "${TEXT}"
then CMD="CPY OBJ('${TEXT}') TOOBJ('${MEMBER}') TOCCSID(${TGTCCSID})"
CMD="${CMD} DTAFMT(*TEXT) REPLACE(*YES)"
CLcommand "${CMD}"
fi
done
# Create the RPGXAMPLES source file if it does not exist.
if action_needed "${LIBIFSNAME}/RPGXAMPLES.FILE"
then CMD="CRTSRCPF FILE(${TARGETLIB}/RPGXAMPLES) RCDLEN(240)"
CMD="${CMD} CCSID(${TGTCCSID}) TEXT('ILE/RPG examples')"
CLcommand "${CMD}"
fi
# Copy RPG examples if needed.
for EXAMPLE in "${SCRIPTDIR}/rpg-examples"/*
do MEMBER="`basename \"${EXAMPLE}\"`"
IFSMEMBER="${LIBIFSNAME}/RPGXAMPLES.FILE/`db2_name \"${MEMBER}\"`.MBR"
[ -e "${EXAMPLE}" ] || continue
if action_needed "${IFSMEMBER}" "${EXAMPLE}"
then CMD="CPY OBJ('${EXAMPLE}') TOOBJ('${IFSMEMBER}')"
CMD="${CMD} TOCCSID(${TGTCCSID}) DTAFMT(*TEXT) REPLACE(*YES)"
CLcommand "${CMD}"
MBRTEXT=`sed -e '1!d;/^ \*/!d;s/^ *\* *//' \
-e 's/ *$//;s/'"'"'/&&/g' < "${EXAMPLE}"`
CMD="CHGPFM FILE(${TARGETLIB}/RPGXAMPLES) MBR(${MEMBER})"
CMD="${CMD} SRCTYPE(RPGLE) TEXT('${MBRTEXT}')"
CLcommand "${CMD}"
fi
done
# Compile the QADRTMAIN2 replacement module.
if action_needed "${LIBIFSNAME}/CURLMAIN.MODULE" "${SCRIPTDIR}/curlmain.c"
then CMD="CRTCMOD MODULE(${TARGETLIB}/CURLMAIN)"
CMD="${CMD} SRCSTMF('${SCRIPTDIR}/curlmain.c')"
CMD="${CMD} SYSIFCOPT(*IFS64IO) LOCALETYPE(*LOCALE) FLAG(10)"
CMD="${CMD} TGTCCSID(${TGTCCSID}) TGTRLS(${TGTRLS})"
CMD="${CMD} OUTPUT(${OUTPUT})"
CMD="${CMD} OPTIMIZE(${OPTIMIZE})"
CMD="${CMD} DBGVIEW(${DEBUG})"
CLcommand "${CMD}"
fi
# Build in each directory.
# for SUBDIR in include lib src tests
for SUBDIR in include lib src
do "${SCRIPTDIR}/make-${SUBDIR}.sh"
done

1040
deps/curl/packages/OS400/os400sys.c vendored Normal file

File diff suppressed because it is too large Load Diff

57
deps/curl/packages/OS400/os400sys.h vendored Normal file
View File

@ -0,0 +1,57 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 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 https://curl.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.
*
* SPDX-License-Identifier: curl
*
*
***************************************************************************/
/* OS/400 additional definitions. */
#ifndef __OS400_SYS_
#define __OS400_SYS_
/* Per-thread item identifiers. */
typedef enum {
LK_GSK_ERROR,
LK_LDAP_ERROR,
LK_CURL_VERSION,
LK_VERSION_INFO,
LK_VERSION_INFO_DATA,
LK_EASY_STRERROR,
LK_SHARE_STRERROR,
LK_MULTI_STRERROR,
LK_URL_STRERROR,
LK_ZLIB_VERSION,
LK_ZLIB_MSG,
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

View File

@ -0,0 +1,146 @@
* Curl header API: extract headers post transfer
*
h DFTACTGRP(*NO) ACTGRP(*NEW)
h OPTION(*NOSHOWCPY)
h BNDDIR('CURL')
*
**************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 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 https://curl.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.
*
* SPDX-License-Identifier: curl
*
**************************************************************************
*
/include H,CURL.INC
*
* Extract headers post transfer with the header API.
*
d pi
d url 120
*
d urllen s 10u 0 URL length
*
**************************************************************************
urllen = trimmed_length(url: %len(url));
// Do the curl stuff.
curl_global_init(CURL_GLOBAL_ALL);
main();
curl_global_cleanup();
*inlr = *on; // Exit
*
**************************************************************************
* Main procedure: do the curl job.
**************************************************************************
*
p main b
d main pi
*
d h s * Easy handle
d result s like(CURLcode) Curl return code
d inz(CURLE_OUT_OF_MEMORY)
d header ds likeds(curl_header) based(hp)
d strp1 s * Work string pointer
d strp2 s * Work string pointer
d inout s 52 For error display
// Create and fill curl handle.
h = curl_easy_init();
if h <> *NULL;
curl_easy_setopt_ccsid(h: CURLOPT_URL: %subst(url: 1: urllen): 0);
curl_easy_setopt(h: CURLOPT_FOLLOWLOCATION: 1);
curl_easy_setopt(h: CURLOPT_WRITEFUNCTION: %paddr(in_data_cb)); // Ignore input data
// Perform the request.
result = curl_easy_perform(h);
endif;
// Check for error and report if some.
if result <> CURLE_OK;
inout = %str(curl_easy_strerror_ccsid(result: 0));
dsply '' '*EXT' inout;
else;
if curl_easy_header_ccsid(h: 'Content-Type': 0: CURLH_HEADER: -1:
hp: 0) = CURLHE_OK;
strp2 = curl_to_ccsid(header.value: 0);
inout = 'Content-Type: ' + %str(strp2);
dsply inout;
curl_free(strp2);
endif;
dsply ' All server headers:';
hp = *NULL;
dow *on;
hp = curl_easy_nextheader(h: CURLH_HEADER: -1: hp);
if hp = *NULL;
leave;
endif;
strp1 = curl_to_ccsid(header.name: 0);
strp2 = curl_to_ccsid(header.value: 0);
inout = %str(strp1) + ': ' + %str(strp2) +
' (' + %char(header.amount) + ')';
curl_free(strp2);
curl_free(strp1);
dsply inout;
enddo;
inout = 'Done';
dsply '' '*EXT' inout;
curl_easy_cleanup(h); // Release handle
endif;
p main e
*
**************************************************************************
* Dummy data input callback procedure.
**************************************************************************
*
p in_data_cb b
d in_data_cb pi 10u 0
d ptr * value Input data pointer
d size 10u 0 value Data element size
d nmemb 10u 0 value Data element count
d userdata * value User data pointer
*
return size * nmemb;
p in_data_cb e
*
**************************************************************************
* Get the length of right-trimmed string
**************************************************************************
*
p trimmed_length b
d trimmed_length pi 10u 0
d string 999999 const options(*varsize)
d length 10u 0 value
*
d len s 10u 0
*
len = %scan(X'00': string: 1: length); // Limit to zero-terminated string
if len = 0;
len = length + 1;
endif;
if len <= 1;
return 0;
endif;
return %checkr(' ': string: len - 1); // Trim right
p trimmed_length e

View File

@ -0,0 +1,129 @@
* Curl MIME post data and display response
*
h DFTACTGRP(*NO) ACTGRP(*NEW)
h OPTION(*NOSHOWCPY)
h BNDDIR('CURL')
*
**************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 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 https://curl.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.
*
* SPDX-License-Identifier: curl
*
**************************************************************************
*
/include H,CURL.INC
*
* Example to HTTP POST data using the MIME API. Displays the response.
*
d pi
d userinput 120 User data to post
*
d url c 'http://httpbin.org/anything'
*
*
d inputlen s 10u 0 User input length
**************************************************************************
inputlen = trimmed_length(userinput: %len(userinput));
// Do the curl stuff.
curl_global_init(CURL_GLOBAL_ALL);
main();
curl_global_cleanup();
*inlr = *on; // Exit
*
**************************************************************************
* Main procedure: do the curl job.
**************************************************************************
*
p main b
d main pi
*
d h s * Easy handle
d result s like(CURLcode) Curl return code
d inz(CURLE_OUT_OF_MEMORY)
d errmsgp s * Error string pointer
d response s 52 For error display
d mime s * MIME handle
d mimepart s * MIME part handle
d parthdrs s * inz(*NULL) Part headers
// Create and fill curl handle.
h = curl_easy_init();
if h <> *NULL;
curl_easy_setopt_ccsid(h: CURLOPT_URL: url: 0);
curl_easy_setopt(h: CURLOPT_FOLLOWLOCATION: 1);
mime = curl_mime_init(h);
mimepart = curl_mime_addpart(mime);
curl_mime_name_ccsid(mimepart: 'autofield': 0);
curl_mime_data_ccsid(mimepart: 'program-generated value':
CURL_ZERO_TERMINATED: 0);
mimepart = curl_mime_addpart(mime);
curl_mime_name_ccsid(mimepart: 'userfield': 0);
curl_mime_data_ccsid(mimepart: %subst(userinput: 1: inputlen):
CURL_ZERO_TERMINATED: 0);
mimepart = curl_mime_addpart(mime);
curl_mime_name_ccsid(mimepart: 'ebcdicfield': 0);
curl_mime_data(mimepart: %subst(userinput: 1: inputlen): inputlen);
curl_mime_encoder_ccsid(mimepart: 'base64': 0);
// Avoid server to convert base64 to text.
parthdrs = curl_slist_append_ccsid(parthdrs:
'Content-Transfer-Encoding: bit': 0);
curl_mime_headers(mimepart: parthdrs: 1);
curl_easy_setopt(h: CURLOPT_MIMEPOST: mime);
// Perform the request.
result = curl_easy_perform(h);
curl_mime_free(mime);
curl_easy_cleanup(h); // Release handle
endif;
// Check for error and report if some.
if result <> CURLE_OK;
errmsgp = curl_easy_strerror_ccsid(result: 0);
response = %str(errmsgp);
dsply '' '*EXT' response;
endif;
p main e
*
**************************************************************************
* Get the length of right-trimmed string
**************************************************************************
*
p trimmed_length b
d trimmed_length pi 10u 0
d string 999999 const options(*varsize)
d length 10u 0 value
*
d len s 10u 0
*
len = %scan(X'00': string: 1: length); // Limit to zero-terminated string
if len = 0;
len = length + 1;
endif;
if len <= 1;
return 0;
endif;
return %checkr(' ': string: len - 1); // Trim right
p trimmed_length e

View File

@ -0,0 +1,159 @@
* Curl get in memory and count HTML tags
*
h DFTACTGRP(*NO) ACTGRP(*NEW)
h OPTION(*NOSHOWCPY)
h BNDDIR('CURL')
*
**************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 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 https://curl.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.
*
* SPDX-License-Identifier: curl
*
**************************************************************************
*
/include H,CURL.INC
*
* Example to request the URL given as command line parameter and count
* HTML tags in its response.
*
d pi
d url 120
*
d countdata ds qualified based(###dummyptr) User data type
d tagcount 10u 0 Tag counter
d tagopen n Possible opening tag
*
d urllen s 10u 0 URL length
*
**************************************************************************
urllen = trimmed_length(url: %len(url));
// Do the curl stuff.
curl_global_init(CURL_GLOBAL_ALL);
main();
curl_global_cleanup();
*inlr = *on; // Exit
*
**************************************************************************
* Main procedure: do the curl job.
**************************************************************************
*
p main b
d main pi
*
d h s * Easy handle
d result s like(CURLcode) Curl return code
d inz(CURLE_OUT_OF_MEMORY)
d errmsgp s * Error string pointer
d response s 52 For error display
d counter ds likeds(countdata) HTML tag counter
counter.tagcount = 0;
counter.tagopen = *off;
// Create and fill curl handle.
h = curl_easy_init();
if h <> *NULL;
curl_easy_setopt_ccsid(h: CURLOPT_URL: %subst(url: 1: urllen): 0);
curl_easy_setopt(h: CURLOPT_FOLLOWLOCATION: 1);
curl_easy_setopt(h: CURLOPT_WRITEFUNCTION: %paddr(in_data_cb));
curl_easy_setopt(h: CURLOPT_WRITEDATA: %addr(counter));
// Perform the request.
result = curl_easy_perform(h);
curl_easy_cleanup(h); // Release handle
endif;
// Check for error and report if some.
if result <> CURLE_OK;
errmsgp = curl_easy_strerror_ccsid(result: 0);
response = %str(errmsgp);
dsply '' '*EXT' response;
else;
// Display the tag count.
response = 'Tag count: ' + %char(counter.tagcount);
dsply '' '*EXT' response;
endif;
p main e
*
**************************************************************************
* Data input callback procedure.
**************************************************************************
*
p in_data_cb b
d in_data_cb pi 10u 0
d ptr * value Input data pointer
d size 10u 0 value Data element size
d nmemb 10u 0 value Data element count
d userdata * value User data pointer
*
d counter ds likeds(countdata) based(userdata) HTML tag counter
d ebcdata s * EBCDIC data pointer
d chars s 1 based(ebcdata) dim(1000000)
d i s 10u 0 Character position
*
size = size * nmemb; // The size in bytes.
ebcdata = curl_to_ccsid(%str(ptr: size): 0); // Convert to EBCDIC.
i = 1;
dow i <= size;
if counter.tagopen; // Did we see '<' ?
counter.tagopen = *off;
if chars(i) <> '/'; // Reject closing tag.
counter.tagcount = counter.tagcount + 1; // Count this tag.
endif;
else;
i = %scan('<': %str(ebcdata): i); // Search next possible tag.
if i = 0;
leave;
endif;
counter.tagopen = *on; // Found one: flag it.
endif;
i = i + 1;
enddo;
curl_free(ebcdata);
return size;
p in_data_cb e
*
**************************************************************************
* Get the length of right-trimmed string
**************************************************************************
*
p trimmed_length b
d trimmed_length pi 10u 0
d string 999999 const options(*varsize)
d length 10u 0 value
*
d len s 10u 0
*
len = %scan(X'00': string: 1: length); // Limit to zero-terminated string
if len = 0;
len = length + 1;
endif;
if len <= 1;
return 0;
endif;
return %checkr(' ': string: len - 1); // Trim right
p trimmed_length e

View File

@ -0,0 +1,108 @@
* Curl simple URL request
*
h DFTACTGRP(*NO) ACTGRP(*NEW)
h OPTION(*NOSHOWCPY)
h BNDDIR('CURL')
*
**************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 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 https://curl.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.
*
* SPDX-License-Identifier: curl
*
**************************************************************************
*
/include H,CURL.INC
*
* Simple example to request the URL given as command line parameter and
* output its response.
*
d pi
d url 120
*
d urllen s 10u 0 URL length
*
**************************************************************************
*
c eval urllen = trimmed_length(url: %len(url))
*
* Do the curl stuff.
*
c callp curl_global_init(CURL_GLOBAL_ALL)
c callp main
c callp curl_global_cleanup()
c seton lr Exit
*
**************************************************************************
* Main procedure: do the curl job.
**************************************************************************
*
p main b
d main pi
*
d h s * Easy handle
d result s like(CURLcode) Curl return code
d inz(CURLE_OUT_OF_MEMORY)
d errmsgp s * Error string pointer
d response s 52 For error display
*
* Create and fill curl handle.
*
c eval h = curl_easy_init()
c if h <> *NULL
c callp curl_easy_setopt_ccsid(h: CURLOPT_URL:
c %subst(url: 1: urllen): 0)
c callp curl_easy_setopt_long(h:
c CURLOPT_FOLLOWLOCATION: 1)
*
* Perform the request.
*
c eval result = curl_easy_perform(h)
c callp curl_easy_cleanup(h) Release handle
c endif
*
* Check for error and report if some.
*
c if result <> CURLE_OK
c eval errmsgp = curl_easy_strerror_ccsid(result: 0)
c eval response = %str(errmsgp)
c dsply response
c endif
p main e
*
**************************************************************************
* Get the length of right-trimmed string
**************************************************************************
*
p trimmed_length b
d trimmed_length pi 10u 0
d string 999999 const options(*varsize)
d length 10u 0 value
*
d len s 10u 0
*
c eval len = %scan(X'00': string: 1: length) Limit 0-terminated
c if len = 0
c eval len = length + 1
c endif
c if len <= 1
c return 0
c endif
c return %checkr(' ': string: len - 1) Trim right
p trimmed_length e

View File

@ -0,0 +1,108 @@
* Curl simple URL request (free-format RPG)
*
ctl-opt dftactgrp(*NO) actgrp(*NEW)
option(*NOSHOWCPY)
bnddir('CURL');
*
**************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 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 https://curl.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.
*
* SPDX-License-Identifier: curl
*
**************************************************************************
/include H,CURL.INC
* Simple free-format RPG program to request the URL given as command line
* parameter and output its response.
dcl-pi *N;
url char(120);
end-pi;
dcl-s urllen int(10); // URL length
**************************************************************************
urllen = trimmed_length(url: %len(url));
// Do the curl stuff.
curl_global_init(CURL_GLOBAL_ALL);
main();
curl_global_cleanup();
*inlr = *on; // Exit
**************************************************************************
* Main procedure: do the curl job.
**************************************************************************
dcl-proc main;
dcl-pi *N end-pi;
dcl-s h pointer; // Easy handle
dcl-s result like(CURLcode) inz(CURLE_OUT_OF_MEMORY); // Curl return code
dcl-s errmsgp pointer; // Error string pointer
dcl-s response char(52); // For error display
// Create and fill curl handle.
h = curl_easy_init();
if h <> *NULL;
curl_easy_setopt_ccsid(h: CURLOPT_URL: %subst(url: 1: urllen):
0);
curl_easy_setopt(h: CURLOPT_FOLLOWLOCATION: 1);
// Perform the request.
result = curl_easy_perform(h);
curl_easy_cleanup(h); // Release handle
endif;
// Check for error and report if some.
if result <> CURLE_OK;
errmsgp = curl_easy_strerror_ccsid(result: 0);
response = %str(errmsgp);
dsply '' '*EXT' response;
endif;
end-proc;
*
**************************************************************************
* Get the length of right-trimmed string
**************************************************************************
*
dcl-proc trimmed_length;
dcl-pi *N uns(10);
string char(9999999) const options(*varsize);
length uns(10) value;
end-pi;
dcl-s len uns(10);
len = %scan(X'00': string: 1: length); // Limit to zero-terminated string
if len = 0;
len = length + 1;
endif;
if len <= 1;
return 0;
endif;
return %checkr(' ': string: len - 1); // Trim right
end-proc;

View File

@ -0,0 +1,239 @@
* Curl SMTP send source member as attachment
*
h DFTACTGRP(*NO) ACTGRP(*NEW)
h OPTION(*NOSHOWCPY)
h BNDDIR('CURL')
*
**************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 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 https://curl.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.
*
* SPDX-License-Identifier: curl
*
**************************************************************************
*
/include H,CURL.INC
*
* Example to SMTP send source member as attachment via SMTP.
*
fRPGXAMPLESif e disk extmbr(program_name)
f rename(RPGXAMPLES: record)
d pi
d url 60 SMTP server URL
d recipient_mail 40 Recipient mail addr
*
d program_name c 'SMTPSRCMBR' Member name to send
d sender_name c 'Curl' Sender name
d sender_mail c 'curl@example.com' Sender e-mail
d recipient_name c 'WIMC' Recipient name
d crlf c X'0D25'
*
d urllen s 10u 0 URL length
d rcptmlen s 10u 0 Recipient mail len
*
**************************************************************************
urllen = trimmed_length(url: %len(url));
rcptmlen = trimmed_length(recipient_mail: %len(recipient_mail));
// Do the curl stuff.
curl_global_init(CURL_GLOBAL_ALL);
main();
curl_global_cleanup();
*inlr = *on; // Exit
*
**************************************************************************
* Main procedure: do the curl job.
**************************************************************************
*
p main b
d main pi
*
d h s * Easy handle
d result s like(CURLcode) Curl return code
d inz(CURLE_OUT_OF_MEMORY)
d errmsgp s * Error string pointer
d response s 52 For error display
d headers s * inz(*NULL) Mail headers
d rcpts s * inz(*NULL) List of recipients
d mime s * Mail MIME structure
d mimepart s * Mail part
// Create and fill curl handle.
h = curl_easy_init();
if h <> *NULL;
rcpts = curl_slist_append_ccsid(rcpts:
%subst(recipient_mail: 1: rcptmlen): 0);
headers = curl_slist_append_ccsid(headers: 'From: ' + sender_name +
' <' + sender_mail + '>':
0);
headers = curl_slist_append_ccsid(headers: 'To: ' + recipient_name +
' <' + %subst(recipient_mail: 1: rcptmlen) + '>': 0);
headers = curl_slist_append_ccsid(headers: 'Subject: An ILE/RPG ' +
'source program': 0);
headers = curl_slist_append_ccsid(headers: 'Date: ' + mail_date():
0);
curl_easy_setopt_ccsid(h: CURLOPT_URL: %subst(url: 1: urllen): 0);
curl_easy_setopt_ccsid(h: CURLOPT_MAIL_FROM: sender_mail: 0);
curl_easy_setopt(h: CURLOPT_MAIL_RCPT: rcpts);
curl_easy_setopt(h: CURLOPT_HTTPHEADER: headers);
mime = curl_mime_init(h);
mimepart = curl_mime_addpart(mime);
curl_mime_data_ccsid(mimepart: 'Please find the ILE/RPG program ' +
program_name + ' source code in ' +
'attachment.' + crlf:
CURL_ZERO_TERMINATED: 0);
mimepart = curl_mime_addpart(mime);
curl_mime_data_cb(mimepart: -1: %paddr(out_data_cb): *NULL: *NULL:
*NULL);
curl_mime_filename_ccsid(mimepart: program_name: 0);
curl_mime_encoder_ccsid(mimepart: 'quoted-printable': 0);
curl_easy_setopt(h: CURLOPT_MIMEPOST: mime);
// Perform the request.
setll *start RPGXAMPLES;
result = curl_easy_perform(h);
// Cleanup.
curl_mime_free(mime);
curl_slist_free_all(headers);
curl_slist_free_all(rcpts);
curl_easy_cleanup(h); // Release handle
endif;
// Check for error and report if some.
if result <> CURLE_OK;
errmsgp = curl_easy_strerror_ccsid(result: 0);
response = %str(errmsgp);
dsply '' '*EXT' response;
else;
response = 'Mail sent';
dsply '' '*EXT' response;
endif;
p main e
*
**************************************************************************
* Attachment data callback procedure.
**************************************************************************
*
p out_data_cb b
d out_data_cb pi 10u 0
d ptr * value Output data pointer
d size 10u 0 value Data element size
d nmemb 10u 0 value Data element count
d userdata * value User data pointer
*
d buffer s 9999999 based(ptr) Output buffer
d line s 9999999 based(lineptr) ASCII line pointer
d linelen s 10u 0
d i s 10u 0 Buffer position
*
size = size * nmemb; // The size in bytes.
i = 0;
dow size - i >= %len(SRCDTA) + %len(crlf) and not %eof(RPGXAMPLES);
read record;
lineptr = curl_from_ccsid(%trimr(SRCDTA) + crlf: 0);
linelen = %scan(X'00': line) - 1;
%subst(buffer: i + 1: linelen) = %str(lineptr);
curl_free(lineptr);
i = i + linelen;
enddo;
return i;
p out_data_cb e
*
**************************************************************************
* Mail-formatted date procedure.
**************************************************************************
*
p mail_date b
d mail_date pi 50 varying
*
d sysval ds qualified To retrieve timezone
d numsysval 10u 0
d offset 10u 0
d 100
*
d get_sysval pr extpgm('QWCRSVAL')
d outdata likeds(sysval)
d outsize 10u 0 const
d numsysval 10u 0 const
d name 10 const
d errcode 10000 options(*varsize)
*
d now ds qualified
d ts z
d year 4s 0 overlay(ts: 1)
d month 2s 0 overlay(ts: 6)
d day 2s 0 overlay(ts: 9)
d hour 2s 0 overlay(ts: 12)
d minute 2 overlay(ts: 15)
d second 2 overlay(ts: 18)
*
d sysvalinfo ds qualified based(sysvalinfoptr)
d name 10
d type 1
d status 1
d length 10u 0
d value 99999
*
d qusec ds qualified
d 10u 0 inz(0)
*
d weekday s 10u 0
*
now.ts = %timestamp(*SYS);
get_sysval(sysval: %len(sysval): 1: 'QUTCOFFSET': qusec);
sysvalinfoptr = %addr(sysval) + sysval.offset;
weekday = %rem(%diff(now.ts: %timestamp('2001-01-01-00.00.00.000000'):
*DAYS): 7);
return %subst('MonTueWedThuFriSatSun': 3 * weekday + 1: 3) + ', ' +
%char(now.day) + ' ' +
%subst('JanFebMarAprMayJunJulAugSepOctNovDec':
3 * now.month - 2: 3) + ' ' +
%char(now.year) + ' ' +
%char(now.hour) + ':' + now.minute + ':' + now.second + ' ' +
%subst(sysvalinfo.value: 1: sysvalinfo.length);
p mail_date e
*
**************************************************************************
* Get the length of right-trimmed string
**************************************************************************
*
p trimmed_length b
d trimmed_length pi 10u 0
d string 999999 const options(*varsize)
d length 10u 0 value
*
d addrdiff s 10i 0
d len s 10u 0
*
len = %scan(X'00': string: 1: length); // Limit to zero-terminated string
if len = 0;
len = length + 1;
endif;
if len <= 1;
return 0;
endif;
return %checkr(' ': string: len - 1); // Trim right
p trimmed_length e