From 46b854884a159cdf1523f1e35175ec6b1251330e Mon Sep 17 00:00:00 2001 From: Nishi Date: Wed, 9 Oct 2024 02:44:20 +0000 Subject: [PATCH] add service support git-svn-id: file:///raid/svn-personal/tewi/trunk@284 8739d7e6-ffea-ec47-b151-bdff447c6205 --- Server/main.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Server/main.c b/Server/main.c index 51ab896..c107608 100644 --- a/Server/main.c +++ b/Server/main.c @@ -124,6 +124,7 @@ void WINAPI servhandler(DWORD control) { void WINAPI servmain(DWORD argc, LPSTR* argv) { char* path = get_registry("Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Tewi HTTPd", "InstallDir"); + int st; if(path != NULL) { char* lpath = cm_strcat(path, "/logs/tewi.log"); logfile = fopen(lpath, "a"); @@ -143,7 +144,7 @@ void WINAPI servmain(DWORD argc, LPSTR* argv) { status_handle = RegisterServiceCtrlHandler("Tewi HTTPd", servhandler); if(status_handle == NULL) return; if(SetServiceStatus(status_handle, &status) == 0) return; - int st = startup(argc, argv); + st = startup(argc, argv); if(st != -1) { status.dwWin32ExitCode = NO_ERROR; status.dwServiceSpecificExitCode = st; @@ -527,11 +528,15 @@ void show_png(void) { #if !defined(BUILD_GUI_VALID) int main(int argc, char** argv) { int st; - logfile = stderr; #ifdef SERVICE SERVICE_TABLE_ENTRY table[] = {{"Tewi HTTPd", servmain}, {NULL, NULL}}; - StartServiceCtrlDispatcher(table); + logfile = stderr; + if(!StartServiceCtrlDispatcher(table)){ + printf("Failed to start the service dispatcher\n"); + return 1; + } #else + logfile = stderr; #ifdef _PSP pspDebugScreenInit(); pspDebugScreenSetXY(0, 0); -- 2.45.2