Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
60f599f5
Commit
60f599f5
authored
Oct 04, 2015
by
Jonathan Vollebregt
Committed by
Alexandre Julliard
Oct 07, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reg: Simplify root key search.
Signed-off-by:
Michel Zou
<
xantares09@hotmail.com
>
Signed-off-by:
Stefan Dösinger
<
stefan@codeweavers.com
>
parent
97ee9451
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
42 deletions
+43
-42
reg.c
programs/reg/reg.c
+43
-42
No files found.
programs/reg/reg.c
View file @
60f599f5
...
...
@@ -22,6 +22,32 @@
#define ARRAY_SIZE(A) (sizeof(A)/sizeof(*A))
static
const
WCHAR
short_hklm
[]
=
{
'H'
,
'K'
,
'L'
,
'M'
,
0
};
static
const
WCHAR
short_hkcu
[]
=
{
'H'
,
'K'
,
'C'
,
'U'
,
0
};
static
const
WCHAR
short_hkcr
[]
=
{
'H'
,
'K'
,
'C'
,
'R'
,
0
};
static
const
WCHAR
short_hku
[]
=
{
'H'
,
'K'
,
'U'
,
0
};
static
const
WCHAR
short_hkcc
[]
=
{
'H'
,
'K'
,
'C'
,
'C'
,
0
};
static
const
WCHAR
long_hklm
[]
=
{
'H'
,
'K'
,
'E'
,
'Y'
,
'_'
,
'L'
,
'O'
,
'C'
,
'A'
,
'L'
,
'_'
,
'M'
,
'A'
,
'C'
,
'H'
,
'I'
,
'N'
,
'E'
,
0
};
static
const
WCHAR
long_hkcu
[]
=
{
'H'
,
'K'
,
'E'
,
'Y'
,
'_'
,
'C'
,
'U'
,
'R'
,
'R'
,
'E'
,
'N'
,
'T'
,
'_'
,
'U'
,
'S'
,
'E'
,
'R'
,
0
};
static
const
WCHAR
long_hkcr
[]
=
{
'H'
,
'K'
,
'E'
,
'Y'
,
'_'
,
'C'
,
'L'
,
'A'
,
'S'
,
'S'
,
'E'
,
'S'
,
'_'
,
'R'
,
'O'
,
'O'
,
'T'
,
0
};
static
const
WCHAR
long_hku
[]
=
{
'H'
,
'K'
,
'E'
,
'Y'
,
'_'
,
'U'
,
'S'
,
'E'
,
'R'
,
'S'
,
0
};
static
const
WCHAR
long_hkcc
[]
=
{
'H'
,
'K'
,
'E'
,
'Y'
,
'_'
,
'C'
,
'U'
,
'R'
,
'R'
,
'E'
,
'N'
,
'T'
,
'_'
,
'C'
,
'O'
,
'N'
,
'F'
,
'I'
,
'G'
,
0
};
static
const
struct
{
HKEY
key
;
const
WCHAR
*
short_name
;
const
WCHAR
*
long_name
;
}
root_rels
[]
=
{
{
HKEY_LOCAL_MACHINE
,
short_hklm
,
long_hklm
},
{
HKEY_CURRENT_USER
,
short_hkcu
,
long_hkcu
},
{
HKEY_CLASSES_ROOT
,
short_hkcr
,
long_hkcr
},
{
HKEY_USERS
,
short_hku
,
long_hku
},
{
HKEY_CURRENT_CONFIG
,
short_hkcc
,
long_hkcc
},
};
static
const
WCHAR
type_none
[]
=
{
'R'
,
'E'
,
'G'
,
'_'
,
'N'
,
'O'
,
'N'
,
'E'
,
0
};
static
const
WCHAR
type_sz
[]
=
{
'R'
,
'E'
,
'G'
,
'_'
,
'S'
,
'Z'
,
0
};
static
const
WCHAR
type_expand_sz
[]
=
{
'R'
,
'E'
,
'G'
,
'_'
,
'E'
,
'X'
,
'P'
,
'A'
,
'N'
,
'D'
,
'_'
,
'S'
,
'Z'
,
0
};
...
...
@@ -95,51 +121,26 @@ static int reg_message(int msg)
return
reg_printfW
(
formatW
,
msg_buffer
);
}
static
in
t
reg_StrCmpNIW
(
LPCWSTR
str
,
LPCWSTR
comp
,
int
len
)
static
in
line
BOOL
path_rootname_cmp
(
const
WCHAR
*
input_path
,
const
WCHAR
*
rootkey_name
)
{
int
i
;
DWORD
length
=
strlenW
(
rootkey_name
)
;
for
(
i
=
0
;
i
<
len
;
i
++
)
{
if
(
!
str
[
i
])
{
len
=
i
+
1
;
break
;
}
}
return
CompareStringW
(
CP_ACP
,
NORM_IGNORECASE
,
str
,
len
,
comp
,
len
)
-
CSTR_EQUAL
;
return
(
!
strncmpiW
(
input_path
,
rootkey_name
,
length
)
&&
(
input_path
[
length
]
==
0
||
input_path
[
length
]
==
'\\'
));
}
static
HKEY
get_rootkey
(
LPWSTR
key
)
static
HKEY
path_get_rootkey
(
const
WCHAR
*
path
)
{
static
const
WCHAR
szHKLM
[]
=
{
'H'
,
'K'
,
'L'
,
'M'
,
0
};
static
const
WCHAR
szHKEY_LOCAL_MACHINE
[]
=
{
'H'
,
'K'
,
'E'
,
'Y'
,
'_'
,
'L'
,
'O'
,
'C'
,
'A'
,
'L'
,
'_'
,
'M'
,
'A'
,
'C'
,
'H'
,
'I'
,
'N'
,
'E'
,
0
};
static
const
WCHAR
szHKCU
[]
=
{
'H'
,
'K'
,
'C'
,
'U'
,
0
};
static
const
WCHAR
szHKEY_CURRENT_USER
[]
=
{
'H'
,
'K'
,
'E'
,
'Y'
,
'_'
,
'C'
,
'U'
,
'R'
,
'R'
,
'E'
,
'N'
,
'T'
,
'_'
,
'U'
,
'S'
,
'E'
,
'R'
,
0
};
static
const
WCHAR
szHKCR
[]
=
{
'H'
,
'K'
,
'C'
,
'R'
,
0
};
static
const
WCHAR
szHKEY_CLASSES_ROOT
[]
=
{
'H'
,
'K'
,
'E'
,
'Y'
,
'_'
,
'C'
,
'L'
,
'A'
,
'S'
,
'S'
,
'E'
,
'S'
,
'_'
,
'R'
,
'O'
,
'O'
,
'T'
,
0
};
static
const
WCHAR
szHKU
[]
=
{
'H'
,
'K'
,
'U'
,
0
};
static
const
WCHAR
szHKEY_USERS
[]
=
{
'H'
,
'K'
,
'E'
,
'Y'
,
'_'
,
'U'
,
'S'
,
'E'
,
'R'
,
'S'
,
0
};
static
const
WCHAR
szHKCC
[]
=
{
'H'
,
'K'
,
'C'
,
'C'
,
0
};
static
const
WCHAR
szHKEY_CURRENT_CONFIG
[]
=
{
'H'
,
'K'
,
'E'
,
'Y'
,
'_'
,
'C'
,
'U'
,
'R'
,
'R'
,
'E'
,
'N'
,
'T'
,
'_'
,
'C'
,
'O'
,
'N'
,
'F'
,
'I'
,
'G'
,
0
};
if
(
!
reg_StrCmpNIW
(
key
,
szHKLM
,
4
)
||
!
reg_StrCmpNIW
(
key
,
szHKEY_LOCAL_MACHINE
,
18
))
return
HKEY_LOCAL_MACHINE
;
else
if
(
!
reg_StrCmpNIW
(
key
,
szHKCU
,
4
)
||
!
reg_StrCmpNIW
(
key
,
szHKEY_CURRENT_USER
,
17
))
return
HKEY_CURRENT_USER
;
else
if
(
!
reg_StrCmpNIW
(
key
,
szHKCR
,
4
)
||
!
reg_StrCmpNIW
(
key
,
szHKEY_CLASSES_ROOT
,
17
))
return
HKEY_CLASSES_ROOT
;
else
if
(
!
reg_StrCmpNIW
(
key
,
szHKU
,
3
)
||
!
reg_StrCmpNIW
(
key
,
szHKEY_USERS
,
10
))
return
HKEY_USERS
;
else
if
(
!
reg_StrCmpNIW
(
key
,
szHKCC
,
4
)
||
!
reg_StrCmpNIW
(
key
,
szHKEY_CURRENT_CONFIG
,
19
))
return
HKEY_CURRENT_CONFIG
;
else
return
NULL
;
DWORD
i
;
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
root_rels
);
i
++
)
{
if
(
path_rootname_cmp
(
path
,
root_rels
[
i
].
short_name
)
||
path_rootname_cmp
(
path
,
root_rels
[
i
].
long_name
))
return
root_rels
[
i
].
key
;
}
return
NULL
;
}
static
DWORD
wchar_get_type
(
const
WCHAR
*
type_name
)
...
...
@@ -280,7 +281,7 @@ static int reg_add(WCHAR *key_name, WCHAR *value_name, BOOL value_empty,
}
p
++
;
root
=
get_rootkey
(
key_name
);
root
=
path_
get_rootkey
(
key_name
);
if
(
!
root
)
{
reg_message
(
STRING_INVALID_KEY
);
...
...
@@ -350,7 +351,7 @@ static int reg_delete(WCHAR *key_name, WCHAR *value_name, BOOL value_empty,
}
p
++
;
root
=
get_rootkey
(
key_name
);
root
=
path_
get_rootkey
(
key_name
);
if
(
!
root
)
{
reg_message
(
STRING_INVALID_KEY
);
...
...
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