keyword.cpp 880 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /* (C) C.D.F. Miller, Heriot-Watt University, March 1984
  2. *
  3. * Permission is hereby given to reproduce or modify this
  4. * software freely, provided that this notice be retained,
  5. * and that no use be made of the software for commercial
  6. * purposes without the express written permission of the
  7. * author.
  8. */
  9. /* keyword.c:
  10. * look up a command keyword (by sequential search).
  11. */
  12. #include <string.h>
  13. #include <lbl.h>
  14. #include "keyword.h"
  15. extern int a_delimiter();
  16. extern int a_format();
  17. extern int a_last();
  18. static Keyword keytable[] = {
  19. {"delimiter", a_delimiter, 2, 2},
  20. {"format", a_format, 3, 3},
  21. {"last", a_last, 3, 22}
  22. };
  23. #define NKEYS (sizeof(keytable) / sizeof(Keyword))
  24. Keyword *
  25. findkeyword(char *word)
  26. {
  27. unsigned long indx;
  28. for (indx = 0; indx < NKEYS; indx++)
  29. if (strcmp(word, keytable[indx].k_name) == 0)
  30. return keytable + indx;
  31. return NULL;
  32. }