Subversion Repositories Tewi

Rev

Rev 257 | Rev 299 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 257 Rev 284
Line 1... Line 1...
1
/* $Id: main.c 257 2024-10-04 05:34:27Z nishi $ */
1
/* $Id: main.c 284 2024-10-09 02:44:20Z nishi $ */
2
 
2
 
3
#define SOURCE
3
#define SOURCE
4
 
4
 
5
#include "../config.h"
5
#include "../config.h"
6
 
6
 
Line 122... Line 122...
122
	SetServiceStatus(status_handle, &status);
122
	SetServiceStatus(status_handle, &status);
123
}
123
}
124
 
124
 
125
void WINAPI servmain(DWORD argc, LPSTR* argv) {
125
void WINAPI servmain(DWORD argc, LPSTR* argv) {
126
	char* path = get_registry("Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Tewi HTTPd", "InstallDir");
126
	char* path = get_registry("Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Tewi HTTPd", "InstallDir");
-
 
127
	int st;
127
	if(path != NULL) {
128
	if(path != NULL) {
128
		char* lpath = cm_strcat(path, "/logs/tewi.log");
129
		char* lpath = cm_strcat(path, "/logs/tewi.log");
129
		logfile = fopen(lpath, "a");
130
		logfile = fopen(lpath, "a");
130
		free(lpath);
131
		free(lpath);
131
		free(path);
132
		free(path);
Line 141... Line 142...
141
	status.dwCheckPoint = 0;
142
	status.dwCheckPoint = 0;
142
	status.dwWaitHint = 0;
143
	status.dwWaitHint = 0;
143
	status_handle = RegisterServiceCtrlHandler("Tewi HTTPd", servhandler);
144
	status_handle = RegisterServiceCtrlHandler("Tewi HTTPd", servhandler);
144
	if(status_handle == NULL) return;
145
	if(status_handle == NULL) return;
145
	if(SetServiceStatus(status_handle, &status) == 0) return;
146
	if(SetServiceStatus(status_handle, &status) == 0) return;
146
	int st = startup(argc, argv);
147
	st = startup(argc, argv);
147
	if(st != -1) {
148
	if(st != -1) {
148
		status.dwWin32ExitCode = NO_ERROR;
149
		status.dwWin32ExitCode = NO_ERROR;
149
		status.dwServiceSpecificExitCode = st;
150
		status.dwServiceSpecificExitCode = st;
150
		status.dwCurrentState = SERVICE_STOPPED;
151
		status.dwCurrentState = SERVICE_STOPPED;
151
		SetServiceStatus(status_handle, &status);
152
		SetServiceStatus(status_handle, &status);
Line 525... Line 526...
525
#endif
526
#endif
526
 
527
 
527
#if !defined(BUILD_GUI_VALID)
528
#if !defined(BUILD_GUI_VALID)
528
int main(int argc, char** argv) {
529
int main(int argc, char** argv) {
529
	int st;
530
	int st;
530
	logfile = stderr;
-
 
531
#ifdef SERVICE
531
#ifdef SERVICE
532
	SERVICE_TABLE_ENTRY table[] = {{"Tewi HTTPd", servmain}, {NULL, NULL}};
532
	SERVICE_TABLE_ENTRY table[] = {{"Tewi HTTPd", servmain}, {NULL, NULL}};
-
 
533
	logfile = stderr;
533
	StartServiceCtrlDispatcher(table);
534
	if(!StartServiceCtrlDispatcher(table)){
-
 
535
		printf("Failed to start the service dispatcher\n");
-
 
536
		return 1;
-
 
537
	}
534
#else
538
#else
-
 
539
	logfile = stderr;
535
#ifdef _PSP
540
#ifdef _PSP
536
	pspDebugScreenInit();
541
	pspDebugScreenInit();
537
	pspDebugScreenSetXY(0, 0);
542
	pspDebugScreenSetXY(0, 0);
538
	printf("PSP Bootstrap, Tewi/%s\n", tw_get_version());
543
	printf("PSP Bootstrap, Tewi/%s\n", tw_get_version());
539
	int thid = sceKernelCreateThread("update_thread", psp_callback_thread, 0x11, 0xfa0, 0, NULL);
544
	int thid = sceKernelCreateThread("update_thread", psp_callback_thread, 0x11, 0xfa0, 0, NULL);