libroken: Build on windows
[openafs.git] / src / WINNT / afsadmsvr / TaAfsAdmSvrDebug.cpp
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
5  * This software has been released under the terms of the IBM Public
6  * License.  For details, see the LICENSE file in the top-level source
7  * directory or online at http://www.openafs.org/dl/license10.html
8  */
9
10 #include <winsock2.h>
11 #include <ws2tcpip.h>
12
13 extern "C" {
14 #include <afsconfig.h>
15 #include <afs/param.h>
16 #include <afs/stds.h>
17 #include <roken.h>
18 }
19
20 #include "TaAfsAdmSvrInternal.h"
21
22
23 /*
24  * VARIABLES __________________________________________________________________
25  *
26  */
27
28 static DWORD PrintDetailLevel = dlDEFAULT;
29
30
31 /*
32  * ROUTINES ___________________________________________________________________
33  *
34  */
35
36 void cdecl vPrint (DWORD level, LPTSTR pszLine, va_list arg)
37 {
38    static LPCRITICAL_SECTION pcs = NULL;
39    if (!pcs)
40       {
41       pcs = New (CRITICAL_SECTION);
42       InitializeCriticalSection (pcs);
43       }
44
45    EnterCriticalSection (pcs);
46
47    if ((!level) || (PrintDetailLevel & level))
48       {
49       TCHAR szOut[ 1024 ];
50       wvsprintf (szOut, pszLine, arg);
51       printf ("AdmSvr: ");
52       if (!level)
53          printf (" * ");
54       if (level & dlINDENT1)
55          printf ("   ");
56       if (level & dlINDENT2)
57          printf ("      ");
58       printf ("%s\n", szOut);
59       }
60
61    LeaveCriticalSection (pcs);
62 }
63
64
65 void cdecl Print (LPTSTR pszLine, ...)
66 {
67    va_list arg;
68    va_start (arg, pszLine);
69    vPrint (dlSTANDARD, pszLine, arg);
70 }
71
72
73 void cdecl Print (DWORD level, LPTSTR pszLine, ...)
74 {
75    va_list arg;
76    va_start (arg, pszLine);
77    vPrint (level, pszLine, arg);
78 }
79
80
81 DWORD GetPrintDetailLevel (void)
82 {
83    return PrintDetailLevel;
84 }
85
86
87 void SetPrintDetailLevel (DWORD level)
88 {
89    PrintDetailLevel = level;
90 }
91