Blame os400/README400

Packit Service a31ea6
Packit Service a31ea6
Implementation notes:
Packit Service a31ea6
Packit Service a31ea6
  This is a true OS/400 implementation, not a PASE implementation (for PASE,
Packit Service a31ea6
use an AIX implementation).
Packit Service a31ea6
Packit Service a31ea6
  The biggest problem with OS/400 is EBCDIC. The current libxml2 implementation
Packit Service a31ea6
uses UTF-8 internally. To ease encoding conversion between the calling
Packit Service a31ea6
applications and libxml2, supplementary "convert and latch" functions are
Packit Service a31ea6
provided (See below). To bind the EBCDIC OS/400 system calls and libxml2,
Packit Service a31ea6
an ASCII run-time environment (QADRT) has been used and wrapper functions have
Packit Service a31ea6
been designed.
Packit Service a31ea6
Packit Service a31ea6
Other problems are:
Packit Service a31ea6
- Source code line length: to be stored in DB2 members, source files may not
Packit Service a31ea6
  have lines longer than 100 characters. Some header and documentation files
Packit Service a31ea6
  have been modified accordingly.
Packit Service a31ea6
- va_list dereferencing: the OS/400 implementation of va_list type is an array
Packit Service a31ea6
  but the compiler forbids explicit array dereferencing. Source files have
Packit Service a31ea6
  been updated accordingly.
Packit Service a31ea6
- Depending on the compilation/execution environment, it is possible that
Packit Service a31ea6
  stdin/stdout/stderr are not associated with a file descriptor; as a side
Packit Service a31ea6
  effect, open() may return a file descriptor value 0, 1 or 2 that is NOT
Packit Service a31ea6
  a C standard file. Thus using such a number may be inaccurate.
Packit Service a31ea6
- iconv_open() arguments: OS/400 uses non-standard encoding names and does not
Packit Service a31ea6
  support standard names. For this reason, a name wrapper has been designed.
Packit Service a31ea6
- dlopen() (support for xmodule): the function and its corollaries are not
Packit Service a31ea6
  provided by the OS/400 library. However a local implementation is provided.
Packit Service a31ea6
Packit Service a31ea6
Packit Service a31ea6
Compiling on OS/400:
Packit Service a31ea6
Packit Service a31ea6
_ As a prerequisite, QADRT development environment must be installed.
Packit Service a31ea6
_ Install the libxml2 source directory in IFS.
Packit Service a31ea6
_ Enter shell (QSH)
Packit Service a31ea6
_ Change current directory to the libxml2 installation directory
Packit Service a31ea6
_ Change current directory to ./os400
Packit Service a31ea6
_ Edit file iniscript.sh. You may want to change tunable configuration
Packit Service a31ea6
  parameters, like debug info generation, optimisation level, listing option,
Packit Service a31ea6
  target library, zlib availability, etc.
Packit Service a31ea6
_ Copy any file in the current directory to makelog (i.e.:
Packit Service a31ea6
  cp initscript.sh makelog): this is intended to create the makelog file with
Packit Service a31ea6
  an ASCII CCSID!
Packit Service a31ea6
_ Enter the command "sh make.sh >makelog 2>&1'
Packit Service a31ea6
_ Examine the makelog file to check for compilation errors.
Packit Service a31ea6
Packit Service a31ea6
  Leaving file initscript.sh unchanged, this will produce the following
Packit Service a31ea6
OS/400 objects:
Packit Service a31ea6
_ Library LIBXML2. All other objects will be stored in this library.
Packit Service a31ea6
_ Modules for all libxml2 units, with full debug info and no code optimization.
Packit Service a31ea6
_ Binding directory LIBXML2_A, to be used at calling program link time for
Packit Service a31ea6
  statically binding the modules (specify BNDSRVPGM(QADRTTS QGLDCLNT QGLDBRDR)
Packit Service a31ea6
  when creating a program using LIBXML2_A).
Packit Service a31ea6
_ Service program LIBXML2. To be used at calling program run-time
Packit Service a31ea6
  when this program has dynamically bound libxml2 at link time.
Packit Service a31ea6
_ Binding directory LIBXML2. To be used to dynamically bind libxml2 when
Packit Service a31ea6
  linking a calling program.
Packit Service a31ea6
_ Source file LIBXML. It contains all the header members needed to compile a
Packit Service a31ea6
  C/C++ module using libxml2.
Packit Service a31ea6
_ Standard and additional C/C++ libxml2 header members (possibly renamed) in
Packit Service a31ea6
  file LIBXML.
Packit Service a31ea6
_ IFS directory /libxml2 with subdirectory include/libxml containing all
Packit Service a31ea6
  C/C++ header files for IFS-based compilation.
Packit Service a31ea6
_ Source file LIBXMLRPG. It contains all the include members needed to compile a
Packit Service a31ea6
  ILE/RPG module/program using libxml2 (ILE/RPG binding).
Packit Service a31ea6
_ ILE/RPG binding include members (possibly renamed) in file LIBXMLRPG.
Packit Service a31ea6
_ IFS subdirectory /libxml2/include/libxmlrpg containing all ILE/RPG include
Packit Service a31ea6
  files for IFS-based compilation.
Packit Service a31ea6
Packit Service a31ea6
Packit Service a31ea6
Renamed header files in DB2 members:
Packit Service a31ea6
  DB2 member names are limited to 10 characters, thus the following C/C++
Packit Service a31ea6
header members are renamed as:
Packit Service a31ea6
  parserInternals.h     -->     PARSERINTE
Packit Service a31ea6
  schemasInternals.h    -->     SCHEMASINT
Packit Service a31ea6
  xmlautomata.h         -->     XMLAUTOMAT
Packit Service a31ea6
  xmlschemastype.h      -->     SCHMTYPES
Packit Service a31ea6
  xpathInternals.h      -->     XPATHINTER
Packit Service a31ea6
IFS header files are NOT renamed.
Packit Service a31ea6
ILE/RPG headers are processed likewise.
Packit Service a31ea6
Packit Service a31ea6
Packit Service a31ea6
Special programming consideration:
Packit Service a31ea6
Packit Service a31ea6
QADRT being used, the following points must be considered:
Packit Service a31ea6
_ If static binding is used, service program QADRTTS must be linked too.
Packit Service a31ea6
_ The EBCDIC CCSID used by QADRT is 37 by default, NOT THE JOB'S CCSID. If
Packit Service a31ea6
  another EBCDIC CCSID is required, it must be set via a locale through a call
Packit Service a31ea6
  to setlocale_a (QADRT's setlocale() ASCII wrapper) with category LC_ALL or
Packit Service a31ea6
  LC_CTYPE, or by setting environment variable QADRT_ENV_LOCALE to the locale
Packit Service a31ea6
  object path before executing the program.
Packit Service a31ea6
_ Always use *IFSIO or *IFS64IO to compile calling programs.
Packit Service a31ea6
Packit Service a31ea6
Packit Service a31ea6
Packit Service a31ea6
Supplementary (non libxml2 standard) support procedures for OS/400.
Packit Service a31ea6
Packit Service a31ea6
  As cited above, there are some procedures to ease encoding conversion of
Packit Service a31ea6
libxml2 function arguments and results: the mechanism is based on
Packit Service a31ea6
dictionaries. The functions convert a string, latch the result in a dictionary
Packit Service a31ea6
to ensure its persistence and return its address. It is the caller's
Packit Service a31ea6
responsibility to clean the dictionary when it becomes too big or disappears.
Packit Service a31ea6
Packit Service a31ea6
The procedures are:
Packit Service a31ea6
Packit Service a31ea6
#include <libxml/transcode.h>
Packit Service a31ea6
Packit Service a31ea6
const char *  xmlTranscodeResult(const xmlChar * s,
Packit Service a31ea6
                                 const char * encoding,
Packit Service a31ea6
                                 xmlDictPtr * dict,
Packit Service a31ea6
                                 void (*freeproc)(const void *));
Packit Service a31ea6
Packit Service a31ea6
const xmlChar * xmlTranscodeString(const char * s,
Packit Service a31ea6
                                   const char * encoding,
Packit Service a31ea6
                                   xmlDictPtr * dict);
Packit Service a31ea6
Packit Service a31ea6
const xmlChar * xmlTranscodeWString(const char * s,
Packit Service a31ea6
                                    const char * encoding,
Packit Service a31ea6
                                    xmlDictPtr * dict);
Packit Service a31ea6
Packit Service a31ea6
const xmlChar * xmlTranscodeWString(const char * s,
Packit Service a31ea6
                                    const char * encoding,
Packit Service a31ea6
                                    xmlDictPtr * dict);
Packit Service a31ea6
Packit Service a31ea6
where:
Packit Service a31ea6
s               is the string to translate.
Packit Service a31ea6
encoding        is the alternate character encoding. If null, the current job's
Packit Service a31ea6
                encoding (CCSID) is used.
Packit Service a31ea6
dict            is the address of the latching directory. If NULL, the procedure
Packit Service a31ea6
                functions as a simple non-latching encoding converter and
Packit Service a31ea6
                its result value should be freed by the caller.
Packit Service a31ea6
freeproc        is a procedure to release the original string, or NULL.
Packit Service a31ea6
Packit Service a31ea6
xmlTranscodeResult()  converts from UTF-8 to the given alternate encoding.
Packit Service a31ea6
xmlTranscodeString()  converts from the given 8-bit encoding to UTF-8 (note that
Packit Service a31ea6
                      UTF-8 itself is considered as a 8-bit encoding).
Packit Service a31ea6
xmlTranscodeWString() converts from the given 16-bit encoding to UTF-8.
Packit Service a31ea6
xmlTranscodeHString() converts from the given 32-bit encoding to UTF-8.
Packit Service a31ea6
Packit Service a31ea6
Packit Service a31ea6
To shorten statements using these functions, shorthands are defined:
Packit Service a31ea6
Packit Service a31ea6
xmlTR for xmlTranscodeResult
Packit Service a31ea6
xmlTS for xmlTranscodeString
Packit Service a31ea6
xmlTW for xmlTranscodeWString
Packit Service a31ea6
xmlTH for xmlTranscodeHstring
Packit Service a31ea6
Packit Service a31ea6
These shorthands may be disabled by defining XML_NO_SHORT_NAMES before
Packit Service a31ea6
libxml/transcode.h inclusion.
Packit Service a31ea6
Packit Service a31ea6
A directory pointer must be preset to NULL before the first call using it to
Packit Service a31ea6
one of the above procedure.
Packit Service a31ea6
Packit Service a31ea6
To release a latching directory, use function
Packit Service a31ea6
Packit Service a31ea6
void          xmlZapDict(xmlDictPtr * dict);
Packit Service a31ea6
Packit Service a31ea6
Packit Service a31ea6
Example:
Packit Service a31ea6
Packit Service a31ea6
#include <libxml/transcode.h>
Packit Service a31ea6
#include <libxml/tree.h>
Packit Service a31ea6
Packit Service a31ea6
xmlDocPtr mySimpleXMLDoc(char * element, char * text)
Packit Service a31ea6
{
Packit Service a31ea6
        xmlDocPtr doc;
Packit Service a31ea6
        xmlNodePtr node;
Packit Service a31ea6
        xmlDictPtr dict = NULL;
Packit Service a31ea6
Packit Service a31ea6
        /* element and text are encoded in the current job's encoding. */
Packit Service a31ea6
Packit Service a31ea6
        doc = xmlNewDoc();
Packit Service a31ea6
        xmlNewTextChild((xmlNodePtr) doc, NULL, xmlTS(element, NULL,
Packit Service a31ea6
                               &dict), xmlTS(text, NULL, &dict));
Packit Service a31ea6
        xmlZapDict(&dict);
Packit Service a31ea6
        return doc;
Packit Service a31ea6
}
Packit Service a31ea6
Packit Service a31ea6
Packit Service a31ea6
Additionally, a formatter into latched/dynamic storage is provided:
Packit Service a31ea6
Packit Service a31ea6
const char *    xmlVasprintf(xmlDictPtr * dict,
Packit Service a31ea6
                             const char * encoding,
Packit Service a31ea6
                             const xmlChar * fmt,
Packit Service a31ea6
                             va_list args);
Packit Service a31ea6
Packit Service a31ea6
Packit Service a31ea6
xmllint and xmlcatalog programs:
Packit Service a31ea6
Packit Service a31ea6
  These programs are fully implemented at the qshell level, with standard
Packit Service a31ea6
command line options. Links to these are installed in sub-directory bin of
Packit Service a31ea6
the IFS installation directory.
Packit Service a31ea6
  CL command interfaces to these programs are also provided with limited
Packit Service a31ea6
support. In particular, interactive mode is not supported and argument count
Packit Service a31ea6
and lengths are limited by the CL command syntax.
Packit Service a31ea6
Packit Service a31ea6
Packit Service a31ea6
ILE/RPG binding:
Packit Service a31ea6
Packit Service a31ea6
  All standard types and procedures are provided. Since ILE/RPG does not
Packit Service a31ea6
support macros, they have not been ported. However some of them are emulated
Packit Service a31ea6
as functions: these are the more useful ones (xmlXPathNodeSetGetLength,
Packit Service a31ea6
xmlXPathNodeSetItem, xmlXPathNodeSetIsEmpty, htmlDefaultSubelement,
Packit Service a31ea6
htmlElementAllowedHereDesc, htmlRequiredAttrs) and the global/threaded
Packit Service a31ea6
variables access macros. These variables can be read with function
Packit Service a31ea6
get_xxx(void), where xxxx is the name of the variable; they may be set by
Packit Service a31ea6
calling function set_xxxx(value), where value is of the same type as the
Packit Service a31ea6
variable.
Packit Service a31ea6
Packit Service a31ea6
  The C va_list is not implemented as such in ILE/RPG. Functions implementing
Packit Service a31ea6
va_list and associated methods are provided:
Packit Service a31ea6
Packit Service a31ea6
      /include "libxmlrpg/xmlstdarg"
Packit Service a31ea6
Packit Service a31ea6
     d xmlVaStart      pr
Packit Service a31ea6
     d  list                               like(xmlVaList)
Packit Service a31ea6
     d  lastargaddr                    *   value
Packit Service a31ea6
     d  lastargsize                  10u 0 value
Packit Service a31ea6
Packit Service a31ea6
     d xmlVaArg        pr
Packit Service a31ea6
     d  list                               like(xmlVaList)
Packit Service a31ea6
     d  dest                           *   value
Packit Service a31ea6
     d  argsize                      10i 0 value
Packit Service a31ea6
Packit Service a31ea6
     d xmlVaEnd        pr
Packit Service a31ea6
     d  list                               like(xmlVaList)