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