regedit: Hard-code "regedit" instead of passing getAppName() as an argument.
Signed-off-by: Hugh McMaster <hugh.mcmaster@outlook.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
7e72247d07
commit
493b5aab22
|
@ -59,12 +59,6 @@ typedef enum {
|
||||||
ACTION_UNDEF, ACTION_ADD, ACTION_EXPORT, ACTION_DELETE
|
ACTION_UNDEF, ACTION_ADD, ACTION_EXPORT, ACTION_DELETE
|
||||||
} REGEDIT_ACTION;
|
} REGEDIT_ACTION;
|
||||||
|
|
||||||
|
|
||||||
const CHAR *getAppName(void)
|
|
||||||
{
|
|
||||||
return "regedit";
|
|
||||||
}
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* Copies file name from command line string to the buffer.
|
* Copies file name from command line string to the buffer.
|
||||||
* Rewinds the command line string pointer to the next non-space character
|
* Rewinds the command line string pointer to the next non-space character
|
||||||
|
@ -91,8 +85,7 @@ static void get_file_name(CHAR **command_line, CHAR *file_name)
|
||||||
(*command_line)++;
|
(*command_line)++;
|
||||||
while(s[0] != '"') {
|
while(s[0] != '"') {
|
||||||
if (!s[0]) {
|
if (!s[0]) {
|
||||||
fprintf(stderr,"%s: Unexpected end of file name!\n",
|
fprintf(stderr, "regedit: Unexpected end of file name!\n");
|
||||||
getAppName());
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
s++;
|
s++;
|
||||||
|
@ -132,7 +125,7 @@ static BOOL PerformRegAction(REGEDIT_ACTION action, LPSTR s)
|
||||||
|
|
||||||
get_file_name(&s, filename);
|
get_file_name(&s, filename);
|
||||||
if (!filename[0]) {
|
if (!filename[0]) {
|
||||||
fprintf(stderr,"%s: No file name was specified\n", getAppName());
|
fprintf(stderr, "regedit: No file name was specified\n");
|
||||||
fprintf(stderr,usage);
|
fprintf(stderr,usage);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
@ -156,15 +149,15 @@ static BOOL PerformRegAction(REGEDIT_ACTION action, LPSTR s)
|
||||||
}
|
}
|
||||||
if (size == 0)
|
if (size == 0)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s: File not found \"%s\" (%d)\n",
|
fprintf(stderr, "regedit: File not found \"%s\" (%d)\n",
|
||||||
getAppName(), filename, GetLastError());
|
filename, GetLastError());
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
reg_file = fopen(realname, "rb");
|
reg_file = fopen(realname, "rb");
|
||||||
if (reg_file == NULL)
|
if (reg_file == NULL)
|
||||||
{
|
{
|
||||||
perror("");
|
perror("");
|
||||||
fprintf(stderr, "%s: Can't open file \"%s\"\n", getAppName(), filename);
|
fprintf(stderr, "regedit: Can't open file \"%s\"\n", filename);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -183,8 +176,7 @@ static BOOL PerformRegAction(REGEDIT_ACTION action, LPSTR s)
|
||||||
|
|
||||||
get_file_name(&s, reg_key_name);
|
get_file_name(&s, reg_key_name);
|
||||||
if (!reg_key_name[0]) {
|
if (!reg_key_name[0]) {
|
||||||
fprintf(stderr,"%s: No registry key was specified for removal\n",
|
fprintf(stderr, "regedit: No registry key was specified for removal\n");
|
||||||
getAppName());
|
|
||||||
fprintf(stderr,usage);
|
fprintf(stderr,usage);
|
||||||
exit(1);
|
exit(1);
|
||||||
} else
|
} else
|
||||||
|
@ -202,7 +194,7 @@ static BOOL PerformRegAction(REGEDIT_ACTION action, LPSTR s)
|
||||||
filename[0] = '\0';
|
filename[0] = '\0';
|
||||||
get_file_name(&s, filename);
|
get_file_name(&s, filename);
|
||||||
if (!filename[0]) {
|
if (!filename[0]) {
|
||||||
fprintf(stderr,"%s: No file name was specified\n", getAppName());
|
fprintf(stderr, "regedit: No filename was specified\n");
|
||||||
fprintf(stderr,usage);
|
fprintf(stderr,usage);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
@ -223,7 +215,7 @@ static BOOL PerformRegAction(REGEDIT_ACTION action, LPSTR s)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
fprintf(stderr,"%s: Unhandled action!\n", getAppName());
|
fprintf(stderr, "regedit: Unhandled action!\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,8 +59,8 @@ static HKEY reg_class_keys[] = {
|
||||||
#define CHECK_ENOUGH_MEMORY(p) \
|
#define CHECK_ENOUGH_MEMORY(p) \
|
||||||
if (!(p)) \
|
if (!(p)) \
|
||||||
{ \
|
{ \
|
||||||
fprintf(stderr,"%s: file %s, line %d: Not enough memory\n", \
|
fprintf(stderr, "regedit: file %s, line %d: Not enough memory\n", \
|
||||||
getAppName(), __FILE__, __LINE__); \
|
__FILE__, __LINE__); \
|
||||||
exit(NOT_ENOUGH_MEMORY); \
|
exit(NOT_ENOUGH_MEMORY); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ static BOOL convertHexToDWord(WCHAR* str, DWORD *dw)
|
||||||
|
|
||||||
WideCharToMultiByte(CP_ACP, 0, str, -1, buf, 9, NULL, NULL);
|
WideCharToMultiByte(CP_ACP, 0, str, -1, buf, 9, NULL, NULL);
|
||||||
if (lstrlenW(str) > 8 || sscanf(buf, "%x%c", dw, &dummy) != 1) {
|
if (lstrlenW(str) > 8 || sscanf(buf, "%x%c", dw, &dummy) != 1) {
|
||||||
fprintf(stderr,"%s: ERROR, invalid hex value\n", getAppName());
|
fprintf(stderr, "regedit: ERROR, invalid hex value\n");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -181,8 +181,7 @@ static BYTE* convertHexCSVToHex(WCHAR *str, DWORD *size)
|
||||||
wc = strtoulW(s,&end,16);
|
wc = strtoulW(s,&end,16);
|
||||||
if (end == s || wc > 0xff || (*end && *end != ',')) {
|
if (end == s || wc > 0xff || (*end && *end != ',')) {
|
||||||
char* strA = GetMultiByteString(s);
|
char* strA = GetMultiByteString(s);
|
||||||
fprintf(stderr,"%s: ERROR converting CSV hex stream. Invalid value at '%s'\n",
|
fprintf(stderr, "regedit: ERROR converting CSV hex stream. Invalid value at '%s'\n", strA);
|
||||||
getAppName(), strA);
|
|
||||||
HeapFree(GetProcessHeap(), 0, data);
|
HeapFree(GetProcessHeap(), 0, data);
|
||||||
HeapFree(GetProcessHeap(), 0, strA);
|
HeapFree(GetProcessHeap(), 0, strA);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -401,7 +400,7 @@ static LONG setValue(WCHAR* val_name, WCHAR* val_data, BOOL is_unicode)
|
||||||
}
|
}
|
||||||
else /* unknown format */
|
else /* unknown format */
|
||||||
{
|
{
|
||||||
fprintf(stderr,"%s: ERROR, unknown data format\n", getAppName());
|
fprintf(stderr, "regedit: ERROR, unknown data format\n");
|
||||||
return ERROR_INVALID_DATA;
|
return ERROR_INVALID_DATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -510,21 +509,21 @@ static void processSetValue(WCHAR* line, BOOL is_unicode)
|
||||||
}
|
}
|
||||||
while ( isspaceW(line[line_idx]) ) line_idx++;
|
while ( isspaceW(line[line_idx]) ) line_idx++;
|
||||||
if (!line[line_idx]) {
|
if (!line[line_idx]) {
|
||||||
fprintf(stderr, "%s: warning: unexpected EOL\n", getAppName());
|
fprintf(stderr, "regedit: warning: unexpected EOL\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (line[line_idx] != '=') {
|
if (line[line_idx] != '=') {
|
||||||
char* lineA;
|
char* lineA;
|
||||||
line[line_idx] = '\"';
|
line[line_idx] = '\"';
|
||||||
lineA = GetMultiByteString(line);
|
lineA = GetMultiByteString(line);
|
||||||
fprintf(stderr,"%s: warning: unrecognized line: '%s'\n", getAppName(), lineA);
|
fprintf(stderr, "regedit: warning: unrecognized line: '%s'\n", lineA);
|
||||||
HeapFree(GetProcessHeap(), 0, lineA);
|
HeapFree(GetProcessHeap(), 0, lineA);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
char* lineA = GetMultiByteString(line);
|
char* lineA = GetMultiByteString(line);
|
||||||
fprintf(stderr,"%s: warning: unrecognized line: '%s'\n", getAppName(), lineA);
|
fprintf(stderr, "regedit: warning: unrecognized line: '%s'\n", lineA);
|
||||||
HeapFree(GetProcessHeap(), 0, lineA);
|
HeapFree(GetProcessHeap(), 0, lineA);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -543,8 +542,7 @@ static void processSetValue(WCHAR* line, BOOL is_unicode)
|
||||||
{
|
{
|
||||||
char* val_nameA = GetMultiByteString(val_name);
|
char* val_nameA = GetMultiByteString(val_name);
|
||||||
char* val_dataA = GetMultiByteString(val_data);
|
char* val_dataA = GetMultiByteString(val_data);
|
||||||
fprintf(stderr,"%s: ERROR Key %s not created. Value: %s, Data: %s\n",
|
fprintf(stderr, "regedit: ERROR Key %s not created. Value: %s, Data: %s\n",
|
||||||
getAppName(),
|
|
||||||
currentKeyName,
|
currentKeyName,
|
||||||
val_nameA,
|
val_nameA,
|
||||||
val_dataA);
|
val_dataA);
|
||||||
|
@ -587,8 +585,7 @@ static void processRegEntry(WCHAR* stdInput, BOOL isUnicode)
|
||||||
} else if ( openKeyW(stdInput) != ERROR_SUCCESS )
|
} else if ( openKeyW(stdInput) != ERROR_SUCCESS )
|
||||||
{
|
{
|
||||||
char* stdInputA = GetMultiByteString(stdInput);
|
char* stdInputA = GetMultiByteString(stdInput);
|
||||||
fprintf(stderr,"%s: setValue failed to open key %s\n",
|
fprintf(stderr, "regedit: setValue failed to open key %s\n", stdInputA);
|
||||||
getAppName(), stdInputA);
|
|
||||||
HeapFree(GetProcessHeap(), 0, stdInputA);
|
HeapFree(GetProcessHeap(), 0, stdInputA);
|
||||||
}
|
}
|
||||||
} else if( currentKeyHandle &&
|
} else if( currentKeyHandle &&
|
||||||
|
@ -732,8 +729,7 @@ static void processRegLinesA(FILE *in, char* first_chars)
|
||||||
|
|
||||||
if(c == EOF)
|
if(c == EOF)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"%s: ERROR - invalid continuation.\n",
|
fprintf(stderr, "regedit: ERROR - invalid continuation.\n");
|
||||||
getAppName());
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -891,8 +887,8 @@ static void REGPROC_print_error(void)
|
||||||
status = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
|
status = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
|
||||||
NULL, error_code, 0, (LPSTR) &lpMsgBuf, 0, NULL);
|
NULL, error_code, 0, (LPSTR) &lpMsgBuf, 0, NULL);
|
||||||
if (!status) {
|
if (!status) {
|
||||||
fprintf(stderr,"%s: Cannot display message for error %d, status %d\n",
|
fprintf(stderr, "regedit: Cannot display message for error %d, status %d\n",
|
||||||
getAppName(), error_code, GetLastError());
|
error_code, GetLastError());
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
puts(lpMsgBuf);
|
puts(lpMsgBuf);
|
||||||
|
@ -1205,9 +1201,8 @@ static void export_hkey(FILE *file, HKEY key,
|
||||||
{
|
{
|
||||||
char* key_nameA = GetMultiByteString(*reg_key_name_buf);
|
char* key_nameA = GetMultiByteString(*reg_key_name_buf);
|
||||||
char* value_nameA = GetMultiByteString(*val_name_buf);
|
char* value_nameA = GetMultiByteString(*val_name_buf);
|
||||||
fprintf(stderr,"%s: warning - unsupported registry format '%d', "
|
fprintf(stderr, "regedit: warning - unsupported registry format '%d', "
|
||||||
"treat as binary\n",
|
"treat as binary\n", value_type);
|
||||||
getAppName(), value_type);
|
|
||||||
fprintf(stderr,"key name: \"%s\"\n", key_nameA);
|
fprintf(stderr,"key name: \"%s\"\n", key_nameA);
|
||||||
fprintf(stderr,"value name:\"%s\"\n\n", value_nameA);
|
fprintf(stderr,"value name:\"%s\"\n\n", value_nameA);
|
||||||
HeapFree(GetProcessHeap(), 0, key_nameA);
|
HeapFree(GetProcessHeap(), 0, key_nameA);
|
||||||
|
@ -1275,7 +1270,7 @@ static FILE *REGPROC_open_export_file(WCHAR *file_name, BOOL unicode)
|
||||||
file = fopen(file_nameA, "wb");
|
file = fopen(file_nameA, "wb");
|
||||||
if (!file) {
|
if (!file) {
|
||||||
perror("");
|
perror("");
|
||||||
fprintf(stderr,"%s: Can't open file \"%s\"\n", getAppName(), file_nameA);
|
fprintf(stderr, "regedit: Can't open file \"%s\"\n", file_nameA);
|
||||||
HeapFree(GetProcessHeap(), 0, file_nameA);
|
HeapFree(GetProcessHeap(), 0, file_nameA);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
@ -1336,8 +1331,7 @@ BOOL export_registry_key(WCHAR *file_name, WCHAR *reg_key_name, DWORD format)
|
||||||
/* open the specified key */
|
/* open the specified key */
|
||||||
if (!parseKeyName(reg_key_name, ®_key_class, &branch_name)) {
|
if (!parseKeyName(reg_key_name, ®_key_class, &branch_name)) {
|
||||||
CHAR* key_nameA = GetMultiByteString(reg_key_name);
|
CHAR* key_nameA = GetMultiByteString(reg_key_name);
|
||||||
fprintf(stderr,"%s: Incorrect registry class specification in '%s'\n",
|
fprintf(stderr, "regedit: Incorrect registry class specification in '%s'\n", key_nameA);
|
||||||
getAppName(), key_nameA);
|
|
||||||
HeapFree(GetProcessHeap(), 0, key_nameA);
|
HeapFree(GetProcessHeap(), 0, key_nameA);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
@ -1359,8 +1353,7 @@ BOOL export_registry_key(WCHAR *file_name, WCHAR *reg_key_name, DWORD format)
|
||||||
RegCloseKey(key);
|
RegCloseKey(key);
|
||||||
} else {
|
} else {
|
||||||
CHAR* key_nameA = GetMultiByteString(reg_key_name);
|
CHAR* key_nameA = GetMultiByteString(reg_key_name);
|
||||||
fprintf(stderr,"%s: Can't export. Registry key '%s' does not exist!\n",
|
fprintf(stderr, "regedit: Can't export. Registry key '%s' does not exist!\n", key_nameA);
|
||||||
getAppName(), key_nameA);
|
|
||||||
HeapFree(GetProcessHeap(), 0, key_nameA);
|
HeapFree(GetProcessHeap(), 0, key_nameA);
|
||||||
REGPROC_print_error();
|
REGPROC_print_error();
|
||||||
}
|
}
|
||||||
|
@ -1435,15 +1428,13 @@ void delete_registry_key(WCHAR *reg_key_name)
|
||||||
|
|
||||||
if (!parseKeyName(reg_key_name, &key_class, &key_name)) {
|
if (!parseKeyName(reg_key_name, &key_class, &key_name)) {
|
||||||
char* reg_key_nameA = GetMultiByteString(reg_key_name);
|
char* reg_key_nameA = GetMultiByteString(reg_key_name);
|
||||||
fprintf(stderr,"%s: Incorrect registry class specification in '%s'\n",
|
fprintf(stderr, "regedit: Incorrect registry class specification in '%s'\n", reg_key_nameA);
|
||||||
getAppName(), reg_key_nameA);
|
|
||||||
HeapFree(GetProcessHeap(), 0, reg_key_nameA);
|
HeapFree(GetProcessHeap(), 0, reg_key_nameA);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if (!*key_name) {
|
if (!*key_name) {
|
||||||
char* reg_key_nameA = GetMultiByteString(reg_key_name);
|
char* reg_key_nameA = GetMultiByteString(reg_key_name);
|
||||||
fprintf(stderr,"%s: Can't delete registry class '%s'\n",
|
fprintf(stderr, "regedit: Can't delete registry class '%s'\n", reg_key_nameA);
|
||||||
getAppName(), reg_key_nameA);
|
|
||||||
HeapFree(GetProcessHeap(), 0, reg_key_nameA);
|
HeapFree(GetProcessHeap(), 0, reg_key_nameA);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,6 @@
|
||||||
#define REG_FORMAT_5 1
|
#define REG_FORMAT_5 1
|
||||||
#define REG_FORMAT_4 2
|
#define REG_FORMAT_4 2
|
||||||
|
|
||||||
const CHAR *getAppName(void);
|
|
||||||
|
|
||||||
BOOL export_registry_key(WCHAR *file_name, WCHAR *reg_key_name, DWORD format);
|
BOOL export_registry_key(WCHAR *file_name, WCHAR *reg_key_name, DWORD format);
|
||||||
BOOL import_registry_file(FILE *in);
|
BOOL import_registry_file(FILE *in);
|
||||||
void delete_registry_key(WCHAR *reg_key_name);
|
void delete_registry_key(WCHAR *reg_key_name);
|
||||||
|
|
Loading…
Reference in New Issue