Commit | Line | Data |
---|---|---|
9e8e5516 C |
1 | /* ryopblock.c - manage operation blocks */ |
2 | ||
3 | #ifndef lint | |
4 | static char *rcsid = "$Header: /f/osi/rosy/RCS/ryopblock.c,v 7.3 91/02/22 09:42:03 mrose Interim $"; | |
5 | #endif | |
6 | ||
7 | /* | |
8 | * $Header: /f/osi/rosy/RCS/ryopblock.c,v 7.3 91/02/22 09:42:03 mrose Interim $ | |
9 | * | |
10 | * | |
11 | * $Log: ryopblock.c,v $ | |
12 | * Revision 7.3 91/02/22 09:42:03 mrose | |
13 | * Interim 6.8 | |
14 | * | |
15 | * Revision 7.2 90/12/23 18:42:48 mrose | |
16 | * update | |
17 | * | |
18 | * Revision 7.1 90/07/01 21:06:36 mrose | |
19 | * pepsy | |
20 | * | |
21 | * Revision 7.0 89/11/23 22:22:01 mrose | |
22 | * Release 6.0 | |
23 | * | |
24 | */ | |
25 | ||
26 | /* | |
27 | * NOTICE | |
28 | * | |
29 | * Acquisition, use, and distribution of this module and related | |
30 | * materials are subject to the restrictions of a license agreement. | |
31 | * Consult the Preface in the User's Manual for the full terms of | |
32 | * this agreement. | |
33 | * | |
34 | */ | |
35 | ||
36 | ||
37 | /* LINTLIBRARY */ | |
38 | ||
39 | #include <stdio.h> | |
40 | #include "rosy.h" | |
41 | ||
42 | /* \f DATA */ | |
43 | ||
44 | static int once_only = 0; | |
45 | static struct opsblk opsque; | |
46 | static struct opsblk *OPHead = &opsque; | |
47 | ||
48 | /* \f OPERATION BLOCKS */ | |
49 | ||
50 | struct opsblk *newopblk (sd, id) | |
51 | int sd, | |
52 | id; | |
53 | { | |
54 | register struct opsblk *opb; | |
55 | ||
56 | opb = (struct opsblk *) calloc (1, sizeof *opb); | |
57 | if (opb == NULL) | |
58 | return NULL; | |
59 | ||
60 | opb -> opb_flags |= OPB_INITIATOR; | |
61 | ||
62 | opb -> opb_fd = sd; | |
63 | opb -> opb_id = id; | |
64 | ||
65 | if (once_only == 0) { | |
66 | OPHead -> opb_forw = OPHead -> opb_back = OPHead; | |
67 | once_only++; | |
68 | } | |
69 | ||
70 | insque (opb, OPHead -> opb_back); | |
71 | ||
72 | return opb; | |
73 | } | |
74 | ||
75 | /* \f */ | |
76 | ||
77 | freeopblk (opb) | |
78 | register struct opsblk *opb; | |
79 | { | |
80 | if (opb == NULL) | |
81 | return; | |
82 | ||
83 | #ifdef PEPSY_DEFINITIONS | |
84 | if (opb -> opb_out && opb -> opb_free_mod) | |
85 | (void) fre_obj (opb -> opb_out, | |
86 | opb -> opb_free_mod -> md_dtab[opb -> opb_free_index], | |
87 | opb -> opb_free_mod, 1); | |
88 | #else | |
89 | if (opb -> opb_out && opb -> opb_free) | |
90 | (void) (*opb -> opb_free) (opb -> opb_out); | |
91 | #endif | |
92 | ||
93 | if (opb -> opb_pe) | |
94 | pe_free (opb -> opb_pe); | |
95 | ||
96 | remque (opb); | |
97 | ||
98 | free ((char *) opb); | |
99 | } | |
100 | ||
101 | /* \f */ | |
102 | ||
103 | struct opsblk *findopblk (sd, id, flags) | |
104 | register int sd, | |
105 | id, | |
106 | flags; | |
107 | { | |
108 | register struct opsblk *opb; | |
109 | ||
110 | if (once_only == 0) | |
111 | return NULL; | |
112 | ||
113 | flags &= OPB_INITIATOR | OPB_RESPONDER; | |
114 | for (opb = OPHead -> opb_forw; opb != OPHead; opb = opb -> opb_forw) | |
115 | if (opb -> opb_fd == sd | |
116 | && opb -> opb_id == id | |
117 | && (opb -> opb_flags & flags)) | |
118 | return opb; | |
119 | ||
120 | return NULL; | |
121 | } | |
122 | ||
123 | /* \f */ | |
124 | ||
125 | struct opsblk *firstopblk (sd) | |
126 | register int sd; | |
127 | { | |
128 | register struct opsblk *opb, | |
129 | *op2; | |
130 | ||
131 | if (once_only == 0) | |
132 | return NULL; | |
133 | ||
134 | op2 = NULLOPB; | |
135 | for (opb = OPHead -> opb_forw; opb != OPHead; opb = opb -> opb_forw) | |
136 | if (opb -> opb_fd == sd && (opb -> opb_flags & OPB_INITIATOR)) { | |
137 | if (opb -> opb_flags & OPB_EVENT) | |
138 | return opb; | |
139 | if (op2 == NULLOPB) | |
140 | op2 = opb; | |
141 | } | |
142 | ||
143 | return op2; | |
144 | } | |
145 | ||
146 | /* \f */ | |
147 | ||
148 | loseopblk (sd, reason) | |
149 | register int sd; | |
150 | int reason; | |
151 | { | |
152 | register struct opsblk *opb, | |
153 | *op2; | |
154 | struct RoSAPindication rois; | |
155 | ||
156 | if (once_only == 0) | |
157 | return; | |
158 | ||
159 | for (opb = OPHead -> opb_forw; opb != OPHead; opb = op2) { | |
160 | op2 = opb -> opb_forw; | |
161 | ||
162 | if (opb -> opb_fd == sd) { | |
163 | if (opb -> opb_errfnx) | |
164 | (*opb -> opb_errfnx) (sd, opb -> opb_id, RY_REJECT, | |
165 | (caddr_t) reason, &rois); | |
166 | ||
167 | freeopblk (opb); | |
168 | } | |
169 | } | |
170 | } | |
171 | ||
172 | /* \f */ | |
173 | ||
174 | #ifdef lint | |
175 | ||
176 | /* VARARGS */ | |
177 | ||
178 | int rosaplose (roi, reason, what, fmt) | |
179 | struct RoSAPindication *roi; | |
180 | int reason; | |
181 | char *what, | |
182 | *fmt; | |
183 | { | |
184 | return rosaplose (roi, reason, what, fmt); | |
185 | } | |
186 | #endif |