summaryrefslogtreecommitdiffstats
path: root/private/rpc/ndrdbg/print.cxx
blob: ea08b13284ea8f76493088d239c01c83dca28a9e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
/*++

Copyright (c) 1994  Microsoft Corporation

Module Name:

    print.cxx

Abstract:

    This file contains print wrapping for ndr debug extensions.

Author:

    Ryszard K. Kott     September 13, 1994

Revision History:

--*/

#include "print.hxx"

extern  DWORD   NdrRegKeyOutputLimit;

#define INDENT_STEP     1
#define INDENT_LIMIT    30
#define INDENT_CHAR     ' ';

// =======================================================================

PNTSD_OUTPUT_ROUTINE    NtsdPrint;

unsigned long OutputLimitCount = 0;

BOOL    fOutputLimitReached = FALSE;
BOOL    fSilentOutput = FALSE;

short   IndentCount = 0;
char *  IndentSpaces = "                                                ";

void
InitPrintCount()
{
    OutputLimitCount = 0;
    fOutputLimitReached = FALSE;
    fSilentOutput = FALSE;
    IndentCount = 0;
    IndentSpaces[ IndentCount ] = 0;
}

void
SetPrintMode( BOOL Mode )
{
    fSilentOutput = ! Mode;
}

void
Print(
    char *          pFormat,
    unsigned long   Arg1,
    unsigned long   Arg2,
    unsigned long   Arg3 )
{
   if ( fOutputLimitReached  ||  fSilentOutput )
       return;

   (*NtsdPrint)( pFormat, Arg1, Arg2, Arg3 );

   fOutputLimitReached = ++OutputLimitCount > NdrRegKeyOutputLimit;

   if ( fOutputLimitReached )
       {
       (*NtsdPrint)( "\nOutput limit reached (%x), use .kol to change\n",
                     NdrRegKeyOutputLimit );
       }
}

void
Print(
    char *          pFormat )
{
    Print( pFormat, (unsigned long) 0, 0, 0 );
}

void
Print(
    char *          pFormat,
    void *          pArg1,
    unsigned long   Arg2,
    unsigned long   Arg3 )
{
    Print( pFormat, (unsigned long) pArg1, Arg2, Arg3 );
}

void
Print(
    char *          pFormat,
    unsigned long   Arg1,
    char *          pArg2,
    unsigned long   Arg3 )
{
    Print( pFormat, Arg1, (unsigned long) pArg2, Arg3 );
}

void
IndentInc()
{
    if ( 0 <= IndentCount  &&
         IndentCount < INDENT_LIMIT )
        {
        IndentSpaces[ IndentCount ] = INDENT_CHAR;
        }

    IndentCount += INDENT_STEP;

    if ( IndentCount > INDENT_LIMIT )
        IndentSpaces[29] = '+';
    else
    if ( 0 <= IndentCount )
        IndentSpaces[ IndentCount ] = 0;
}

void
IndentDec()
{
    if ( 0 < IndentCount  &&
         IndentCount < INDENT_LIMIT )
        {
        IndentSpaces[ IndentCount ] = INDENT_CHAR;
        }

    IndentCount -= INDENT_STEP;

    if ( 0 <= IndentCount  &&
         IndentCount <= INDENT_LIMIT )
        IndentSpaces[ IndentCount ] = 0;
    else
    if ( 0 > IndentCount )
        Print( "IndentDec < 0?\n" );
}

void
PrintIndent()
{
    Print( "%s", IndentSpaces );
}