Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
9138f589
Commit
9138f589
authored
Mar 30, 2021
by
Hugh McMaster
Committed by
Alexandre Julliard
Mar 30, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reg: Parse 'reg add' command-line arguments in add.c.
Signed-off-by:
Hugh McMaster
<
hugh.mcmaster@outlook.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
434c345e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
71 additions
and
81 deletions
+71
-81
add.c
programs/reg/add.c
+65
-2
reg.c
programs/reg/reg.c
+5
-77
reg.h
programs/reg/reg.h
+1
-2
No files found.
programs/reg/add.c
View file @
9138f589
...
...
@@ -149,8 +149,8 @@ static LPBYTE get_regdata(const WCHAR *data, DWORD reg_type, WCHAR separator, DW
return
out_data
;
}
int
reg
_add
(
HKEY
root
,
WCHAR
*
path
,
WCHAR
*
value_name
,
BOOL
value_empty
,
WCHAR
*
type
,
WCHAR
separator
,
WCHAR
*
data
,
BOOL
force
)
static
int
run
_add
(
HKEY
root
,
WCHAR
*
path
,
WCHAR
*
value_name
,
BOOL
value_empty
,
WCHAR
*
type
,
WCHAR
separator
,
WCHAR
*
data
,
BOOL
force
)
{
HKEY
key
;
...
...
@@ -208,3 +208,66 @@ int reg_add(HKEY root, WCHAR *path, WCHAR *value_name, BOOL value_empty,
return
0
;
}
int
reg_add
(
int
argc
,
WCHAR
*
argvW
[])
{
HKEY
root
;
WCHAR
*
path
,
*
key_name
,
*
value_name
=
NULL
,
*
type
=
NULL
,
*
data
=
NULL
,
separator
=
'\0'
;
BOOL
value_empty
=
FALSE
,
force
=
FALSE
;
int
i
;
if
(
!
parse_registry_key
(
argvW
[
2
],
&
root
,
&
path
,
&
key_name
))
return
1
;
for
(
i
=
3
;
i
<
argc
;
i
++
)
{
if
(
argvW
[
i
][
0
]
==
'/'
||
argvW
[
i
][
0
]
==
'-'
)
{
WCHAR
*
str
=
&
argvW
[
i
][
1
];
if
(
!
lstrcmpiW
(
str
,
L"ve"
))
{
value_empty
=
TRUE
;
continue
;
}
else
if
(
!
str
[
0
]
||
str
[
1
])
goto
invalid
;
switch
(
towlower
(
*
str
))
{
case
'v'
:
if
(
value_name
||
!
(
value_name
=
argvW
[
++
i
]))
goto
invalid
;
break
;
case
't'
:
if
(
type
||
!
(
type
=
argvW
[
++
i
]))
goto
invalid
;
break
;
case
'd'
:
if
(
data
||
!
(
data
=
argvW
[
++
i
]))
goto
invalid
;
break
;
case
's'
:
str
=
argvW
[
++
i
];
if
(
!
str
||
lstrlenW
(
str
)
!=
1
)
goto
invalid
;
separator
=
str
[
0
];
break
;
case
'f'
:
force
=
TRUE
;
break
;
default:
goto
invalid
;
}
}
}
if
(
value_name
&&
value_empty
)
goto
invalid
;
return
run_add
(
root
,
path
,
value_name
,
value_empty
,
type
,
separator
,
data
,
force
);
invalid:
output_message
(
STRING_INVALID_CMDLINE
);
return
1
;
}
programs/reg/reg.c
View file @
9138f589
...
...
@@ -333,11 +333,7 @@ static enum operations get_operation(const WCHAR *str, int *op_help)
int
__cdecl
wmain
(
int
argc
,
WCHAR
*
argvW
[])
{
int
i
,
op
,
op_help
;
static
const
WCHAR
switchVEW
[]
=
{
'v'
,
'e'
,
0
};
WCHAR
*
key_name
,
*
path
,
*
value_name
=
NULL
,
*
type
=
NULL
,
*
data
=
NULL
,
separator
=
'\0'
;
BOOL
value_empty
=
FALSE
,
force
=
FALSE
;
HKEY
root
;
int
op
,
op_help
;
if
(
argc
==
1
)
{
...
...
@@ -373,6 +369,9 @@ int __cdecl wmain(int argc, WCHAR *argvW[])
return
0
;
}
if
(
op
==
REG_ADD
)
return
reg_add
(
argc
,
argvW
);
if
(
op
==
REG_DELETE
)
return
reg_delete
(
argc
,
argvW
);
...
...
@@ -382,76 +381,5 @@ int __cdecl wmain(int argc, WCHAR *argvW[])
if
(
op
==
REG_IMPORT
)
return
reg_import
(
argc
,
argvW
);
if
(
op
==
REG_QUERY
)
return
reg_query
(
argc
,
argvW
);
if
(
!
parse_registry_key
(
argvW
[
2
],
&
root
,
&
path
,
&
key_name
))
return
1
;
for
(
i
=
3
;
i
<
argc
;
i
++
)
{
if
(
argvW
[
i
][
0
]
==
'/'
||
argvW
[
i
][
0
]
==
'-'
)
{
WCHAR
*
ptr
=
&
argvW
[
i
][
1
];
if
(
!
lstrcmpiW
(
ptr
,
switchVEW
))
{
value_empty
=
TRUE
;
continue
;
}
else
if
(
!
ptr
[
0
]
||
ptr
[
1
])
{
output_message
(
STRING_INVALID_CMDLINE
);
return
1
;
}
switch
(
towlower
(
argvW
[
i
][
1
]))
{
case
'v'
:
if
(
value_name
||
!
(
value_name
=
argvW
[
++
i
]))
{
output_message
(
STRING_INVALID_CMDLINE
);
return
1
;
}
break
;
case
't'
:
if
(
type
||
!
(
type
=
argvW
[
++
i
]))
{
output_message
(
STRING_INVALID_CMDLINE
);
return
1
;
}
break
;
case
'd'
:
if
(
data
||
!
(
data
=
argvW
[
++
i
]))
{
output_message
(
STRING_INVALID_CMDLINE
);
return
1
;
}
break
;
case
's'
:
ptr
=
argvW
[
++
i
];
if
(
!
ptr
||
lstrlenW
(
ptr
)
!=
1
)
{
output_message
(
STRING_INVALID_CMDLINE
);
return
1
;
}
separator
=
ptr
[
0
];
break
;
case
'f'
:
force
=
TRUE
;
break
;
default:
output_message
(
STRING_INVALID_CMDLINE
);
return
1
;
}
}
}
if
(
value_name
&&
value_empty
)
{
output_message
(
STRING_INVALID_CMDLINE
);
return
1
;
}
return
reg_add
(
root
,
path
,
value_name
,
value_empty
,
type
,
separator
,
data
,
force
);
return
reg_query
(
argc
,
argvW
);
}
programs/reg/reg.h
View file @
9138f589
...
...
@@ -43,8 +43,7 @@ BOOL parse_registry_key(const WCHAR *key, HKEY *root, WCHAR **path, WCHAR **long
BOOL
is_switch
(
const
WCHAR
*
s
,
const
WCHAR
c
);
/* add.c */
int
reg_add
(
HKEY
root
,
WCHAR
*
path
,
WCHAR
*
value_name
,
BOOL
value_empty
,
WCHAR
*
type
,
WCHAR
separator
,
WCHAR
*
data
,
BOOL
force
);
int
reg_add
(
int
arc
,
WCHAR
*
argvW
[]);
/* delete.c */
int
reg_delete
(
int
argc
,
WCHAR
*
argvW
[]);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment