home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_08_12 / 8n12045b < prev    next >
Text File  |  1990-10-15  |  939b  |  50 lines

  1. /*
  2.  *  KEY.C
  3.  *
  4.  *  routines for manipulating the key reassignment buffers
  5.  *
  6.  */
  7.  
  8. #include    "char.h"
  9.  
  10.  
  11. /*
  12.  *  k_seek()
  13.  *
  14.  *  k_seek() finds a buffer based on the global variable
  15.  *  'keycheck'.  the first match returns a pointer to the
  16.  *  replacement string; the variable 'len' is also set to
  17.  *  point to the length field.  If no match, then it returns
  18.  *  a null pointer
  19.  */
  20.  
  21. char    *k_seek()
  22.     {
  23.     for (kp = &kbuffer[ 0 ], k = 0; k < NKEYS; k++, kp++)
  24.         {
  25.         if (kp->keystroke == keycheck)
  26.             {
  27.             len = &(kp->length);
  28.             ptr = kp->buffer;
  29.             return ptr;
  30.             }
  31.         }
  32.     return ((char *) 0);
  33.     }
  34.  
  35.  
  36. /*
  37.  *  k_alloc()
  38.  *
  39.  *  k_alloc() searches for an unallocated key buffer.
  40.  *  It does so by searching for a zero keystroke field.
  41.  *  Simple.
  42.  */
  43.  
  44. char    *k_alloc()
  45.     {
  46.     keycheck = 0;
  47.     return k_seek();
  48.     }
  49.  
  50.