home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 534.lha / sregexp.library_v11.1 / sregexpbase.h < prev    next >
C/C++ Source or Header  |  1991-08-08  |  3KB  |  162 lines

  1.  
  2. /*
  3.  *
  4.  * sregexpbase.h -- C include file for sregexp.library
  5.  *
  6.  * Copyright (C) 1991, Jon Spencer.
  7.  *
  8.  * Created: April 20,1991
  9.  *
  10.  */
  11.  
  12. #ifndef LIBRARIES_SREGEXPBASE_H
  13. #define LIBRARIES_SREGEXPBASE_H
  14.  
  15. #ifndef EXEC_TYPE_H
  16. #include <exec/types.h>
  17. #endif
  18.  
  19. #ifndef EXEC_LISTS_H
  20. #include <exec/lists.h>
  21. #endif
  22.  
  23. #ifndef EXEC_LIBRARIES_H
  24. #include <exec/libraries.h>
  25. #endif
  26.  
  27. #ifndef LIBRARIES_DOS_H
  28. #include <libraries/dos.h>
  29. #endif
  30.  
  31.  
  32. /*
  33.  *
  34.  * Library base structure, all of these fields are private, and
  35.  * should not be accessed.
  36.  *
  37.  */
  38.  
  39. struct SregExpBase {
  40.     struct Library  LibNode;
  41.     struct Library  *SysBase;
  42.     struct Library  *DOSBase;
  43.     BPTR        Segment;
  44. };
  45.  
  46. #define SREGEXPNAME       "sregexp.library"
  47.  
  48.  
  49. /*
  50.  *
  51.  * Here are the defines for the structures used and returned by
  52.  * the various sreg functions.    They should probably not be
  53.  * accessed for there contents, unless you have really good
  54.  * reason...
  55.  *
  56.  */
  57.  
  58. struct SregExp {
  59.     char            sre_Type,sre_Flag;
  60.     SHORT            sre_MinLen;
  61.     union {
  62.     char    onechar;
  63.     char    *setchar;
  64.     char    *string;
  65.     LONG    number;
  66.     }                sre_Data;
  67.     struct SregExp *        sre_List[];
  68. };
  69.  
  70.  
  71. /* This is an internal structure for a singly linked list of sregexp's */
  72. struct SregList {
  73.     struct SregExp        *srl_sreg;
  74.     struct SregList        *srl_next;
  75. };
  76.  
  77.  
  78. /* various types of wildcard pattern elements.
  79.     Goes in struct SregExp.type field */
  80.  
  81. #define SRP_SETCHAR    1
  82. #define SRP_ANYCHAR    2
  83. #define SRP_ONECHAR    3
  84. #define SRP_STRING    4
  85. #define SRP_NULL    5
  86. #define SRP_OR        6
  87. #define SRP_SUM     7
  88.  
  89.  
  90.  
  91. /* various flags to mark special properties of patterns.
  92.    Goes in struct SregExp.flag */
  93.  
  94. #define SRF_NOT     (1<<0)
  95. #define SRF_REPEAT    (1<<1)
  96. #define SRF_FIXLEN    (1<<2)
  97. #define SRF_JUSTDIRS    (1<<6)    /* special flag used in path matching */
  98. #define SRF_RECURSE    (1<<7)    /* dito. */
  99.  
  100. /* defines for the wildcard characters */
  101.  
  102. #define CHR_REPEAT    '#'
  103. #define CHR_NOT     '~'
  104. #define CHR_OPENBRACE    '('
  105. #define CHR_CLOSEBRACE    ')'
  106. #define CHR_OPENSET    '['
  107. #define CHR_CLOSESET    ']'
  108. #define CHR_ANYCHAR    '?'
  109. #define CHR_NULL    '%'
  110. #define CHR_OR        '|'
  111. #define CHR_ESCAPE    '\''
  112. #define CHR_RANGE    '-'
  113. #define CHR_STAR    '*'
  114.  
  115.  
  116.  
  117.  
  118. /* These are the structures used for the path matching routines. */
  119.  
  120. struct SpathInfo {
  121.     struct SpathNode *        spi_Head;
  122.     struct SpathNode *        spi_Tail;
  123.     struct SpathNode *        spi_TailPred;
  124.     struct SregList *        spi_SregList;
  125. };
  126.  
  127.  
  128. /* Note: because of the fileinfoblock, this whole structure MUST
  129.   be longword aligned. */
  130.  
  131. struct SpathNode {
  132.     struct SpathNode *        spn_Succ;
  133.     struct SpathNode *        spn_Pred;
  134.     struct FileInfoBlock    spn_FIB;
  135.     BPTR            spn_Lock;
  136.     struct SregList *        spn_SregList;
  137.     char *            spn_NodeName;
  138.     short int            spn_Flags;
  139. };
  140.  
  141. /* flags used in spn_Flags, which is  really library private  */
  142. #define SPF_DECEND    (1<<0)      /* Should recursively search, when we get the chance. */
  143. #define SPF_DONEONCE    (1<<1)      /* Already done it, don't do again */
  144. #define SPF_NEXTPARENT    (1<<2)      /* Next one is lock on parentdir */
  145.  
  146.  
  147. /* These are the possible error returns sent by NextFile and BuildPath */
  148.  
  149. #define SPE_ALL_DONE    -1    /* no more matching files */
  150. #define SPE_ERROR    -2    /* some error occured, see IoErr() */
  151. #define SPE_BUFF_FULL    -3    /* you didn't give me enough room! */
  152. #define SPE_SIGBREAK    -4    /* A control signal came through.  */
  153.  
  154.  
  155. /* Some defines for what kind of events we match to. */
  156.  
  157. #define SP_DIRS_ONLY    1
  158. #define SP_BOTH     0
  159. #define SP_FILES_ONLY    -1
  160.  
  161. #endif
  162.