home *** CD-ROM | disk | FTP | other *** search
/ AMIGA PD 1 / AMIGA-PD-1.iso / Programme_zum_Heft / Anwendungen / Kurztests / GoldED / data / tools / GEDScan / define.c < prev    next >
C/C++ Source or Header  |  1995-02-17  |  2KB  |  63 lines

  1. /* -----------------------------------------------------------------------------
  2.  
  3.   Example: scan handler looking for #defines. Scan handlers are plain functions 
  4.   (LoadSeg'ed by GED): no standard C startup code, no library calls. 
  5.   
  6.   DICE-C:
  7.   
  8.   dcc define.c -// -l0 -md -mRR -o ram:Defines
  9.  
  10.   ------------------------------------------------------------------------------
  11. */
  12.  
  13. #include <exec/types.h>
  14.  
  15. #define UPPER(a) ((a) & 95)
  16.  
  17. ULONG
  18. ScanHandlerGuide(__D0 ULONG len, __A0 char **text)
  19. {
  20.     const char *version = "$VER: Define 1.0 (24.3.94)";
  21.  
  22.     if (**text == '#') {
  23.  
  24.         if (len > 8) {
  25.  
  26.             UBYTE *next = *text + 1;
  27.  
  28.             if (UPPER(*next++) == 'D') {
  29.  
  30.                 if (UPPER(*next++) == 'E') {
  31.  
  32.                     if (UPPER(*next++) == 'F') {
  33.  
  34.                         if (UPPER(*next++) == 'I') {
  35.  
  36.                             if (UPPER(*next++) == 'N') {
  37.  
  38.                                 if (UPPER(*next++) == 'E') {
  39.  
  40.                                     if (*next++ == ' ') {
  41.  
  42.                                         UWORD letters = 0;
  43.  
  44.                                         for (len -= 8; (*next == 32) && len; --len)
  45.                                             ++next;
  46.  
  47.                                         for (*text = next; len && (*next++ != ' '); --len)
  48.                                             ++letters;
  49.  
  50.                                         return(letters);
  51.                                     }
  52.                                 }
  53.                             }
  54.                         }
  55.                     }
  56.                 }
  57.             }
  58.         }
  59.     }
  60.  
  61.     return(NULL);
  62. }
  63.