+Option '--debug-messages' (default off) - variable 'captive_debug_messages'
[reactos.git] / ntoskrnl / dbg / print.c
1 /*
2  *  ReactOS kernel
3  *  Copyright (C) 1998, 1999, 2000, 2001 ReactOS Team
4  *
5  *  This program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; either version 2 of the License, or
8  *  (at your option) any later version.
9  *
10  *  This program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with this program; if not, write to the Free Software
17  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */
19 /* $Id$
20  *
21  * COPYRIGHT:       See COPYING in the top level directory
22  * PROJECT:         ReactOS kernel
23  * FILE:            ntoskrnl/dbg/print.c
24  * PURPOSE:         Debug output 
25  * PROGRAMMER:      Eric Kohl (ekohl@abo.rhein-zeitung.de)
26  * PORTABILITY:     Unchecked
27  * UPDATE HISTORY:
28  *                  14/10/99: Created
29  */
30
31 /* INCLUDES *****************************************************************/
32
33 #include <ddk/ntddk.h>
34 #include <internal/kd.h>
35 #ifdef LIBCAPTIVE
36 #include <glib/gtypes.h>        /* for gboolean */
37 #endif /* LIBCAPTIVE */
38
39
40 /* FUNCTIONS ****************************************************************/
41
42 #if 0
43 ULONG DbgService (ULONG Service, PVOID Context1, PVOID Context2);
44 __asm__ ("\n\t.global _DbgService\n\t"
45          "_DbgService:\n\t"
46          "mov 4(%esp), %eax\n\t"
47          "mov 8(%esp), %ecx\n\t"
48          "mov 12(%esp), %edx\n\t"
49          "int $0x2D\n\t"
50          "ret\n\t");
51 #endif
52
53 /*
54  * Note: DON'T CHANGE THIS FUNCTION!!!
55  *       DON'T CALL HalDisplayString OR SOMETING ELSE!!!
56  *       You'll only break the serial/bochs debugging feature!!!
57  */
58
59 #ifdef LIBCAPTIVE
60 extern gboolean captive_debug_messages;
61 #endif /* LIBCAPTIVE */
62
63 ULONG 
64 DbgPrint(PCH Format, ...)
65 {
66    ANSI_STRING DebugString;
67    CHAR Buffer[1024];
68    va_list ap;
69
70 #ifdef LIBCAPTIVE
71    if (!captive_debug_messages)
72       return 0;
73 #endif /* LIBCAPTIVE */
74
75    /* init ansi string */
76    DebugString.Buffer = Buffer;
77    DebugString.MaximumLength = sizeof(Buffer);
78
79    va_start (ap, Format);
80    DebugString.Length = _vsnprintf (Buffer, sizeof( Buffer ), Format, ap);
81    va_end (ap);
82
83    KdpPrintString (&DebugString);
84
85    return (ULONG)DebugString.Length;
86 }
87
88
89 VOID STDCALL
90 DbgPrompt (PCH OutputString,
91            PCH InputString,
92            USHORT InputSize)
93 {
94    ANSI_STRING Output;
95    ANSI_STRING Input;
96    
97    Input.Length = 0;
98    Input.MaximumLength = InputSize;
99    Input.Buffer = InputString;
100    
101    Output.Length = strlen (OutputString);
102    Output.MaximumLength = Output.Length + 1;
103    Output.Buffer = OutputString;
104
105    /* FIXME: Not implemented yet! */
106    //   KdpPromptString (&Output,
107    //                    &Input);
108 }
109
110 /* EOF */