ReactOS  0.4.14-dev-833-g5f692ed
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 180 of file cmd.c.

181 {
182  char cmd;
183  char sep = '\n';
184  char *arg;
185  char *l = Line;
186  int res = 1;
187  int cnt = 0;
188  int changed = 0;
189 
190  l = backSpaceEdit(l);
191  if (l[1] != KDBG_ESC_CHAR)
192  return l[1]; //for reprocessing as not escaped
193 
194  log(outFile, "\n");
195 
196  l += 2; //skip space+escape character
197  if ( (cnt=sscanf(l,"%c%c",&cmd,&sep)) < 1)
198  {
199  esclog(outFile, "Command expected\n");
200  res = 0;
201  }
202 
203  if (res && cnt==2 && sep != ' ')
204  {
205  esclog(outFile, "' ' expected\n");
206  res = 0;
207  }
208  l++; //skip cmd
209  while ( *l == ' ')l++; //skip more spaces
210  arg = l;
211  opt_cli = 1;
212  switch (cmd)
213  {
214  case 'a':
215  handle_address_cmd(outFile, arg);
216  break;
217  case 'h':
218  usage(1);
219  break;
220  case 'b':
221  if (handle_switch(outFile, &opt_buffered, arg, "-b Logfile buffering"))
222  set_LogFile(&logFile); //re-open same logfile
223  break;
224  case 'c':
225  handle_switch(outFile, &opt_console, NULL, "-c Console option");
226  break;
227  case 'd':
228  handle_switch_str(outFile, opt_dir, NULL, "-d Directory option");
229  break;
230  case 'l':
231  if (handle_switch_str(outFile, opt_logFile, arg, "-l logfile") || (strcmp(opt_mod,"a")!=0))
232  {
233  opt_mod = "a";
234  set_LogFile(&logFile); //open new logfile
235  }
236  break;
237  case 'L':
238  if (handle_switch_str(outFile, opt_logFile, arg, "-L logfile") || (strcmp(opt_mod,"w")!=0))
239  {
240  opt_mod = "w";
241  set_LogFile(&logFile); //open new logfile
242  }
243  break;
244  case 'm':
245  handle_switch(outFile, &opt_Mark, arg, "-m mark (*)");
246  break;
247  case 'M':
248  handle_switch(outFile, &opt_Mark, arg, "-M Mark (?)");
249  break;
250  case 'P':
251  handle_switch_str(outFile, opt_Pipe, NULL, "-P Pipeline option");
252  break;
253  case 'q':
254  opt_quit = 1;
255  esclog(outFile, "Bye!\n");
256  break;
257  case 'r':
258  handle_switch(outFile, &opt_raw, arg, "-r Raw");
259  break;
260  case 'R':
261  changed = handle_switch_pstr(outFile, &opt_Revision, arg, NULL);
262  opt_Revision_check = 0;
263  if (opt_Revision)
264  {
265  opt_Revision_check = 1;
266  if (strstr(opt_Revision, "check") == opt_Revision)
267  {
268  esclog(outFile, "-R is \"%s\" (%s)\n", opt_Revision, changed ? "changed":"unchanged");
269  }
270  else if (strstr(opt_Revision, "regscan") == opt_Revision)
271  {
272  char *s = strchr(opt_Revision, ',');
273 
275  if (s)
276  {
277  *s++ = '\0';
278  revinfo.range = atoi(s);
279  }
280  regscan(outFile);
281  }
282  else if (strstr(opt_Revision, "regclear") == opt_Revision)
283  {
285  summ.regfound = 0;
286  esclog(outFile, "cleared regression scan results\n");
287  }
288  }
289  break;
290  case 's':
291  if (strcmp(arg,"clear") == 0)
292  {
293  memset(&summ, 0, sizeof(SUMM));
294  esclog(outFile, "Statistics cleared\n");
295  }
296  else
297  stat_print(outFile, &summ);
298  break;
299  case 'S':
300  cnt = sscanf(arg, "%d+%d", &opt_Source, &opt_SrcPlus);
301  if (opt_Source)
302  {
303  handle_switch(outFile, &opt_undo, "1", "-u Undo");
304  handle_switch(outFile, &opt_redo, "1", "-U Undo and reprocess");
305  opt_Revision_check = 1;
306  }
307  esclog(outFile, "-S Sources option is %d+%d,\"%s\"\n", opt_Source, opt_SrcPlus, opt_SourcesPath);
308  esclog(outFile, "(Setting source tree not implemented)\n");
309  break;
310  case 't':
311  handle_switch(outFile, &opt_twice, arg, "-t Translate twice");
312  break;
313  case 'T':
314  handle_switch(outFile, &opt_twice, arg, NULL);
315  handle_switch(outFile, &opt_Twice, arg, "-T Translate for (address-1)");
316  break;
317  case 'u':
318  handle_switch(outFile, &opt_undo, arg, "-u undo");
319  break;
320  case 'U':
321  handle_switch(outFile, &opt_undo, arg, NULL);
322  handle_switch(outFile, &opt_redo, arg, "-U Undo and reprocess");
323  break;
324  case 'v':
325  handle_switch(outFile, &opt_verbose, arg, "-v Verbosity");
326  break;
327  case 'z':
328  handle_switch_str(outFile, opt_7z, NULL, "-z 7z path");
329  break;
330  default:
331  if (strchr(optchars, cmd))
332  esclog(outFile, "Command not implemented in cli: %c %s\n",cmd, arg)
333  else
334  esclog(outFile, "Unknown command: %c %s\n",cmd, arg);
335  }
336  opt_cli = 0;
337 
338  memset(Line, '\0', LINESIZE); // flushed
339 
340  return KDBG_ESC_CHAR; //handled escaped command
341 }
int opt_Twice
Definition: options.c:37
int opt_twice
Definition: options.c:36
#define esclog(outFile, fmt,...)
Definition: util.h:22
Definition: ftp_var.h:139
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
int opt_Mark
Definition: options.c:28
int opt_buffered
Definition: options.c:21
int opt_undo
Definition: options.c:38
int opt_raw
Definition: options.c:32
char * cmd
Definition: vfdcmd.c:85
void * arg
Definition: msvc.h:10
char opt_logFile[PATH_MAX]
Definition: options.c:43
static int handle_address_cmd(FILE *outFile, char *arg)
Definition: cmd.c:147
char * opt_mod
Definition: options.c:44
static int handle_switch_str(FILE *outFile, char *sw, char *arg, char *desc)
Definition: cmd.c:73
int opt_Revision_check
Definition: options.c:41
int opt_SrcPlus
Definition: options.c:35
void list_clear(PLIST list)
Definition: list.c:70
int opt_redo
Definition: options.c:39
smooth NULL
Definition: ftsmooth.c:416
REVINFO revinfo
Definition: log2lines.c:37
GLsizei GLenum * sources
Definition: glext.h:7753
char * opt_Pipe
Definition: options.c:29
char logFile[_MAX_PATH]
Definition: tftpd.cpp:38
_Check_return_ _CRTIMP int __cdecl sscanf(_In_z_ const char *_Src, _In_z_ _Scanf_format_string_ const char *_Format,...)
r l[0]
Definition: byte_order.h:167
char opt_7z[PATH_MAX]
Definition: options.c:45
char * opt_Revision
Definition: options.c:40
int opt_Source
Definition: options.c:34
void stat_print(FILE *outFile, PSUMM psumm)
Definition: stat.c:17
Definition: ncftp.h:79
char * optchars
Definition: options.c:20
int set_LogFile(FILE **plogFile)
Definition: util.c:19
GLsizeiptr const GLvoid GLenum usage
Definition: glext.h:5919
GLdouble s
Definition: gl.h:2039
#define DEF_RANGE
Definition: config.h:10
#define KDBG_ESC_CHAR
Definition: cmd.h:13
int opt_verbose
Definition: options.c:25
#define LINESIZE
Definition: chargen.c:18
static char * backSpaceEdit(char *s)
Definition: cmd.c:24
char * strchr(const char *String, int ch)
Definition: utclib.c:501
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
int opt_cli
Definition: options.c:31
static int handle_switch_pstr(FILE *outFile, char **psw, char *arg, char *desc)
Definition: cmd.c:105
int opt_console
Definition: options.c:26
GLuint res
Definition: glext.h:9613
int opt_quit
Definition: options.c:30
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
SUMM summ
Definition: log2lines.c:36
#define memset(x, y, z)
Definition: compat.h:39
int regscan(FILE *outFile)
Definition: revision.c:154
int regfound
Definition: stat.h:21
char opt_dir[PATH_MAX]
Definition: options.c:42
static int handle_switch(FILE *outFile, int *sw, char *arg, char *desc)
Definition: cmd.c:48
#define log(outFile, fmt,...)
Definition: util.h:15
struct Line Line
char opt_SourcesPath[LINESIZE]
Definition: options.c:47

Referenced by translate_files().