… | |
… | |
308 | |
308 | |
309 | end = ns->outputbuffer.start + ns->outputbuffer.len; |
309 | end = ns->outputbuffer.start + ns->outputbuffer.len; |
310 | /* The buffer is already in a wrapped state, so adjust end */ |
310 | /* The buffer is already in a wrapped state, so adjust end */ |
311 | if (end >= SOCKETBUFSIZE) |
311 | if (end >= SOCKETBUFSIZE) |
312 | end -= SOCKETBUFSIZE; |
312 | end -= SOCKETBUFSIZE; |
|
|
313 | |
313 | avail = SOCKETBUFSIZE - end; |
314 | avail = SOCKETBUFSIZE - end; |
314 | |
315 | |
315 | /* We can all fit it behind the current data without wrapping */ |
316 | /* We can all fit it behind the current data without wrapping */ |
316 | if (avail >= len) |
317 | if (avail >= len) |
317 | { |
|
|
318 | memcpy (ns->outputbuffer.data + end, buf, len); |
318 | memcpy (ns->outputbuffer.data + end, buf, len); |
319 | } |
|
|
320 | else |
319 | else |
321 | { |
320 | { |
322 | memcpy (ns->outputbuffer.data + end, buf, avail); |
321 | memcpy (ns->outputbuffer.data + end, buf, avail); |
323 | memcpy (ns->outputbuffer.data, buf + avail, len - avail); |
322 | memcpy (ns->outputbuffer.data, buf + avail, len - avail); |
324 | } |
323 | } |
|
|
324 | |
325 | ns->outputbuffer.len += len; |
325 | ns->outputbuffer.len += len; |
326 | #if 0 |
326 | #if 0 |
327 | LOG (llevDebug, "Added %d to output buffer, total length now %d, start=%d\n", len, ns->outputbuffer.len, ns->outputbuffer.start); |
327 | LOG (llevDebug, "Added %d to output buffer, total length now %d, start=%d\n", len, ns->outputbuffer.len, ns->outputbuffer.start); |
328 | #endif |
328 | #endif |
329 | } |
329 | } |