60a8d5cc20201fe5f7f7f49fb144fd0d795cf7fe
[reactos.git] / 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  * @implemented
31  */
32 ULONG
33 DbgPrint(PCH Format, ...)
34 {
35    ANSI_STRING DebugString;
36    CHAR Buffer[4096];
37    va_list ap;
38
39    /* init ansi string */
40    DebugString.Buffer = Buffer;
41    DebugString.MaximumLength = sizeof(Buffer);
42
43    va_start (ap, Format);
44    DebugString.Length = _vsnprintf (Buffer, sizeof(Buffer), Format, ap);
45    va_end (ap);
46
47    DbgService (1, &DebugString, NULL);
48
49    return (ULONG)DebugString.Length;
50 }
51
52
53 /*
54  * @implemented
55  */
56 VOID
57 STDCALL
58 DbgPrompt (
59         PCH OutputString,
60         PCH InputString,
61         USHORT InputSize
62         )
63 {
64         ANSI_STRING Output;
65         ANSI_STRING Input;
66
67         Input.Length = 0;
68         Input.MaximumLength = InputSize;
69         Input.Buffer = InputString;
70
71         Output.Length = strlen (OutputString);
72         Output.MaximumLength = Output.Length + 1;
73         Output.Buffer = OutputString;
74
75         DbgService (2,
76                     &Output,
77                     &Input);
78 }
79
80 /* EOF */