5e4a281099bb0b808183cd5047b7e5bb1319a973
[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 <ntdll.h>
13 #define NDEBUG
14 #include <debug.h>
15
16 /* FUNCTIONS ***************************************************************/
17
18 ULONG DbgService (ULONG Service, PVOID Context1, PVOID Context2);
19 __asm__ ("\n\t.global _DbgService\n\t"
20 "_DbgService:\n\t"
21 "mov 4(%esp), %eax\n\t"
22 "mov 8(%esp), %ecx\n\t"
23 "mov 12(%esp), %edx\n\t"
24 "int $0x2D\n\t"
25 "ret\n\t");
26
27 /*
28 * @unimplemented
29 */
30 ULONG
31 DbgPrintEx(
32 IN ULONG ComponentId,
33 IN ULONG Level,
34 IN PCH Format,
35 ...
36 )
37 {
38 ANSI_STRING DebugString;
39 CHAR Buffer[4096];
40 va_list ap;
41
42 /* init ansi string */
43 DebugString.Buffer = Buffer;
44 DebugString.MaximumLength = sizeof(Buffer);
45
46 va_start (ap, Format);
47 DebugString.Length = _vsnprintf (Buffer, sizeof(Buffer), Format, ap);
48 va_end (ap);
49
50 DbgService (1, &DebugString, NULL);
51
52 return (ULONG)DebugString.Length;
53 }
54
55
56 /*
57 * @implemented
58 */
59 ULONG
60 DbgPrint(PCH Format, ...)
61 {
62 ANSI_STRING DebugString;
63 CHAR Buffer[4096];
64 va_list ap;
65
66 /* init ansi string */
67 DebugString.Buffer = Buffer;
68 DebugString.MaximumLength = sizeof(Buffer);
69
70 va_start (ap, Format);
71 DebugString.Length = _vsnprintf (Buffer, sizeof(Buffer), Format, ap);
72 va_end (ap);
73
74
75 return DbgPrintEx (0, 0, DebugString.Buffer);
76 }
77
78
79 /*
80 * @implemented
81 */
82 VOID
83 STDCALL
84 DbgPrompt (
85 PCH OutputString,
86 PCH InputString,
87 USHORT InputSize
88 )
89 {
90 ANSI_STRING Output;
91 ANSI_STRING Input;
92
93 Input.Length = 0;
94 Input.MaximumLength = InputSize;
95 Input.Buffer = InputString;
96
97 Output.Length = strlen (OutputString);
98 Output.MaximumLength = Output.Length + 1;
99 Output.Buffer = OutputString;
100
101 DbgService (2,
102 &Output,
103 &Input);
104 }
105
106 /* EOF */