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

  1. /* -----------------------------------------------------------------------------
  2.  
  3.   Example: scan handler looking for  AutoDoc  nodes.  Scan  handlers  are  plain
  4.   functions  (LoadSeg'ed  by GED): no standard C startup code, no library calls.
  5.   This handler is faster than GoldED's built in AutoDoc handler since it  simply
  6.   looks  for formfeeds. Won't work with all AutoDocs though Commodore's AutoDocs
  7.   are handled properly.
  8.   
  9.   DICE C:
  10.  
  11.   dcc ADoc.c -// -l0 -md -mRR -o ram:ADoc
  12.  
  13.   ------------------------------------------------------------------------------
  14. */
  15.  
  16. #include <exec/types.h>
  17.  
  18. #define FORMFEED 12
  19.  
  20. ULONG
  21. ScanHandlerGuide(__D0 ULONG len, __A0 char **text)
  22. {
  23.     // look for node header
  24.  
  25.     const char *version = "$VER: ADoc 1.0 (24.3.94)";
  26.  
  27.     if (**text == FORMFEED) {
  28.  
  29.         // look for beginning of header string (e.g. "Dos.Library/Open")
  30.  
  31.         while (len && (**text <= ' ')) {
  32.  
  33.             ++*text;
  34.             --len;
  35.         }
  36.  
  37.         // ignore first part of header string
  38.  
  39.         while (len && (**text != '/')) {
  40.  
  41.             ++*text;
  42.             len--;
  43.         }
  44.  
  45.         // extract node name
  46.  
  47.         if (len) {
  48.  
  49.             UWORD letters;
  50.  
  51.             ++*text;
  52.             --len;
  53.  
  54.             for (letters = 0; len && ((*text)[letters] != 32); --len)
  55.                 ++letters;
  56.  
  57.             return(letters);
  58.         }
  59.     }
  60.  
  61.     return(NULL);
  62. }
  63.