Subversion Repositories Tewi

Rev

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

Rev 311 Rev 312
Line 1... Line 1...
1
/* $Id: server.c 311 2024-10-13 01:23:22Z nishi $ */
1
/* $Id: server.c 312 2024-10-13 18:17:37Z nishi $ */
2
 
2
 
3
#define SOURCE
3
#define SOURCE
4
 
4
 
5
#include "../config.h"
5
#include "../config.h"
6
 
6
 
Line 16... Line 16...
16
#include "tw_version.h"
16
#include "tw_version.h"
17
 
17
 
18
#if !defined(_MSC_VER) && !defined(__BORLANDC__)
18
#if !defined(_MSC_VER) && !defined(__BORLANDC__)
19
#include <unistd.h>
19
#include <unistd.h>
20
#endif
20
#endif
-
 
21
#include <ctype.h>
21
#include <string.h>
22
#include <string.h>
22
#include <stdbool.h>
23
#include <stdbool.h>
23
#include <stdarg.h>
24
#include <stdarg.h>
24
#include <stdio.h>
25
#include <stdio.h>
25
#include <stdlib.h>
26
#include <stdlib.h>
Line 30... Line 31...
30
 
31
 
31
#include <cm_string.h>
32
#include <cm_string.h>
32
#include <cm_log.h>
33
#include <cm_log.h>
33
#include <cm_dir.h>
34
#include <cm_dir.h>
34
 
35
 
-
 
36
#ifdef __OS2__
-
 
37
#include <types.h>
-
 
38
#include <sys/time.h>
-
 
39
#define INCL_DOSPROCESS
-
 
40
#include <os2.h>
-
 
41
#include <process.h>
-
 
42
#define HANDLE void*
-
 
43
 
-
 
44
#include "strptime.h"
-
 
45
typedef int socklen_t;
-
 
46
 
-
 
47
#include <tcpustd.h>
-
 
48
#endif
-
 
49
 
35
#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || (defined(__WATCOMC__) && !defined(__OS2__))
50
#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || (defined(__WATCOMC__) && !defined(__OS2__))
36
#ifndef NO_GETNAMEINFO
51
#ifndef NO_GETNAMEINFO
37
#include <ws2tcpip.h>
52
#include <ws2tcpip.h>
38
#include <wspiapi.h>
53
#include <wspiapi.h>
39
#endif
54
#endif
Line 106... Line 121...
106
			return *pw == 0;
121
			return *pw == 0;
107
		} else if(*pw == 0) {
122
		} else if(*pw == 0) {
108
			return 0;
123
			return 0;
109
		} else if(*pw == '*') {
124
		} else if(*pw == '*') {
110
			return *(pw + 1) == 0 || tw_wildcard_match(pw, pt + 1) || tw_wildcard_match(pw + 1, pt);
125
			return *(pw + 1) == 0 || tw_wildcard_match(pw, pt + 1) || tw_wildcard_match(pw + 1, pt);
111
		} else if(*pw == '?' || (*pw == *pt)) {
126
		} else if(*pw == '?' || (tolower(*pw) == tolower(*pt))) {
112
			pw++;
127
			pw++;
113
			pt++;
128
			pt++;
114
			continue;
129
			continue;
115
		} else {
130
		} else {
116
			return 0;
131
			return 0;
117
		}
132
		}
118
	}
133
	}
119
}
134
}
120
 
135
 
121
void close_socket(int sock) {
136
void close_socket(int sock) {
-
 
137
#ifdef __OS2__
-
 
138
	soclose(sock);
122
#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__)
139
#elif defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__)
123
	closesocket(sock);
140
	closesocket(sock);
124
#else
141
#else
125
	close(sock);
142
	close(sock);
126
#endif
143
#endif
127
}
144
}
128
 
145
 
129
int tw_server_init(void) {
146
int tw_server_init(void) {
130
	int i;
147
	int i;
131
#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__)
148
#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || (defined(__WATCOMC__) && !defined(__OS2__))
132
	WSADATA wsa;
149
	WSADATA wsa;
133
#ifdef USE_WINSOCK1
150
#ifdef USE_WINSOCK1
134
	WSAStartup(MAKEWORD(1, 1), &wsa);
151
	WSAStartup(MAKEWORD(1, 1), &wsa);
135
#else
152
#else
136
	WSAStartup(MAKEWORD(2, 0), &wsa);
153
	WSAStartup(MAKEWORD(2, 0), &wsa);
137
#endif
154
#endif
138
#endif
155
#endif
-
 
156
#ifdef __OS2__
-
 
157
	sock_init();
-
 
158
#endif
139
	for(i = 0; config.ports[i] != -1; i++)
159
	for(i = 0; config.ports[i] != -1; i++)
140
		;
160
		;
141
	sockcount = i;
161
	sockcount = i;
142
	for(i = 0; config.ports[i] != -1; i++) {
162
	for(i = 0; config.ports[i] != -1; i++) {
143
		int yes = 1;
163
		int yes = 1;
Line 1017... Line 1037...
1017
#endif
1037
#endif
1018
					e->port = config.ports[i];
1038
					e->port = config.ports[i];
1019
					e->addr = claddr;
1039
					e->addr = claddr;
1020
#endif
1040
#endif
1021
#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__)
1041
#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__)
-
 
1042
#ifdef __OS2__
-
 
1043
					_beginthread(tw_server_pass, 0, 0, e);
-
 
1044
#else
1022
					_beginthread(tw_server_pass, 0, e);
1045
					_beginthread(tw_server_pass, 0, e);
-
 
1046
#endif
1023
#elif defined(_PSP) || defined(__PPU__)
1047
#elif defined(_PSP) || defined(__PPU__)
1024
						tw_server_pass(e);
1048
						tw_server_pass(e);
1025
#elif defined(__HAIKU__)
1049
#elif defined(__HAIKU__)
1026
					for(j = 0; j < sizeof(threads) / sizeof(threads[0]); j++) {
1050
					for(j = 0; j < sizeof(threads) / sizeof(threads[0]); j++) {
1027
						if(threads[j].used) {
1051
						if(threads[j].used) {