1 
  2 
  3 
  4 
  5 
  6 
  7 
  8 
  9 
 10 
 11 
 12 
 13 
 14 
 15 
 16 
 17 
 18 
 19 
 20 
 21 #include <stdio.h>
 22 #include <ws.h>
 23 #include <alloc.h>
 24 #include <ws_mcb.h>
 25 #include <ws_error.h>
 26 #include <ws_func.h>
 27 #include <ws_dcls.h>
 28 #include <wsmincap.h>
 29 
 30 #define HEADER_LENGTH 6                
 31 
 32 extern char local_system;              
 33 
 34 execap (p_major_num, p_minor_num, p_arg_ptr, p_arg_len, p_mcb_ptr)
 35 
 36 int  p_major_num;                      
 37 int  p_minor_num;                      
 38 char *p_arg_ptr;                       
 39 int  p_arg_len;                        
 40 mcb  *p_mcb_ptr;                       
 41 {
 42 struct xcap_struc xcap;
 43 char              *c1;
 44 char              *c2;
 45 char              *temp_p_arg_ptr;
 46 int               i;
 47 int               code;
 48 int               copylen;
 49 int               header_size;
 50 struct linklst    *new_msg_portion;
 51 struct linklst    *dead_buffer;
 52 struct linklst    *pending_msg_buffer;
 53 struct linklst    *pending_msg_link;
 54 struct linklst    *portion;
 55 struct linklst    *buffer_portion();
 56 int j;
 57 
 58    code = 0;
 59 
 60 
 61 
 62    if (p_mcb_ptr == NULL)
 63       return (WSINVMCB);
 64 
 65 
 66 
 67    xcap.system =  (p_major_num >> 8);
 68    if ((xcap.system != WSIBMPC) && (xcap.system != WSMULTICS))
 69       return (WSINVSYS);
 70 
 71    xcap.major = (char) (0xff & p_major_num);
 72    if ((xcap.major < WSMAJCAP) || (xcap.major > MAX_CAPABILITY_NUMBER - 1))
 73       return (WSINVNUM);
 74 
 75 
 76 
 77 
 78 
 79    if ((p_arg_len > WSPAKSIZ) && (p_mcb_ptr -> outbuff != NULL))
 80       return (WSBUFOVR);
 81 
 82 
 83 
 84 
 85 
 86 
 87 
 88 
 89    pending_msg_buffer = p_mcb_ptr -> outbuff;
 90    if (pending_msg_buffer != NULL)
 91        while (pending_msg_buffer->nextbuf != NULL)
 92           pending_msg_buffer = pending_msg_buffer -> nextbuf;
 93 
 94    pending_msg_link = NULL;
 95    temp_p_arg_ptr = p_arg_ptr;
 96 
 97 
 98 
 99    while (p_arg_len >= 0)
100    {  if (p_arg_len > (WSPAKSIZ - HEADER_LENGTH))
101       {  copylen = WSPAKSIZ - HEADER_LENGTH;
102          xcap.minor = PARTIAL_MESSAGE;
103          xcap.source_system = p_minor_num;
104          xcap.source_major = p_mcb_ptr->system_id;
105          xcap.xcapstr[0] = p_mcb_ptr->major_capability;
106          header_size = HEADER_LENGTH;
107       }
108       else
109       {  copylen = p_arg_len;
110          xcap.minor = p_minor_num;
111          xcap.source_system = p_mcb_ptr->system_id;
112          xcap.source_major = p_mcb_ptr->major_capability;
113          header_size = 5;
114          p_arg_len = -1;                                
115       }
116 
117 
118 
119       new_msg_portion =
120          (struct linklst *) wsalloc (p_mcb_ptr -> outalloc, header_size+copylen+sizeof(struct linklst));
121 
122 
123 
124       if (new_msg_portion != NULL)
125       {  c1 = (char *) ⋂
126          c2 = &(new_msg_portion -> lldata[0]);
127          for (i = 0; i < header_size; i++)
128             c2[i] = c1[i];
129 
130 
131 
132          c1 = temp_p_arg_ptr;
133          for (i = 0; i < copylen; i++)
134             c2[i + header_size] = c1[i];
135 
136          p_arg_len = p_arg_len - copylen;
137          temp_p_arg_ptr = &(c1[i]);
138 
139 
140 
141          new_msg_portion->nextbuf = NULL;
142          new_msg_portion->nextlink = NULL;
143          new_msg_portion->linkused = copylen + header_size;
144 
145 
146 
147 
148          if (pending_msg_buffer == NULL)              
149          {  p_mcb_ptr->outbuff = new_msg_portion;
150             pending_msg_buffer = new_msg_portion;
151             pending_msg_link = new_msg_portion;
152          }
153          else
154          {  if (pending_msg_link == NULL)             
155             {  pending_msg_link = pending_msg_buffer;
156                while (pending_msg_link->nextlink != NULL)
157                   pending_msg_link = pending_msg_link->nextlink;
158             }
159             pending_msg_link->nextlink = new_msg_portion;
160             pending_msg_link = new_msg_portion;
161          }
162       }
163 
164 
165 
166 
167       else
168       {  dead_buffer = p_mcb_ptr->outbuff;
169          while (dead_buffer != NULL)
170          {  pending_msg_buffer = dead_buffer->nextlink;
171             llpfree(p_mcb_ptr -> outalloc,&p_mcb_ptr->outbuff,dead_buffer);
172             dead_buffer = pending_msg_buffer;
173          }
174          return (WSBUFOVR);
175       }
176    }
177 
178 
179 
180    portion = buffer_portion(p_mcb_ptr, pending_msg_buffer);
181    code = call_mowse_int (I$EXECAP, portion->lldata, portion->linkused);
182    wsfree (p_mcb_ptr -> outalloc, portion);
183    if (code)
184       llpfree (p_mcb_ptr -> outalloc, &(p_mcb_ptr -> outbuff), portion -> nextlink);
185    return (code);
186 }
187 
188 
189 
190 
191 
192 
193 struct linklst *buffer_portion(p_mcb_ptr, p_buffer)
194 
195 mcb *p_mcb_ptr;
196 struct linklst *p_buffer;
197 {
198 struct linklst *portion;
199 struct linklst *msg_buffer_prev;
200 
201 
202 
203    if (p_mcb_ptr == NULL)
204       return(NULL);
205 
206 
207 
208    if (p_buffer == NULL)
209       return(NULL);
210 
211 
212 
213    portion = p_buffer;
214 
215 
216 
217    msg_buffer_prev = p_mcb_ptr->outbuff;
218    if (msg_buffer_prev == NULL)
219       return(NULL);
220 
221 
222 
223 
224    while (msg_buffer_prev->nextbuf != p_buffer)
225       if ((msg_buffer_prev = msg_buffer_prev->nextbuf) == NULL)
226          break;
227 
228    if (msg_buffer_prev == NULL)
229       p_mcb_ptr->outbuff = p_buffer->nextlink;
230    else
231    {  msg_buffer_prev->nextbuf = p_buffer->nextlink;
232       p_buffer->nextlink->nextbuf = p_buffer->nextbuf;
233    }
234 
235    return(portion);
236 }