… | |
… | |
118 | SockList::printf (const char *format, ...) |
118 | SockList::printf (const char *format, ...) |
119 | { |
119 | { |
120 | va_list ap; |
120 | va_list ap; |
121 | va_start (ap, format); |
121 | va_start (ap, format); |
122 | |
122 | |
123 | len += vsprintf ((char *)buf + len, format, ap); |
123 | len += vsnprintf ((char *)buf + len, MAXSOCKBUF, format, ap); |
124 | |
124 | |
125 | va_end (ap); |
125 | va_end (ap); |
126 | } |
126 | } |
127 | |
127 | |
128 | /****************************************************************************** |
128 | /****************************************************************************** |
… | |
… | |
360 | cst_lst.obytes += amt; |
360 | cst_lst.obytes += amt; |
361 | #endif |
361 | #endif |
362 | } |
362 | } |
363 | } |
363 | } |
364 | |
364 | |
365 | |
|
|
366 | /** |
365 | /** |
367 | * Takes a string of data, and writes it out to the socket. A very handy |
366 | * Takes a string of data, and writes it out to the socket. A very handy |
368 | * shortcut function. |
367 | * shortcut function. |
369 | */ |
368 | */ |
370 | void |
|
|
371 | cs_write_string (NewSocket *ns, const char *buf, int len) |
|
|
372 | { |
|
|
373 | SockList sl; |
|
|
374 | |
369 | |
375 | sl.len = len; |
370 | void |
376 | sl.buf = (unsigned char *) buf; |
371 | NewSocket::send_packet (SockList &sl) |
|
|
372 | { |
377 | Send_With_Handling (ns, &sl); |
373 | Send_With_Handling (this, &sl); |
378 | } |
374 | } |
379 | |
375 | |
|
|
376 | void |
|
|
377 | NewSocket::send_packet (const char *buf, int len) |
|
|
378 | { |
|
|
379 | SockList sl (MAXSOCKBUF); |
|
|
380 | |
|
|
381 | sl << data (buf, len); |
|
|
382 | send_packet (sl); |
|
|
383 | sl.free (); |
|
|
384 | } |
|
|
385 | |
|
|
386 | void |
|
|
387 | NewSocket::send_packet (const char *buf) |
|
|
388 | { |
|
|
389 | send_packet (buf, strlen (buf)); |
|
|
390 | } |
380 | |
391 | |
381 | /** |
392 | /** |
382 | * Calls Write_To_Socket to send data to the client. |
393 | * Calls Write_To_Socket to send data to the client. |
383 | * |
394 | * |
384 | * The only difference in this function is that we take a SockList |
395 | * The only difference in this function is that we take a SockList |
… | |
… | |
404 | sbuf[1] = ((uint32) (msg->len)) & 0xFF; |
415 | sbuf[1] = ((uint32) (msg->len)) & 0xFF; |
405 | if (ns->status != Ns_Old) |
416 | if (ns->status != Ns_Old) |
406 | Write_To_Socket (ns, (char *) sbuf, 2); |
417 | Write_To_Socket (ns, (char *) sbuf, 2); |
407 | Write_To_Socket (ns, (char *) msg->buf, msg->len); |
418 | Write_To_Socket (ns, (char *) msg->buf, msg->len); |
408 | } |
419 | } |
409 | |
|
|
410 | /** |
|
|
411 | * Takes a string of data, and writes it out to the socket. A very handy |
|
|
412 | * shortcut function. |
|
|
413 | */ |
|
|
414 | void |
|
|
415 | Write_String_To_Socket (NewSocket *ns, char *buf, int len) |
|
|
416 | { |
|
|
417 | SockList sl; |
|
|
418 | |
|
|
419 | sl.len = len; |
|
|
420 | sl.buf = (unsigned char *) buf; |
|
|
421 | Send_With_Handling (ns, &sl); |
|
|
422 | } |
|
|
423 | |
|
|
424 | |
420 | |
425 | /****************************************************************************** |
421 | /****************************************************************************** |
426 | * |
422 | * |
427 | * statistics logging functions. |
423 | * statistics logging functions. |
428 | * |
424 | * |