263{
264 mBuff *theMsg;
265 char *body;
266 int bleft, bmore, iovX;
267
268
269
270
271
272 if (active)
273 {bleft = 0;
274 for (iovX = 0; iovX < iovcnt; iovX++)
275 if ((bleft = iov[iovX].iov_len)) break;
276 if (!bleft) return iotot;
277 } else {
278 if ((bleft = SendNB(iov, iovcnt, iotot, iovX)) <= 0)
279 return (bleft ? -1 : 0);
280 }
281
282
283
284 bmore = bleft;
285 for (int i = iovX+1; i < iovcnt; i++) bmore += iov[i].iov_len;
286
287
288
289 if (!(theMsg = (mBuff *)malloc(bmore+sizeof(mBuff))))
290 {errno = ENOMEM; return -1;}
291
292
293
294 theMsg->mLen = bmore;
295
296
297
298 body = theMsg->mData;
299 memcpy(body, ((char *)iov[iovX].iov_base)+(iov[iovX].iov_len-bleft), bleft);
300 body += bleft;
301
302
303
304 for (int i = iovX+1; i < iovcnt; i++)
305 {if (iov[i].iov_len)
306 {memcpy(body, iov[i].iov_base, iov[i].iov_len);
307 body += iov[i].iov_len;
308 }
309 }
310
311
312
313 return (QMsg(theMsg) ? iotot : 0);
314}