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
70771f29
Commit
70771f29
authored
Jan 10, 2013
by
Sergey Lyubka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Config edit implemented for mac
parent
12139150
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
24 deletions
+33
-24
main.c
main.c
+33
-24
No files found.
main.c
View file @
70771f29
...
@@ -110,6 +110,33 @@ static void show_usage_and_exit(void) {
...
@@ -110,6 +110,33 @@ static void show_usage_and_exit(void) {
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
#if defined(_WIN32) || defined(USE_COCOA)
static
void
create_config_file
(
const
char
*
path
)
{
const
char
**
names
,
*
value
;
FILE
*
fp
;
int
i
;
// Create config file if it is not present yet
if
((
fp
=
fopen
(
path
,
"r"
))
!=
NULL
)
{
fclose
(
fp
);
}
else
if
((
fp
=
fopen
(
path
,
"a+"
))
!=
NULL
)
{
fprintf
(
fp
,
"%s"
,
"# Mongoose web server configuration file.
\n
"
"# For detailed description of every option, visit
\n
"
"# https://github.com/valenok/mongoose/blob/master/UserManual.md
\n
"
"# Lines starting with '#' and empty lines are ignored.
\n
"
"# To make a change, remove leading '#', modify option's value,
\n
"
"# save this file and then restart Mongoose.
\n\n
"
);
names
=
mg_get_valid_option_names
();
for
(
i
=
0
;
names
[
i
]
!=
NULL
;
i
+=
3
)
{
value
=
mg_get_option
(
ctx
,
names
[
i
]);
fprintf
(
fp
,
"# %s %s
\n
"
,
names
[
i
+
1
],
*
value
?
value
:
"<value>"
);
}
fclose
(
fp
);
}
}
#endif
static
void
verify_document_root
(
const
char
*
root
)
{
static
void
verify_document_root
(
const
char
*
root
)
{
const
char
*
p
,
*
path
;
const
char
*
p
,
*
path
;
char
buf
[
PATH_MAX
];
char
buf
[
PATH_MAX
];
...
@@ -306,28 +333,8 @@ static void WINAPI ServiceMain(void) {
...
@@ -306,28 +333,8 @@ static void WINAPI ServiceMain(void) {
static
NOTIFYICONDATA
TrayIcon
;
static
NOTIFYICONDATA
TrayIcon
;
static
void
edit_config_file
(
void
)
{
static
void
edit_config_file
(
void
)
{
const
char
**
names
,
*
value
;
FILE
*
fp
;
int
i
;
char
cmd
[
200
];
char
cmd
[
200
];
create_config_file
(
config_file
);
// Create config file if it is not present yet
if
((
fp
=
fopen
(
config_file
,
"r"
))
!=
NULL
)
{
fclose
(
fp
);
}
else
if
((
fp
=
fopen
(
config_file
,
"a+"
))
!=
NULL
)
{
fprintf
(
fp
,
"# Mongoose web server configuration file.
\n
"
"# Lines starting with '#' and empty lines are ignored.
\n
"
"# For detailed description of every option, visit
\n
"
"# http://code.google.com/p/mongoose/wiki/MongooseManual
\n\n
"
);
names
=
mg_get_valid_option_names
();
for
(
i
=
0
;
names
[
i
]
!=
NULL
;
i
+=
3
)
{
value
=
mg_get_option
(
ctx
,
names
[
i
]);
fprintf
(
fp
,
"# %s %s
\n
"
,
names
[
i
+
1
],
*
value
?
value
:
"<value>"
);
}
fclose
(
fp
);
}
snprintf
(
cmd
,
sizeof
(
cmd
),
"notepad.exe %s"
,
config_file
);
snprintf
(
cmd
,
sizeof
(
cmd
),
"notepad.exe %s"
,
config_file
);
WinExec
(
cmd
,
SW_SHOW
);
WinExec
(
cmd
,
SW_SHOW
);
}
}
...
@@ -499,14 +506,16 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR cmdline, int show) {
...
@@ -499,14 +506,16 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR cmdline, int show) {
@
end
@
end
@
implementation
Mongoose
@
implementation
Mongoose
-
(
void
)
openBrowser
{
-
(
void
)
openBrowser
{
[[
NSWorkspace
sharedWorkspace
]
[[
NSWorkspace
sharedWorkspace
]
openURL
:
[
NSURL
URLWithString
:
openURL
:
[
NSURL
URLWithString
:
[
NSString
stringWithUTF8String
:
"http://www.yahoo.com"
]]];
[
NSString
stringWithUTF8String
:
"http://www.yahoo.com"
]]];
}
}
-
(
void
)
editConfig
{
-
(
void
)
editConfig
{
create_config_file
(
config_file
);
[[
NSWorkspace
sharedWorkspace
]
[[
NSWorkspace
sharedWorkspace
]
openFile
:
@
"mongoose.conf"
withApplication
:
@
"TextEdit"
];
openFile
:
[
NSString
stringWithUTF8String
:
config_file
]
withApplication
:
@
"TextEdit"
];
}
}
-
(
void
)
shutDown
{
-
(
void
)
shutDown
{
[
NSApp
terminate
:
nil
];
[
NSApp
terminate
:
nil
];
...
...
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