Changeset 3347cd9 in code for icbd.c


Ignore:
Timestamp:
Jun 13, 2015, 11:25:37 PM (10 years ago)
Author:
Mike Belopuhov <mike@…>
Branches:
master
Children:
61fdba7
Parents:
a56efea
Message:

Make packet dump in debug mode more readable

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icbd.c

    ra56efea r3347cd9  
    3636#include <login_cap.h>
    3737#include <locale.h>
     38#include <ctype.h>
    3839#include <netdb.h>
    3940#include <event.h>
     
    386387                            is->rlen, is->length, is->host, is->port);
    387388                        for (i = 0; i < (int)is->rlen; i++)
    388                                 printf(" %02x", (unsigned char)is->buffer[i]);
     389                                printf(isprint(is->buffer[i]) ? "%c" :
     390                                    "\\x%02x", (unsigned char)is->buffer[i]);
    389391                        printf("\n");
    390392                }
     
    415417                printf("-> wrote %lu to %s:%d:\n", size, is->host, is->port);
    416418                for (i = 0; i < size; i++)
    417                         printf(" %02x", (unsigned char)buf[i]);
     419                        printf(isprint(buf[i]) ? "%c" : "\\x%02x",
     420                            (unsigned char)buf[i]);
    418421                printf("\n");
    419422        }
Note: See TracChangeset for help on using the changeset viewer.