README.OS400 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. Implementation notes:
  2. This is a true OS/400 implementation, not a PASE implementation (for PASE,
  3. 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. String values passed to callback procedures are NOT converted,
  28. 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. Two SSL implementations are available to libcurl on OS/400: QsoSSL which is
  38. obsolescent, does not support asynchronous I/O and only allows a single SSL
  39. context within a job, and GSKit that does not suffer from these limitations
  40. and is able to provide some information about the server certificate.
  41. Both implementations of SSL are working on "certificate stores" or keyrings,
  42. rather than individual certificate/key files. Certificate stores, as weel as
  43. "certificate labels" are managed by external IBM-defined applications.
  44. There are two ways to specify an SSL context:
  45. - By an application identifier.
  46. - By a keyring file pathname and (optionally) certificate label.
  47. To identify an SSL context by application identifier, use option
  48. SETOPT_SSLCERT to specify the application identifier.
  49. To address an SSL context by keyring and certificate label, use CURLOPT_CAINFO
  50. to set-up the keyring pathname, CURLOPT_SSLCERT to define the certificate label
  51. (omitting it will cause the default certificate in keyring to be used) and
  52. CURLOPT_KEYPASSWD to give the keyring password. If SSL is used without
  53. defining any of these options, the default (i.e.: system) keyring is used for
  54. server certificate validation.
  55. Non-standard EBCDIC wrapper prototypes are defined in an additional header
  56. file: ccsidcurl.h. These should be self-explanatory to an OS/400-aware
  57. designer. CCSID 0 can be used to select the current job's CCSID.
  58. Wrapper procedures with variable arguments are described below:
  59. _ curl_easy_setopt_ccsid()
  60. Variable arguments are a string pointer and a CCSID (unsigned int) for
  61. options:
  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_DNS_SERVERS
  72. CURLOPT_EGDSOCKET
  73. CURLOPT_ENCODING
  74. CURLOPT_FTP_ACCOUNT
  75. CURLOPT_FTP_ALTERNATIVE_TO_USER
  76. CURLOPT_FTPPORT
  77. CURLOPT_INTERFACE
  78. CURLOPT_ISSUERCERT
  79. CURLOPT_KEYPASSWD
  80. CURLOPT_KRBLEVEL
  81. CURLOPT_LOGIN_OPTIONS
  82. CURLOPT_MAIL_FROM
  83. CURLOPT_MAIL_AUTH
  84. CURLOPT_NETRC_FILE
  85. CURLOPT_NOPROXY
  86. CURLOPT_PASSWORD
  87. CURLOPT_PROXY
  88. CURLOPT_PROXYPASSWORD
  89. CURLOPT_PROXYUSERNAME
  90. CURLOPT_PROXYUSERPWD
  91. CURLOPT_RANDOM_FILE
  92. CURLOPT_RANGE
  93. CURLOPT_REFERER
  94. CURLOPT_RTSP_SESSION_UID
  95. CURLOPT_RTSP_STREAM_URI
  96. CURLOPT_RTSP_TRANSPORT
  97. CURLOPT_SOCKS5_GSSAPI_SERVICE
  98. CURLOPT_SSH_HOST_PUBLIC_KEY_MD5 Note: SSH not available on OS400.
  99. CURLOPT_SSH_KNOWNHOSTS Note: SSH not available on OS400.
  100. CURLOPT_SSH_PRIVATE_KEYFILE Note: SSH not available on OS400.
  101. CURLOPT_SSH_PUBLIC_KEYFILE Note: SSH not available on OS400.
  102. CURLOPT_SSLCERT
  103. CURLOPT_SSLCERTTYPE
  104. CURLOPT_SSL_CIPHER_LIST
  105. CURLOPT_SSLENGINE
  106. CURLOPT_SSLKEY
  107. CURLOPT_SSLKEYTYPE
  108. CURLOPT_TLSAUTH_PASSWORD
  109. CURLOPT_TLSAUTH_TYPE
  110. CURLOPT_TLSAUTH_USERNAME
  111. CURLOPT_URL
  112. CURLOPT_USERAGENT
  113. CURLOPT_USERNAME
  114. CURLOPT_USERPWD
  115. CURLOPT_XOAUTH2_BEARER
  116. Else it is the same as for curl_easy_setopt().
  117. Note that CURLOPT_ERRORBUFFER is not in the list above, since it gives the
  118. address of an (empty) character buffer, not the address of a string.
  119. CURLOPT_POSTFIELDS stores the address of static binary data (of type void *) and
  120. thus is not converted. If CURLOPT_COPYPOSTFIELDS is issued after
  121. CURLOPT_POSTFIELDSIZE != -1, the data size is adjusted according to the
  122. CCSID conversion result length.
  123. _ curl_formadd_ccsid()
  124. In the variable argument list, string pointers should be followed by a (long)
  125. CCSID for the following options:
  126. CURLFORM_FILENAME
  127. CURLFORM_CONTENTTYPE
  128. CURLFORM_BUFFER
  129. CURLFORM_FILE
  130. CURLFORM_FILECONTENT
  131. CURLFORM_COPYCONTENTS
  132. CURLFORM_COPYNAME
  133. CURLFORM_PTRNAME
  134. If taken from an argument array, an additional array entry must follow each
  135. entry containing one of the above option. This additional entry holds the CCSID
  136. in its value field, and the option field is meaningless.
  137. It is not possible to have a string pointer and its CCSID across a function
  138. parameter/array boundary.
  139. Please note that CURLFORM_PTRCONTENTS and CURLFORM_BUFFERPTR are considered
  140. unconvertible strings and thus are NOT followed by a CCSID.
  141. _ curl_easy_getinfo_ccsid
  142. The following options are followed by a 'char * *' and a CCSID. Unlike
  143. curl_easy_getinfo(), the value returned in the pointer should be freed after
  144. use:
  145. CURLINFO_EFFECTIVE_URL
  146. CURLINFO_CONTENT_TYPE
  147. CURLINFO_FTP_ENTRY_PATH
  148. CURLINFO_REDIRECT_URL
  149. CURLINFO_PRIMARY_IP
  150. CURLINFO_RTSP_SESSION_ID
  151. CURLINFO_LOCAL_IP
  152. Likewise, the following options are followed by a struct curl_slist * * and a
  153. CCSID.
  154. CURLINFO_SSL_ENGINES
  155. CURLINFO_COOKIELIST
  156. Lists returned should be released with curl_slist_free_all() after use.
  157. Option CURLINFO_CERTINFO is followed by a struct curl_certinfo * * and a
  158. CCSID. Returned structures sould be free'ed using curl_certinfo_free_all() after
  159. use.
  160. Other options are processed like in curl_easy_getinfo().
  161. Standard compilation environment does support neither autotools nor make;
  162. in fact, very few common utilities are available. As a consequence, the
  163. config-os400.h has been coded manually and the compilation scripts are
  164. a set of shell scripts stored in subdirectory packages/OS400.
  165. The "curl" command and the test environment are currently not supported on
  166. OS/400.
  167. Protocols currently implemented on OS/400:
  168. _ DICT
  169. _ FILE
  170. _ FTP
  171. _ FTPS
  172. _ FTP with secure transmission
  173. _ GOPHER
  174. _ HTTP
  175. _ HTTPS
  176. _ IMAP
  177. _ IMAPS
  178. _ IMAP with secure transmission
  179. _ LDAP
  180. _ POP3
  181. _ POP3S
  182. _ POP3 with secure transmission
  183. _ RTSP
  184. _ SMTP
  185. _ SMTPS
  186. _ SMTP with secure transmission
  187. _ TELNET
  188. _ TFTP
  189. Compiling on OS/400:
  190. These instructions targets people who knows about OS/400, compiling, IFS and
  191. archive extraction. Do not ask questions about these subjects if you're not
  192. familiar with.
  193. _ As a prerequisite, QADRT development environment must be installed.
  194. _ Install the curl source directory in IFS.
  195. _ Enter shell (QSH)
  196. _ Change current directory to the curl installation directory
  197. - If the SSL backend has to be changed, edit file lib/config-os400.h
  198. accordingly.
  199. _ Change current directory to ./packages/OS400
  200. _ Edit file iniscript.sh. You may want to change tunable configuration
  201. parameters, like debug info generation, optimisation level, listing option,
  202. target library, etc.
  203. _ Copy any file in the current directory to makelog (i.e.:
  204. cp initscript.sh makelog): this is intended to create the makelog file with
  205. an ASCII CCSID!
  206. _ Enter the command "sh makefile.sh > makelog 2>&1'
  207. _ Examine the makelog file to check for compilation errors.
  208. Leaving file initscript.sh unchanged, this will produce the following OS/400
  209. objects:
  210. _ Library CURL. All other objects will be stored in this library.
  211. _ Modules for all libcurl units.
  212. _ Binding directory CURL_A, to be used at calling program link time for
  213. statically binding the modules (specify BNDSRVPGM(QADRTTS QGLDCLNT QGLDBRDR)
  214. when creating a program using CURL_A).
  215. _ Service program CURL.<soname>, where <soname> is extracted from the
  216. lib/Makefile.am VERSION variable. To be used at calling program run-time
  217. when this program has dynamically bound curl at link time.
  218. _ Binding directory CURL. To be used to dynamically bind libcurl when linking a
  219. calling program.
  220. _ Source file H. It contains all the include members needed to compile a C/C++
  221. module using libcurl, and an ILE/RPG /copy member for support in this
  222. language.
  223. _ Standard C/C++ libcurl include members in file H.
  224. _ CCSIDCURL member in file H. This defines the non-standard EBCDIC wrappers for
  225. C and C++.
  226. _ CURL.INC member in file H. This defines everything needed by an ILE/RPG
  227. program using libcurl.
  228. _ LIBxxx modules and programs. Although the test environment is not supported
  229. on OS/400, the libcurl test programs are compiled for manual tests.
  230. Special programming consideration:
  231. QADRT being used, the following points must be considered:
  232. _ If static binding is used, service program QADRTTS must be linked too.
  233. _ The EBCDIC CCSID used by QADRT is 37 by default, NOT THE JOB'S CCSID. If
  234. another EBCDIC CCSID is required, it must be set via a locale through a call
  235. to setlocale_a (QADRT's setlocale() ASCII wrapper) with category LC_ALL or
  236. LC_CTYPE, or by setting environment variable QADRT_ENV_LOCALE to the locale
  237. object path before executing the program.
  238. _ Do not use original source include files unless you know what you are doing.
  239. Use the installed members instead (in /QSYS.LIB/CURL.LIB/H.FILE).
  240. ILE/RPG support:
  241. Since 95% of the OS/400 programmers use ILE/RPG exclusively, a definition
  242. /COPY member is provided for this language. To include all libcurl
  243. definitions in an ILE/RPG module, line
  244. h bnddir('CURL/CURL')
  245. must figure in the program header, and line
  246. d/copy curl/h,curl.inc
  247. in the global data section of the module's source code.
  248. No vararg procedure support exists in ILE/RPG: for this reason, the following
  249. considerations apply:
  250. _ Procedures curl_easy_setopt_long(), curl_easy_setopt_object(),
  251. curl_easy_setopt_function() and curl_easy_setopt_offset() are all alias
  252. prototypes to curl_easy_setopt(), but with different parameter lists.
  253. _ Procedures curl_easy_getinfo_string(), curl_easy_getinfo_long(),
  254. curl_easy_getinfo_double() and curl_easy_getinfo_slist() are all alias
  255. prototypes to curl_easy_getinfo(), but with different parameter lists.
  256. _ Procedures curl_multi_setopt_long(), curl_multi_setopt_object(),
  257. curl_multi_setopt_function() and curl_multi_setopt_offset() are all alias
  258. prototypes to curl_multi_setopt(), but with different parameter lists.
  259. _ The prototype of procedure curl_formadd() allows specifying a pointer option
  260. and the CURLFORM_END option. This makes possible to use an option array
  261. without any additional definition. If some specific incompatible argument
  262. list is used in the ILE/RPG program, the latter must define a specialised
  263. alias. The same applies to curl_formadd_ccsid() too.
  264. Since RPG cannot cast a long to a pointer, procedure curl_form_long_value()
  265. is provided for that purpose: this allows storing a long value in the curl_forms
  266. array.