Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
mongoose
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ganil-acq
GANILinux
linux-service
library
mongoose
Commits
65c12789
Commit
65c12789
authored
11 years ago
by
Sergey Lyubka
Browse files
Options
Downloads
Patches
Plain Diff
win32 build of server.c fixed
parent
05e11359
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/server.c
+34
-4
34 additions, 4 deletions
examples/server.c
with
34 additions
and
4 deletions
examples/server.c
+
34
−
4
View file @
65c12789
...
...
@@ -39,12 +39,36 @@
#include
"mongoose.h"
#ifdef _WIN32
#include
<windows.h>
#include
<direct.h>
// For chdir()
#include
<winsvc.h>
#include
<shlobj.h>
#ifndef PATH_MAX
#define PATH_MAX MAX_PATH
#endif
#ifndef S_ISDIR
#define S_ISDIR(x) ((x) & _S_IFDIR)
#endif
#define DIRSEP '\\'
#define snprintf _snprintf
#define vsnprintf _vsnprintf
#define sleep(x) Sleep((x) * 1000)
#define abs_path(rel, abs, abs_size) _fullpath((abs), (rel), (abs_size))
#define SIGCHLD 0
typedef
struct
_stat
file_stat_t
;
#define stat(x, y) _stat((x), (y))
#else
typedef
struct
stat
file_stat_t
;
#include
<sys/wait.h>
#include
<unistd.h>
#define DIRSEP '/'
#define __cdecl
#define abs_path(rel, abs, abs_size) realpath((rel), (abs))
#endif // _WIN32
#define MAX_OPTIONS 100
#define MAX_CONF_FILE_LINE_SIZE (8 * 1024)
...
...
@@ -62,19 +86,17 @@ static void __cdecl signal_handler(int sig_num) {
// Reinstantiate signal handler
signal
(
sig_num
,
signal_handler
);
#ifndef _WIN32
// Do not do the trick with ignoring SIGCHLD, cause not all OSes (e.g. QNX)
// reap zombies if SIGCHLD is ignored. On QNX, for example, waitpid()
// fails if SIGCHLD is ignored, making system() non-functional.
if
(
sig_num
==
SIGCHLD
)
{
do
{}
while
(
waitpid
(
-
1
,
&
sig_num
,
WNOHANG
)
>
0
);
}
else
#endif
{
exit_flag
=
sig_num
;
}
}
#ifdef NO_GUI
#undef _WIN32
#endif
static
void
die
(
const
char
*
fmt
,
...)
{
va_list
ap
;
char
msg
[
200
];
...
...
@@ -209,7 +231,13 @@ static void init_server_name(void) {
}
static
int
is_path_absolute
(
const
char
*
path
)
{
#ifdef _WIN32
return
path
!=
NULL
&&
((
path
[
0
]
==
'\\'
&&
path
[
1
]
==
'\\'
)
||
// UNC path, e.g. \\server\dir
(
isalpha
(
path
[
0
])
&&
path
[
1
]
==
':'
&&
path
[
2
]
==
'\\'
));
// E.g. X:\dir
#else
return
path
!=
NULL
&&
path
[
0
]
==
'/'
;
#endif
}
static
char
*
get_option
(
char
**
options
,
const
char
*
option_name
)
{
...
...
@@ -398,7 +426,9 @@ static void start_mongoose(int argc, char *argv[]) {
// Setup signal handler: quit on Ctrl-C
signal
(
SIGTERM
,
signal_handler
);
signal
(
SIGINT
,
signal_handler
);
#ifndef _WIN32
signal
(
SIGCHLD
,
signal_handler
);
#endif
}
int
main
(
int
argc
,
char
*
argv
[])
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment