home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume26 / mytinfo / part01 / findcap.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-12-26  |  2.6 KB  |  150 lines

  1. /*
  2.  * findcap.c
  3.  *
  4.  * By Ross Ridge
  5.  * Public Domain
  6.  * 92/02/01 07:29:55
  7.  *
  8.  */
  9.  
  10. #include "defs.h"
  11. #include "term.h"
  12.  
  13. #include "bsearch.c"
  14.  
  15. #ifdef USE_SCCS_IDS
  16. static const char SCCSid[] = "@(#) mytinfo findcap.c 3.2 92/02/01 public domain, By Ross Ridge";
  17. #endif
  18.  
  19. extern char **_sboolcodes[], **_snumcodes[], **_sstrcodes[];
  20. extern char **_sboolnames[], **_snumnames[], **_sstrnames[];
  21. extern char **_sboolfnames[], **_snumfnames[], **_sstrfnames[];
  22.  
  23. static char **p2p2c;
  24.  
  25. int
  26. _findboolcode(s)
  27. char *s; {
  28.     char ***match;
  29.  
  30.     p2p2c = &s;
  31.  
  32.     match = (char ***) bsearch((anyptr) &p2p2c, (anyptr) _sboolcodes,
  33.                    NUM_OF_BOOLS, sizeof(p2p2c), _compar);
  34.     if (match == NULL)
  35.         return -1;
  36.     return *match - boolcodes;
  37. }
  38.  
  39. int
  40. _findboolname(s)
  41. char *s; {
  42.     char ***match;
  43.  
  44.     p2p2c = &s;
  45.  
  46.     match = (char ***) bsearch((anyptr) &p2p2c, (anyptr) _sboolnames,
  47.                    NUM_OF_BOOLS, sizeof(p2p2c), _compar);
  48.     if (match == NULL)
  49.         return -1;
  50.     return *match - boolnames;
  51. }
  52.  
  53. int
  54. _findboolfname(s)
  55. char *s; {
  56.     char ***match;
  57.  
  58.     p2p2c = &s;
  59.  
  60.     match = (char ***) bsearch((anyptr) &p2p2c, (anyptr) _sboolfnames,
  61.                    NUM_OF_BOOLS, sizeof(p2p2c), _compar);
  62.     if (match == NULL)
  63.         return -1;
  64.     return *match - boolfnames;
  65. }
  66.  
  67. int
  68. _findnumcode(s)
  69. char *s; {
  70.     char ***match;
  71.  
  72.     p2p2c = &s;
  73.  
  74.     match = (char ***) bsearch((anyptr) &p2p2c, (anyptr) _snumcodes,
  75.                    NUM_OF_NUMS, sizeof(p2p2c), _compar);
  76.     if (match == NULL)
  77.         return -1;
  78.     return *match - numcodes;
  79. }
  80.  
  81. int
  82. _findnumname(s)
  83. char *s; {
  84.     char ***match;
  85.  
  86.     p2p2c = &s;
  87.  
  88.     match = (char ***) bsearch((anyptr) &p2p2c, (anyptr) _snumnames,
  89.                    NUM_OF_NUMS, sizeof(p2p2c), _compar);
  90.     if (match == NULL)
  91.         return -1;
  92.     return *match - numnames;
  93. }
  94.  
  95. int
  96. _findnumfname(s)
  97. char *s; {
  98.     char ***match;
  99.  
  100.     p2p2c = &s;
  101.  
  102.     match = (char ***) bsearch((anyptr) &p2p2c, (anyptr) _snumfnames,
  103.                    NUM_OF_NUMS, sizeof(p2p2c), _compar);
  104.     if (match == NULL)
  105.         return -1;
  106.     return *match - numfnames;
  107. }
  108.  
  109. int
  110. _findstrcode(s)
  111. char *s; {
  112.     char ***match;
  113.  
  114.     p2p2c = &s;
  115.  
  116.     match = (char ***) bsearch((anyptr) &p2p2c, (anyptr) _sstrcodes,
  117.                    NUM_OF_STRS, sizeof(p2p2c), _compar);
  118.     if (match == NULL)
  119.         return -1;
  120.     return *match - strcodes;
  121. }
  122.  
  123. int
  124. _findstrname(s)
  125. char *s; {
  126.     char ***match;
  127.  
  128.     p2p2c = &s;
  129.  
  130.     match = (char ***) bsearch((anyptr) &p2p2c, (anyptr) _sstrnames,
  131.                    NUM_OF_STRS, sizeof(p2p2c), _compar);
  132.     if (match == NULL)
  133.         return -1;
  134.     return *match - strnames;
  135. }
  136.  
  137. int
  138. _findstrfname(s)
  139. char *s; {
  140.     char ***match;
  141.  
  142.     p2p2c = &s;
  143.  
  144.     match = (char ***) bsearch((anyptr) &p2p2c, (anyptr) _sstrfnames,
  145.                    NUM_OF_STRS, sizeof(p2p2c), _compar);
  146.     if (match == NULL)
  147.         return -1;
  148.     return *match - strfnames;
  149. }
  150.