2 *****************************************************************************
6 * Author: Damien S. Stuart
8 * Purpose: General/Generic functions for the fwknop client.
10 * Copyright 2009-2010 Damien Stuart (dstuart@dstuart.org)
12 * License (GNU Public License):
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
29 *****************************************************************************
35 /* Generic hex dump function.
38 hex_dump(const unsigned char *data, const int size)
41 char ascii_str[17] = {0};
47 printf(" %s\n 0x%.4x: ", ascii_str, i);
48 memset(ascii_str, 0x0, 17);
52 printf("%.2x ", data[i]);
54 ascii_str[j++] = (data[i] < 0x20 || data[i] > 0x7e) ? '.' : data[i];
62 ln = strlen(ascii_str);
65 for(i=0; i < 16-ln; i++)
68 printf(" %s\n\n", ascii_str);