2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 /* rx_stream.h: the stream I/O layer for RX */
12 This file is now obsolete.
18 #include <sys/types.h>
22 /* Write descriptor */
24 char *freePtr; /* Pointer to bytes in first packet */
25 int nFree; /* Number of bytes free in first packet */
26 struct rx_call *call; /* The call this stream is attached to */
27 struct rx_queue wq; /* Currently allocated packets for this stream */
28 int packetSize; /* Data size used in each packet */
33 struct rx_packet *packet; /* The current packet */
34 char *nextByte; /* Pointer to bytes in current packet */
35 int nLeft; /* Number of bytes free in current packet */
36 struct rx_call *call; /* The call this stream is attached to */
37 struct rx_queue rq; /* Currently allocated packets for this stream */
38 struct rx_queue freeTheseQ; /* These packets should be freed on the next operation */
41 /* Composite stream descriptor */
44 struct rx_stream_rd rd;
45 struct rx_stream_wd wd;
50 void rx_stream_InitWrite();
51 void rx_stream_InitRead();
52 void rx_stream_FinishWrite();
53 void rx_stream_FinishRead();
55 int rx_stream_Write();
56 int rx_stream_AllocIov();
58 /* Write nbytes of data to the write stream. Returns the number of bytes written */
59 /* If it returns 0, the call status should be checked with rx_Error. */
60 #define rx_stream_Write(iod, buf, nbytes) \
61 (iod)->sd.wd.nFree > (nbytes) ? \
62 (buf) && memcpy((iod)->sd.wd.freePtr, (buf), (nbytes)), \
63 (iod)->sd.wd.nFree -= (nbytes), \
64 (iod)->sd.wd.freePtr += (nbytes), (nbytes) \
65 : rx_stream_WriteProc((iod), (buf), (nbytes))
68 /* Read nbytes of data from the read stream. Returns the number of bytes read */
69 /* If it returns less than requested, the call status should be checked with rx_Error */
70 #define rx_stream_Read(iod, buf, nbytes) \
71 (iod)->sd.rd.nLeft > (nbytes) ? \
72 memcpy((buf), (iod)->sd.rd.nextByte, (nbytes)), \
73 (iod)->sd.rd.nLeft -= (nbytes), (iod)->sd.rd.nextByte += (nbytes), (nbytes) \
74 : rx_stream_ReadProc((iod), (buf), (nbytes))
76 #endif /* _RX_STREAM_ End of rx_stream.h */