home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume10 / parseargs / funclist.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-02-16  |  1.3 KB  |  67 lines

  1. #include <useful.h>
  2. #include <funclist.h>
  3.  
  4. VERSIONID("$Header: funclist.c,v 2.0 89/12/24 00:56:22 eric Exp $");
  5.  
  6. /*
  7. **  FUNCLIST_ADD -- add a function specification to a function list
  8. **
  9. **    Parameters:
  10. **        flh -- the address of a pointer to a function list.  Note
  11. **            that this must be a FUNCLIST **.
  12. **        func -- the function to add to the list.
  13. **        arg -- the first argument to the function.
  14. **
  15. **    Returns:
  16. **        none.
  17. **
  18. **    Side Effects:
  19. **        The indicated function is added to the function list
  20. **        for later invocation by funclist_call.
  21. **
  22. **    Author:
  23. **        Eric Allman
  24. **        University of California, Berkeley
  25. */
  26.  
  27. VOID
  28. funclist_add(flh, func, arg)
  29.     FUNCLIST **flh;
  30.     VOID (*func)();
  31.     ARBPTR arg;
  32. {
  33.     register FUNCLIST *fl;
  34.  
  35.     fl = (FUNCLIST *) ckalloc(sizeof *fl);
  36.     fl->_fl_func = func;
  37.     fl->_fl_arg = arg;
  38.     fl->_fl_next = *flh;
  39.     *flh = fl;
  40. }
  41. /*
  42. **  FUNCLIST_CALL -- call all the functions on a function list.
  43. **
  44. **    Parameters:
  45. **        fl -- the function list to call.  Unlike funclist_add,
  46. **            this should not be an indirect pointer.
  47. **        arg -- the second argument to the functions.
  48. **
  49. **    Returns:
  50. **        none.
  51. **
  52. **    Side Effects:
  53. **        As implied by the function list.
  54. */
  55.  
  56. VOID
  57. funclist_call(fl, arg)
  58.     register FUNCLIST *fl;
  59.     ARBPTR arg;
  60. {
  61.     while (fl != FUNCLISTNULL)
  62.     {
  63.         (*fl->_fl_func)(fl->_fl_arg, arg);
  64.         fl = fl->_fl_next;
  65.     }
  66. }
  67.