2 * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
9 #ifndef SQUID_LIBNTLMAUTH_SUPPORT_BITS_CCI
10 #define SQUID_LIBNTLMAUTH_SUPPORT_BITS_CCI
17 * Defines several functions which are used and mutually shared by the NTLM helpers
18 * These do not (yet) have a defined stable home to go to.
19 * For now include this file into helper main .cc where needed.
22 /* makes a null-terminated string upper-case. Changes CONTENTS! */
33 /* makes a null-terminated string lower-case. Changes CONTENTS! */
45 hex_dump(unsigned char *data, int size)
47 /* dumps size bytes of *data to stdout. Looks like:
48 * [0000] 75 6E 6B 6E 6F 77 6E 20
49 * 30 FF 00 00 00 00 39 00 unknown 0.....9.
50 * (in a single line of course)
57 unsigned char *p = data;
60 char bytestr[4] = {0};
61 char addrstr[10] = {0};
62 char hexstr[16 * 3 + 5] = {0};
63 char charstr[16 * 1 + 5] = {0};
64 for (n = 1; n <= size; ++n) {
66 /* store address for this line */
67 snprintf(addrstr, sizeof(addrstr), "%.4x", (int) (p - data));
70 if (xisalnum(c) == 0) {
73 /* store hex str (for left side) */
74 snprintf(bytestr, sizeof(bytestr), "%02X ", *p);
75 strncat(hexstr, bytestr, sizeof(hexstr) - strlen(hexstr) - 1);
77 /* store char str (for right side) */
78 snprintf(bytestr, sizeof(bytestr), "%c", c);
79 strncat(charstr, bytestr, sizeof(charstr) - strlen(charstr) - 1);
83 fprintf(stderr, "[%4.4s] %-50.50s %s\n", addrstr, hexstr, charstr);
86 } else if (n % 8 == 0) {
87 /* half line: add whitespaces */
88 strncat(hexstr, " ", sizeof(hexstr) - strlen(hexstr) - 1);
89 strncat(charstr, " ", sizeof(charstr) - strlen(charstr) - 1);
94 if (strlen(hexstr) > 0) {
95 /* print rest of buffer if not empty */
96 fprintf(stderr, "[%4.4s] %-50.50s %s\n", addrstr, hexstr, charstr);
100 if (0) { //temporary hack to keep the linker happy
108 #endif /* SQUID_LIBNTLMAUTH_SUPPORT_BITS_CCI */