home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a524 / 33.ddi / lib / iapxit.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-03-04  |  3.2 KB  |  93 lines

  1. #ifdef RCSID
  2. static char *RCSid = 
  3.    "$Header: iapxit.c,v 6.1 88/11/18 16:08:01 lchan Exp $ iapxit.c Copyr (c) 1986 Oracle";
  4. #endif /* RCSID */
  5.  
  6. #include <stdio.h>
  7. #include "usrxit.h"
  8. #include <string.h>
  9.  
  10. extf    int    CHKVAL();
  11.  
  12. /* *************************************************************************
  13.  
  14. CHKVAL is called with the following syntax for the parameter string p:
  15.  
  16. CHKVAL fieldname  value1  value2  ...  valueN
  17.  
  18. Currently, only upper case, string values are able to be processed.
  19. CHKVAL will return FAILURE if the field matches one of the values in the list,
  20. otherwise it will return SUCCESS.
  21.  
  22. The User Exit Table, iapxtb[], is defined in iapxtb.c, which in turn is
  23. usually generated by pgm "genxtb".  See the "Installation and User's Guide"
  24. for details.
  25.  
  26. *************************************************************************** */
  27.  
  28. #define    MAXARGS    128
  29. #define ARBUFSIZ    512
  30.  
  31. int     CHKVAL(p, paramlen, erm, ermlen, query)
  32. register    char       *p;             /* Parameter string */
  33.         int           *paramlen;         /* Ptr to param string length */
  34.         char       *erm;             /* Error message if doesnt match */
  35.         int           *ermlen;                  /* Ptr to error message length */
  36.         int           *query;                 /* Ptr to query status flag */
  37.  
  38. {
  39. extf        int     iapprs();         /* IAP command parser */
  40. extf        int     countargs();         /* Puts "words" into an array */
  41. extf        char       *cpystr();         /* Copies one string to another */
  42. extf        char       *upper();         /* Makes a string uppercase */
  43. extf        char       *rblank();         /* Get rid of extra whitespace */
  44. extf        int     strcmp();         /* Compares two strings */
  45. extf        int     exiterr();         /* Display usrxit error */
  46. extd        char       *wordb[];         /* Holds the blank separated */
  47. register    int     listsiz;         /* Number of values */
  48. register    int     i;             /* Temp counter */
  49.         char    iapcmd[128];         /* To construct the GET command */
  50.         char    arbuf[ARBUFSIZ];    /* To hold string that is passed */
  51.  
  52.    rblank( p );                     /* Remove leading, trailing, and
  53.                         and double spaces */
  54.  
  55.    strncpy(arbuf, p, ARBUFSIZ-1 );
  56.    listsiz = countargs( arbuf );             /* get fieldname and value list
  57.                         in wordb[] */
  58.  
  59.    if ( listsiz < 3 )                 /* Check for minimum # of args */
  60.    {
  61.       exiterr( "CHKVAL: Not enough arguments!" );
  62.       return FATAL_ERR;
  63.    }
  64.  
  65.    if ( listsiz >= MAXARGS )             /* Check for maximum # of args */
  66.    {
  67.       exiterr( "CHKVAL: Too many arguments!" );
  68.       return FATAL_ERR;
  69.    }
  70.  
  71. /* NOTE: This method is unsupported.  Use "EXEC IAF GET ..." within a Pro*C */
  72. /* module to obtain this functionality.                        */
  73.  
  74.    cpystr( iapcmd, "GET ", wordb[1],         /* Make GET fieldname string */
  75.            (char *) 0 );         /* Last parameter must be NULL */
  76.  
  77.    if ( iapprs( iapcmd ) )             /* Get field value into iaprval */
  78.       return FATAL_ERR;              /* Fieldname error */
  79.  
  80.    listsiz -= 2;
  81.    for ( i = 2; listsiz--; i++ )         /* Check field value against each
  82.                         value until we have a match
  83.                         or run out of values */
  84.  
  85.       if ( !strcmp( wordb[i], iaprval ) )    /* Value matches? */
  86.      return SUCCESS;             /* Yes, return success code */
  87.    exiterr( erm );                 /* Display error message */
  88.    return FAILURE;                 /* Return failure code */
  89. }
  90.  
  91.  
  92. /* End of example iapxit.c */
  93.