home *** CD-ROM | disk | FTP | other *** search
/ Amiga Elysian Archive / AmigaElysianArchive.iso / prog / utils / sercli.shr / sercli / src / config.c next >
Encoding:
C/C++ Source or Header  |  1993-06-16  |  1.5 KB  |  76 lines

  1. /*
  2. **  $Source: WB_2.1:homes/rkr/prog/sercli/src/RCS/config.c,v $
  3. **  $Author: rkr $
  4. **  $Revision: 1.5 $
  5. **  $Locker: rkr $
  6. **  $State: Exp $
  7. **  $Date: 1993/06/16 23:28:53 $
  8. **
  9. **  sercli (an Amiga .device <-> FIFO interface tool)
  10. **  Copyright (C) 1993  Richard Rauch
  11. **
  12. **  See /doc/sercli.doc and /COPYING for use and distribution license.
  13. **
  14. */
  15.  
  16. #include "defs.h"
  17. #include "misc.h"
  18. #include "config.h"
  19.  
  20.  
  21.  
  22. /*
  23. **  If the text is blank, or begins with one of certain characters, the
  24. **  text is considered a comment.
  25. **
  26. **  It might be better to provide these in a global string variable, or a
  27. **  parameter to this function, and use one of the ANSI searching functions
  28. **  to scan {comment_chars} for the first char in {text}.
  29. **
  30. **
  31. **  If the text is not deemed a comment, we locate the first colon in the
  32. **  line; this becomes a terminator for a compare.
  33. **
  34. **  Then, each option in {opts} is compared to text, up to, but not
  35. **  including, the colon.  Case INsensitive
  36. **
  37. */
  38. int match (char *text, option *opts)
  39. {
  40.     int
  41.     end,
  42.     result;
  43.  
  44.     switch (*text)
  45.     {
  46.     case 0:
  47.     case ' ':
  48.     case '\t':
  49.     case '\n':
  50.     case '\v':
  51.     case '\r':
  52.     case '*':
  53.     case '#':
  54.     case ';':
  55.     case ':':
  56.     result = OPTION_COMMENT;
  57.     break;
  58.  
  59.     default:
  60.     for (end = 0; (text [end]) && (text [end] != ':') ; ++end)
  61.         ;
  62.  
  63.     for (; OPTION_NULL != opts->o_id; ++opts)
  64.         if (strnicmp (text, opts->o_text, end) == 0)
  65.         break;
  66.  
  67.     result = opts->o_id;
  68.     if (!result)
  69.         result = OPTION_NOT_FOUND;
  70.  
  71.     break;
  72.     }
  73.     return (result);
  74. }
  75.  
  76.