README.OS400 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. $Id$
  2. Implementation notes:
  3. This is a true OS/400 implementation, not a PASE implementation (for PASE,
  4. use AIX implementation).
  5. The biggest problem with OS/400 is EBCDIC. Libcurl implements an internal
  6. conversion mechanism, but it has been designed for computers that have a
  7. single native character set. OS/400 default native character set varies
  8. depending on the country for which it has been localized. And more, a job
  9. may dynamically alter its "native" character set.
  10. Several characters that do not have fixed code in EBCDIC variants are
  11. used in libcurl strings. As a consequence, using the existing conversion
  12. mechanism would have lead in a localized binary library - not portable across
  13. countries.
  14. For this reason, and because libcurl was originally designed for ASCII based
  15. operating systems, the current OS/400 implementation uses ASCII as internal
  16. character set. This has been accomplished using the QADRT library and
  17. include files, a C and system procedures ASCII wrapper library. See IBM QADRT
  18. description for more information.
  19. This then results in libcurl being an ASCII library: any function string
  20. argument is taken/returned in ASCII and a C/C++ calling program built around
  21. QADRT may use libcurl functions as on any other platform.
  22. QADRT does not define ASCII wrappers for all C/system procedures: the
  23. OS/400 configuration header file and an additional module (os400sys.c) define
  24. some more of them, that are used by libcurl and that QADRT left out.
  25. To support all the different variants of EBCDIC, non-standard wrapper
  26. procedures have been added to libcurl on OS/400: they provide an additional
  27. CCSID (numeric Coded Character Set ID specific to OS/400) parameter for each
  28. string argument. String values passed to callback procedures are NOT converted,
  29. so text gathered this way is (probably !) ASCII.
  30. Another OS/400 problem comes from the fact that the last fixed argument of a
  31. vararg procedure may not be of type char, unsigned char, short or unsigned
  32. short. Enums that are internally implemented by the C compiler as one of these
  33. types are also forbidden. Libcurl uses enums as vararg procedure tagfields...
  34. Happily, there is a pragma forcing enums to type "int". The original libcurl
  35. header files are thus altered during build process to use this pragma, in
  36. order to force libcurl enums of being type int (the pragma disposition in use
  37. before inclusion is restored before resuming the including unit compilation).
  38. Three SSL implementations were present in libcurl. Nevertheless, none of them
  39. is available on OS/400. To support SSL on OS/400, a fourth implementation has
  40. been added (qssl.[ch]). There is no way to have different certificate stores
  41. for CAs and for personal/application certificates/key. More, the SSL context
  42. may be defined as an application identifier in the main certificate store,
  43. or as a keyring file. As a consequence, the meaning of some fields have been
  44. slightly altered:
  45. _ The "certificate identifier" is taken from CURLOPT_SSLCERT if defined, else
  46. from CURLOPT_CAINFO.
  47. _ The certificate identifier is then used as an application identifier in the
  48. main certificate store. If successful, this context is used.
  49. _ If the previous step failed, the certificate identifier is used as the file
  50. name of a keyring. CURLOPT_KEYPASSWD is used here as the keyring password.
  51. _ The default ca-bundle (CURLOPT_CAINFO) is set to the main certificate store's
  52. keyring file name: this allows to use the system global CAs by default. (In that
  53. case, the keyring password is safely recovered from the system... IBM dixit!)
  54. Non-standard EBCDIC wrapper prototypes are defined in an additional header
  55. file: ccsidcurl.h. These should be self-explanatory to an OS/400-aware
  56. designer. CCSID 0 can be used to select the current job's CCSID.
  57. Wrapper procedures with variable arguments are described below:
  58. _ curl_easy_setopt_ccsid()
  59. Variable arguments are a string pointer and a CCSID (unsigned int) for
  60. options:
  61. CURLOPT_CAINFO
  62. CURLOPT_CAPATH
  63. CURLOPT_COOKIE
  64. CURLOPT_COOKIEFILE
  65. CURLOPT_COOKIEJAR
  66. CURLOPT_COOKIELIST
  67. CURLOPT_CUSTOMREQUEST
  68. CURLOPT_EGDSOCKET
  69. CURLOPT_ENCODING
  70. CURLOPT_FTPPORT
  71. CURLOPT_FTP_ACCOUNT
  72. CURLOPT_FTP_ALTERNATIVE_TO_USER
  73. CURLOPT_INTERFACE
  74. CURLOPT_KEYPASSWD
  75. CURLOPT_KRBLEVEL
  76. CURLOPT_NETRC_FILE
  77. CURLOPT_COPYPOSTFIELDS
  78. CURLOPT_PROXY
  79. CURLOPT_PROXYUSERPWD
  80. CURLOPT_RANDOM_FILE
  81. CURLOPT_RANGE
  82. CURLOPT_REFERER
  83. CURLOPT_SSH_PRIVATE_KEYFILE
  84. CURLOPT_SSH_PUBLIC_KEYFILE
  85. CURLOPT_SSLCERT
  86. CURLOPT_SSLCERTTYPE
  87. CURLOPT_SSLENGINE
  88. CURLOPT_SSLKEY
  89. CURLOPT_SSLKEYTYPE
  90. CURLOPT_SSL_CIPHER_LIST
  91. CURLOPT_URL
  92. CURLOPT_USERAGENT
  93. CURLOPT_USERPWD
  94. CURLOPT_SSH_HOST_PUBLIC_KEY_MD5
  95. CURLOPT_CRLFILE
  96. CURLOPT_ISSUERCERT
  97. Else it is the same as for curl_easy_setopt().
  98. Note that CURLOPT_ERRORBUFFER is not in the list above, since it gives the
  99. address of an (empty) character buffer, not the address of a string.
  100. CURLOPT_POSTFIELDS stores the address of static binary data (of type void *) and
  101. thus is not converted. If CURLOPT_COPYPOSTFIELDS is issued after
  102. CURLOPT_POSTFIELDSIZE != -1, the data size is adjusted according to the
  103. CCSID conversion result length.
  104. _ curl_formadd_ccsid()
  105. In the variable argument list, string pointers should be followed by a (long)
  106. CCSID for the following options:
  107. CURLFORM_FILENAME
  108. CURLFORM_CONTENTTYPE
  109. CURLFORM_BUFFER
  110. CURLFORM_FILE
  111. CURLFORM_FILECONTENT
  112. CURLFORM_COPYCONTENTS
  113. CURLFORM_COPYNAME
  114. CURLFORM_PTRNAME
  115. If taken from an argument array, an additional array entry must follow each
  116. entry containing one of the above option. This additional entry holds the CCSID
  117. in its value field, and the option field is meaningless.
  118. It is not possible to have a string pointer and its CCSID across a function
  119. parameter/array boundary.
  120. Please note that CURLFORM_PTRCONTENTS and CURLFORM_BUFFERPTR are considered
  121. unconvertible strings and thus are NOT followed by a CCSID.
  122. _ curl_easy_getinfo_ccsid
  123. The following options are followed by a 'char * *' and a CCSID. Unlike
  124. curl_easy_getinfo(), the value returned in the pointer should be freed after
  125. use:
  126. CURLINFO_EFFECTIVE_URL
  127. CURLINFO_CONTENT_TYPE
  128. CURLINFO_FTP_ENTRY_PATH
  129. Other options are processed like in curl_easy_getinfo().
  130. Standard compilation environment does support neither autotools nor make;
  131. in fact, very few common utilities are available. As a consequence, the
  132. config-os400.h has been coded manually and the compilation scripts are
  133. a set of shell scripts stored in subdirectory packages/OS400.
  134. The "curl" command and the test environment are currently not supported on
  135. OS/400.
  136. Protocols currently implemented on OS/400:
  137. _ HTTP
  138. _ HTTPS
  139. _ FTP
  140. _ FTPS
  141. _ FTP with secure transmission.
  142. _ LDAP
  143. _ DICT
  144. _ TELNET
  145. Compiling on OS/400:
  146. These instructions targets people who knows about OS/400, compiling, IFS and
  147. archive extraction. Do not ask questions about these subjects if you're not
  148. familiar with.
  149. _ As a prerequisite, QADRT development environment must be installed.
  150. _ Install the curl source directory in IFS.
  151. _ Enter shell (QSH)
  152. _ Change current directory to the curl installation directory
  153. _ Change current directory to ./packages/OS400
  154. _ Edit file iniscript.sh. You may want to change tunable configuration
  155. parameters, like debug info generation, optimisation level, listing option,
  156. target library, etc.
  157. _ Copy any file in the current directory to makelog (i.e.:
  158. cp initscript.sh makelog): this is intended to create the makelog file with
  159. an ASCII CCSID!
  160. _ Enter the command "sh makefile.sh > makelog 2>&1'
  161. _ Examine the makelog file to check for compilation errors.
  162. Leaving file initscript.sh unchanged, this will produce the following OS/400
  163. objects:
  164. _ Library CURL. All other objects will be stored in this library.
  165. _ Modules for all libcurl units.
  166. _ Binding directory CURL_A, to be used at calling program link time for
  167. statically binding the modules (specify BNDSRVPGM(QADRTTS QGLDCLNT QGLDBRDR)
  168. when creating a program using CURL_A).
  169. _ Service program CURL.<soname>, where <soname> is extracted from the
  170. lib/Makefile.am VERSION variable. To be used at calling program run-time
  171. when this program has dynamically bound curl at link time.
  172. _ Binding directory CURL. To be used to dynamically bind libcurl when linking a
  173. calling program.
  174. _ Source file H. It contains all the include members needed to compile a C/C++
  175. module using libcurl, and an ILE/RPG /copy member for support in this
  176. language.
  177. _ Standard C/C++ libcurl include members in file H.
  178. _ CCSIDCURL member in file H. This defines the non-standard EBCDIC wrappers for
  179. C and C++.
  180. _ CURL.INC member in file H. This defines everything needed by an ILE/RPG
  181. program using libcurl.
  182. _ LIBxxx modules and programs. Although the test environment is not supported
  183. on OS/400, the libcurl test programs are compiled for manual tests.
  184. Special programming consideration:
  185. QADRT being used, the following points must be considered:
  186. _ If static binding is used, service program QADRTTS must be linked too.
  187. _ The EBCDIC CCSID used by QADRT is 37 by default, NOT THE JOB'S CCSID. If
  188. another EBCDIC CCSID is required, it must be set via a locale through a call
  189. to setlocale_a (QADRT's setlocale() ASCII wrapper) with category LC_ALL or
  190. LC_CTYPE, or by setting environment variable QADRT_ENV_LOCALE to the locale
  191. object path before executing the program.
  192. _ Do not use original source include files unless you know what you are doing.
  193. Use the installed members instead (in /QSYS.LIB/CURL.LIB/H.FILE).
  194. ILE/RPG support:
  195. Since 95% of the OS/400 programmers use ILE/RPG exclusively, a definition
  196. /COPY member is provided for this language. To include all libcurl
  197. definitions in an ILE/RPG module, line
  198. h bnddir('CURL/CURL')
  199. must figure in the program header, and line
  200. d/copy curl/h,curl.inc
  201. in the global data section of the module's source code.
  202. No vararg procedure support exists in ILE/RPG: for this reason, the following
  203. considerations apply:
  204. _ Procedures curl_easy_setopt_long(), curl_easy_setopt_object(),
  205. curl_easy_setopt_function() and curl_easy_setopt_offset() are all alias
  206. prototypes to curl_easy_setopt(), but with different parameter lists.
  207. _ Procedures curl_easy_getinfo_string(), curl_easy_getinfo_long(),
  208. curl_easy_getinfo_double() and curl_easy_getinfo_slist() are all alias
  209. prototypes to curl_easy_getinfo(), but with different parameter lists.
  210. _ Procedures curl_multi_setopt_long(), curl_multi_setopt_object(),
  211. curl_multi_setopt_function() and curl_multi_setopt_offset() are all alias
  212. prototypes to curl_multi_setopt(), but with different parameter lists.
  213. _ The prototype of procedure curl_formadd() allows specifying a pointer option
  214. and the CURLFORM_END option. This makes possible to use an option array
  215. without any additional definition. If some specific incompatible argument
  216. list is used in the ILE/RPG program, the latter must define a specialised
  217. alias. The same applies to curl_formadd_ccsid() too.
  218. Since RPG cannot cast a long to a pointer, procedure curl_form_long_value()
  219. is provided for that purpose: this allows storing a long value in the curl_forms
  220. array.