ocm_chan.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /* $Header$ */
  2. /* channel.h - channel definitions */
  3. #include <stdio.h>
  4. #include "parco.h"
  5. typedef union channel {
  6. struct { /* Interprocess channel */
  7. char _type; /* Channel type, see note */
  8. char synch; /* State in channel synchronization */
  9. long val; /* Transmitted value */
  10. } c;
  11. struct { /* File channel */
  12. char _type; /* Dummy field, see note */
  13. char index; /* Index in the file array */
  14. char flgs; /* Status flags: in use & readahead */
  15. char preread; /* Possible preread character */
  16. } f;
  17. } chan;
  18. #define type c._type /* Channel type */
  19. /* Note: The channel type should not be part of each structure in chan. But
  20. * the C alignment rules would make chan about 50% bigger if we had done it
  21. * the right way. Note that the order of fields in a struct cannot be a problem
  22. * as long as struct c is the largest within the union.
  23. */
  24. #define C_T_CHAN 0 /* Type of a interprocess channel */
  25. #define C_T_FILE 1 /* Type of a file channel */
  26. #define C_S_FREE 0 /* IP channel is free */
  27. #define C_S_ANY 1 /* IP channel contains data */
  28. #define C_S_ACK 2 /* IP channel data is removed */
  29. #define C_F_EOF (-1L) /* File channel returns EOF */
  30. #define C_F_TEXT (-2L) /* File channel becomes line oriented */
  31. #define C_F_RAW (-3L) /* File channel becomes character oriented */
  32. #define C_F_INUSE 0x01 /* File channel is connected to a UNIX file */
  33. #define C_F_READAHEAD 0x02 /* File channel has a preread character */
  34. extern chan file[_NFILE]; /* Array of file channels */
  35. extern FILE *unix_file[_NFILE]; /* Pointers to buffered UNIX files */
  36. void c_init();
  37. void chan_in(), cbyte_in(), c_wa_in(), c_ba_in();
  38. void chan_out(), c_wa_out(), c_ba_out();
  39. int chan_any();