home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / gnu / fax-3.2.1 / lib / libutil / dispatch.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-07-31  |  2.5 KB  |  148 lines

  1. /*
  2.   This file is part of the NetFax system.
  3.  
  4.   (c) Copyright 1989 by David M. Siegel and Sundar Narasimhan.
  5.       All rights reserved.
  6.  
  7.     This program is free software; you can redistribute it and/or modify
  8.     it under the terms of the GNU General Public License as published by
  9.     the Free Software Foundation.
  10.  
  11.     This program is distributed in the hope that it will be useful, 
  12.     but WITHOUT ANY WARRANTY; without even the implied warranty of 
  13.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.     GNU General Public License for more details.
  15.  
  16.     You should have received a copy of the GNU General Public License
  17.     along with this program; if not, write to the Free Software
  18.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19. */
  20.  
  21. #ifndef INCdispatchh
  22. #define INCdispatchh 1
  23.  
  24. #include <sys/types.h>
  25. #include <sys/time.h>
  26.  
  27. #define DIO_READ     00001
  28. #define DIO_WRITE    00002
  29. #define DIO_EXCEPT   00004
  30. #define DIO_TIMEOUT  00010
  31. #define DIO_REPEAT   00020
  32. #define DIO_DELETED  00100
  33. #define DIO_RPC         00200
  34.  
  35. #define DIO_FD_EVENT(x) ((x)&(DIO_READ|DIO_WRITE|DIO_EXCEPT))
  36. #define DIO_FD_MASK(x)  ((DIO_FD_EVENT(x))>>1)
  37.  
  38. typedef struct _dio {
  39.     int dtype;
  40.     int fd;
  41.     struct timeval time_next;
  42.     struct timeval time_interval;
  43.     int (*routine)();
  44.     char *data;
  45. } DIO;
  46.  
  47. /*
  48.   Prototypes:
  49. */
  50.  
  51. int dispatch_unregister(
  52. #ifdef _PROTO
  53.     DIO *d
  54. #endif
  55. );
  56.  
  57. DIO *dispatch_register_fd(
  58. #ifdef _PROTO
  59.     int dtype,
  60.     int priority,
  61.     int fd,
  62.     int (*routine)(),
  63.     char *data
  64. #endif
  65. );
  66.  
  67. DIO *dispatch_register_fd_timeout(
  68. #ifdef _PROTO
  69.     int dtype,
  70.     int priority,
  71.     int fd,
  72.     double timeout,
  73.     int (*routine)(),
  74.     char *data
  75. #endif
  76. );
  77.  
  78. DIO *dispatch_register_alarm(
  79. #ifdef _PROTO
  80.     int priority,
  81.     double period,
  82.     int (*routine)(),
  83.     char *data
  84. #endif
  85. );
  86.  
  87. DIO *dispatch_register_periodic(
  88. #ifdef _PROTO
  89.     int priority,
  90.     double period,
  91.     int (*routine)(),
  92.     char *data
  93. #endif
  94. );
  95.  
  96. DIO *dispatch_register_rpc(
  97. #ifdef _PROTO
  98.     int priority
  99. #endif
  100. );
  101.  
  102. int dispatch_unregister_fd(
  103. #ifdef _PROTO
  104.     int dtype,
  105.     int fd
  106. #endif
  107. );
  108.  
  109. DIO *dispatch_change_handler(
  110. #ifdef _PROTO
  111.     DIO *d,
  112.     int (*routine)()
  113. #endif
  114. );
  115.  
  116. DIO *dispatch_change_priority(
  117. #ifdef _PROTO
  118.     DIO *d,
  119.     int priority
  120. #endif
  121. );
  122.  
  123. int dispatch_print_queues(
  124. #ifdef _PROTO
  125.     void
  126. #endif
  127. );
  128.  
  129. struct timeval *dispatch_timeval(
  130. #ifdef _PROTO
  131.     struct timeval *tp
  132. #endif
  133. );
  134.  
  135. time_t dispatch_time(
  136. #ifdef _PROTO
  137.     time_t *tloc
  138. #endif
  139. );
  140.  
  141. int dispatch_run(
  142. #ifdef _PROTO
  143.     void
  144. #endif
  145. );
  146.  
  147. #endif
  148.