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