gxluGenStrIDTable — generate StringID table from an OSR

Description

This utility will extract generate and return the StringID table associated with the current OSR for this generator instance. See the usage notes for a description of how to make an OSR current.

Performance Implications

There are no performance implications.

Syntax

int gxluGenStrIDTable(void * oima_p,
                GXLHXSTR ** strid_tbl_p_p,
                int * rc_p,
                int * rsn_p)

Parameters

oima_p
Supplied parameter
Type:
void *

A pointer to an OSR generator Instance Memory Area (OIMA).

strid_tbl_p_p
Supplied and returned parameter
Type:
GXLHXSTR **

A pointer to an area that will receive the address of a table of containing the StringIDs that are generated from the current OSR. See the usage notes below for more details.

rc_p
Returned parameter
Type:
int *

A pointer to an area where the utility stores the return code.

rsn_p
Returned parameter
Type:
int *

A pointer to an area where the utility stores the reason code. The reason code is only relevant if the return code is not XRC_SUCCESS.

All parameters in the parameter list are required.

Return Value:

The value returned by this utility is the length of the StringID table returned to the caller through the strid_tbl_p_p parameter. If StringIDs were not in use when the current OSR was originally generated, the return value will be zero, and the pointer specified by strid_tbl_p will remain unchanged. If there is a problem during the generation of the StringID table, the value returned will be -1. See the usage notes below for more information about this value, and the StringID table returned.

Return and Reason Codes:

Register 15 will contain the return value of this utility (see above). The return and reason code are both set as output parameters. The value of the reason code is undefined when the return code has no associated reasons. Return and reason codes are defined in the header file gxlhxr.h (see gxlhxr.h (GXLYXR) - defines the return codes and reason codes). For reason code descriptions, also see Reason codes listed by value.

Example

#include <stdlib.h>
#include <stdio.h>
#include <gxlhosrg.h>
#include <gxlhxec.h>

void *        oima_p;
unsigned long oima_l;
char          handler_parms[128];
char          osrbuf[OSR_BUFFER_LEN];
int           osrbuf_l;
GXLHXSTR *    strIDTbl_p;
int           strIDTbl_l;
int           osr_l;
int           rc, rsn;

if (oima_p = malloc(GXLHXEC_MIN_OIMA_SIZE))
      { /* oima malloc succeeded   */
      oima_l = GXLHXEC_MIN_OIMA_SIZE;

 gxluInitOSRG(oima_p, oima_l,
         0,
         (void *)handler_parms,
         &rc, &rsn);
    }  /* oima malloc succeeded   */

<acquire the OSR from a persistent location like a file> 

/* Load the OSR to operate on. */                                            
                
if ((oima_p > 0) && (rc == GXLHXRC_SUCCESS))
    {  /* generator initialized */
    gxluLoadOSR(oima_p,
               (void *)osrbuf,
                osrbuf_l,,
                &rc, &rsn);

    if (rc == GXLHXRC_SUCCESS)
       { /* OSR load succeeded   */

       /* Generate the OSR */
       strIDTbl_l = gxluGenSTRIDTable(oima_p,
                          &strIDTbl_p,
                          &rc, &rsn);
 
       if (strIDTbl_l > 0) then
        { /* strID table generated   */

   <write the StringID table out to a persistent>
   <repository like a file or a database so that>
   <it can be used later when parsing a document>
 
           ...
           }      /* strID table generated  */     
       ...
       }  /* OSR load succeeded      */
    
      ...
      } /* generator initialized */ 

Usage notes

The StringID table is generated from the OSR that has been made current through either a gxluGenOSR or a gxluLoadOSR request. The actual length of the StringID table is calculated during table generation, and cannot be known ahead of time. For this reason, the gxluGenStrIDTable service will return the address and length of the generated table on success. The table remains allocated for the duration of the OSR generator instance, and gets freed when the instance is terminated. The caller may use or copy the StringID table to another location as long as the instance is active. Referencing the StringID table after the generator instance has been terminated may result in unpredictable results.

StringID tables may be generated from OSRs that were created either with or without StringIDs. If no StringIDs were used when the OSR was originally generated, this service will assign the StringID values to return in the table. Callers who wish to control the values of StringIDs must use the StringID handler interface at OSR generation time.

The format of the StringID table that the OSR generator creates is defined by the gxlhxstr.h header file. See the definition of this header file below for more details.