Subversion Repositories Tewi

Rev

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

Rev 349 Rev 359
Line 1... Line 1...
1
/* $Id: main.c 349 2024-10-15 20:08:08Z nishi $ */
1
/* $Id: main.c 359 2024-10-16 14:34:51Z nishi $ */
2
 
2
 
3
#define SOURCE
3
#define SOURCE
4
 
4
 
5
#include "../config.h"
5
#include "../config.h"
6
 
6
 
Line 25... Line 25...
25
 
25
 
26
#ifdef __OS2__
26
#ifdef __OS2__
27
#include <types.h>
27
#include <types.h>
28
#endif
28
#endif
29
 
29
 
-
 
30
#ifdef __DOS__
-
 
31
#include <tcp.h>
-
 
32
#endif
-
 
33
 
30
#include <cm_log.h>
34
#include <cm_log.h>
31
#include <cm_string.h>
35
#include <cm_string.h>
32
 
36
 
33
#include "tw_config.h"
37
#include "tw_config.h"
34
#include "tw_server.h"
38
#include "tw_server.h"
35
#include "tw_version.h"
39
#include "tw_version.h"
36
 
40
 
37
#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || (defined(__WATCOMC__) && !defined(__OS2__) && !defined(__NETWARE__))
41
#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || (defined(__WATCOMC__) && !defined(__OS2__) && !defined(__NETWARE__) && !defined(__DOS__))
38
#include <windows.h>
42
#include <windows.h>
39
#elif defined(__NETWARE__)
43
#elif defined(__NETWARE__)
40
#endif
44
#endif
41
 
45
 
42
#ifdef _PSP
46
#ifdef _PSP
Line 91... Line 95...
91
 
95
 
92
char tw_server[2048];
96
char tw_server[2048];
93
 
97
 
94
int startup(int argc, char** argv);
98
int startup(int argc, char** argv);
95
 
99
 
96
#if defined(__MINGW32__) || defined(_MSC_VER) || (defined(__WATCOMC__) && !defined(__OS2__) && !defined(__NETWARE__)) || defined(__BORLANDC__)
100
#if defined(__MINGW32__) || defined(_MSC_VER) || (defined(__WATCOMC__) && !defined(__OS2__) && !defined(__NETWARE__) && !defined(__DOS__)) || defined(__BORLANDC__)
97
char* get_registry(const char* main, const char* sub) {
101
char* get_registry(const char* main, const char* sub) {
98
	DWORD bufsize = 512;
102
	DWORD bufsize = 512;
99
	HKEY handle;
103
	HKEY handle;
100
	char* value = malloc(513);
104
	char* value = malloc(513);
101
	int err = RegOpenKeyEx(HKEY_LOCAL_MACHINE, main, 0, KEY_QUERY_VALUE, &handle);
105
	int err = RegOpenKeyEx(HKEY_LOCAL_MACHINE, main, 0, KEY_QUERY_VALUE, &handle);
Line 748... Line 752...
748
#endif
752
#endif
749
 
753
 
750
int startup(int argc, char** argv) {
754
int startup(int argc, char** argv) {
751
	int i;
755
	int i;
752
	char* r;
756
	char* r;
753
#if defined(__MINGW32__) || defined(_MSC_VER) || (defined(__WATCOMC__) && !defined(__OS2__) && !defined(__NETWARE__)) || defined(__BORLANDC__)
757
#if defined(__MINGW32__) || defined(_MSC_VER) || (defined(__WATCOMC__) && !defined(__OS2__) && !defined(__NETWARE__) && !defined(__DOS__)) || defined(__BORLANDC__)
754
	char* confpath = cm_strdup(PREFIX "/etc/tewi.conf");
758
	char* confpath = cm_strdup(PREFIX "/etc/tewi.conf");
755
	char* regpath = get_registry("Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Tewi HTTPd", "InstallDir");
759
	char* regpath = get_registry("Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Tewi HTTPd", "InstallDir");
756
	if(regpath != NULL) {
760
	if(regpath != NULL) {
757
		free(confpath);
761
		free(confpath);
758
		confpath = cm_strcat(regpath, "/etc/tewi.conf");
762
		confpath = cm_strcat(regpath, "/etc/tewi.conf");
Line 821... Line 825...
821
	tw_config_init();
825
	tw_config_init();
822
	if(tw_config_read(confpath) != 0) {
826
	if(tw_config_read(confpath) != 0) {
823
		STDERR_LOG("Could not read the config\n");
827
		STDERR_LOG("Could not read the config\n");
824
		return 1;
828
		return 1;
825
	}
829
	}
-
 
830
#ifdef __DOS__
-
 
831
	sock_init();
-
 
832
#endif
826
	if(tw_server_init() != 0) {
833
	if(tw_server_init() != 0) {
827
		STDERR_LOG("Could not initialize the server\n");
834
		STDERR_LOG("Could not initialize the server\n");
828
		return 1;
835
		return 1;
829
	}
836
	}
830
	sprintf(tw_server, "Tewi/%s (%s)%s", tw_get_version(), tw_get_platform(), config.extension == NULL ? "" : config.extension);
837
	sprintf(tw_server, "Tewi/%s (%s)%s", tw_get_version(), tw_get_platform(), config.extension == NULL ? "" : config.extension);
Line 832... Line 839...
832
	cm_force_log(r);
839
	cm_force_log(r);
833
	free(r);
840
	free(r);
834
#if !defined(__MINGW32__) && !defined(_MSC_VER) && !defined(__BORLANDC__) && !defined(__WATCOMC__)
841
#if !defined(__MINGW32__) && !defined(_MSC_VER) && !defined(__BORLANDC__) && !defined(__WATCOMC__)
835
	signal(SIGCHLD, SIG_IGN);
842
	signal(SIGCHLD, SIG_IGN);
836
	signal(SIGPIPE, SIG_IGN);
843
	signal(SIGPIPE, SIG_IGN);
837
#elif !defined(BUILD_GUI) && !defined(__OS2__) && !defined(__NETWARE__)
844
#elif !defined(BUILD_GUI) && !defined(__OS2__) && !defined(__NETWARE__) && !defined(__DOS__)
838
	SetConsoleTitle(tw_server);
845
	SetConsoleTitle(tw_server);
839
#endif
846
#endif
840
	return -1;
847
	return -1;
841
}
848
}