Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mongoose
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
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
esp
mongoose
Commits
74511b42
Commit
74511b42
authored
Jan 12, 2014
by
Sergey Lyubka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Using unicode winapi to load config file
parent
04862eec
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
24 deletions
+36
-24
main.c
build/main.c
+36
-24
No files found.
build/main.c
View file @
74511b42
...
@@ -208,6 +208,34 @@ static void set_option(char **options, const char *name, const char *value) {
...
@@ -208,6 +208,34 @@ static void set_option(char **options, const char *name, const char *value) {
}
}
}
}
#ifdef WIN32
static
int
my_argc
;
static
char
**
my_argv
;
static
void
to_utf8
(
wchar_t
*
src
,
char
*
dst
,
size_t
dst_len
)
{
WideCharToMultiByte
(
CP_UTF8
,
0
,
src
,
-
1
,
dst
,
dst_len
,
0
,
0
);
}
static
void
to_wchar
(
const
char
*
src
,
wchar_t
*
dst
,
size_t
dst_len
)
{
MultiByteToWideChar
(
CP_UTF8
,
0
,
src
,
-
1
,
dst
,
dst_len
);
}
static
void
init_utf8_argc_argv
(
void
)
{
wchar_t
**
wargv
=
CommandLineToArgvW
(
GetCommandLineW
(),
&
my_argc
);
if
(
wargv
!=
NULL
)
{
char
buf
[
1024
*
8
];
int
i
;
// TODO(lsm): free that at some point.
my_argv
=
calloc
(
my_argc
+
1
,
sizeof
(
my_argv
[
0
]));
for
(
i
=
0
;
i
<
my_argc
;
i
++
)
{
to_utf8
(
wargv
[
i
],
buf
,
sizeof
(
buf
));
my_argv
[
i
]
=
strdup
(
buf
);
}
LocalFree
(
wargv
);
}
}
#endif
static
void
process_command_line_arguments
(
char
*
argv
[],
char
**
options
)
{
static
void
process_command_line_arguments
(
char
*
argv
[],
char
**
options
)
{
char
line
[
MAX_CONF_FILE_LINE_SIZE
],
opt
[
sizeof
(
line
)],
val
[
sizeof
(
line
)],
*
p
;
char
line
[
MAX_CONF_FILE_LINE_SIZE
],
opt
[
sizeof
(
line
)],
val
[
sizeof
(
line
)],
*
p
;
FILE
*
fp
=
NULL
;
FILE
*
fp
=
NULL
;
...
@@ -225,7 +253,15 @@ static void process_command_line_arguments(char *argv[], char **options) {
...
@@ -225,7 +253,15 @@ static void process_command_line_arguments(char *argv[], char **options) {
(
int
)
(
p
-
argv
[
0
]),
argv
[
0
],
DIRSEP
,
CONFIG_FILE
);
(
int
)
(
p
-
argv
[
0
]),
argv
[
0
],
DIRSEP
,
CONFIG_FILE
);
}
}
#ifdef WIN32
{
wchar_t
path
[
PATH_MAX
];
to_wchar
(
config_file
,
path
,
sizeof
(
path
)
/
sizeof
(
path
[
0
]));
fp
=
_wfopen
(
path
,
L"r"
);
}
#else
fp
=
fopen
(
config_file
,
"r"
);
fp
=
fopen
(
config_file
,
"r"
);
#endif
// If config file was set in command line and open failed, die
// If config file was set in command line and open failed, die
if
(
cmd_line_opts_start
==
2
&&
fp
==
NULL
)
{
if
(
cmd_line_opts_start
==
2
&&
fp
==
NULL
)
{
...
@@ -318,30 +354,6 @@ static void verify_existence(char **options, const char *option_name,
...
@@ -318,30 +354,6 @@ static void verify_existence(char **options, const char *option_name,
}
}
}
}
#ifdef WIN32
static
int
my_argc
;
static
char
**
my_argv
;
static
void
to_utf8
(
wchar_t
*
src
,
char
*
dst
,
size_t
dst_len
)
{
WideCharToMultiByte
(
CP_UTF8
,
0
,
src
,
-
1
,
dst
,
dst_len
,
0
,
0
);
}
static
void
init_utf8_argc_argv
(
void
)
{
wchar_t
**
wargv
=
CommandLineToArgvW
(
GetCommandLineW
(),
&
my_argc
);
if
(
wargv
!=
NULL
)
{
char
buf
[
1024
*
8
];
int
i
;
// TODO(lsm): free that at some point.
my_argv
=
calloc
(
my_argc
+
1
,
sizeof
(
my_argv
[
0
]));
for
(
i
=
0
;
i
<
my_argc
;
i
++
)
{
to_utf8
(
wargv
[
i
],
buf
,
sizeof
(
buf
));
my_argv
[
i
]
=
strdup
(
buf
);
}
LocalFree
(
wargv
);
}
}
#endif
static
void
set_absolute_path
(
char
*
options
[],
const
char
*
option_name
,
static
void
set_absolute_path
(
char
*
options
[],
const
char
*
option_name
,
const
char
*
path_to_mongoose_exe
)
{
const
char
*
path_to_mongoose_exe
)
{
char
path
[
PATH_MAX
],
abs
[
PATH_MAX
],
*
option_value
;
char
path
[
PATH_MAX
],
abs
[
PATH_MAX
],
*
option_value
;
...
...
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