4 * printf.c - printf like debug print function
8 * Copyright (c) 2000,2002 Japan Network Information Center.
11 * By using this file, you agree to the terms and conditions set forth bellow.
13 * LICENSE TERMS AND CONDITIONS
15 * The following License Terms and Conditions apply, unless a different
16 * license is obtained from Japan Network Information Center ("JPNIC"),
17 * a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda,
18 * Chiyoda-ku, Tokyo 101-0047, Japan.
20 * 1. Use, Modification and Redistribution (including distribution of any
21 * modified or derived work) in source and/or binary forms is permitted
22 * under this License Terms and Conditions.
24 * 2. Redistribution of source code must retain the copyright notices as they
25 * appear in each source code file, this License Terms and Conditions.
27 * 3. Redistribution in binary form must reproduce the Copyright Notice,
28 * this License Terms and Conditions, in the documentation and/or other
29 * materials provided with the distribution. For the purposes of binary
30 * distribution the "Copyright Notice" refers to the following language:
31 * "Copyright (c) 2000-2002 Japan Network Information Center. All rights reserved."
33 * 4. The name of JPNIC may not be used to endorse or promote products
34 * derived from this Software without specific prior written approval of
37 * 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC
38 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
39 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
40 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JPNIC BE LIABLE
41 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
42 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
43 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
44 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
45 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
46 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
47 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
56 #include "wrapcommon.h"
59 * Debug Tracer for DLL
62 static char logfile_name
[256];
63 static int log_level
= -1;
64 static char log_header
[30];
67 idnPrintf(char *fmt
, ...) {
72 if (log_level
< 0 || logfile_name
[0] == '\0')
75 va_start(arg_ptr
, fmt
);
76 vsprintf(msg
, fmt
, arg_ptr
);
79 if ((fp
= fopen(logfile_name
, "a")) != NULL
) {
80 fputs(log_header
, fp
);
87 idnLogPrintf(int level
, char *fmt
, ...) {
92 if (level
> log_level
|| logfile_name
[0] == '\0')
95 va_start(arg_ptr
, fmt
);
96 vsprintf(msg
, fmt
, arg_ptr
);
99 if ((fp
= fopen(logfile_name
, "a")) != NULL
) {
100 fputs(log_header
, fp
);
107 log_proc(int level
, const char *msg
) {
110 if (log_level
< 0 || logfile_name
[0] == '\0')
113 if ((fp
= fopen(logfile_name
, "a")) != NULL
) {
120 idnLogInit(const char *title
) {
121 log_level
= idnGetLogLevel();
122 /* If log file is not stored in the registry, don't do logging. */
123 if (idnGetLogFile(logfile_name
, sizeof(logfile_name
)) == FALSE
) {
126 sprintf(log_header
, "%08x %-.16s: ", getpid(), title
);
127 idn_log_setproc(log_proc
);
128 idn_log_setlevel(log_level
< 0 ? 0 : log_level
);
133 idn_log_setproc(log_proc
);
138 idn_log_setproc(NULL
);
139 /* idn_log_setlevel(0); */