home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume6 / lbl / src / find.c < prev    next >
Encoding:
C/C++ Source or Header  |  1986-11-30  |  885 b   |  47 lines

  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.  
  10. /* find.c:
  11.  *    routines to find a type entry and a label entry
  12.  */
  13.  
  14. #include    <lbl.h>
  15.  
  16. extern type    *typetable;
  17.  
  18. type *
  19. findtype(name, create)
  20.     rg char    *name;
  21.     rg int    create;
  22. {
  23.     rg type    *tp;
  24.  
  25.     for (tp = typetable; tp != NULL; tp = tp->t_next)
  26.         if (strcmp(name, tp->t_name) == 0)
  27.             return tp;
  28.     if (create)
  29.         return addtype(name);
  30.     return NULL;
  31. }
  32.  
  33. label *
  34. findlabel(tp, name)
  35.     rg type        *tp;
  36.     rg char        *name;
  37. {
  38.     rg label    *lp;
  39.  
  40.     if (tp == NULL)
  41.         return NULL;
  42.     for (lp = tp->t_labels; lp != NULL; lp = lp->l_next)
  43.         if (strcmp(name, lp->l_name) == 0)
  44.             return lp;
  45.     return NULL;
  46. }
  47.