1 #ifndef SQUID_LIBNTLMAUTH_SUPPORT_BITS_CCI
2 #define SQUID_LIBNTLMAUTH_SUPPORT_BITS_CCI
9 * Defines several functions which are used and mutually shared by the NTLM helpers
10 * These do not (yet) have a defined stable home to go to.
11 * For now include this file into helper main .cc where needed.
14 /* makes a null-terminated string upper-case. Changes CONTENTS! */
25 /* makes a null-terminated string lower-case. Changes CONTENTS! */
37 hex_dump(unsigned char *data, int size)
39 /* dumps size bytes of *data to stdout. Looks like:
40 * [0000] 75 6E 6B 6E 6F 77 6E 20
41 * 30 FF 00 00 00 00 39 00 unknown 0.....9.
42 * (in a single line of course)
49 unsigned char *p = data;
52 char bytestr[4] = {0};
53 char addrstr[10] = {0};
54 char hexstr[16 * 3 + 5] = {0};
55 char charstr[16 * 1 + 5] = {0};
56 for (n = 1; n <= size; ++n) {
58 /* store address for this line */
59 snprintf(addrstr, sizeof(addrstr), "%.4x", (int) (p - data));
62 if (xisalnum(c) == 0) {
65 /* store hex str (for left side) */
66 snprintf(bytestr, sizeof(bytestr), "%02X ", *p);
67 strncat(hexstr, bytestr, sizeof(hexstr) - strlen(hexstr) - 1);
69 /* store char str (for right side) */
70 snprintf(bytestr, sizeof(bytestr), "%c", c);
71 strncat(charstr, bytestr, sizeof(charstr) - strlen(charstr) - 1);
75 fprintf(stderr, "[%4.4s] %-50.50s %s\n", addrstr, hexstr, charstr);
78 } else if (n % 8 == 0) {
79 /* half line: add whitespaces */
80 strncat(hexstr, " ", sizeof(hexstr) - strlen(hexstr) - 1);
81 strncat(charstr, " ", sizeof(charstr) - strlen(charstr) - 1);
86 if (strlen(hexstr) > 0) {
87 /* print rest of buffer if not empty */
88 fprintf(stderr, "[%4.4s] %-50.50s %s\n", addrstr, hexstr, charstr);
92 if (0) { //temporary hack to keep the linker happy
100 #endif /* SQUID_LIBNTLMAUTH_SUPPORT_BITS_CCI */