mirror of
https://github.com/lammertb/libhttp.git
synced 2025-09-04 12:42:09 +03:00
Allow to specify title and tray icon for the Windows standalone server
This commit is contained in:
@@ -5,6 +5,7 @@ Release Notes v1.6 (Under Development)
|
|||||||
Changes
|
Changes
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Allow to specify title and tray icon for the Windows standalone server (bel)
|
||||||
- Fix minor memory leaks (bel)
|
- Fix minor memory leaks (bel)
|
||||||
- Redirect all memory allocation/deallocation through mg functions which may be overwritten (bel)
|
- Redirect all memory allocation/deallocation through mg functions which may be overwritten (bel)
|
||||||
- Support Cross-Origin Resource Sharing (CORS) for static files and scripts (bel)
|
- Support Cross-Origin Resource Sharing (CORS) for static files and scripts (bel)
|
||||||
|
19
src/main.c
19
src/main.c
@@ -80,6 +80,7 @@ extern char *_getcwd(char *buf, size_t size);
|
|||||||
static int exit_flag;
|
static int exit_flag;
|
||||||
static char server_base_name[40]; /* Set by init_server_name() */
|
static char server_base_name[40]; /* Set by init_server_name() */
|
||||||
static char *server_name; /* Set by init_server_name() */
|
static char *server_name; /* Set by init_server_name() */
|
||||||
|
static char *icon_name; /* Set by init_server_name() */
|
||||||
static char config_file[PATH_MAX] = ""; /* Set by process_command_line_arguments() */
|
static char config_file[PATH_MAX] = ""; /* Set by process_command_line_arguments() */
|
||||||
static struct mg_context *ctx; /* Set by start_civetweb() */
|
static struct mg_context *ctx; /* Set by start_civetweb() */
|
||||||
|
|
||||||
@@ -222,7 +223,7 @@ static int set_option(char **options, const char *name, const char *value)
|
|||||||
const struct mg_option *default_options = mg_get_valid_options();
|
const struct mg_option *default_options = mg_get_valid_options();
|
||||||
|
|
||||||
for (i = 0; main_config_options[i].name != 0; i++) {
|
for (i = 0; main_config_options[i].name != 0; i++) {
|
||||||
if (0==strcmp(name, main_config_options[OPTION_TITLE].name)) {
|
if (0==strcmp(name, main_config_options[i].name)) {
|
||||||
/* This option is evaluated by main.c, not civetweb.c - just skip it and return OK */
|
/* This option is evaluated by main.c, not civetweb.c - just skip it and return OK */
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -401,6 +402,12 @@ static void init_server_name(int argc, const char *argv[])
|
|||||||
server_name = (char*)(argv[i+1]);
|
server_name = (char*)(argv[i+1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
icon_name = 0;
|
||||||
|
for (i=0; i<argc-1; i++) {
|
||||||
|
if ((argv[i][0]=='-') && (0==strcmp(argv[i]+1, main_config_options[OPTION_ICON].name))) {
|
||||||
|
icon_name = (char*)(argv[i+1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int log_message(const struct mg_connection *conn, const char *message)
|
static int log_message(const struct mg_connection *conn, const char *message)
|
||||||
@@ -1077,12 +1084,16 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR cmdline, int show)
|
|||||||
0, 0, 0, 0, NULL, NULL, NULL, NULL);
|
0, 0, 0, 0, NULL, NULL, NULL, NULL);
|
||||||
ShowWindow(hWnd, SW_HIDE);
|
ShowWindow(hWnd, SW_HIDE);
|
||||||
|
|
||||||
|
if (icon_name) {
|
||||||
|
hIcon = LoadImage(NULL, icon_name, IMAGE_ICON, 16, 16, LR_LOADFROMFILE);
|
||||||
|
} else {
|
||||||
|
hIcon = LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(ID_ICON), IMAGE_ICON, 16, 16, 0);
|
||||||
|
}
|
||||||
|
|
||||||
TrayIcon.cbSize = sizeof(TrayIcon);
|
TrayIcon.cbSize = sizeof(TrayIcon);
|
||||||
TrayIcon.uID = ID_ICON;
|
TrayIcon.uID = ID_ICON;
|
||||||
TrayIcon.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
|
TrayIcon.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
|
||||||
TrayIcon.hIcon = hIcon = LoadImage(GetModuleHandle(NULL),
|
TrayIcon.hIcon = hIcon;
|
||||||
MAKEINTRESOURCE(ID_ICON),
|
|
||||||
IMAGE_ICON, 16, 16, 0);
|
|
||||||
TrayIcon.hWnd = hWnd;
|
TrayIcon.hWnd = hWnd;
|
||||||
snprintf(TrayIcon.szTip, sizeof(TrayIcon.szTip), "%s", server_name);
|
snprintf(TrayIcon.szTip, sizeof(TrayIcon.szTip), "%s", server_name);
|
||||||
TrayIcon.uCallbackMessage = WM_USER;
|
TrayIcon.uCallbackMessage = WM_USER;
|
||||||
|
BIN
test/test.ico
Normal file
BIN
test/test.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
Reference in New Issue
Block a user