*** empty log message ***
[arla.git] / rx / rx_strm.h
blobe3dd427c1da57d9a012edf64220ae41d7856d978
1 /* $Header$ */
2 /* $Source$ */
4 /*
5 ****************************************************************************
6 * Copyright IBM Corporation 1988, 1989 - All Rights Reserved *
7 * *
8 * Permission to use, copy, modify, and distribute this software and its *
9 * documentation for any purpose and without fee is hereby granted, *
10 * provided that the above copyright notice appear in all copies and *
11 * that both that copyright notice and this permission notice appear in *
12 * supporting documentation, and that the name of IBM not be used in *
13 * advertising or publicity pertaining to distribution of the software *
14 * without specific, written prior permission. *
15 * *
16 * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL *
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL IBM *
18 * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY *
19 * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER *
20 * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING *
21 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. *
22 ****************************************************************************
25 /* rx_stream.h: the stream I/O layer for RX */
27 This file is now obsolete.
31 #ifndef _RX_STREAM_
32 #define _RX_STREAM_
34 #ifdef KERNEL
35 #include "../rx/rx.h"
36 #else /* KERNEL */
37 #include <sys/types.h>
38 #include <sys/uio.h>
39 #include "rx.h"
40 #endif /* KERNEL */
42 /* Write descriptor */
43 struct rx_stream_wd {
44 char *freePtr; /* Pointer to bytes in first packet */
45 int nFree; /* Number of bytes free in first
46 * packet */
47 struct rx_call *call; /* The call this stream is attached to */
48 struct rx_queue wq; /* Currently allocated packets for
49 * this stream */
50 int packetSize; /* Data size used in each packet */
53 /* Read descriptor */
54 struct rx_stream_rd {
55 struct rx_packet *packet; /* The current packet */
56 char *nextByte; /* Pointer to bytes in current packet */
57 int nLeft; /* Number of bytes free in current
58 * packet */
59 struct rx_call *call; /* The call this stream is attached to */
60 struct rx_queue rq; /* Currently allocated packets for
61 * this stream */
62 struct rx_queue freeTheseQ; /* These packets should be freed on
63 * the next operation */
66 /* Composite stream descriptor */
67 struct rx_stream {
68 union {
69 struct rx_stream_rd rd;
70 struct rx_stream_wd wd;
71 } sd;
74 /* Externals */
75 void rx_stream_InitWrite();
76 void rx_stream_InitRead();
77 void rx_stream_FinishWrite();
78 void rx_stream_FinishRead();
79 int rx_stream_Read();
80 int rx_stream_Write();
81 int rx_stream_AllocIov();
83 /* Write nbytes of data to the write stream. Returns the number of bytes written */
84 /* If it returns 0, the call status should be checked with rx_Error. */
85 #define rx_stream_Write(iod, buf, nbytes) \
86 (iod)->sd.wd.nFree > (nbytes) ? \
87 (buf) && memcpy((iod)->sd.wd.freePtr, (buf), (nbytes)), \
88 (iod)->sd.wd.nFree -= (nbytes), \
89 (iod)->sd.wd.freePtr += (nbytes), (nbytes) \
90 : rx_stream_WriteProc((iod), (buf), (nbytes))
93 /* Read nbytes of data from the read stream. Returns the number of bytes read */
94 /* If it returns less than requested, the call status should be checked with rx_Error */
95 #define rx_stream_Read(iod, buf, nbytes) \
96 (iod)->sd.rd.nLeft > (nbytes) ? \
97 memcpy((buf), (iod)->sd.rd.nextByte, (nbytes)), \
98 (iod)->sd.rd.nLeft -= (nbytes), (iod)->sd.rd.nextByte += (nbytes), (nbytes) \
99 : rx_stream_ReadProc((iod), (buf), (nbytes))
101 #endif /* _RX_STREAM_ End of rx_stream.h */