Subversion Repositories Tewi

Rev

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

Rev 215 Rev 216
Line 1... Line 1...
1
/* $Id: server.c 215 2024-10-02 19:24:43Z nishi $ */
1
/* $Id: server.c 216 2024-10-02 19:31:23Z nishi $ */
2
 
2
 
3
#define SOURCE
3
#define SOURCE
4
 
4
 
5
#include "../config.h"
5
#include "../config.h"
6
 
6
 
Line 40... Line 40...
40
#include <winsock2.h>
40
#include <winsock2.h>
41
#include <process.h>
41
#include <process.h>
42
#include <windows.h>
42
#include <windows.h>
43
 
43
 
44
#include "strptime.h"
44
#include "strptime.h"
-
 
45
typedef int socklen_t;
45
#else
46
#else
46
#ifdef USE_POLL
47
#ifdef USE_POLL
47
#ifdef __PPU__
48
#ifdef __PPU__
48
#include <net/poll.h>
49
#include <net/poll.h>
49
#else
50
#else
Line 446... Line 447...
446
	int port;
447
	int port;
447
	bool ssl;
448
	bool ssl;
448
	SOCKADDR addr;
449
	SOCKADDR addr;
449
};
450
};
450
 
451
 
451
#if defined(__MINGW32__) || defined(_MSC_VER)
452
#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__)
452
unsigned int WINAPI tw_server_pass(void* ptr) {
-
 
453
#elif defined(__BORLANDC__)
453
#define NO_RETURN_THREAD
454
void tw_server_pass(void* ptr) {
454
void tw_server_pass(void* ptr) {
455
#elif defined(__HAIKU__)
455
#elif defined(__HAIKU__)
456
int32_t tw_server_pass(void* ptr) {
456
int32_t tw_server_pass(void* ptr) {
457
#elif defined(_PSP) || defined(__PPU__)
457
#elif defined(_PSP) || defined(__PPU__)
458
int tw_server_pass(void* ptr) {
458
int tw_server_pass(void* ptr) {
Line 462... Line 462...
462
	int sock = ((struct pass_entry*)ptr)->sock;
462
	int sock = ((struct pass_entry*)ptr)->sock;
463
	bool ssl = ((struct pass_entry*)ptr)->ssl;
463
	bool ssl = ((struct pass_entry*)ptr)->ssl;
464
	int port = ((struct pass_entry*)ptr)->port;
464
	int port = ((struct pass_entry*)ptr)->port;
465
	SOCKADDR addr = ((struct pass_entry*)ptr)->addr;
465
	SOCKADDR addr = ((struct pass_entry*)ptr)->addr;
466
#else
466
#else
-
 
467
#define NO_RETURN_THREAD
467
	void tw_server_pass(int sock, bool ssl, int port, SOCKADDR addr) {
468
	void tw_server_pass(int sock, bool ssl, int port, SOCKADDR addr) {
468
#endif
469
#endif
469
	SSL* s = NULL;
470
	SSL* s = NULL;
470
#ifndef NO_SSL
471
#ifndef NO_SSL
471
	SSL_CTX* ctx = NULL;
472
	SSL_CTX* ctx = NULL;
Line 616... Line 617...
616
			char* slash;
617
			char* slash;
617
			cm_log("Server", "Document root is %s", vhost_entry->root == NULL ? "not set" : vhost_entry->root);
618
			cm_log("Server", "Document root is %s", vhost_entry->root == NULL ? "not set" : vhost_entry->root);
618
			path = cm_strcat(vhost_entry->root == NULL ? "" : vhost_entry->root, req.path);
619
			path = cm_strcat(vhost_entry->root == NULL ? "" : vhost_entry->root, req.path);
619
			cm_log("Server", "Filesystem path is %s", path);
620
			cm_log("Server", "Filesystem path is %s", path);
620
#if defined(_MSC_VER) || defined(__BORLANDC__)
621
#if defined(_MSC_VER) || defined(__BORLANDC__)
621
			for(i = strlen(path) - 1; i >= 0; i--){
622
			for(i = strlen(path) - 1; i >= 0; i--) {
622
				if(path[i] == '/'){
623
				if(path[i] == '/') {
623
					path[i] = 0;
624
					path[i] = 0;
624
				}else{
625
				} else {
625
					break;
626
					break;
626
				}
627
				}
627
			}
628
			}
628
#endif
629
#endif
629
#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__)
630
#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__)
Line 896... Line 897...
896
	}
897
	}
897
	SSL_free(s);
898
	SSL_free(s);
898
#endif
899
#endif
899
	close_socket(sock);
900
	close_socket(sock);
900
#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__)
901
#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__)
901
	_endthread(
902
	_endthread();
902
#ifndef __BORLANDC__
-
 
903
		0
-
 
904
#endif
-
 
905
	);
-
 
906
#elif defined(__HAIKU__)
903
#elif defined(__HAIKU__)
907
		exit_thread(0);
904
		exit_thread(0);
908
#endif
905
#endif
909
#ifndef __BORLANDC__
906
#ifndef NO_RETURN_THREAD
910
	return 0;
907
	return 0;
911
#endif
908
#endif
912
}
909
}
913
 
910
 
914
#ifdef SERVICE
911
#ifdef SERVICE