home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 January: Mac OS SDK / Dev.CD Jan 96 SDK / Dev.CD Jan 96 SDK1.toast / Development Kits (Disc 1) / OpenTransport / Open Transport 1.0.5b4 / Open Transport SDK / Open Tpt Module Developer / Includes / stropts.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-06-24  |  8.5 KB  |  219 lines  |  [TEXT/MPS ]

  1. /** Copyright (c) 1991, 1992, 1993  Mentat Inc.
  2.  ** stropts.h 4.5, last change 05 Nov 1993
  3.  ** miioccom.h 4.1, last change 31 Aug 1993
  4.  **/
  5.  
  6. #ifndef _MPS_STROPTS_
  7. #define _MPS_STROPTS_
  8.  
  9.  
  10. #define I_NREAD         MIOC_CMD(MIOC_STREAMIO,1)        /* return the number of bytes in 1st msg */
  11. #define I_PUSH            MIOC_CMD(MIOC_STREAMIO,2)        /* push module just below stream head */
  12. #define I_POP            MIOC_CMD(MIOC_STREAMIO,3)        /* pop module below stream head */
  13. #define I_LOOK            MIOC_CMD(MIOC_STREAMIO,4)        /* retrieve name of first stream module */
  14. #define I_FLUSH         MIOC_CMD(MIOC_STREAMIO,5)        /* flush all input and/or output queues */
  15. #define I_SRDOPT        MIOC_CMD(MIOC_STREAMIO,6)        /* set the read mode */
  16. #define I_GRDOPT        MIOC_CMD(MIOC_STREAMIO,7)        /* get the current read mode */
  17. #define I_SETSIG        MIOC_CMD(MIOC_STREAMIO,9)        /* request SIGPOLL signal on events */
  18. #define I_GETSIG        MIOC_CMD(MIOC_STREAMIO,10)        /* query the registered events */
  19. #define I_LINK            MIOC_CMD(MIOC_STREAMIO,12)        /* connect stream under mux fd */
  20. #define I_UNLINK        MIOC_CMD(MIOC_STREAMIO,13)        /* disconnect two streams */
  21. #define I_PEEK            MIOC_CMD(MIOC_STREAMIO,15)        /* peek at data on read queue */
  22. #define I_FDINSERT        MIOC_CMD(MIOC_STREAMIO,16)        /* create a message and send downstream */
  23. #define I_SENDFD        MIOC_CMD(MIOC_STREAMIO,17)        /* send an fd to a connected pipe stream */
  24. #define I_RECVFD        MIOC_CMD(MIOC_STREAMIO,18)        /* retrieve a file descriptor */
  25. #define I_FLUSHBAND     MIOC_CMD(MIOC_STREAMIO,19)        /* flush a particular input and/or output band */
  26. #define I_SWROPT        MIOC_CMD(MIOC_STREAMIO,20)        /* set the write mode */
  27. #define I_GWROPT        MIOC_CMD(MIOC_STREAMIO,21)        /* get the current write mode */
  28. #define I_ATMARK        MIOC_CMD(MIOC_STREAMIO,23)        /* check to see if the next message is "marked" */
  29. #define I_CKBAND        MIOC_CMD(MIOC_STREAMIO,24)        /* check for a message of a particular band */
  30. #define I_GETBAND        MIOC_CMD(MIOC_STREAMIO,25)        /* get the band of the next message to be read */
  31. #define I_CANPUT        MIOC_CMD(MIOC_STREAMIO,26)        /* check to see if a message may be passed on a stream */
  32. #define I_SETCLTIME     MIOC_CMD(MIOC_STREAMIO,27)        /* set the close timeout wait */
  33. #define I_GETCLTIME     MIOC_CMD(MIOC_STREAMIO,28)        /* get the current close timeout wait */
  34. #define I_PLINK         MIOC_CMD(MIOC_STREAMIO,29)        /* permanently connect a stream under a mux */
  35. #define I_PUNLINK        MIOC_CMD(MIOC_STREAMIO,30)        /* disconnect a permanent link */
  36.  
  37. /* ioctl values needed on non-SYS V systems */
  38. #define I_GETMSG        MIOC_CMD(MIOC_STREAMIO,40)        /* getmsg() system call */
  39. #define I_PUTMSG        MIOC_CMD(MIOC_STREAMIO,41)        /* putmsg() system call */
  40. #define I_POLL            MIOC_CMD(MIOC_STREAMIO,42)        /* poll() system call */
  41. #define I_SETDELAY        MIOC_CMD(MIOC_STREAMIO,43)        /* set blocking status */
  42. #define I_GETDELAY        MIOC_CMD(MIOC_STREAMIO,44)        /* get blocking status */
  43. #define I_RUN_QUEUES    MIOC_CMD(MIOC_STREAMIO,45)        /* sacrifice for the greater good */
  44. #define I_GETPMSG        MIOC_CMD(MIOC_STREAMIO,46)        /* getpmsg() system call */
  45. #define I_PUTPMSG        MIOC_CMD(MIOC_STREAMIO,47)        /* putpmsg() system call */
  46. #define I_AUTOPUSH        MIOC_CMD(MIOC_STREAMIO,48)        /* for systems that cannot do the autopush in open */
  47. #define I_PIPE            MIOC_CMD(MIOC_STREAMIO,49)        /* for pipe library call */
  48. #define I_HEAP_REPORT    MIOC_CMD(MIOC_STREAMIO,50)        /* get heap statistics */
  49. #define    I_FIFO            MIOC_CMD(MIOC_STREAMIO,51)        /* for fifo library call */
  50.  
  51. /* priority message request on putmsg() or strpeek */
  52. #define RS_HIPRI        0x1
  53.  
  54. /* flags for getpmsg and putpmsg */
  55. #define MSG_HIPRI        RS_HIPRI
  56. #define MSG_BAND        0x2             /* Retrieve a message from a particular band */
  57. #define MSG_ANY         0x4             /* Retrieve a message from any band */
  58.  
  59. /* return values from getmsg(), 0 indicates all ok */
  60. #define MORECTL         0x1     /* more control info available */
  61. #define MOREDATA        0x2     /* more data available */
  62.  
  63. #ifndef FMNAMESZ
  64. #define FMNAMESZ        31    /* maximum length of a module or device name */
  65. #endif
  66.  
  67. /* Infinite poll wait time */
  68. #define INFTIM            -1
  69.  
  70. /* flush requests */
  71. #define FLUSHR            0x1             /* Flush the read queue */
  72. #define FLUSHW            0x2             /* Flush the write queue */
  73. #define FLUSHRW         (FLUSHW|FLUSHR) /* Flush both */
  74. #define FLUSHBAND        0x40            /* Flush a particular band */
  75.  
  76. /* I_FLUSHBAND */
  77. struct bandinfo 
  78. {
  79.     unsigned char    bi_pri;         /* Band to flush */
  80.     int             bi_flag;        /* One of the above flush requests */
  81. };
  82.  
  83. /* flags for I_ATMARK */
  84. #define ANYMARK         0x1             /* Check if message is marked */
  85. #define LASTMARK        0x2             /* Check if this is the only message marked */
  86.  
  87. /* signal event masks */
  88. #define S_INPUT         0x1     /* A non-M_PCPROTO message has arrived */
  89. #define S_HIPRI         0x2     /* A priority (M_PCPROTO) message is available */
  90. #define S_OUTPUT        0x4     /* The write queue is no longer full */
  91. #define S_MSG            0x8     /* A signal message has reached the front of read queue */
  92. #define S_RDNORM        0x10    /* A non-priority message is available */
  93. #define S_RDBAND        0x20    /* A banded messsage is available */
  94. #define S_WRNORM        0x40    /* Same as S_OUTPUT */
  95. #define S_WRBAND        0x80    /* A priority band exists and is writable */
  96. #define S_ERROR         0x100    /* Error message has arrived */
  97. #define S_HANGUP        0x200    /* Hangup message has arrived */
  98. #define S_BANDURG        0x400    /* Use SIGURG instead of SIGPOLL on S_RDBAND signals */
  99.  
  100. /* read mode bits for I_S|GRDOPT; choose one of the following */
  101. #define RNORM            0x01    /* byte-stream mode, default */
  102. #define RMSGD            0x02    /* message-discard mode */
  103. #define RMSGN            0x04    /* message-nondiscard mode */
  104. #define RFILL            0x08    /* fill read buffer mode (PSE private) */
  105.  
  106. /* More read modes, these are bitwise or'ed with the modes above */
  107. #define RPROTNORM        0x10    /* Normal handling of M_PROTO/M_PCPROTO messages, default */
  108. #define RPROTDIS        0x20    /* Discard M_PROTO/M_PCPROTO message blocks */
  109. #define RPROTDAT        0x40    /* Convert M_PROTO/M_PCPROTO message blocks into M_DATA */
  110.  
  111. /* write modes for I_S|GWROPT */
  112. #define SNDZERO         0x1     /* Send a zero-length message downstream on a write of zero bytes */
  113.  
  114. #define MUXID_ALL        -1        /* Unlink all lower streams for I_UNLINK and I_PUNLINK */
  115.  
  116. struct strbuf 
  117. {
  118.     int     maxlen;         /* max buffer length */
  119.     int     len;            /* length of data */
  120.     char*    buf;            /* pointer to buffer */
  121. };
  122.  
  123. /* structure of ioctl data on I_FDINSERT */
  124. struct strfdinsert 
  125. {
  126.     struct strbuf    ctlbuf;
  127.     struct strbuf    databuf;
  128.     long            flags;    /* type of message, 0 or RS_HIPRI */
  129.     long            fildes; /* fd of other stream (FDCELL) */
  130.     int             offset; /* where to put other stream read qp */
  131. };
  132.  
  133. /* I_LIST structures */
  134. struct str_list 
  135. {
  136.     int     sl_nmods;                /* number of modules in sl_modlist array */
  137.     struct str_mlist* sl_modlist;
  138. };
  139.  
  140. struct str_mlist 
  141. {
  142.     char    l_name[FMNAMESZ + 1];
  143. };
  144.  
  145. /* I_PEEK structure */
  146. struct strpeek 
  147. {
  148.     struct strbuf    ctlbuf;
  149.     struct strbuf    databuf;
  150.     long            flags;    /* if RS_HIPRI, get priority messages only */
  151. };
  152.  
  153. struct strpmsg                 /* structure for getpmsg and putpmsg */
  154. {
  155.     struct strbuf    ctlbuf;
  156.     struct strbuf    databuf;
  157.     int             band;
  158.     long            flags;
  159. };
  160.  
  161. /* structure of ioctl data on I_RECVFD */
  162. struct strrecvfd 
  163. {
  164.     long            fd;     /* new file descriptor (FDCELL) */
  165.     unsigned short    uid;    /* user id of sending stream */
  166.     unsigned short    gid;
  167.     char            fill[8];
  168. };
  169.  
  170. #if 0
  171. /* structure of ioctl data on I_STR */
  172. struct strioctl 
  173. {
  174.     int     ic_cmd;         /* downstream command */
  175.     int     ic_timout;        /* ACK/NAK timeout */
  176.     int     ic_len;         /* length of data arg */
  177.     char*    ic_dp;        /* ptr to data arg */
  178. };
  179. #endif
  180.  
  181. #if !OTKERNEL
  182.  
  183. #ifdef __cplusplus
  184. extern "C" {
  185. #endif
  186.  
  187. pascal    int getmsg(int fd, struct strbuf* ctlbuf, struct strbuf* databuf, int* flagsp);
  188. pascal    int putmsg(int fd, const struct strbuf* ctlbuf, const struct strbuf* databuf, int flags);
  189. pascal    int getpmsg(int fd, struct strbuf* ctlbuf, struct strbuf* databuf, int* bandp, int* flagsp);
  190. pascal    int putpmsg(int fd, const struct strbuf* ctlbuf, const struct strbuf* databuf, int band, int flags);
  191. //
  192. // These are here for compatibility with the rest of xti, but are not the preferred interfaces.
  193. //
  194. #ifdef __OPENTRANSPORT__
  195. pascal int    stream_installnotifier(int fd, OTNotifyProcPtr, void* contextPtr);
  196. pascal int    stream_blocking(int fd);
  197. pascal int    stream_nonblocking(int fd);
  198. pascal int    stream_isblocking(int fd);
  199. pascal int    stream_synchronous(int fd);
  200. pascal int    stream_asynchronous(int fd);
  201. pascal int    stream_issynchronous(int fd);
  202. #endif
  203. pascal int    stream_open(char* path, unsigned long);
  204. pascal int    stream_close(int fd);
  205. pascal int    stream_read(int fd, void* buf, size_t len);
  206. pascal int    stream_write(int fd, void* buf, size_t len);
  207.        int    stream_ioctl(int fd, unsigned long type, ...);
  208. pascal int    stream_pipe(int*);
  209. pascal int    poll(struct pollfd* fds, size_t nfds, unsigned long timeout);
  210.  
  211. #ifdef __cplusplus
  212. }
  213. #endif
  214.  
  215. #endif /* OTKERNEL */
  216.  
  217. #endif            /* ifdef _STROPTS_ */
  218.  
  219.