ReactOS 0.4.15-dev-8241-g63935f8
kdb_cmdhist.c File Reference
#include <ntoskrnl.h>
Include dependency graph for kdb_cmdhist.c:

Go to the source code of this file.

Functions

VOID KdbpCommandHistoryAppend (_In_ PCSTR Command)
 Appends a command to the command history.
 
static PCSTR KdbpGetPrevHistoryEntry (_Inout_ PLONG NextIndex)
 
static PCSTR KdbpGetNextHistoryEntry (_Inout_ PLONG NextIndex)
 
PCSTR KdbGetHistoryEntry (_Inout_ PLONG NextIndex, _In_ BOOLEAN Next)
 

Variables

static CHAR KdbCommandHistoryBuffer [2048]
 
static PCHAR KdbCommandHistory [sizeof(KdbCommandHistoryBuffer)/8] = { NULL }
 
static LONG KdbCommandHistoryBufferIndex = 0
 
static LONG KdbCommandHistoryIndex = 0
 

Function Documentation

◆ KdbGetHistoryEntry()

PCSTR KdbGetHistoryEntry ( _Inout_ PLONG  NextIndex,
_In_ BOOLEAN  Next 
)

Definition at line 152 of file kdb_cmdhist.c.

155{
156 if (Next)
157 return KdbpGetNextHistoryEntry(NextIndex);
158 else
159 return KdbpGetPrevHistoryEntry(NextIndex);
160}
static PCSTR KdbpGetPrevHistoryEntry(_Inout_ PLONG NextIndex)
Definition: kdb_cmdhist.c:109
static PCSTR KdbpGetNextHistoryEntry(_Inout_ PLONG NextIndex)
Definition: kdb_cmdhist.c:133

◆ KdbpCommandHistoryAppend()

VOID KdbpCommandHistoryAppend ( _In_ PCSTR  Command)

Appends a command to the command history.

Parameters
[in]CommandPointer to the command to append to the history.

Definition at line 37 of file kdb_cmdhist.c.

39{
41 SIZE_T Length2 = 0;
42 LONG i;
44
46
47 /*
48 * Do not append the string if:
49 * - it is empty (just the NULL terminator);
50 * - or the last command is the same.
51 */
52 if (Length1 <= 1 ||
55 {
56 return;
57 }
58
59 /* Calculate Length1 and Length2 */
63 {
67 }
68
69 /* Remove previous commands until there is enough space to append the new command */
71 {
72 if ((Length2 > 0 &&
75 (Length2 <= 0 &&
78 {
80 }
81
82 i--;
83 if (i < 0)
85
87 break;
88 }
89
90 /* Make sure the new command history entry is free */
94 {
96 }
97
98 /* Append command */
102 if (Length2 > 0)
103 {
105 }
106}
INT Length2
Definition: FsRtlDissect.c:16
INT Length1
Definition: FsRtlDissect.c:15
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
Definition: bufpool.h:45
#define NULL
Definition: types.h:112
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static LONG KdbCommandHistoryBufferIndex
Definition: kdb_cmdhist.c:25
static LONG KdbCommandHistoryIndex
Definition: kdb_cmdhist.c:26
static CHAR KdbCommandHistoryBuffer[2048]
Definition: kdb_cmdhist.c:22
static PCHAR KdbCommandHistory[sizeof(KdbCommandHistoryBuffer)/8]
Definition: kdb_cmdhist.c:24
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define ASSERT(a)
Definition: mode.c:44
long LONG
Definition: pedump.c:60
Definition: shell.h:41
ULONG_PTR SIZE_T
Definition: typedefs.h:80
char * PCHAR
Definition: typedefs.h:51

Referenced by KdbpCliMainLoop().

◆ KdbpGetNextHistoryEntry()

static PCSTR KdbpGetNextHistoryEntry ( _Inout_ PLONG  NextIndex)
static

Definition at line 133 of file kdb_cmdhist.c.

135{
136 LONG i;
137
138 if (!(*NextIndex > 0 && *NextIndex != KdbCommandHistoryIndex))
139 return NULL;
140
141 i = *NextIndex + 1;
143 i = 0;
144
145 if (KdbCommandHistory[i])
146 *NextIndex = i;
147
148 return KdbCommandHistory[i];
149}

Referenced by KdbGetHistoryEntry().

◆ KdbpGetPrevHistoryEntry()

static PCSTR KdbpGetPrevHistoryEntry ( _Inout_ PLONG  NextIndex)
static

Definition at line 109 of file kdb_cmdhist.c.

111{
112 if (*NextIndex < 0)
113 {
114 /* Start at the end of the history */
115 *NextIndex = KdbCommandHistoryIndex;
116 }
117 else
118 {
119 LONG i = *NextIndex - 1;
120 if (i < 0)
121 *NextIndex = RTL_NUMBER_OF(KdbCommandHistory) - 1;
122
124 *NextIndex = i;
125 else
126 return NULL;
127 }
128
129 return KdbCommandHistory[*NextIndex];
130}

Referenced by KdbGetHistoryEntry().

Variable Documentation

◆ KdbCommandHistory

PCHAR KdbCommandHistory[sizeof(KdbCommandHistoryBuffer)/8] = { NULL }
static

◆ KdbCommandHistoryBuffer

CHAR KdbCommandHistoryBuffer[2048]
static

History range in ring buffer: (KdbCommandHistoryIndex; RTL_NUMBER_OF(KdbCommandHistory) - 1] and [0; KdbCommandHistoryIndex].

Definition at line 22 of file kdb_cmdhist.c.

Referenced by KdbpCommandHistoryAppend().

◆ KdbCommandHistoryBufferIndex

LONG KdbCommandHistoryBufferIndex = 0
static

Definition at line 25 of file kdb_cmdhist.c.

Referenced by KdbpCommandHistoryAppend().

◆ KdbCommandHistoryIndex

LONG KdbCommandHistoryIndex = 0
static