home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c070 / 4.ddi / TOOLS.4 / TCTSRC1.EXE / EDRETKEY.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-03-31  |  1.9 KB  |  69 lines

  1. /**
  2. *
  3. * Name        EDRETKEY -- Return an edit key record from the edit key
  4. *                list.
  5. *
  6. * Synopsis    presult = edretkey(pkey_sequence);
  7. *
  8. *        ED_KEY      *presult  Pointer to the located edit key
  9. *                    record, or NIL if failure.
  10. *        const KEY_SEQUENCE  Character code and scan code of the
  11. *        *pkey_sequence        edit key to be located.
  12. *
  13. * Description    This function searches the linked list of edit keys
  14. *        looking for a record having the same character and
  15. *        scan code (key_sequence) as specified.    If one is
  16. *        found, a pointer to it is returned. If no match is
  17. *        found, NIL is returned.  If the edit key list has not
  18. *        yet been initialized, it is initialized before the
  19. *        search.
  20. *
  21. * Returns    *presult       Pointer to the matching edit key
  22. *                   record from the linked list of
  23. *                   edit key key records, or NIL if
  24. *                   there is no match.
  25. *        b_pkey_root       Pointer to start of newly
  26. *                   initialized edit key list, if it
  27. *                   was not already initialized.
  28. *
  29. * Version    6.00 (C)Copyright Blaise Computing Inc.  1989
  30. *
  31. **/
  32. #include <butil.h>
  33. #include <bedit.h>
  34.  
  35.  
  36. ED_KEY *edretkey(pkey_sequence)
  37. const KEY_SEQUENCE *pkey_sequence;
  38. {
  39.     ED_LIST *pcurrent;
  40.     int error_code;
  41.  
  42.     if (b_pkeys_init == 0)
  43.     {
  44.     error_code = edinitky();
  45.     if (error_code != ED_NO_ERROR)
  46.         return(NIL);
  47.     }
  48.  
  49.     pcurrent = b_pkey_root;
  50.  
  51.         /* Do a sequential search of the linked list until the  */
  52.         /* key is found, or the list is exhausted.            */
  53.     while (pcurrent != NIL)
  54.     if ((pcurrent->edit_key.key_sequence.character_code ==
  55.          pkey_sequence->character_code) &&
  56.         (pcurrent->edit_key.key_sequence.key_code ==
  57.          pkey_sequence->key_code))
  58.         break;
  59.     else
  60.         pcurrent = pcurrent->pnext;
  61.  
  62.         /* If the edit key was found, pcurrent points to it;    */
  63.         /* otherwise, pcurrent is NIL.                */
  64.     if (pcurrent != NIL)
  65.     return(&pcurrent->edit_key);
  66.     else
  67.     return(NIL);
  68. }
  69.