… | |
… | |
202 | {"mapinfo", PC(MapInfoCmd) 0 }, /* CF+ */ |
202 | {"mapinfo", PC(MapInfoCmd) 0 }, /* CF+ */ |
203 | |
203 | |
204 | {"reply", SC(ReplyCmd) 0 }, |
204 | {"reply", SC(ReplyCmd) 0 }, |
205 | {"exti", SC(ExtiCmd) 0 }, /* CF+ */ |
205 | {"exti", SC(ExtiCmd) 0 }, /* CF+ */ |
206 | {"addme", SC(AddMeCmd) 0 }, |
206 | {"addme", SC(AddMeCmd) 0 }, |
207 | {"askface", SC(SendFaceCmd) 0 }, /* Added: phil */ |
207 | {"askface", SC(AskFaceCmd) 0 }, |
208 | {"requestinfo", SC(RequestInfo) 0 }, |
208 | {"requestinfo", SC(RequestInfo) 0 }, |
209 | {"setfacemode", SC(SetFaceMode) 0 }, |
209 | {"setfacemode", SC(SetFaceMode) 0 }, |
210 | {"setsound", SC(SetSound) 0 }, |
210 | {"setsound", SC(SetSound) 0 }, |
211 | {"setup", SC(SetUp) 0 }, |
211 | {"setup", SC(SetUp) 0 }, |
212 | {"version", SC(VersionCmd) 0 }, |
212 | {"version", SC(VersionCmd) 0 }, |
… | |
… | |
409 | */ |
409 | */ |
410 | void |
410 | void |
411 | client::send (void *buf_, int len) |
411 | client::send (void *buf_, int len) |
412 | { |
412 | { |
413 | char *buf = (char *)buf_; |
413 | char *buf = (char *)buf_; |
414 | char *pos = buf; |
|
|
415 | int amt = 0; |
|
|
416 | |
414 | |
417 | if (destroyed () || !buf) |
415 | if (destroyed () || !buf) |
418 | return; |
416 | return; |
419 | |
417 | |
420 | if (len + outputbuffer.len > SOCKETBUFSIZE) |
418 | if (len + outputbuffer.len > SOCKETBUFSIZE) |
421 | { |
419 | { |
422 | LOG (llevDebug, "socket on fd %d has overrun internal buffer - marking as dead\n", fd); |
420 | LOG (llevDebug, "socket on fd %d has overrun internal buffer - marking as dead\n", fd); |
423 | destroy (); |
421 | // shutdown the socket, this is safer than destroying it immediately |
|
|
422 | // as lots of code in the callchain might still access the map etc. |
|
|
423 | shutdown (fd, SHUT_RDWR); |
424 | return; |
424 | return; |
425 | } |
425 | } |
426 | |
426 | |
427 | int avail, end; |
427 | int avail, end; |
428 | |
428 | |
… | |
… | |
504 | va_end (ap); |
504 | va_end (ap); |
505 | |
505 | |
506 | send_packet (sl); |
506 | send_packet (sl); |
507 | } |
507 | } |
508 | |
508 | |
|
|
509 | void |
|
|
510 | client::send_drawinfo (const char *msg, int flags) |
|
|
511 | { |
|
|
512 | send_packet_printf ("drawinfo %d %s", flags, msg); |
|
|
513 | } |
|
|
514 | |
509 | /*********************************************************************** |
515 | /*********************************************************************** |
510 | * |
516 | * |
511 | * packet functions/utilities |
517 | * packet functions/utilities |
512 | * |
518 | * |
513 | **********************************************************************/ |
519 | **********************************************************************/ |
… | |
… | |
517 | reset (); |
523 | reset (); |
518 | |
524 | |
519 | int len = strlen (name); |
525 | int len = strlen (name); |
520 | memcpy (cur, name, len); cur += len; |
526 | memcpy (cur, name, len); cur += len; |
521 | *cur++ = ' '; |
527 | *cur++ = ' '; |
|
|
528 | } |
|
|
529 | |
|
|
530 | packet &packet::operator <<(const ber32 v) |
|
|
531 | { |
|
|
532 | enum { maxlen = 32 / 7 + 1}; |
|
|
533 | uint8 buf[maxlen]; |
|
|
534 | uint8 *p = buf + maxlen; |
|
|
535 | uint32 val = v.val; |
|
|
536 | |
|
|
537 | *--p = val & 0x7F; |
|
|
538 | |
|
|
539 | while (val > 0x7F) |
|
|
540 | { |
|
|
541 | val >>= 7; |
|
|
542 | *--p = (val & 0x7F) | 0x80; |
|
|
543 | } |
|
|
544 | |
|
|
545 | return *this << data (p, buf + maxlen - p); |
522 | } |
546 | } |
523 | |
547 | |
524 | packet &packet::operator <<(const data &v) |
548 | packet &packet::operator <<(const data &v) |
525 | { |
549 | { |
526 | if (room () < v.len) |
550 | if (room () < v.len) |