Example: ILE C/400 Program for exit point QIBM_QZDA_SQL1

The following ILE C/400® program will reject any UPDATE request for user GUEST. It can be used as a shell for developing exit programs tailored for your operating environment.

/*--------------------------------------------------------------------------
 *                @@ss1s@@ Servers - Sample Exit Program
 *
 *    Exit Point Name         : QIBM_QZDA_SQL1
 *
 *    Description             : The following ILE C/400 program will
 *                              reject any UPDATE request for user GUEST.
 *                              It can be used as a shell for developing
 *                              exit programs tailored for your
 *                              operating environment.
 *
 *    Input                   : A 1-byte return code value
 *                                 X'F0' server rejects the request
 *                                 anything else server allows the request
 *                              Structure containing information about the
 *                                request.  The format used by this program
 *                                is ZDAQ0100.
 *------------------------------------------------------------------------*/
/*------------------------------------------------------------------------
 *     Includes
 *------------------------------------------------------------------------*/
#include <string.h>                 /* string functions                   */
#include <stdio.h>                  /* standard IO functions              */
#include <ctype.h>                  /* type conversion functions          */
/*========================================================================
 *    Start of mainline executable code
 *========================================================================*/
main(int argc, char *argv[])
{
    long i;
    _Packed struct zdaq0100 {
        char name[10];
        char servid[10];
        char fmtid[8];
        long funcid;
        char stmtname[18];
        char cursname[18];
        char prepopt[2];
        char opnattr[2];
        char pkgname[10];
        char pkglib[10];
        short drdaind;
        char commitf;
        char stmttxt[512];
    } *sptr, stx;

/*------------------------------------------------------------------------
   ------------------------------------------------------------------------*/
    /* initialize return variable to indicate ok status                   */
    strncpy(argv[1],"1",1);
 
    /**********************************************************************/
    /*  Address parameter structure for @@sqll@@ exit program and move local   */
    /*  parameters into local variables.                                  */
    /* (note : this is not necessary to evaluate the arguments passed in). */
    /**********************************************************************/
    sptr = (_Packed struct zdaq0100 *) argv[2];
 
    strncpy(stx.name, sptr->name, 10);
    strncpy(stx.servid, sptr->servid, 10);
    strncpy(stx.fmtid, sptr->fmtid, 8);
    stx.funcid = sptr->funcid;
    strncpy(stx.stmtname, sptr->stmtname, 18);
    strncpy(stx.cursname, sptr->cursname, 18);
    strncpy(stx.opnattr, sptr->opnattr, 2);
    strncpy(stx.prepopt, sptr->prepopt, 2);
    strncpy(stx.pkglib, sptr->pkglib, 10);
    strncpy(stx.pkgname, sptr->pkgname, 10);
    stx.drdaind = sptr->drdaind;
    stx.commitf = sptr->commitf;
    strncpy(stx.stmttxt, sptr->stmttxt, 512);
 
    /**********************************************************************/
    /* check for user GUEST and an UPDATE statement                       */
    /* if found return an error                                           */
    /**********************************************************************/
    if (! (strncmp(stx.name, "GUEST     ", 10)) )
    {
        for (i=0; i<6; i++)
            stx.stmttxt[i] = toupper(stx.stmttxt[i]);
 
        if (! strncmp(stx.stmttxt, "UPDATE", 6) )
            /* Force error out of  @@sqll@@ user exit pgm                      */
            strncpy(argv[1], "0", 1);
        else;
    }
    return;
}  /* End of mainline executable code                                     */

/*------------------------------------------------------------------------
   ------------------------------------------------------------------------*/

    /* initialize return variable to indicate ok status                   */
    strncpy(argv[1],"1",1);
 
    /**********************************************************************/
    /*  Address parameter structure for @@sqll@@ exit program and move local   */
    /*  parameters into local variables.                                  */
    /* (note : this is not necessary to evaluate the arguments passed in). */
    /**********************************************************************/
    sptr = (_Packed struct zdaq0100 *) argv[2];
 
    strncpy(stx.name, sptr->name, 10);
    strncpy(stx.servid, sptr->servid, 10);
    strncpy(stx.fmtid, sptr->fmtid, 8);
    stx.funcid = sptr->funcid;
    strncpy(stx.stmtname, sptr->stmtname, 18);
    strncpy(stx.cursname, sptr->cursname, 18);
    strncpy(stx.opnattr, sptr->opnattr, 2);
    strncpy(stx.prepopt, sptr->prepopt, 2);
    strncpy(stx.pkglib, sptr->pkglib, 10);
    strncpy(stx.pkgname, sptr->pkgname, 10);
    stx.drdaind = sptr->drdaind;
    stx.commitf = sptr->commitf;
    strncpy(stx.stmttxt, sptr->stmttxt, 512);
 
    /**********************************************************************/
    /* check for user GUEST and an UPDATE statement                       */
    /* if found return an error                                           */
    /**********************************************************************/
    if (! (strncmp(stx.name, "GUEST     ", 10)) )
    {
        for (i=0; i<6; i++)
            stx.stmttxt[i] = toupper(stx.stmttxt[i]);
 
        if (! strncmp(stx.stmttxt, "UPDATE", 6) )
            /* Force error out of  @@sqll@@ user exit pgm                      */
            strncpy(argv[1], "0", 1);
        else;
    }
    return;
}  /* End of mainline executable code                                     */