DbgPrint calls DbgPrintEx
[reactos.git] / reactos / lib / ntdll / dbg / print.c
1 /* $Id$
2 *
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: lib/ntdll/dbg/print.c
6 * PURPOSE: Debug output
7 * PROGRAMMER: Eric Kohl
8 * UPDATE HISTORY:
9 * Created 28/12/1999
10 */
11
12 #include <ddk/ntddk.h>
13 #include <stdarg.h>
14 #include <stdio.h>
15 #include <string.h>
16
17
18 /* FUNCTIONS ***************************************************************/
19
20 ULONG DbgService (ULONG Service, PVOID Context1, PVOID Context2);
21 __asm__ ("\n\t.global _DbgService\n\t"
22 "_DbgService:\n\t"
23 "mov 4(%esp), %eax\n\t"
24 "mov 8(%esp), %ecx\n\t"
25 "mov 12(%esp), %edx\n\t"
26 "int $0x2D\n\t"
27 "ret\n\t");
28
29 /*
30 * @unimplemented
31 */
32 ULONG
33 DbgPrintEx(
34 IN ULONG ComponentId,
35 IN ULONG Level,
36 IN PCH Format,
37 ...
38 )
39 {
40 ANSI_STRING DebugString;
41 CHAR Buffer[4096];
42 va_list ap;
43
44 /* init ansi string */
45 DebugString.Buffer = Buffer;
46 DebugString.MaximumLength = sizeof(Buffer);
47
48 va_start (ap, Format);
49 DebugString.Length = _vsnprintf (Buffer, sizeof(Buffer), Format, ap);
50 va_end (ap);
51
52 DbgService (1, &DebugString, NULL);
53
54 return (ULONG)DebugString.Length;
55 }
56
57
58 /*
59 * @implemented
60 */
61 ULONG
62 DbgPrint(PCH Format, ...)
63 {
64 ANSI_STRING DebugString;
65 CHAR Buffer[4096];
66 va_list ap;
67
68 /* init ansi string */
69 DebugString.Buffer = Buffer;
70 DebugString.MaximumLength = sizeof(Buffer);
71
72 va_start (ap, Format);
73 DebugString.Length = _vsnprintf (Buffer, sizeof(Buffer), Format, ap);
74 va_end (ap);
75
76
77 return DbgPrintEx (0, 0, DebugString.Buffer);
78 }
79
80
81 /*
82 * @implemented
83 */
84 VOID
85 STDCALL
86 DbgPrompt (
87 PCH OutputString,
88 PCH InputString,
89 USHORT InputSize
90 )
91 {
92 ANSI_STRING Output;
93 ANSI_STRING Input;
94
95 Input.Length = 0;
96 Input.MaximumLength = InputSize;
97 Input.Buffer = InputString;
98
99 Output.Length = strlen (OutputString);
100 Output.MaximumLength = Output.Length + 1;
101 Output.Buffer = OutputString;
102
103 DbgService (2,
104 &Output,
105 &Input);
106 }
107
108 /* EOF */