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

  1. /* -----------------------------------------------------------------------------
  2.  
  3.   Example: scan handler looking for AmigaGuide nodes (DICE-C). Scan handlers are 
  4.   plain functions loadSeg'ed by GED: no standard C startup code and no library
  5.   calls.
  6.  
  7.   DICE C (-ms1 makes DICE compiler put string constants into code hunk):
  8.   
  9.   dcc guide.c -// -l0 -md -ms1 -mRR -o ram:Guides
  10.  
  11.   ------------------------------------------------------------------------------
  12. */
  13.  
  14. #include <exec/types.h>
  15.  
  16. #define UPPER(a) ((a) & 95)
  17.  
  18. ULONG
  19. ScanHandlerGuide(__D0 ULONG len, __A0 char **text)
  20. {
  21.     const char *version = "$VER: Guides 1.1 (21.7.94)";
  22.  
  23.     if (**text == '@') {
  24.  
  25.         if (len > 4) {
  26.  
  27.             UBYTE *next = *text + 1;
  28.  
  29.             if (UPPER(*next++) == 'N') {
  30.  
  31.                 if (UPPER(*next++) == 'O') {
  32.  
  33.                     if (UPPER(*next++) == 'D') {
  34.  
  35.                         if (UPPER(*next++) == 'E') {
  36.  
  37.                             UWORD letters = 0;
  38.  
  39.                             for (len -= 5; len; --len) {
  40.  
  41.                                 if (*next == '"') {
  42.  
  43.                                     for (*text = ++next, --len; len && (*next != '"'); ++next)
  44.                                         ++letters;
  45.  
  46.                                     return(letters);
  47.                                 }
  48.                                 else if (*next == ' ')
  49.  
  50.                                     next++;
  51.  
  52.                                 else {
  53.  
  54.                                     for (*text = next; len-- && (*next != ' ') && (*next != '"'); ++next)
  55.                                         ++letters;
  56.  
  57.                                     return(letters);
  58.                                 }
  59.                             }
  60.  
  61.                             *text = "(unnamed)";
  62.  
  63.                             return(9);
  64.                         }
  65.                     }
  66.                 }
  67.             }
  68.         }
  69.     }
  70.  
  71.     return(NULL);
  72. }
  73.