ReactOS 0.4.15-dev-7674-gc0b4db1
cmd.h File Reference
#include <stdio.h>
Include dependency graph for cmd.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define KDBG_BS_CHAR   0x08
 
#define KDBG_ESC_CHAR   '`'
 
#define KDBG_ESC_STR   "`"
 
#define KDBG_ESC_RESP   "| L2L- "
 
#define KDBG_ESC_OFF   "off"
 
#define KDBG_PROMPT   "kdb:>"
 
#define KDBG_CONT   "---"
 
#define KDBG_DISCARD   "Command '" KDBG_ESC_STR
 

Functions

char handle_escape_cmd (FILE *outFile, char *Line)
 

Macro Definition Documentation

◆ KDBG_BS_CHAR

#define KDBG_BS_CHAR   0x08

Definition at line 12 of file cmd.h.

◆ KDBG_CONT

#define KDBG_CONT   "---"

Definition at line 18 of file cmd.h.

◆ KDBG_DISCARD

#define KDBG_DISCARD   "Command '" KDBG_ESC_STR

Definition at line 19 of file cmd.h.

◆ KDBG_ESC_CHAR

#define KDBG_ESC_CHAR   '`'

Definition at line 13 of file cmd.h.

◆ KDBG_ESC_OFF

#define KDBG_ESC_OFF   "off"

Definition at line 16 of file cmd.h.

◆ KDBG_ESC_RESP

#define KDBG_ESC_RESP   "| L2L- "

Definition at line 15 of file cmd.h.

◆ KDBG_ESC_STR

#define KDBG_ESC_STR   "`"

Definition at line 14 of file cmd.h.

◆ KDBG_PROMPT

#define KDBG_PROMPT   "kdb:>"

Definition at line 17 of file cmd.h.

Function Documentation

◆ handle_escape_cmd()

char handle_escape_cmd ( FILE outFile,
char Line 
)

Definition at line 138 of file cmd.c.

139{
140 char cmd;
141 char sep = '\n';
142 char *arg;
143 char *l = Line;
144 int res = 1;
145 int cnt = 0;
146 int changed = 0;
147
148 l = backSpaceEdit(l);
149 if (l[1] != KDBG_ESC_CHAR)
150 return l[1]; //for reprocessing as not escaped
151
152 log(outFile, "\n");
153
154 l += 2; //skip space+escape character
155 if ( (cnt=sscanf(l,"%c%c",&cmd,&sep)) < 1)
156 {
157 esclog(outFile, "Command expected\n");
158 res = 0;
159 }
160
161 if (res && cnt==2 && sep != ' ')
162 {
163 esclog(outFile, "' ' expected\n");
164 res = 0;
165 }
166 l++; //skip cmd
167 while ( *l == ' ')l++; //skip more spaces
168 arg = l;
169 opt_cli = 1;
170 switch (cmd)
171 {
172 case 'a':
173 handle_address_cmd(outFile, arg);
174 break;
175 case 'h':
176 usage(1);
177 break;
178 case 'b':
179 if (handle_switch(outFile, &opt_buffered, arg, "-b Logfile buffering"))
180 set_LogFile(&logFile); //re-open same logfile
181 break;
182 case 'c':
183 handle_switch(outFile, &opt_console, NULL, "-c Console option");
184 break;
185 case 'd':
186 handle_switch_str(outFile, opt_dir, NULL, "-d Directory option");
187 break;
188 case 'l':
189 if (handle_switch_str(outFile, opt_logFile, arg, "-l logfile") || (strcmp(opt_mod,"a")!=0))
190 {
191 opt_mod = "a";
192 set_LogFile(&logFile); //open new logfile
193 }
194 break;
195 case 'L':
196 if (handle_switch_str(outFile, opt_logFile, arg, "-L logfile") || (strcmp(opt_mod,"w")!=0))
197 {
198 opt_mod = "w";
199 set_LogFile(&logFile); //open new logfile
200 }
201 break;
202 case 'm':
203 handle_switch(outFile, &opt_Mark, arg, "-m mark (*)");
204 break;
205 case 'M':
206 handle_switch(outFile, &opt_Mark, arg, "-M Mark (?)");
207 break;
208 case 'P':
209 handle_switch_str(outFile, opt_Pipe, NULL, "-P Pipeline option");
210 break;
211 case 'q':
212 opt_quit = 1;
213 esclog(outFile, "Bye!\n");
214 break;
215 case 'r':
216 handle_switch(outFile, &opt_raw, arg, "-r Raw");
217 break;
218 case 's':
219 if (strcmp(arg,"clear") == 0)
220 {
221 memset(&summ, 0, sizeof(SUMM));
222 esclog(outFile, "Statistics cleared\n");
223 }
224 else
225 stat_print(outFile, &summ);
226 break;
227 case 'S':
228 cnt = sscanf(arg, "%d+%d", &opt_Source, &opt_SrcPlus);
229 if (opt_Source)
230 {
231 handle_switch(outFile, &opt_undo, "1", "-u Undo");
232 handle_switch(outFile, &opt_redo, "1", "-U Undo and reprocess");
233 }
234 esclog(outFile, "-S Sources option is %d+%d,\"%s\"\n", opt_Source, opt_SrcPlus, opt_SourcesPath);
235 esclog(outFile, "(Setting source tree not implemented)\n");
236 break;
237 case 't':
238 handle_switch(outFile, &opt_twice, arg, "-t Translate twice");
239 break;
240 case 'T':
241 handle_switch(outFile, &opt_twice, arg, NULL);
242 handle_switch(outFile, &opt_Twice, arg, "-T Translate for (address-1)");
243 break;
244 case 'u':
245 handle_switch(outFile, &opt_undo, arg, "-u undo");
246 break;
247 case 'U':
248 handle_switch(outFile, &opt_undo, arg, NULL);
249 handle_switch(outFile, &opt_redo, arg, "-U Undo and reprocess");
250 break;
251 case 'v':
252 handle_switch(outFile, &opt_verbose, arg, "-v Verbosity");
253 break;
254 case 'z':
255 handle_switch_str(outFile, opt_7z, NULL, "-z 7z path");
256 break;
257 default:
258 if (strchr(optchars, cmd))
259 esclog(outFile, "Command not implemented in cli: %c %s\n",cmd, arg)
260 else
261 esclog(outFile, "Unknown command: %c %s\n",cmd, arg);
262 }
263 opt_cli = 0;
264
265 memset(Line, '\0', LINESIZE); // flushed
266
267 return KDBG_ESC_CHAR; //handled escaped command
268}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
char * strchr(const char *String, int ch)
Definition: utclib.c:501
r l[0]
Definition: byte_order.h:168
#define LINESIZE
Definition: chargen.c:18
#define NULL
Definition: types.h:112
GLuint res
Definition: glext.h:9613
GLsizeiptr const GLvoid GLenum usage
Definition: glext.h:5919
_Check_return_ _CRTIMP int __cdecl sscanf(_In_z_ const char *_Src, _In_z_ _Scanf_format_string_ const char *_Format,...)
SUMM summ
Definition: log2lines.c:36
#define memset(x, y, z)
Definition: compat.h:39
static int handle_switch_str(FILE *outFile, char *sw, char *arg, char *desc)
Definition: cmd.c:73
static int handle_address_cmd(FILE *outFile, char *arg)
Definition: cmd.c:105
static char * backSpaceEdit(char *s)
Definition: cmd.c:24
static int handle_switch(FILE *outFile, int *sw, char *arg, char *desc)
Definition: cmd.c:48
#define KDBG_ESC_CHAR
Definition: cmd.h:13
int opt_undo
Definition: options.c:38
char opt_SourcesPath[LINESIZE]
Definition: options.c:45
int opt_cli
Definition: options.c:31
char * opt_Pipe
Definition: options.c:29
char * opt_mod
Definition: options.c:42
int opt_redo
Definition: options.c:39
int opt_SrcPlus
Definition: options.c:35
int opt_raw
Definition: options.c:32
int opt_verbose
Definition: options.c:25
char * optchars
Definition: options.c:20
int opt_quit
Definition: options.c:30
char opt_dir[PATH_MAX]
Definition: options.c:40
int opt_Mark
Definition: options.c:28
int opt_twice
Definition: options.c:36
char opt_7z[PATH_MAX]
Definition: options.c:43
int opt_console
Definition: options.c:26
int opt_buffered
Definition: options.c:21
char opt_logFile[PATH_MAX]
Definition: options.c:41
int opt_Source
Definition: options.c:34
int opt_Twice
Definition: options.c:37
int set_LogFile(FILE **plogFile)
Definition: util.c:19
#define esclog(outFile, fmt,...)
Definition: util.h:22
#define log(outFile, fmt,...)
Definition: util.h:15
Definition: ncftp.h:79
Definition: ftp_var.h:139
char logFile[_MAX_PATH]
Definition: tftpd.cpp:38
void stat_print(FILE *outFile, PSUMM psumm)
Definition: stat.c:17
void * arg
Definition: msvc.h:10

Referenced by translate_files().