gxluLoadOSR — load an OSR into the OSR generator

Description

This utility is used to load an Optimized Schema Representation into the OSR generator. Once loaded, the OSR may be processed using one of the OSR generator operations.

Performance Implications

There are no performance implications.

Syntax

int gxluLoadOSR(void * oima_p,
                void * osr_p,
                int osr_l,
                int *  rc_p,
                int * rsn_p)

Parameters

oima_p
Supplied parameter
Type:
void *

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

osr_p
Supplied parameter
Type:
void *

A pointer to a buffer containing an OSR.

osr_l
Supplied parameter
Type:
int

The length of a buffer containing an OSR.

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 service is return code (see below).

Return and Reason Codes:

On return from a call to this utility, register 15 will contain the return code. The return and reason code are both also 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;
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 an OSR to be processed.    */
                
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   */

       <process the loaded OSR>
      
         ...
       }  /* OSR load succeeded   */
    
      ...
      } /* generator initialized */ 

Usage notes

Use this utility when you need to query an OSR that has already been created from one or more human-readable schemas. This is useful, for instance, when a caller needs access to a StringID table from an existing OSR. This allows the StringID table to be used by the validating parser at parse time.