Changeset 43 in Main
- Timestamp:
- Sep 18, 2024, 6:19:03 PM (2 months ago)
- Location:
- trunk
- Files:
-
- 2 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Makefile
r37 r43 13 13 all: ./Server ./Module ./Manpage 14 14 15 ./Server:: ./Common 16 $(MAKE) -C $@ $(FLAGS) 15 ./Server/option: ./Server/option.c 16 cc -o $@ ./Server/option.c 17 18 ./Server:: ./Common ./Server/option 19 $(MAKE) -C $@ $(FLAGS) EXTOBJS=`./Server/option objs ../` EXTLIBS=`./Server/option libs ../` 17 20 18 21 ./Module:: ./Common … … 26 29 27 30 format: 28 clang-format --verbose -i `find ./Server ./Common ./Module "(" -name "*.c" -or -name "*.h" ")" -and -not -name "strptime.*"` 31 clang-format --verbose -i `find ./Server ./Common ./Module "(" -name "*.c" -or -name "*.h" ")" -and -not -name "strptime.*"` config.h 29 32 30 33 clean: … … 33 36 $(MAKE) -C ./Common $(FLAGS) clean 34 37 $(MAKE) -C ./Manpage $(FLAGS) clean 38 rm -f ./Server/option -
trunk/Platform/win32.mk
r42 r43 5 5 CC = i686-w64-mingw32-gcc 6 6 AR = i686-w64-mingw32-ar 7 CFLAGS = -g -std=c99 -DPREFIX=\"$(PREFIX)\" -I $(PWD)/Common - I $(PWD)/openssl/include -fPIC8 LDFLAGS = -L $(PWD)/openssl/lib327 CFLAGS = -g -std=c99 -DPREFIX=\"$(PREFIX)\" -I $(PWD)/Common -fPIC 8 LDFLAGS = 9 9 LIBS = -lws2_32 10 10 EXEC = .exe -
trunk/Platform/win64.mk
r42 r43 5 5 CC = x86_64-w64-mingw32-gcc 6 6 AR = x86_64-w64-mingw32-ar 7 CFLAGS = -g -std=c99 -DPREFIX=\"$(PREFIX)\" -I $(PWD)/Common - I $(PWD)/openssl/include -fPIC8 LDFLAGS = -L $(PWD)/openssl/lib647 CFLAGS = -g -std=c99 -DPREFIX=\"$(PREFIX)\" -I $(PWD)/Common -fPIC 8 LDFLAGS = 9 9 LIBS = -lws2_32 10 10 EXEC = .exe -
trunk/Server/Makefile
r32 r43 6 6 .SUFFIXES: .c .o 7 7 8 OBJS = version.o main.o config.o server.o ssl.o http.o module.o strptime.o8 OBJS = version.o main.o config.o server.o http.o module.o strptime.o $(EXTOBJS) 9 9 10 10 all: tewi$(EXEC) 11 11 12 12 tewi$(EXEC): $(OBJS) ../Common/common.a 13 $(CC) $(LDFLAGS) -o $@ $(OBJS) -lssl -lcrypto$(LIBS) ../Common/common.a13 $(CC) $(LDFLAGS) -o $@ $(OBJS) $(EXTLIBS) $(LIBS) ../Common/common.a 14 14 15 15 .c.o: -
trunk/Server/http.c
r23 r43 2 2 3 3 #define SOURCE 4 5 #include "../config.h" 4 6 5 7 #include "tw_http.h" … … 60 62 tv.tv_sec = 5; 61 63 tv.tv_usec = 0; 64 #ifndef NO_SSL 62 65 if(ssl == NULL || !SSL_has_pending(ssl)) { 66 #endif 63 67 int n = select(FD_SETSIZE, &fds, NULL, NULL, &tv); 64 68 if(n <= 0) { … … 67 71 return -1; 68 72 } 69 } 73 #ifndef NO_SSL 74 } 75 #endif 70 76 int len = tw_read(ssl, sock, buffer, 512); 71 77 if(len <= 0) break; -
trunk/Server/main.c
r36 r43 2 2 3 3 #define SOURCE 4 5 #include "../config.h" 4 6 5 7 #include <stdio.h> … … 8 10 #include <signal.h> 9 11 12 #ifndef NO_SSL 10 13 #include <openssl/opensslv.h> 14 #endif 11 15 12 16 #include <cm_log.h> … … 29 33 if(!cm_do_log) { 30 34 cm_do_log = true; 35 #ifndef NO_SSL 31 36 cm_log("", "This is Tewi HTTPd, version %s, using %s", tw_get_version(), OPENSSL_VERSION_TEXT); 37 #else 38 cm_log("", "This is Tewi HTTPd, version %s", tw_get_version()); 39 #endif 32 40 } else { 33 41 cm_do_log = true; -
trunk/Server/server.c
r33 r43 3 3 #define SOURCE 4 4 5 #include "../config.h" 6 5 7 #include "tw_server.h" 6 8 9 #ifndef NO_SSL 7 10 #include "tw_ssl.h" 11 #endif 12 8 13 #include "tw_config.h" 9 14 #include "tw_http.h" … … 15 20 #include <stdbool.h> 16 21 #include <stdarg.h> 22 #include <stdio.h> 23 #include <stdlib.h> 17 24 #include <sys/stat.h> 18 25 #include <time.h> … … 143 150 144 151 size_t tw_read(SSL* ssl, int s, void* data, size_t len) { 152 #ifndef NO_SSL 145 153 if(ssl == NULL) { 146 154 return recv(s, data, len, 0); … … 148 156 return SSL_read(ssl, data, len); 149 157 } 158 #else 159 return recv(s, data, len, 0); 160 #endif 150 161 } 151 162 152 163 size_t tw_write(SSL* ssl, int s, void* data, size_t len) { 164 #ifndef NO_SSL 153 165 if(ssl == NULL) { 154 166 return send(s, data, len, 0); … … 156 168 return SSL_write(ssl, data, len); 157 169 } 170 #else 171 return send(s, data, len, 0); 172 #endif 158 173 } 159 174 … … 389 404 char* name = config.hostname; 390 405 406 #ifndef NO_SSL 391 407 SSL_CTX* ctx = NULL; 392 408 SSL* s = NULL; … … 399 415 sslworks = true; 400 416 } 417 #else 418 void* s = NULL; 419 #endif 401 420 struct tw_http_request req; 402 421 struct tw_http_response res; … … 661 680 } 662 681 cleanup: 682 #ifndef NO_SSL 663 683 if(sslworks) { 664 684 SSL_shutdown(s); … … 666 686 SSL_free(s); 667 687 close_socket(sock); 688 #endif 668 689 #ifdef __MINGW32__ 669 690 _endthreadex(0); 670 691 #endif 692 ; 671 693 } 672 694 -
trunk/Server/tw_http.h
r32 r43 5 5 6 6 #include <stdbool.h> 7 8 #include "../config.h" 7 9 8 10 struct tw_http_request { … … 22 24 23 25 #ifdef SOURCE 26 #ifndef NO_SSL 24 27 #include <openssl/ssl.h> 28 #endif 25 29 void tw_free_request(struct tw_http_request* req); 30 #ifndef NO_SSL 26 31 int tw_http_parse(SSL* ssl, int sock, struct tw_http_request* req); 32 #else 33 int tw_http_parse(void* ssl, int sock, struct tw_http_request* req); 34 #endif 27 35 #endif 28 36 -
trunk/Server/tw_server.h
r16 r43 4 4 #define __TW_SERVER_H__ 5 5 6 #include "../config.h" 7 8 #include <stddef.h> 9 10 #ifndef NO_SSL 6 11 #include <openssl/ssl.h> 12 #endif 7 13 8 14 int tw_server_init(void); 9 15 void tw_server_loop(void); 16 17 #ifndef NO_SSL 10 18 size_t tw_read(SSL* ssl, int s, void* data, size_t len); 11 19 size_t tw_write(SSL* ssl, int s, void* data, size_t len); 20 #else 21 size_t tw_read(void* ssl, int s, void* data, size_t len); 22 size_t tw_write(void* ssl, int s, void* data, size_t len); 23 #endif 12 24 13 25 #endif
Note:
See TracChangeset
for help on using the changeset viewer.