home *** CD-ROM | disk | FTP | other *** search
/ MACD 4 / MACD4.iso / cdity / smartwin_src.lha / SmartWIN / source / Misc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-10-16  |  932 b   |  72 lines

  1. /*
  2. **    SmartWIN
  3. **
  4. **        © 1996 by Timo C. Nentwig
  5. **        All Rights Reserved !
  6. **
  7. **        Tcn@oxygen.in-berlin.de
  8. **
  9. */
  10.  
  11. /// #include
  12.  
  13. #include "GST.h"
  14. #include "Protos.h"
  15.  
  16. ///
  17. /// proto
  18.  
  19. proto BOOL    atob (const STRPTR Key);
  20.  
  21. ///
  22.  
  23. /// atob ()
  24.  
  25.     /*
  26.      *    FUNCTION    Convert a string to boolean.
  27.      *
  28.      *    NOTE
  29.      *
  30.      *    EXAMPLE     atob ("on");
  31.      *
  32.      */
  33.  
  34. BOOL
  35. atob (const STRPTR Key)
  36. {
  37.  
  38.     const struct { STRPTR Key; BOOL Value; } Table [] =
  39.     {
  40.  
  41.         "yes",      TRUE,
  42.         "true",     TRUE,
  43.         "on",       TRUE,
  44.         "1",        TRUE,
  45.         "no",       FALSE,
  46.         "false",    FALSE,
  47.         "off",      FALSE,
  48.         "0",        FALSE,
  49.  
  50.         NULL,       -1
  51.  
  52.     };
  53.  
  54.  
  55.     LONG    i;
  56.  
  57.     for (i = 0; i < NumElements (Table); i++)
  58.     {
  59.  
  60.         if (stricmp (Table [i] . Key, Key) == 0)
  61.         {
  62.  
  63.             return (Table [i] . Value);
  64.  
  65.         }
  66.  
  67.     }
  68.  
  69. }
  70.  
  71. ///
  72.