README.OS400 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. Implementation notes:
  2. This is a true OS/400 ILE implementation, not a PASE implementation (for
  3. PASE, use AIX implementation).
  4. The biggest problem with OS/400 is EBCDIC. Libcurl implements an internal
  5. conversion mechanism, but it has been designed for computers that have a
  6. single native character set. OS/400 default native character set varies
  7. depending on the country for which it has been localized. And more, a job
  8. may dynamically alter its "native" character set.
  9. Several characters that do not have fixed code in EBCDIC variants are
  10. used in libcurl strings. As a consequence, using the existing conversion
  11. mechanism would have lead in a localized binary library - not portable across
  12. countries.
  13. For this reason, and because libcurl was originally designed for ASCII based
  14. operating systems, the current OS/400 implementation uses ASCII as internal
  15. character set. This has been accomplished using the QADRT library and
  16. include files, a C and system procedures ASCII wrapper library. See IBM QADRT
  17. description for more information.
  18. This then results in libcurl being an ASCII library: any function string
  19. argument is taken/returned in ASCII and a C/C++ calling program built around
  20. QADRT may use libcurl functions as on any other platform.
  21. QADRT does not define ASCII wrappers for all C/system procedures: the
  22. OS/400 configuration header file and an additional module (os400sys.c) define
  23. some more of them, that are used by libcurl and that QADRT left out.
  24. To support all the different variants of EBCDIC, non-standard wrapper
  25. procedures have been added to libcurl on OS/400: they provide an additional
  26. CCSID (numeric Coded Character Set ID specific to OS/400) parameter for each
  27. string argument. Callback procedures arguments giving access to strings are
  28. NOT converted, so text gathered this way is (probably !) ASCII.
  29. Another OS/400 problem comes from the fact that the last fixed argument of a
  30. vararg procedure may not be of type char, unsigned char, short or unsigned
  31. short. Enums that are internally implemented by the C compiler as one of these
  32. types are also forbidden. Libcurl uses enums as vararg procedure tagfields...
  33. Happily, there is a pragma forcing enums to type "int". The original libcurl
  34. header files are thus altered during build process to use this pragma, in
  35. order to force libcurl enums of being type int (the pragma disposition in use
  36. before inclusion is restored before resuming the including unit compilation).
  37. Secure socket layer is provided by the IBM GSKit API: unlike other SSL
  38. implementations, GSKit is based on "certificate stores" or keyrings
  39. rather than individual certificate/key files. Certificate stores, as well as
  40. "certificate labels" are managed by external IBM-defined applications.
  41. There are two ways to specify an SSL context:
  42. - By an application identifier.
  43. - By a keyring file pathname and (optionally) certificate label.
  44. To identify an SSL context by application identifier, use option
  45. SETOPT_SSLCERT to specify the application identifier.
  46. To address an SSL context by keyring and certificate label, use CURLOPT_CAINFO
  47. to set-up the keyring pathname, CURLOPT_SSLCERT to define the certificate label
  48. (omitting it will cause the default certificate in keyring to be used) and
  49. CURLOPT_KEYPASSWD to give the keyring password. If SSL is used without
  50. defining any of these options, the default (i.e.: system) keyring is used for
  51. server certificate validation.
  52. Non-standard EBCDIC wrapper prototypes are defined in an additional header
  53. file: ccsidcurl.h. These should be self-explanatory to an OS/400-aware
  54. designer. CCSID 0 can be used to select the current job's CCSID.
  55. Wrapper procedures with variable arguments are described below:
  56. _ curl_easy_setopt_ccsid()
  57. Variable arguments are a string pointer and a CCSID (unsigned int) for
  58. options:
  59. CURLOPT_ABSTRACT_UNIX_SOCKET
  60. CURLOPT_ALTSVC
  61. CURLOPT_AWS_SIGV4
  62. CURLOPT_CAINFO
  63. CURLOPT_CAPATH
  64. CURLOPT_COOKIE
  65. CURLOPT_COOKIEFILE
  66. CURLOPT_COOKIEJAR
  67. CURLOPT_COOKIELIST
  68. CURLOPT_COPYPOSTFIELDS
  69. CURLOPT_CRLFILE
  70. CURLOPT_CUSTOMREQUEST
  71. CURLOPT_DEFAULT_PROTOCOL
  72. CURLOPT_DNS_SERVERS
  73. CURLOPT_DOH_URL
  74. CURLOPT_EGDSOCKET
  75. CURLOPT_ENCODING
  76. CURLOPT_FTPPORT
  77. CURLOPT_FTP_ACCOUNT
  78. CURLOPT_FTP_ALTERNATIVE_TO_USER
  79. CURLOPT_HSTS
  80. CURLOPT_INTERFACE
  81. CURLOPT_ISSUERCERT
  82. CURLOPT_KEYPASSWD
  83. CURLOPT_KRBLEVEL
  84. CURLOPT_LOGIN_OPTIONS
  85. CURLOPT_MAIL_AUTH
  86. CURLOPT_MAIL_FROM
  87. CURLOPT_NETRC_FILE
  88. CURLOPT_NOPROXY
  89. CURLOPT_PASSWORD
  90. CURLOPT_PINNEDPUBLICKEY
  91. CURLOPT_PRE_PROXY
  92. CURLOPT_PROTOCOLS_STR
  93. CURLOPT_PROXY
  94. CURLOPT_PROXYPASSWORD
  95. CURLOPT_PROXYUSERNAME
  96. CURLOPT_PROXYUSERPWD
  97. CURLOPT_PROXY_CAINFO
  98. CURLOPT_PROXY_CAPATH
  99. CURLOPT_PROXY_CRLFILE
  100. CURLOPT_PROXY_KEYPASSWD
  101. CURLOPT_PROXY_PINNEDPUBLICKEY
  102. CURLOPT_PROXY_SERVICE_NAME
  103. CURLOPT_PROXY_SSLCERT
  104. CURLOPT_PROXY_SSLCERTTYPE
  105. CURLOPT_PROXY_SSLKEY
  106. CURLOPT_PROXY_SSLKEYTYPE
  107. CURLOPT_PROXY_SSL_CIPHER_LIST
  108. CURLOPT_PROXY_TLS13_CIPHERS
  109. CURLOPT_PROXY_TLSAUTH_PASSWORD
  110. CURLOPT_PROXY_TLSAUTH_TYPE
  111. CURLOPT_PROXY_TLSAUTH_USERNAME
  112. CURLOPT_RANDOM_FILE
  113. CURLOPT_RANGE
  114. CURLOPT_REDIR_PROTOCOLS_STR
  115. CURLOPT_REFERER
  116. CURLOPT_REQUEST_TARGET
  117. CURLOPT_RTSP_SESSION_UID
  118. CURLOPT_RTSP_STREAM_URI
  119. CURLOPT_RTSP_TRANSPORT
  120. CURLOPT_SASL_AUTHZID
  121. CURLOPT_SERVICE_NAME
  122. CURLOPT_SOCKS5_GSSAPI_SERVICE
  123. CURLOPT_SSH_HOST_PUBLIC_KEY_MD5
  124. CURLOPT_SSH_HOST_PUBLIC_KEY_SHA256
  125. CURLOPT_SSH_KNOWNHOSTS
  126. CURLOPT_SSH_PRIVATE_KEYFILE
  127. CURLOPT_SSH_PUBLIC_KEYFILE
  128. CURLOPT_SSLCERT
  129. CURLOPT_SSLCERTTYPE
  130. CURLOPT_SSLENGINE
  131. CURLOPT_SSLKEY
  132. CURLOPT_SSLKEYTYPE
  133. CURLOPT_SSL_CIPHER_LIST
  134. CURLOPT_TLS13_CIPHERS
  135. CURLOPT_TLSAUTH_PASSWORD
  136. CURLOPT_TLSAUTH_TYPE
  137. CURLOPT_TLSAUTH_USERNAME
  138. CURLOPT_UNIX_SOCKET_PATH
  139. CURLOPT_URL
  140. CURLOPT_USERAGENT
  141. CURLOPT_USERNAME
  142. CURLOPT_USERPWD
  143. CURLOPT_XOAUTH2_BEARER
  144. All blob options are also supported.
  145. In all other cases, it ignores the ccsid parameter and behaves as
  146. curl_easy_setopt().
  147. Note that CURLOPT_ERRORBUFFER is not in the list above, since it gives the
  148. address of an (empty) character buffer, not the address of a string.
  149. CURLOPT_POSTFIELDS stores the address of static binary data (of type void *)
  150. and thus is not converted. If CURLOPT_COPYPOSTFIELDS is issued after
  151. CURLOPT_POSTFIELDSIZE != -1, the data size is adjusted according to the
  152. CCSID conversion result length.
  153. _ curl_formadd_ccsid()
  154. In the variable argument list, string pointers should be followed by a (long)
  155. CCSID for the following options:
  156. CURLFORM_FILENAME
  157. CURLFORM_CONTENTTYPE
  158. CURLFORM_BUFFER
  159. CURLFORM_FILE
  160. CURLFORM_FILECONTENT
  161. CURLFORM_COPYCONTENTS
  162. CURLFORM_COPYNAME
  163. CURLFORM_PTRNAME
  164. If taken from an argument array, an additional array entry must follow each
  165. entry containing one of the above option. This additional entry holds the CCSID
  166. in its value field, and the option field is meaningless.
  167. It is not possible to have a string pointer and its CCSID across a function
  168. parameter/array boundary.
  169. Please note that CURLFORM_PTRCONTENTS and CURLFORM_BUFFERPTR are considered
  170. unconvertible strings and thus are NOT followed by a CCSID.
  171. _ curl_easy_getinfo_ccsid()
  172. The following options are followed by a 'char * *' and a CCSID. Unlike
  173. curl_easy_getinfo(), the value returned in the pointer should be released with
  174. curl_free() after use:
  175. CURLINFO_EFFECTIVE_URL
  176. CURLINFO_CONTENT_TYPE
  177. CURLINFO_FTP_ENTRY_PATH
  178. CURLINFO_REDIRECT_URL
  179. CURLINFO_REFERER
  180. CURLINFO_PRIMARY_IP
  181. CURLINFO_RTSP_SESSION_ID
  182. CURLINFO_LOCAL_IP
  183. CURLINFO_SCHEME
  184. Likewise, the following options are followed by a struct curl_slist * * and a
  185. CCSID.
  186. CURLINFO_SSL_ENGINES
  187. CURLINFO_COOKIELIST
  188. Lists returned should be released with curl_slist_free_all() after use.
  189. Option CURLINFO_CERTINFO is followed by a struct curl_certinfo * * and a
  190. CCSID. Returned structures should be freed with curl_certinfo_free_all()
  191. after use.
  192. Other options are processed like in curl_easy_getinfo().
  193. _ curl_easy_strerror_ccsid(), curl_multi_strerror_ccsid(),
  194. curl_share_strerror_ccsid() and curl_url_strerror_ccsid() work as their
  195. non-ccsid version and return a string encoded in the additional ccsid
  196. parameter. These strings belong to libcurl and may not be freed by the caller.
  197. A subsequent call to the same procedure in the same thread invalidates the
  198. previous result.
  199. _ curl_pushheader_bynum_cssid() and curl_pushheader_byname_ccsid()
  200. Although the prototypes are self-explanatory, the returned string pointer
  201. should be released with curl_free() after use, as opposite to the non-ccsid
  202. versions of these procedures.
  203. Please note that HTTP2 is not (yet) implemented on OS/400, thus these
  204. functions will always return NULL.
  205. _ curl_easy_option_by_name_ccsid() returns a pointer to an untranslated option
  206. metadata structure. As each curl_easyoption structure holds the option name in
  207. ASCII, the curl_easy_option_get_name_ccsid() function allows getting it in any
  208. supported ccsid. However the caller should release the returned pointer with
  209. curl_free() after use.
  210. _ curl_easy_header_ccsid() works as its non-CCSID counterpart but requires an
  211. additional ccsid parameter specifying the name parameter encoding. The output
  212. hout parameter is kept in libcurl's encoding and should not be altered.
  213. _ curl_from_ccsid() and curl_to_ccsid() are string encoding conversion
  214. functions between ASCII (latin1) and the given CCSID. The first parameter is
  215. the source string, the second is the CCSID and the returned value is a pointer
  216. to the dynamically allocated string. These functions do not impact on Curl's
  217. behavior and are only provided for user convenience. After use, returned values
  218. must be released with curl_free().
  219. Standard compilation environment does support neither autotools nor make;
  220. in fact, very few common utilities are available. As a consequence, the
  221. config-os400.h has been coded manually and the compilation scripts are
  222. a set of shell scripts stored in subdirectory packages/OS400.
  223. The "curl" command and the test environment are currently not supported on
  224. OS/400.
  225. Protocols currently implemented on OS/400:
  226. _ DICT
  227. _ FILE
  228. _ FTP
  229. _ FTPS
  230. _ FTP with secure transmission
  231. _ GOPHER
  232. _ HTTP
  233. _ HTTPS
  234. _ IMAP
  235. _ IMAPS
  236. _ IMAP with secure transmission
  237. _ LDAP
  238. _ POP3
  239. _ POP3S
  240. _ POP3 with secure transmission
  241. _ RTSP
  242. _ SCP if libssh2 is enabled
  243. _ SFTP if libssh2 is enabled
  244. _ SMTP
  245. _ SMTPS
  246. _ SMTP with secure transmission
  247. _ TELNET
  248. _ TFTP
  249. Compiling on OS/400:
  250. These instructions targets people who knows about OS/400, compiling, IFS and
  251. archive extraction. Do not ask questions about these subjects if you're not
  252. familiar with.
  253. _ As a prerequisite, QADRT development environment must be installed.
  254. For more information on downloading and installing the QADRT development kit,
  255. please see https://www.ibm.com/support/pages/node/6258183
  256. _ If data compression has to be supported, ZLIB development environment must
  257. be installed.
  258. _ Likewise, if SCP and SFTP protocols have to be compiled in, LIBSSH2
  259. developent environment must be installed.
  260. _ Install the curl source directory in IFS. Do NOT install it in the
  261. installation target directory (which defaults to /curl).
  262. _ Enter Qshell (QSH, not PASE)
  263. _ Change current directory to the curl installation directory
  264. _ Change current directory to ./packages/OS400
  265. _ Edit file iniscript.sh. You may want to change tunable configuration
  266. parameters, like debug info generation, optimization level, listing option,
  267. target library, ZLIB/LIBSSH2 availability and location, etc.
  268. _ Copy any file in the current directory to makelog (i.e.:
  269. cp initscript.sh makelog): this is intended to create the makelog file with
  270. an ASCII CCSID!
  271. _ Enter the command "sh makefile.sh > makelog 2>&1"
  272. _ Examine the makelog file to check for compilation errors. CZM0383 warnings on
  273. C or system standard API come from QADRT inlining and can safely be ignored.
  274. Leaving file initscript.sh unchanged, this will produce the following OS/400
  275. objects:
  276. _ Library CURL. All other objects will be stored in this library.
  277. _ Modules for all libcurl units.
  278. _ Binding directory CURL_A, to be used at calling program link time for
  279. statically binding the modules (specify BNDSRVPGM(QADRTTS QGLDCLNT QGLDBRDR)
  280. when creating a program using CURL_A).
  281. _ Service program CURL.<soname>, where <soname> is extracted from the
  282. lib/Makefile.am VERSION variable. To be used at calling program run-time
  283. when this program has dynamically bound curl at link time.
  284. _ Binding directory CURL. To be used to dynamically bind libcurl when linking a
  285. calling program.
  286. _ Source file H. It contains all the include members needed to compile a C/C++
  287. module using libcurl, and an ILE/RPG /copy member for support in this
  288. language.
  289. _ Standard C/C++ libcurl include members in file H.
  290. _ CCSIDCURL member in file H. This defines the non-standard EBCDIC wrappers for
  291. C and C++.
  292. _ CURL.INC member in file H. This defines everything needed by an ILE/RPG
  293. program using libcurl.
  294. _ LIBxxx modules and programs. Although the test environment is not supported
  295. on OS/400, the libcurl test programs are compiled for manual tests.
  296. _ IFS directory /curl/include/curl containing the C header files for IFS source
  297. C/C++ compilation and curl.inc.rpgle for IFS source ILE/RPG compilation.
  298. Special programming consideration:
  299. QADRT being used, the following points must be considered:
  300. _ If static binding is used, service program QADRTTS must be linked too.
  301. _ The EBCDIC CCSID used by QADRT is 37 by default, NOT THE JOB'S CCSID. If
  302. another EBCDIC CCSID is required, it must be set via a locale through a call
  303. to setlocale_a (QADRT's setlocale() ASCII wrapper) with category LC_ALL or
  304. LC_CTYPE, or by setting environment variable QADRT_ENV_LOCALE to the locale
  305. object path before executing the program.
  306. _ Do not use original source include files unless you know what you are doing.
  307. Use the installed members instead (in /QSYS.LIB/CURL.LIB/H.FILE and
  308. /curl/include/curl).
  309. ILE/RPG support:
  310. Since most of the ILE OS/400 programmers use ILE/RPG exclusively, a
  311. definition /INCLUDE member is provided for this language. To include all
  312. libcurl definitions in an ILE/RPG module, line
  313. h bnddir('CURL/CURL')
  314. must figure in the program header, and line
  315. d/include curl/h,curl.inc
  316. in the global data section of the module's source code.
  317. No vararg procedure support exists in ILE/RPG: for this reason, the following
  318. considerations apply:
  319. _ Procedures curl_easy_setopt_long(), curl_easy_setopt_object(),
  320. curl_easy_setopt_function(), curl_easy_setopt_offset() and
  321. curl_easy_setopt_blob() are all alias prototypes to curl_easy_setopt(), but
  322. with different parameter lists.
  323. _ Procedures curl_easy_getinfo_string(), curl_easy_getinfo_long(),
  324. curl_easy_getinfo_double(), curl_easy_getinfo_slist(),
  325. curl_easy_getinfo_ptr(), curl_easy_getinfo_socket() and
  326. curl_easy_getinfo_off_t() are all alias prototypes to curl_easy_getinfo(),
  327. but with different parameter lists.
  328. _ Procedures curl_multi_setopt_long(), curl_multi_setopt_object(),
  329. curl_multi_setopt_function() and curl_multi_setopt_offset() are all alias
  330. prototypes to curl_multi_setopt(), but with different parameter lists.
  331. _ Procedures curl_share_setopt_int(), curl_share_setopt_ptr() and
  332. curl_share_setopt_proc() are all alias prototypes to curl_share_setopt,
  333. but with different parameter lists.
  334. _ Procedure curl_easy_setopt_blob_ccsid() is an alias of
  335. curl_easy_setopt_ccsid() supporting blob encoding conversion.
  336. _ The prototype of procedure curl_formadd() allows specifying a pointer option
  337. and the CURLFORM_END option. This makes possible to use an option array
  338. without any additional definition. If some specific incompatible argument
  339. list is used in the ILE/RPG program, the latter must define a specialised
  340. alias. The same applies to curl_formadd_ccsid() too.
  341. _ Since V7R4M0, procedure overloading is used to emulate limited "vararg-like"
  342. definitions of curl_easy_setopt(), curl_multi_setopt(), curl_share_setopt()
  343. and curl_easy_getinfo(). Blob and CCSID alternatives are NOT included in
  344. overloading.
  345. Since RPG cannot cast a long to a pointer, procedure curl_form_long_value()
  346. is provided for that purpose: this allows storing a long value in the
  347. curl_forms array. Please note the form API is deprecated and the MIME API
  348. should be used instead.