Example: ILE C/400 user exit program for exit point QIBM_QZDA_INIT

The following ILE C/400® program handles ODBC security by rejecting requests from certain users. 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_INIT
 *
 *    Description             : The following ILE C/400 program handles
 *                              ODBC security by rejecting requests from
 *                              certain users.
 *                              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 ZDAI0100.
 *------------------------------------------------------------------------*/
/*------------------------------------------------------------------------
 *     Includes
 *------------------------------------------------------------------------*/
#include <string.h>                 /* string functions                   */
/*------------------------------------------------------------------------
 *    User Types
 *------------------------------------------------------------------------*/
typedef struct {             /* Exit Point QIBM_QZDA_INIT format ZDAI0100 */
    char User_profile_name[10];     /* Name of user profile calling server*/
    char Server_identifier[10];     /* database server value (*SQL)       */
    char Exit_format_name[8];       /* User exit format name (ZDAI0100)   */
    long Requested_function;        /* function being preformed (0)       */
} ZDAI0100_fmt_t;

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

/*========================================================================
 *    Start of mainline executable code
 *========================================================================*/
int main (int argc, char *argv[])
{
    ZDAI0100_fmt_t input;           /* input format record                */
 
    /* copy input parm into structure                                     */
    memcpy(&input, (ZDAI0100_fmt_t *)argv[2], 32);
 
    if /* if user name is GUEST                                           */
        ( memcmp(input.User_profile_name, "GUEST     ", 10)==0 )
    {
        /* set return code to reject the request.                         */
        memcpy( argv[1], "0", 1);
    }
    else /* else user is someone else                                     */
    {
        /* set return code to allow the request.                          */
        memcpy( argv[1], "1", 1);
    }
}  /* End of mainline executable code                                     */