ReactOS  0.4.14-dev-323-g6fe6a88
interpreter.c File Reference
#include "diskpart.h"
Include dependency graph for interpreter.c:

Go to the source code of this file.

Functions

BOOL exit_main (INT argc, LPWSTR *argv)
 
BOOL rem_main (INT argc, LPWSTR *argv)
 
BOOL InterpretCmd (int argc, LPWSTR *argv)
 
BOOL InterpretScript (LPWSTR input_line)
 
VOID InterpretMain (VOID)
 

Variables

COMMAND cmds []
 

Function Documentation

◆ exit_main()

BOOL exit_main ( INT  argc,
LPWSTR argv 
)

◆ InterpretCmd()

BOOL InterpretCmd ( int  argc,
LPWSTR argv 
)

Definition at line 68 of file interpreter.c.

69 {
70  PCOMMAND cmdptr;
71 
72  /* If no args provided */
73  if (argc < 1)
74  return TRUE;
75 
76  /* First, determine if the user wants to exit
77  or to use a comment */
78  if(wcsicmp(argv[0], L"exit") == 0)
79  return FALSE;
80 
81  if(wcsicmp(argv[0], L"rem") == 0)
82  return TRUE;
83 
84  /* Scan internal command table */
85  for (cmdptr = cmds; cmdptr->name; cmdptr++)
86  {
87  if (wcsicmp(argv[0], cmdptr->name) == 0)
88  return cmdptr->func(argc, argv);
89  }
90 
91  help_cmdlist();
92 
93  return TRUE;
94 }
static int argc
Definition: ServiceArgs.c:12
#define TRUE
Definition: types.h:120
VOID help_cmdlist(VOID)
Definition: help.c:15
INT(* func)(INT, WCHAR **)
Definition: main.c:17
#define argv
Definition: mplay32.c:18
static const WCHAR L[]
Definition: oid.c:1250
#define wcsicmp
Definition: string.h:1152
Definition: main.c:14
COMMAND cmds[]
Definition: interpreter.c:16
WCHAR * name
Definition: main.c:16

Referenced by InterpretMain(), and InterpretScript().

◆ InterpretMain()

VOID InterpretMain ( VOID  )

Definition at line 145 of file interpreter.c.

146 {
147  WCHAR input_line[MAX_STRING_SIZE];
148  LPWSTR args_vector[MAX_ARGS_COUNT];
149  INT args_count = 0;
150  BOOL bWhiteSpace = TRUE;
151  BOOL bRun = TRUE;
152  LPWSTR ptr;
153 
154  while (bRun != FALSE)
155  {
156  args_count = 0;
157  memset(args_vector, 0, sizeof(args_vector));
158 
159  /* Shown just before the input where the user places commands */
161 
162  /* Get input from the user. */
163  fgetws(input_line, MAX_STRING_SIZE, stdin);
164 
165  ptr = input_line;
166  while (*ptr != 0)
167  {
168  if (iswspace(*ptr) || *ptr == L'\n')
169  {
170  *ptr = 0;
171  bWhiteSpace = TRUE;
172  }
173  else
174  {
175  if ((bWhiteSpace != FALSE) && (args_count < MAX_ARGS_COUNT))
176  {
177  args_vector[args_count] = ptr;
178  args_count++;
179  }
180  bWhiteSpace = FALSE;
181  }
182  ptr++;
183  }
184 
185  /* Send the string to find the command */
186  bRun = InterpretCmd(args_count, args_vector);
187  }
188 }
#define TRUE
Definition: types.h:120
FILE * stdin
int32_t INT
Definition: typedefs.h:56
unsigned int BOOL
Definition: ntddk_ex.h:94
static PVOID ptr
Definition: dispmode.c:27
#define MAX_STRING_SIZE
Definition: diskpart.h:69
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define iswspace(_c)
Definition: ctype.h:669
INT ConResPuts(IN PCON_STREAM Stream, IN UINT uID)
Definition: outstream.c:610
static const WCHAR L[]
Definition: oid.c:1250
#define IDS_APP_PROMPT
Definition: resource.h:18
BOOL InterpretCmd(int argc, LPWSTR *argv)
Definition: interpreter.c:68
#define MAX_ARGS_COUNT
Definition: diskpart.h:70
#define StdOut
Definition: stream.h:76
wchar_t * fgetws(wchar_t *buf, int bufsize, FILE *file)
Definition: wmain.c:22
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define memset(x, y, z)
Definition: compat.h:39

Referenced by wmain().

◆ InterpretScript()

BOOL InterpretScript ( LPWSTR  input_line)

Definition at line 102 of file interpreter.c.

103 {
104  LPWSTR args_vector[MAX_ARGS_COUNT];
105  INT args_count = 0;
106  BOOL bWhiteSpace = TRUE;
107  LPWSTR ptr;
108 
109  memset(args_vector, 0, sizeof(args_vector));
110 
111  ptr = input_line;
112  while (*ptr != 0)
113  {
114  if (iswspace(*ptr) || *ptr == L'\n')
115  {
116  *ptr = 0;
117  bWhiteSpace = TRUE;
118  }
119  else
120  {
121  if ((bWhiteSpace != FALSE) && (args_count < MAX_ARGS_COUNT))
122  {
123  args_vector[args_count] = ptr;
124  args_count++;
125  }
126 
127  bWhiteSpace = FALSE;
128  }
129 
130  ptr++;
131  }
132 
133  /* sends the string to find the command */
134  return InterpretCmd(args_count, args_vector);
135 }
#define TRUE
Definition: types.h:120
int32_t INT
Definition: typedefs.h:56
unsigned int BOOL
Definition: ntddk_ex.h:94
static PVOID ptr
Definition: dispmode.c:27
#define iswspace(_c)
Definition: ctype.h:669
static const WCHAR L[]
Definition: oid.c:1250
BOOL InterpretCmd(int argc, LPWSTR *argv)
Definition: interpreter.c:68
#define MAX_ARGS_COUNT
Definition: diskpart.h:70
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define memset(x, y, z)
Definition: compat.h:39

Referenced by RunScript().

◆ rem_main()

BOOL rem_main ( INT  argc,
LPWSTR argv 
)

Variable Documentation

◆ cmds

COMMAND cmds[]

Definition at line 16 of file interpreter.c.

Referenced by InterpretCmd().