/[pcsclite]/trunk/Drivers/ccid/src/debug.c
ViewVC logotype

Contents of /trunk/Drivers/ccid/src/debug.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 892 - (show annotations) (download)
Mon May 24 12:58:43 2004 UTC (9 years ago) by rousseau
File MIME type: text/plain
File size: 1728 byte(s)
recompile using gcc -pedantic and correct:
- some C++ syntax comments
- many signedness "problems"
1 /*
2 debug.c: log (or not) messages
3 Copyright (C) 2003-2004 Ludovic Rousseau
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20 /*
21 * $Id$
22 */
23
24
25 #include "config.h"
26 #include "debug.h"
27
28 #include <stdarg.h>
29 #include <stdio.h>
30 #include <string.h>
31
32 #define DEBUG_BUF_SIZE ((256+20)*3+10)
33
34 static char DebugBuffer[DEBUG_BUF_SIZE];
35
36 void debug_msg(char *fmt, ...)
37 {
38 va_list argptr;
39
40 va_start(argptr, fmt);
41 vsnprintf(DebugBuffer, DEBUG_BUF_SIZE, fmt, argptr);
42 va_end(argptr);
43
44 fprintf(stderr, "%s\n", DebugBuffer);
45 } /* debug_msg */
46
47 void debug_xxd(const char *msg, const unsigned char *buffer, const int len)
48 {
49 int i;
50 char *c, *debug_buf_end;
51
52 debug_buf_end = DebugBuffer + DEBUG_BUF_SIZE - 5;
53
54 strncpy(DebugBuffer, msg, sizeof(DebugBuffer)-1);
55 c = DebugBuffer + strlen(DebugBuffer);
56
57 for (i = 0; (i < len) && (c < debug_buf_end); ++i)
58 {
59 sprintf(c, "%02X ", (unsigned char)buffer[i]);
60 c += strlen(c);
61 }
62
63 if (c >= debug_buf_end)
64 fprintf(stderr, "Debug buffer too short\n");
65
66 fprintf(stderr, "%s\n", DebugBuffer);
67 } /* debug_xxd */
68

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.5