Changeset 619


Ignore:
Timestamp:
Mar 15, 2006, 4:03:43 PM (14 years ago)
Author:
Jean-Yves Lamoureux
Message:
  • Added telnet commands and options strings for debug
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/caca/driver_network.c

    r611 r619  
    4747/* Following vars are static */
    4848#define INIT_PREFIX \
    49     "\xff\xfb\x01" /* WILL ECHO */ \
    50     "\xff\xfb\x03" /* WILL SUPPRESS GO AHEAD */ \
    51     "\xff\xfd\x31" /* DO NAWS */ \
    52     "\xff\xfe\x1f" /* DON'T NAWS */ \
    53     "\xff\x1f\xfa____" /* Set size, replaced in display */ \
    54     "\xff\xf0" \
     49    "\xff\xfb\x01"     /* WILL ECHO */ \
     50    "\xff\xfb\x03"     /* WILL SUPPRESS GO AHEAD */ \
     51    "\xff\xfd\x31"     /* DO NAWS */ \
     52    "\xff\x1f\xfa____" /* SB NAWS */ \
     53    "\xff\xf0"         /* SE */  \
    5554    "\x1b]2;caca for the network\x07" /* Change window title */ \
    56     "\x1b[H\x1b[J" /* Clear screen */ \
    57     /*"\x1b[?25l"*/ /* Hide cursor */ \
     55    "\x1b[H\x1b[J" /* Clear screen */
     56    /*"\x1b[?25l"*/ /* Hide cursor */
    5857
    5958#define ANSI_PREFIX \
     
    6564    "\x1b[?1049h" /* Clear screen */ \
    6665    "\x1b[?1049h" /* Clear screen again */
     66
     67
     68static char const telnet_commands[16][5] =
     69    {"SE  ", "NOP ", "DM  ", "BRK ", "IP  ", "AO  ", "AYT ", "EC  ",
     70     "EL  ", "GA  ", "SB  ", "WILL", "WONT", "DO  ", "DONT", "IAC "};
     71
     72static char const telnet_options[37][5] =
     73    {"????", "ECHO", "????", "SUGH", "????", "STTS", "TIMK", "????", "????", "????",
     74     "????", "????", "????", "????", "????", "????", "????", "????", "????", "????",
     75     "????", "????", "????", "????", "TTYP", "????", "????", "????", "????", "????",
     76     "????", "NAWS", "TRSP", "RMFC", "LIMO", "????", "EVAR"};
     77
     78
     79#define COMMAND_NAME(x) (x>=240)?telnet_commands[x-240]:"????"
     80#define OPTION_NAME(x) (x<=36)?telnet_options[x]:"????"
     81
    6782
    6883struct client
     
    358373                if(c->inbytes == 3)
    359374                {
    360                     fprintf(stderr, "client %i said: %.02x %.02x %.02x\n",
    361                             c->fd, c->inbuf[0], c->inbuf[1], c->inbuf[2]);
     375                    fprintf(stderr, "client %i said: %.02x %.02x %.02x (%s %s %s)\n",
     376                            c->fd, c->inbuf[0], c->inbuf[1], c->inbuf[2],
     377                            COMMAND_NAME(c->inbuf[0]), COMMAND_NAME(c->inbuf[1]), OPTION_NAME(c->inbuf[2]));
    362378                    /* Just ignore, lol */
    363379                    c->inbytes = 0;
Note: See TracChangeset for help on using the changeset viewer.