home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / gened10.zip / GDSTYPES.H < prev    next >
Text File  |  1996-04-03  |  13KB  |  259 lines

  1. /*** $PROLOG(C,INCLUDE) **********************************************/
  2. /*                                                                   */
  3. /*  INCLUDE NAME : GDSTYPES                                          */
  4. /*                                                                   */
  5. /*  DESCRIPTIVE NAME : GDSED types                                   */
  6. /*                                                                   */
  7. /*  STATUS :                                                         */
  8. /*                                                                   */
  9. /*    RELEASE : 1.0.0                                                */
  10. /*    MODIFICATION : 0                                               */
  11. /*    DATE : 930930                                                  */
  12. /*                                                                   */
  13. /*  DESCRIPTION :  GDSED types declarations. This must be included   */
  14. /*                 by User Application Program.                      */
  15. /*                                                                   */
  16. /*  MODULE TYPE : INCLUDE FILE                                       */
  17. /*                                                                   */
  18. /*      SIZE :                                                       */
  19. /*                                                                   */
  20. /*  CHANGE ACTIVITY :                                                */
  21. /*                                                                   */
  22. /*  $INC(GDSTYPES),COMP(GDS),    PROD(GDS)    : MODULE DESCRIPTOR    */
  23. /*                                                                   */
  24. /*  FLAG REASON   RLSE     DATE   ORIGIN  FLAG DESCRIPTOR            */
  25. /*  ---- -------- -------- ------ ------  -------------------------  */
  26. /*  $X0= GDSED    100      930930   RNSL: IMPLICIT FLAG, ORIGINAL    */
  27. /*  $Y1= xxxxxxxx nnn      yymmdd _logo_: _____Description_______    */
  28. /*                                                                   */
  29. /*                                                                   */
  30. /*** $EPROLOG(C,INCLUDE) *********************************************/
  31. /*********************************************************************/
  32. /*  Licensed Materials - Property of IBM                             */
  33. /*                                                                   */
  34. /*  GenE/D version 1.00 - 5648-075                                   */
  35. /*  Copyright (C) International Business Machines Corp., 1993        */
  36. /*  All rights reserved                                              */
  37. /*********************************************************************/
  38.  
  39. /*********************************************************************
  40.  * The following identifies the ASN.1 base types
  41.  *********************************************************************
  42.  */
  43. enum basetypes {
  44.    bas_unknown,                 /*  0 unknown */
  45.    bas_integer,                 /*  1 integer */
  46.    bas_choice,                  /*  2 choice */
  47.    bas_boolean,                 /*  3 boolean */
  48.    bas_null,                    /*  4 null */
  49.    bas_bitstr,                  /*  5 bit string */
  50.    bas_octstr,                  /*  6 octet string */
  51.    bas_seqenum,                 /*  7 sequence{...} */
  52.    bas_seqof,                   /*  8 sequence of ... */
  53.    bas_setenum,                 /*  9 set{...} */
  54.    bas_setof,                   /* 10 set of ... */
  55.    bas_any,                     /* 11 any */
  56.    bas_objid,                   /* 12 object identifier */
  57.    bas_real,                    /* 13 real */
  58.    bas_enum,                    /* 14 enumerated */
  59.    bas_charstr,                 /* 15 character string type */
  60.    bas_anytbl,                  /* 16 any defined by table */
  61.    bas_expltag                  /* 17 explicit encoded type */
  62. };  /* basetypes */
  63.  
  64. /************************************************************************
  65.  * Tag classes. The ones beginning with "GDS" are not ASN.1 standard,
  66.  * they can be used if IBM GDS Definition encoding is used.
  67.  ************************************************************************
  68.  */
  69. enum tagclass {
  70.    cont,                        /* CONTEXT SPECIFIC - only BER */
  71.    univ,                        /* UNIVERSAL - BER and GDSD */
  72.    appl,                        /* APPLICATION - only BER */
  73.    priv,                        /* PRIVATE - only BER */
  74.    gdstl,                       /* GDSTL - only GDSD */
  75.    gdslt,                       /* GDSLT - only GDSD */
  76.    gdssegiss,                   /* GDSSEGISS - only GDSD */
  77.    gdssegll,                    /* GDSSEGLL - only GDSD */
  78.    gdslen,                      /* GDSLENGTH - only GDSD */
  79.    gdsuniq,                     /* GDSUNIQUE - only GDSD */
  80.    gdsflen,                     /* GDSFLEN - only GDSD */
  81.    gdsuntil,                    /* GDSOccursUntilLKAHD - only GDSD */
  82.    gdswhen,                     /* GDSOccursWhenLKAHD - only GDSD */
  83.    gdswhile,                    /* GDSOccursWhileLKAHD - only GDSD */
  84.    gdsunkn,                     /* GDSUNKNLT - only GDSD */
  85.    noclass                      /* class not specified, error situations */
  86. };   /* tagclass */
  87.  
  88.  
  89. /************************************************************************
  90.  * Type of encoding. Used by GDSencode routine, in order to do correctly
  91.  * some encoding decision, and by GDSprintgds routine in order to print
  92.  * correctly the GDS structure tree.
  93.  ************************************************************************
  94.  */
  95. enum TypOfEnc {
  96.    ber,                         /* Basic Encoding Rules */
  97.    gdsd,                        /* IBM General Data Stream Definitions */
  98.    none                         /* the lengths are not calculated by encode,
  99.                                  * useful if other encoding rules are used */
  100. };
  101.  
  102. /************************************************************************
  103.  * Storage class: dynamic or static
  104.  ************************************************************************
  105.  */
  106. enum stg {
  107.    stat,                        /* static - not subject to reclaimation */
  108.    allocd                       /* allocated - subject to reclaimation */
  109. };
  110.  
  111. /************************************************************************
  112.  * Status of GDS, used during BER decoding of SET type
  113.  ************************************************************************
  114.  */
  115. enum setstat {                  /* set element status */
  116.    matched,                     /* GDS is matched in the set element */
  117.    unmatched                    /* GDS is unmatched */
  118. };
  119.  
  120. /************************************************************************
  121.  * Form of type: primitive or constructor
  122.  ************************************************************************
  123.  */
  124. enum frm {
  125.    prim,                        /* primitive form */
  126.    constr                       /* constructor form */
  127. };
  128.  
  129. /************************************************************************
  130.  * Last piece of data indicator, used if the content data is passed
  131.  * using an user exit.
  132.  ************************************************************************
  133.  */
  134. enum lastflag {
  135.    NO,                          /* this is not last piece of data */
  136.    YES                          /* this is last piece of data */
  137. };
  138.  
  139. /************************************************************************
  140.  * User exit for passing the content data
  141.  ************************************************************************
  142.  */
  143. #define usr_cont_exit\
  144.  int (*usrcontent) (char **buff, unsigned long *buflen, enum lastflag *lastf)
  145.  
  146. /************************************************************************
  147.  * Segment structure, used in case of IBM GDSD segmentation
  148.  ************************************************************************
  149.  */
  150. struct segment {
  151.   unsigned long   seg_len;      /* length of the segment */
  152.   char           *seg_content;  /* segment content data */
  153.   struct segment *next_seg;     /* pointer to the next segment.
  154.                                  * NULL if it is the last */
  155. };
  156.  
  157. /************************************************************************
  158.  * GDS structure
  159.  ************************************************************************
  160.  */
  161. struct gds {
  162.    enum tagclass   cls;         /* class */
  163.    unsigned long   id;          /* identifier number */
  164.    enum frm        form;        /* primitive or constructed */
  165.    long            loc;         /* length of CONTENTS field */
  166.    long            log;         /* length of GDS */
  167.    int             basetype;    /* base type of GDS */
  168.    char           *modname;     /* module name pointer */
  169.    char           *name;        /* type/value name pointer */
  170.    char           *sop;         /* address of start of GDS */
  171.    char           *contents;    /* address of contents */
  172.    struct gds     *next;        /* sibling ptr */
  173.    struct gds     *contains;    /* contained GDSs */
  174.    struct gds     *parent;      /* parent (containing) GDS */
  175.    enum stg        gdsstg;      /* storage class for GDS structure */
  176.    enum stg        contstg;     /* storage class for GDS contents
  177.                                    field */
  178.    enum setstat    sstat;       /* set element matching status */
  179.    unsigned long   id_seg_len;  /* the maximum length of the segment
  180.                                  * or the IDENTIFIER length */
  181.    usr_cont_exit;               /* the pointer to the user exit called by */
  182.                                 /* GDSencgdsd and GDSencber routines to get */
  183.                                 /* the data that must be encoded. It could be */
  184.                                 /* used in case of GDSD segmentation */
  185.    struct segment *seg_list;    /* pointer to a list of segments. It is set
  186.                                  * by GDSdecgdsd function if decoding user-exit
  187.                                  * is not used and content data are segmentated
  188.                                  */
  189. };
  190.  
  191. /************************************************************************
  192.  * The following are structures to pass during the GDS tree walking
  193.  * process for encoding.
  194.  ************************************************************************
  195.  */
  196. struct encinh {                 /* inherited attributes */
  197.    struct ietag   *it;          /* points to the structure containing
  198.                                  * the information of implicit tagging if
  199.                                  * the type is implicit tagged */
  200.    char           *symname;     /* name of the current item to encode */
  201.    char           *modname;     /* current module name */
  202.    void           *module_ptr;  /* module for type to encode */
  203.    void           *usrparms;    /* user parms */
  204.    char            opt;         /* TRUE if item is optional or defaulted,
  205.                                    FALSE if mandatory */
  206. };
  207.  
  208. struct encinhsyn {              /* inherited and synthesized attributes */
  209.    struct gds     *p;           /* the GDS structure allocated fo the type */
  210.    unsigned short ndx;          /* Metatable index of the type encoded */
  211.    enum basetypes base;         /* base type of GDS */
  212.    long   ssof_items_num;       /* num of items inside a SET OF or SEQ OF */
  213. };
  214.  
  215. /************************************************************************
  216.  * This indicates if LLIDFISS segmentation is used. The UAP can decide,
  217.  * calling GDSencgdsd function, if it wants to use LLIDFISS segmention
  218.  * or not.
  219.  ************************************************************************
  220.  */
  221. typedef enum {
  222.     nouse,                      /* segmentation is not used */
  223.     use                         /* the LLIDFISS segmentation is used */
  224. } useLLIDFISS;
  225.  
  226.  
  227. /************************************************************************
  228.  * Used by GDSdecgdsd function to return to the UAP information
  229.  * about decoding errors.
  230.  ************************************************************************
  231.  */
  232. struct errdata {
  233.   void *err_item;               /* item in error */
  234.   int   err_item_len;           /* length of item in error */
  235. };
  236.  
  237. /************************************************************************
  238.  * Contents structures, used by UAP to pass content data to GDSencode
  239.  * function instead of encoding user-exit mechanism.
  240.  ************************************************************************
  241.  */
  242.  struct contents_str {
  243.    char *content;               /* content data */
  244.    usr_cont_exit;               /* content user exit */
  245.    struct content_str *contlist; /* list of contents, used for SET OF and
  246.                                   * SEQUENCE OF */
  247.    enum stg contstg;            /* storage class */
  248.    long                len;     /* content length (number of bytes), or
  249.                                  * number of contents in contlist */
  250.  };
  251.  
  252.  struct content_str {
  253.    char *content;               /* content data */
  254.    usr_cont_exit;               /* content user exit */
  255.    enum stg contstg;            /* storage class */
  256.    long                len;     /* content length (number of bytes) */
  257.  };
  258.  
  259.