home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume36 / unpost / part07 / parse.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-04-18  |  3.6 KB  |  102 lines

  1. /******************************************************************************
  2. * Module    :   Parser header file.
  3. *
  4. * Author    :   John W. M. Stevens
  5. ******************************************************************************/
  6.  
  7. #if ! defined(PARSER_HEADER_FILE)
  8. #define     PARSER_HEADER_FILE
  9.  
  10. #include    "regexp.h"
  11. #include    "uudec.h"
  12.  
  13. #define PRS_NO_SEGMENT  -1L     /*  Found end of file before SEGMENT begin. */
  14. #define PRS_NO_ID_STR   -2L     /*  Did not find an ID string.              */
  15. #define PRS_NO_UU_LN    -3L     /*  Did not find a UU line in SEGMENT.      */
  16. #define PRS_NO_BEGIN    -4L     /*  Did not find expected uuencode begin.   */
  17. #define PRS_NO_SEG_NUM  -5L     /*  Did not find a SEGMENT number.          */
  18. #define PRS_NO_NUM_SEGS -6L     /*  Did not find total number of SEGMENTs.  */
  19. #define PRS_UNX_END_SEG -7L     /*  Found unexpected end of segment.        */
  20.  
  21. /*  Part numbering parsing RE's.    */
  22. typedef struct  {
  23.     char            *ReExpStr;  /*  RE source string.                   */
  24.     int             IDStr;      /*  Sub-Expr. number for ID string.     */
  25.     int             SegNo;      /*  Sub-Expr. for segment number.       */
  26.     int             NoSegs;     /*  Sub-Expr. for number of segments.   */
  27.     int             AltIDStr;   /*  Sub-Expr. for alternate ID string.  */
  28.     CASE_CMP        Case;       /*  Case sensitivity switch.            */
  29.     REG_EXP_NODE    *ReExpr;    /*  Pointer to compiled RE.             */
  30. } PART_RE;
  31.  
  32. /*  Subject line structure. */
  33. typedef struct  {
  34.     char            *ReExprStr; /*  Pointer to RE source string.        */
  35.     PART_RE         *IdParts;   /*  List of part number parsing RE's.   */
  36.     REG_EXP_NODE    *ReExpr;    /*  Pointer to compiled RE.             */
  37. } IDENT;
  38.  
  39. /*  Segment RE structure.   */
  40. typedef struct  {
  41.     char            *ReExprStr; /*  Pointer to RE source string.        */
  42.     IDENT           *Header;    /*  Header ID regular expressions.      */
  43.     IDENT           *Body;      /*  Body ID regular expressions.        */
  44.     REG_EXP_NODE    *ReExpr;    /*  Pointer to compiled RE.             */
  45. } SEGMENT;
  46.  
  47. /*  Define a structure to store the results of the first pass.  */
  48. typedef struct  {
  49.     long        SegOfs;
  50.     long        UUOfs;
  51.     int         Exists;
  52.     int         SegNo;
  53.     int         SegLstOrd;
  54. } SEGS;
  55.  
  56. /*  File list structure.    */
  57. typedef struct  {
  58.     char    *IDString;      /*  Pointer to SEGMENT ID string.           */
  59.     char    *FlName;        /*  File name.                              */
  60.     int     Success;        /*  Successful unpost flag.                 */
  61.     int     NoSegs;         /*  Number of segments in binary.           */
  62.     SEGS    *Segs;          /*  Pointer to list of segment desc.        */
  63. } FL_LIST;
  64.  
  65. /*  Segment information.    */
  66. typedef struct  {
  67.     int     NoSegs;
  68.     int     SegNo;
  69.     long    SegOfs;
  70.     long    UUOfs;
  71.     char    *IDString;
  72.     char    *FlName;
  73. } SEG_INFO;
  74.  
  75. /*  Function prototypes.    */
  76. extern
  77. void    GetBinFlNm(FILE     *InFlPtr,
  78.                    char     **RetStrs,
  79.                    char     *FlName);
  80. extern
  81. int     MatchEnd(char   *Line);
  82. extern
  83. int     MatchBegin(char     *Line,
  84.                    char     ***RetStrs);
  85. extern
  86. int     MatchSegment(char       *Line,
  87.                      IDENT      **Hdr,
  88.                      IDENT      **Body);
  89. extern
  90. long    Parse(FILE      *InFlPtr,
  91.               char      *SegLine,
  92.               char      *IDLine,
  93.               SEG_INFO  *SegInfo);
  94. extern
  95. void    SetSegBegin(char    *SegType);
  96. extern
  97. void    LoadCfg(char   *CfgFlNm);
  98. extern
  99. void    ParseInit(void);
  100.  
  101. #endif
  102.