ReactOS 0.4.15-dev-7906-g1b85a5f
regcmds.c File Reference
#include <windows.h>
#include <tchar.h>
#include <stdio.h>
#include <ctype.h>
#include "regproc.h"
Include dependency graph for regcmds.c:

Go to the source code of this file.

Macros

#define WIN32_LEAN_AND_MEAN
 

Enumerations

enum  REGEDIT_ACTION {
  ACTION_ADD , ACTION_EXPORT , ACTION_DELETE , ACTION_UNDEF ,
  ACTION_ADD , ACTION_EXPORT , ACTION_DELETE , ACTION_VIEW
}
 

Functions

void error_unknown_switch (char chu, char *s)
 
BOOL PerformRegAction (REGEDIT_ACTION action, LPSTR s)
 
BOOL ProcessCmdLine (LPSTR lpCmdLine)
 

Variables

static charusage
 

Macro Definition Documentation

◆ WIN32_LEAN_AND_MEAN

#define WIN32_LEAN_AND_MEAN

Definition at line 25 of file regcmds.c.

Enumeration Type Documentation

◆ REGEDIT_ACTION

Enumerator
ACTION_ADD 
ACTION_EXPORT 
ACTION_DELETE 
ACTION_UNDEF 
ACTION_ADD 
ACTION_EXPORT 
ACTION_DELETE 
ACTION_VIEW 

Definition at line 74 of file regcmds.c.

74 {
REGEDIT_ACTION
Definition: regcmds.c:74
@ ACTION_ADD
Definition: regcmds.c:75
@ ACTION_EXPORT
Definition: regcmds.c:75
@ ACTION_DELETE
Definition: regcmds.c:75
@ ACTION_VIEW
Definition: regcmds.c:75
@ ACTION_UNDEF
Definition: regcmds.c:75

Function Documentation

◆ error_unknown_switch()

void error_unknown_switch ( char  chu,
char s 
)

Process unknown switch.

Params: chu - the switch character in upper-case. s - the command line string where s points to the switch character.

Definition at line 85 of file regcmds.c.

86{
87 if (isalpha(chu)) {
88 printf("Undefined switch /%c!\n", chu);
89 } else {
90 printf("Alphabetic character is expected after '%c' "
91 "in switch specification\n", *(s - 1));
92 }
93 //exit(1);
94}
#define isalpha(c)
Definition: acclib.h:74
#define printf
Definition: freeldr.h:93
GLdouble s
Definition: gl.h:2039

Referenced by ProcessCmdLine().

◆ PerformRegAction()

BOOL PerformRegAction ( REGEDIT_ACTION  action,
LPSTR  s 
)

Definition at line 96 of file regcmds.c.

97{
99 TCHAR reg_key_name[KEY_MAX_LEN];
100
101 switch (action) {
102 case ACTION_ADD:
104 if (!filename[0]) {
105 printf("No file name is specified\n%s", usage);
106 return FALSE;
107 //exit(1);
108 }
109 while (filename[0]) {
111 perror("");
112 printf("Can't open file \"%s\"\n", filename);
113 return FALSE;
114 //exit(1);
115 }
117 }
118 break;
119 case ACTION_DELETE:
120 get_file_name(&s, reg_key_name, KEY_MAX_LEN);
121 if (!reg_key_name[0]) {
122 printf("No registry key is specified for removal\n%s", usage);
123 return FALSE;
124 //exit(1);
125 }
126 delete_registry_key(reg_key_name);
127 break;
128 case ACTION_EXPORT:
129 filename[0] = '\0';
131 if (!filename[0]) {
132 printf("No file name is specified\n%s", usage);
133 return FALSE;
134 //exit(1);
135 }
136 if (s[0]) {
137 get_file_name(&s, reg_key_name, KEY_MAX_LEN);
138 export_registry_key(filename, reg_key_name);
139 } else {
141 }
142 break;
143 default:
144 printf("Unhandled action!\n");
145 return FALSE;
146 }
147 return TRUE;
148}
#define KEY_MAX_LEN
Definition: main.h:42
BOOL import_registry_file(FILE *reg_file)
Definition: regproc.c:1054
BOOL export_registry_key(WCHAR *file_name, WCHAR *path, DWORD format)
Definition: regproc.c:1579
void delete_registry_key(WCHAR *reg_key_name)
Definition: regproc.c:1102
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define MAX_PATH
Definition: compat.h:34
const WCHAR * action
Definition: action.c:7479
GLsizeiptr const GLvoid GLenum usage
Definition: glext.h:5919
_CRTIMP void __cdecl perror(_In_opt_z_ const char *_ErrMsg)
const char * filename
Definition: ioapi.h:137
#define get_file_name
Definition: regproc.h:51
char TCHAR
Definition: xmlstorage.h:189

Referenced by ProcessCmdLine().

◆ ProcessCmdLine()

BOOL ProcessCmdLine ( LPSTR  lpCmdLine)

Definition at line 150 of file regcmds.c.

151{
153 LPSTR s = lpCmdLine; /* command line pointer */
154 CHAR ch = *s; /* current character */
155
156 while (ch && ((ch == '-') || (ch == '/'))) {
157 char chu;
158 char ch2;
159
160 s++;
161 ch = *s;
162 ch2 = *(s+1);
163 chu = toupper(ch);
164 if (!ch2 || isspace(ch2)) {
165 if (chu == 'S' || chu == 'V') {
166 /* ignore these switches */
167 } else {
168 switch (chu) {
169 case 'D':
171 break;
172 case 'E':
174 break;
175 case 'V':
177 break;
178 case '?':
179 printf(usage);
180 return FALSE;
181 //exit(0);
182 break;
183 default:
185 return FALSE;
186 break;
187 }
188 }
189 s++;
190 } else {
191 if (ch2 == ':') {
192 switch (chu) {
193 case 'L':
194 /* fall through */
195 case 'R':
196 s += 2;
197 while (*s && !isspace(*s)) {
198 s++;
199 }
200 break;
201 default:
203 return FALSE;
204 break;
205 }
206 } else {
207 /* this is a file name, starting from '/' */
208 s--;
209 break;
210 }
211 }
212 /* skip spaces to the next parameter */
213 ch = *s;
214 while (ch && isspace(ch)) {
215 s++;
216 ch = *s;
217 }
218 }
219 if (action == ACTION_UNDEF) {
221 }
222 return PerformRegAction(action, s);
223}
#define isspace(c)
Definition: acclib.h:69
int toupper(int c)
Definition: utclib.c:881
REGEDIT_ACTION
Definition: regedit.c:120
BOOL PerformRegAction(REGEDIT_ACTION action, LPSTR s)
Definition: regcmds.c:96
void error_unknown_switch(char chu, char *s)
Definition: regcmds.c:85
char * LPSTR
Definition: xmlstorage.h:182
char CHAR
Definition: xmlstorage.h:175

Variable Documentation

◆ usage

char* usage ( void  )
static

Definition at line 42 of file regcmds.c.