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
9bbbebc2
Commit
9bbbebc2
authored
Apr 23, 2008
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
explorer: Convert the command line parsing to Unicode.
parent
bbd32aac
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
76 additions
and
72 deletions
+76
-72
Makefile.in
programs/explorer/Makefile.in
+1
-1
desktop.c
programs/explorer/desktop.c
+39
-24
explorer.c
programs/explorer/explorer.c
+35
-40
explorer_private.h
programs/explorer/explorer_private.h
+1
-7
No files found.
programs/explorer/Makefile.in
View file @
9bbbebc2
...
...
@@ -3,7 +3,7 @@ TOPOBJDIR = ../..
SRCDIR
=
@srcdir@
VPATH
=
@srcdir@
MODULE
=
explorer.exe
APPMODE
=
-mwindows
APPMODE
=
-mwindows
-municode
IMPORTS
=
rpcrt4 user32 gdi32 advapi32 kernel32 ntdll
DELAYIMPORTS
=
comctl32
...
...
programs/explorer/desktop.c
View file @
9bbbebc2
...
...
@@ -74,21 +74,22 @@ static LRESULT WINAPI desktop_wnd_proc( HWND hwnd, UINT message, WPARAM wp, LPAR
}
/* create the desktop and the associated X11 window, and make it the current desktop */
static
unsigned
long
create_desktop
(
const
char
*
name
,
unsigned
int
width
,
unsigned
int
height
)
static
unsigned
long
create_desktop
(
const
WCHAR
*
name
,
unsigned
int
width
,
unsigned
int
height
)
{
static
const
WCHAR
rootW
[]
=
{
'r'
,
'o'
,
'o'
,
't'
,
0
};
HMODULE
x11drv
=
GetModuleHandleA
(
"winex11.drv"
);
HDESK
desktop
;
unsigned
long
xwin
=
0
;
unsigned
long
(
*
create_desktop_func
)(
unsigned
int
,
unsigned
int
);
desktop
=
CreateDesktop
A
(
name
,
NULL
,
NULL
,
0
,
DESKTOP_ALL_ACCESS
,
NULL
);
desktop
=
CreateDesktop
W
(
name
,
NULL
,
NULL
,
0
,
DESKTOP_ALL_ACCESS
,
NULL
);
if
(
!
desktop
)
{
WINE_ERR
(
"failed to create desktop %s error %d
\n
"
,
wine_dbgstr_
a
(
name
),
GetLastError
()
);
WINE_ERR
(
"failed to create desktop %s error %d
\n
"
,
wine_dbgstr_
w
(
name
),
GetLastError
()
);
ExitProcess
(
1
);
}
/* magic: desktop "root" means use the X11 root window */
if
(
x11drv
&&
strc
asecmp
(
name
,
"root"
))
if
(
x11drv
&&
strc
mpiW
(
name
,
rootW
))
{
create_desktop_func
=
(
void
*
)
GetProcAddress
(
x11drv
,
"wine_create_desktop"
);
if
(
create_desktop_func
)
xwin
=
create_desktop_func
(
width
,
height
);
...
...
@@ -97,19 +98,35 @@ static unsigned long create_desktop( const char *name, unsigned int width, unsig
return
xwin
;
}
/* parse the desktop size specification */
static
BOOL
parse_size
(
const
WCHAR
*
size
,
unsigned
int
*
width
,
unsigned
int
*
height
)
{
WCHAR
*
end
;
*
width
=
strtoulW
(
size
,
&
end
,
10
);
if
(
end
==
size
)
return
FALSE
;
if
(
*
end
!=
'x'
)
return
FALSE
;
size
=
end
+
1
;
*
height
=
strtoulW
(
size
,
&
end
,
10
);
return
!*
end
;
}
/* retrieve the default desktop size from the X11 driver config */
/* FIXME: this is for backwards compatibility, should probably be changed */
static
BOOL
get_default_desktop_size
(
unsigned
int
*
width
,
unsigned
int
*
height
)
{
static
const
WCHAR
keyW
[]
=
{
'S'
,
'o'
,
'f'
,
't'
,
'w'
,
'a'
,
'r'
,
'e'
,
'\\'
,
'W'
,
'i'
,
'n'
,
'e'
,
'\\'
,
'X'
,
'1'
,
'1'
,
' '
,
'D'
,
'r'
,
'i'
,
'v'
,
'e'
,
'r'
,
0
};
static
const
WCHAR
desktopW
[]
=
{
'D'
,
'e'
,
's'
,
'k'
,
't'
,
'o'
,
'p'
,
0
};
HKEY
hkey
;
char
buffer
[
64
];
WCHAR
buffer
[
64
];
DWORD
size
=
sizeof
(
buffer
);
BOOL
ret
=
FALSE
;
/* @@ Wine registry key: HKCU\Software\Wine\X11 Driver */
if
(
RegOpenKey
A
(
HKEY_CURRENT_USER
,
"Software
\\
Wine
\\
X11 Driver"
,
&
hkey
))
return
FALSE
;
if
(
!
RegQueryValueEx
A
(
hkey
,
"Desktop"
,
0
,
NULL
,
(
LPBYTE
)
buffer
,
&
size
))
ret
=
(
sscanf
(
buffer
,
"%ux%u"
,
width
,
height
)
==
2
);
if
(
RegOpenKey
W
(
HKEY_CURRENT_USER
,
keyW
,
&
hkey
))
return
FALSE
;
if
(
!
RegQueryValueEx
W
(
hkey
,
desktopW
,
0
,
NULL
,
(
LPBYTE
)
buffer
,
&
size
))
ret
=
parse_size
(
buffer
,
width
,
height
);
RegCloseKey
(
hkey
);
return
ret
;
}
...
...
@@ -144,13 +161,12 @@ static void initialize_display_settings( HWND desktop )
}
}
static
void
set_desktop_window_title
(
HWND
hwnd
,
const
char
*
name
)
static
void
set_desktop_window_title
(
HWND
hwnd
,
const
WCHAR
*
name
)
{
static
const
WCHAR
desktop_nameW
[]
=
{
'W'
,
'i'
,
'n'
,
'e'
,
' '
,
'd'
,
'e'
,
's'
,
'k'
,
't'
,
'o'
,
'p'
,
0
};
static
const
WCHAR
desktop_name_separatorW
[]
=
{
' '
,
'-'
,
' '
,
0
};
WCHAR
*
window_titleW
=
NULL
;
int
window_title_len
;
int
name_len
;
if
(
!
name
[
0
])
{
...
...
@@ -158,8 +174,7 @@ static void set_desktop_window_title( HWND hwnd, const char *name )
return
;
}
name_len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
name
,
-
1
,
NULL
,
0
);
window_title_len
=
name_len
*
sizeof
(
WCHAR
)
window_title_len
=
strlenW
(
name
)
*
sizeof
(
WCHAR
)
+
sizeof
(
desktop_name_separatorW
)
+
sizeof
(
desktop_nameW
);
window_titleW
=
HeapAlloc
(
GetProcessHeap
(),
0
,
window_title_len
);
...
...
@@ -169,8 +184,7 @@ static void set_desktop_window_title( HWND hwnd, const char *name )
return
;
}
MultiByteToWideChar
(
CP_ACP
,
0
,
name
,
-
1
,
window_titleW
,
name_len
);
strcpyW
(
window_titleW
,
name
);
strcatW
(
window_titleW
,
desktop_name_separatorW
);
strcatW
(
window_titleW
,
desktop_nameW
);
...
...
@@ -179,15 +193,16 @@ static void set_desktop_window_title( HWND hwnd, const char *name )
}
/* main desktop management function */
void
manage_desktop
(
char
*
arg
)
void
manage_desktop
(
WCHAR
*
arg
)
{
static
const
WCHAR
defaultW
[]
=
{
'D'
,
'e'
,
'f'
,
'a'
,
'u'
,
'l'
,
't'
,
0
};
MSG
msg
;
HWND
hwnd
;
unsigned
long
xwin
=
0
;
unsigned
int
width
,
height
;
char
*
cmdline
=
NULL
;
char
*
p
=
arg
;
const
char
*
name
=
NULL
;
WCHAR
*
cmdline
=
NULL
;
WCHAR
*
p
=
arg
;
const
WCHAR
*
name
=
NULL
;
/* get the rest of the command line (if any) */
while
(
*
p
&&
!
isspace
(
*
p
))
p
++
;
...
...
@@ -203,8 +218,8 @@ void manage_desktop( char *arg )
if
(
*
arg
==
'='
||
*
arg
==
','
)
{
arg
++
;
if
((
p
=
strchr
(
arg
,
','
)))
*
p
++
=
0
;
if
(
!
p
||
sscanf
(
p
,
"%ux%u"
,
&
width
,
&
height
)
!=
2
)
if
((
p
=
strchr
W
(
arg
,
','
)))
*
p
++
=
0
;
if
(
!
p
||
!
parse_size
(
p
,
&
width
,
&
height
)
)
{
width
=
800
;
height
=
600
;
...
...
@@ -214,7 +229,7 @@ void manage_desktop( char *arg )
}
else
if
(
get_default_desktop_size
(
&
width
,
&
height
))
{
name
=
"Default"
;
name
=
defaultW
;
xwin
=
create_desktop
(
name
,
width
,
height
);
}
...
...
@@ -245,13 +260,13 @@ void manage_desktop( char *arg )
/* if we have a command line, execute it */
if
(
cmdline
)
{
STARTUPINFO
A
si
;
STARTUPINFO
W
si
;
PROCESS_INFORMATION
pi
;
memset
(
&
si
,
0
,
sizeof
(
si
)
);
si
.
cb
=
sizeof
(
si
);
WINE_TRACE
(
"starting %s
\n
"
,
wine_dbgstr_
a
(
cmdline
)
);
if
(
CreateProcess
A
(
NULL
,
cmdline
,
NULL
,
NULL
,
FALSE
,
0
,
NULL
,
NULL
,
&
si
,
&
pi
))
WINE_TRACE
(
"starting %s
\n
"
,
wine_dbgstr_
w
(
cmdline
)
);
if
(
CreateProcess
W
(
NULL
,
cmdline
,
NULL
,
NULL
,
FALSE
,
0
,
NULL
,
NULL
,
&
si
,
&
pi
))
{
CloseHandle
(
pi
.
hThread
);
CloseHandle
(
pi
.
hProcess
);
...
...
programs/explorer/explorer.c
View file @
9bbbebc2
...
...
@@ -20,8 +20,8 @@
*/
#include <windows.h>
#include <ctype.h>
#include "wine/unicode.h"
#include "explorer_private.h"
typedef
struct
parametersTAG
{
...
...
@@ -31,37 +31,25 @@ typedef struct parametersTAG {
}
parameters_struct
;
static
int
CopyPathString
(
LPWSTR
target
,
LPSTR
source
)
static
int
CopyPathString
(
LPWSTR
target
,
LP
W
STR
source
)
{
CHAR
temp_buf
[
MAX_PATH
];
INT
i
=
0
;
while
(
isspace
(
*
source
))
source
++
;
while
(
isspace
W
(
*
source
))
source
++
;
if
(
*
source
==
'\"'
)
{
source
++
;
while
(
*
source
!=
'\"'
)
{
temp_buf
[
i
]
=
*
source
;
i
++
;
source
++
;
}
temp_buf
[
i
]
=
0
;
while
(
*
source
!=
'\"'
)
target
[
i
++
]
=
*
source
++
;
target
[
i
]
=
0
;
source
++
;
i
+=
2
;
}
else
{
while
(
*
source
&&
!
isspace
(
*
source
))
{
temp_buf
[
i
]
=
*
source
;
i
++
;
source
++
;
}
temp_buf
[
i
]
=
0
;
while
(
*
source
&&
!
isspaceW
(
*
source
))
target
[
i
++
]
=
*
source
++
;
target
[
i
]
=
0
;
}
MultiByteToWideChar
(
CP_ACP
,
0
,
temp_buf
,
-
1
,
target
,
MAX_PATH
);
return
i
;
}
...
...
@@ -98,45 +86,52 @@ static void CopyPathRoot(LPWSTR root, LPWSTR path)
* [/root,object] Specifies the root level of the view
* [/select,object] parent folder is opened and specified object is selected
*/
static
void
ParseCommandLine
(
LPSTR
commandline
,
parameters_struct
*
parameters
)
static
void
ParseCommandLine
(
LP
W
STR
commandline
,
parameters_struct
*
parameters
)
{
LPSTR
p
;
LPSTR
p2
;
static
const
WCHAR
arg_n
[]
=
{
'/'
,
'n'
};
static
const
WCHAR
arg_e
[]
=
{
'/'
,
'e'
,
','
};
static
const
WCHAR
arg_root
[]
=
{
'/'
,
'r'
,
'o'
,
'o'
,
't'
,
','
};
static
const
WCHAR
arg_select
[]
=
{
'/'
,
's'
,
'e'
,
'l'
,
'e'
,
'c'
,
't'
,
','
};
static
const
WCHAR
arg_desktop
[]
=
{
'/'
,
'd'
,
'e'
,
's'
,
'k'
,
't'
,
'o'
,
'p'
};
LPWSTR
p
,
p2
;
p2
=
commandline
;
p
=
strchr
(
commandline
,
'/'
);
p
=
strchr
W
(
commandline
,
'/'
);
while
(
p
)
{
p
++
;
if
(
strncmp
(
p
,
"n"
,
1
)
==
0
)
if
(
strncmpW
(
p
,
arg_n
,
sizeof
(
arg_n
)
/
sizeof
(
WCHAR
))
==
0
)
{
parameters
->
explorer_mode
=
FALSE
;
p
++
;
p
+=
sizeof
(
arg_n
)
/
sizeof
(
WCHAR
)
;
}
else
if
(
strncmp
(
p
,
"e,"
,
2
)
==
0
)
else
if
(
strncmp
W
(
p
,
arg_e
,
sizeof
(
arg_e
)
/
sizeof
(
WCHAR
)
)
==
0
)
{
parameters
->
explorer_mode
=
TRUE
;
p
+=
2
;
p
+=
sizeof
(
arg_e
)
/
sizeof
(
WCHAR
)
;
}
else
if
(
strncmp
(
p
,
"root,"
,
5
)
==
0
)
else
if
(
strncmp
W
(
p
,
arg_root
,
sizeof
(
arg_root
)
/
sizeof
(
WCHAR
)
)
==
0
)
{
p
+=
5
;
p
+=
sizeof
(
arg_root
)
/
sizeof
(
WCHAR
)
;
p
+=
CopyPathString
(
parameters
->
root
,
p
);
}
else
if
(
strncmp
(
p
,
"select,"
,
7
)
==
0
)
else
if
(
strncmp
W
(
p
,
arg_select
,
sizeof
(
arg_select
)
/
sizeof
(
WCHAR
)
)
==
0
)
{
p
+=
7
;
p
+=
sizeof
(
arg_select
)
/
sizeof
(
WCHAR
)
;
p
+=
CopyPathString
(
parameters
->
selection
,
p
);
if
(
!
parameters
->
root
[
0
])
CopyPathRoot
(
parameters
->
root
,
parameters
->
selection
);
}
else
if
(
strncmp
(
p
,
"desktop"
,
7
)
==
0
)
else
if
(
strncmp
W
(
p
,
arg_desktop
,
sizeof
(
arg_desktop
)
/
sizeof
(
WCHAR
)
)
==
0
)
{
manage_desktop
(
p
+
7
);
/* the rest of the command line is handled by desktop mode */
p
+=
sizeof
(
arg_desktop
)
/
sizeof
(
WCHAR
);
manage_desktop
(
p
);
/* the rest of the command line is handled by desktop mode */
}
else
p
++
;
p2
=
p
;
p
=
strchr
(
p
,
'/'
);
p
=
strchr
W
(
p
,
'/'
);
}
if
(
p2
&&
*
p2
)
{
...
...
@@ -145,10 +140,10 @@ static void ParseCommandLine(LPSTR commandline,parameters_struct *parameters)
}
}
int
WINAPI
WinMain
(
HINSTANCE
hinstance
,
HINSTANCE
previnstance
,
LP
STR
cmdline
,
int
cmdshow
)
int
WINAPI
w
WinMain
(
HINSTANCE
hinstance
,
HINSTANCE
previnstance
,
LPW
STR
cmdline
,
int
cmdshow
)
{
STARTUPINFOW
si
;
PROCESS_INFORMATION
info
;
...
...
programs/explorer/explorer_private.h
View file @
9bbbebc2
...
...
@@ -21,13 +21,7 @@
#ifndef __WINE_EXPLORER_PRIVATE_H
#define __WINE_EXPLORER_PRIVATE_H
extern
BOOL
add_dos_device
(
const
char
*
udi
,
const
char
*
device
,
const
char
*
mount_point
,
const
char
*
type
);
extern
BOOL
remove_dos_device
(
const
char
*
udi
);
extern
void
manage_desktop
(
char
*
arg
);
extern
void
initialize_diskarbitration
(
void
);
extern
void
initialize_hal
(
void
);
extern
void
manage_desktop
(
WCHAR
*
arg
);
extern
void
initialize_systray
(
void
);
#endif
/* __WINE_EXPLORER_PRIVATE_H */
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