From 153fc54e7525240fc3d7c56ac251d32031494fbc Mon Sep 17 00:00:00 2001 From: Nishi Date: Mon, 23 Sep 2024 10:19:19 +0000 Subject: [PATCH] release 1.04 git-svn-id: file:///raid/svn-personal/tewi/trunk@128 8739d7e6-ffea-ec47-b151-bdff447c6205 --- Server/powered.gif => Binary/pbtewi.gif | Bin {Server => Binary}/tewi-install.ico | Bin {Server => Binary}/tewi.ico | Bin Makefile | 23 ++++++----- Server/Makefile | 2 +- Server/config.c | 10 +++++ Server/install.nsi | 5 ++- Server/tewi.rc | 2 +- Server/tw_config.h | 1 + Server/tw_version.h | 2 +- Tool/genconf.c | 49 ++++++++++++++++++++++++ {Server => Tool}/option.c | 0 config.h.tmpl | 2 + example-win.conf | 31 --------------- installer.sh | 9 +++++ itworks.html | 11 ------ 16 files changed, 91 insertions(+), 56 deletions(-) rename Server/powered.gif => Binary/pbtewi.gif (100%) rename {Server => Binary}/tewi-install.ico (100%) rename {Server => Binary}/tewi.ico (100%) create mode 100644 Tool/genconf.c rename {Server => Tool}/option.c (100%) delete mode 100644 example-win.conf delete mode 100644 itworks.html diff --git a/Server/powered.gif b/Binary/pbtewi.gif similarity index 100% rename from Server/powered.gif rename to Binary/pbtewi.gif diff --git a/Server/tewi-install.ico b/Binary/tewi-install.ico similarity index 100% rename from Server/tewi-install.ico rename to Binary/tewi-install.ico diff --git a/Server/tewi.ico b/Binary/tewi.ico similarity index 100% rename from Server/tewi.ico rename to Binary/tewi.ico diff --git a/Makefile b/Makefile index 1379f31..f026bba 100644 --- a/Makefile +++ b/Makefile @@ -10,13 +10,16 @@ FLAGS = PWD=$(PWD) PLATFORM=$(PLATFORM) PREFIX=$(PREFIX) .PHONY: all format clean ./Server ./Common ./Module ./Manpage get-version -all: ./Server ./Module ./Manpage +all: ./Server ./Module ./Manpage ./Tool/genconf ./Tool/itworks -./Server/option: ./Server/option.c - cc -o $@ ./Server/option.c +./Tool/option: ./Tool/option.c + cc -o $@ ./Tool/option.c -./Server:: ./Common ./Server/option - $(MAKE) -C $@ $(FLAGS) EXTOBJS="`./Server/option objs ../`" EXTLIBS="`./Server/option libs ../`" EXTCFLAGS="`./Server/option cflags ../`" EXTLDFLAGS="`./Server/option ldflags ../`" +./Tool/genconf: ./Tool/genconf.c + cc -o $@ ./Tool/genconf.c + +./Server:: ./Common ./Tool/option + $(MAKE) -C $@ $(FLAGS) EXTOBJS="`./Tool/option objs ../`" EXTLIBS="`./Tool/option libs ../`" EXTCFLAGS="`./Tool/option cflags ../`" EXTLDFLAGS="`./Tool/option ldflags ../`" ./Module:: ./Common $(MAKE) -C $@ $(FLAGS) @@ -27,9 +30,11 @@ all: ./Server ./Module ./Manpage ./Manpage:: $(MAKE) -C $@ $(FLAGS) -install: all - mkdir -p $(PREFIX)/bin $(PREFIX)/lib/tewi $(PREFIX)/share/man/man5 $(PREFIX)/etc - if [ ! -e $(PREFIX)/etc/tewi.conf ]; then cp example.conf $(PREFIX)/etc/tewi.conf ; fi +install: all ./Tool/genconf ./Tool/itworks + mkdir -p $(PREFIX)/bin $(PREFIX)/lib/tewi $(PREFIX)/share/man/man5 $(PREFIX)/etc $(PREFIX)/www + if [ ! -e $(PREFIX)/etc/tewi.conf ]; then ( ./Tool/genconf $(PREFIX) > $(PREFIX)/etc/tewi.conf || ( rm $(PREFIX)/etc/tewi.conf ; exit 1 ) ) ; fi + if [ ! -e $(PREFIX)/www/index.html ]; then ( ./Tool/itworks > $(PREFIX)/www/index.html || ( rm $(PREFIX)/www/index.html ; exit 1 ) ) ; fi + if [ ! -e $(PREFIX)/www/pbtewi.gif ]; then ( cp Binary/pbtewi.gif $(PREFIX)/www/ || ( rm $(PREFIX)/www/pbtewi.gif ; exit 1 ) ) ; fi cp ./Server/tewi $(PREFIX)/bin/ cp ./Module/*.so $(PREFIX)/lib/tewi/ cp ./Manpage/tewi.conf.5 $(PREFIX)/share/man/man5/ @@ -45,4 +50,4 @@ clean: $(MAKE) -C ./Module $(FLAGS) clean $(MAKE) -C ./Common $(FLAGS) clean $(MAKE) -C ./Manpage $(FLAGS) clean - rm -f ./Server/option + rm -f ./Tool/option ./Tool/genconf diff --git a/Server/Makefile b/Server/Makefile index 43b0e0e..be2ec17 100644 --- a/Server/Makefile +++ b/Server/Makefile @@ -15,7 +15,7 @@ tewi$(EXEC): $(OBJS) ../Common/common.a .c.o: $(CC) $(CFLAGS) $(EXTCFLAGS) -c -o $@ $< -tewi.res: tewi.rc tewi.ico +tewi.res: tewi.rc ../Binary/tewi.ico $(WINDRES) tewi.rc -O coff -o $@ clean: diff --git a/Server/config.c b/Server/config.c index 1eb7cb9..5fdf216 100644 --- a/Server/config.c +++ b/Server/config.c @@ -89,7 +89,9 @@ void tw_config_init(void) { config.module_count = 0; config.extension = NULL; config.server_root = cm_strdup(PREFIX); + config.server_admin = cm_strdup(SERVER_ADMIN); gethostname(config.hostname, 1024); + chdir(config.server_root); } int tw_config_read(const char* path) { @@ -247,6 +249,14 @@ int tw_config_read(const char* path) { free(config.server_root); config.server_root = cm_strdup(r[1]); } + } else if(cm_strcaseequ(r[0], "ServerAdmin")) { + if(r[1] == NULL) { + cm_log("Config", "Missing email at line %d", ln); + stop = 1; + } else { + free(config.server_admin); + config.server_admin = cm_strdup(r[1]); + } } else if(cm_strcaseequ(r[0], "DocumentRoot")) { if(r[1] == NULL) { cm_log("Config", "Missing path at line %d", ln); diff --git a/Server/install.nsi b/Server/install.nsi index dc6b82e..d98f24b 100644 --- a/Server/install.nsi +++ b/Server/install.nsi @@ -12,7 +12,7 @@ LoadLanguageFile "${NSISDIR}\Contrib\Language files\English.nlf" Name "Tewi HTTPd" OutFile "install.exe" InstallDir "C:\Tewi" -Icon "tewi-install.ico" +Icon "../Binary/tewi-install.ico" LicenseData ../LICENSE LangString EXEC_ONLY ${LANG_ENGLISH} "Install the executable only" @@ -42,9 +42,10 @@ Section File "../Module/*.dll" SetOutPath "$INSTDIR\etc" SetOverWrite off - File /oname=tewi.conf "../example-win.conf" + File /oname=tewi.conf "../generated.conf" SetOutPath "$INSTDIR\www" File /oname=index.html "../itworks.html" + File /oname=pbtewi.gif "../Binary/pbtewi.gif" SetOutPath "$INSTDIR\www\icons" File "../Icons/*.png" SetOverWrite on diff --git a/Server/tewi.rc b/Server/tewi.rc index 68b8ad7..4bb3108 100644 --- a/Server/tewi.rc +++ b/Server/tewi.rc @@ -2,7 +2,7 @@ #include "tw_version.h" #include "../config.h" -id ICON "./tewi.ico" +id ICON "../Binary/tewi.ico" VS_VERSION_INFO VERSIONINFO FILEVERSION 1,0,0,0 PRODUCTVERSION 1,0,0,0 diff --git a/Server/tw_config.h b/Server/tw_config.h index 1ba9826..e405419 100644 --- a/Server/tw_config.h +++ b/Server/tw_config.h @@ -81,6 +81,7 @@ struct tw_config { void* modules[MAX_MODULES]; int module_count; int vhost_count; + char* server_admin; char* server_root; char* extension; }; diff --git a/Server/tw_version.h b/Server/tw_version.h index e6d1335..2e64060 100644 --- a/Server/tw_version.h +++ b/Server/tw_version.h @@ -3,7 +3,7 @@ #ifndef __TW_VERSION_H__ #define __TW_VERSION_H__ -#define TW_VERSION "1.03A\0" +#define TW_VERSION "1.04\0" const char* tw_get_version(void); const char* tw_get_platform(void); diff --git a/Tool/genconf.c b/Tool/genconf.c new file mode 100644 index 0000000..6a9a9a6 --- /dev/null +++ b/Tool/genconf.c @@ -0,0 +1,49 @@ +/* $Id$ */ + +#include "../config.h" + +#include + +int main(int argc, char** argv){ + if(argc < 2){ + return 1; + } + printf("##\n"); + printf("## tewi.conf -- Tewi HTTPd configuration file\n"); + printf("##\n"); + printf("\n"); + printf("# This configuration file is auto-generated.\n"); + printf("\n"); + printf("ServerRoot %s\n", argv[1]); + printf("\n"); + printf("ServerAdmin %s\n", SERVER_ADMIN); + printf("\n"); + printf("LoadModule lib/tewi/mod_cgi.so\n"); + printf("#LoadModule lib/tewi/mod_proxy.so\n"); + printf("\n"); + printf("Listen 80\n"); + printf("#ListenSSL 443\n"); + printf("\n"); + printf("#SSLKey key.pem\n"); + printf("#SSLCertificate cert.pem\n"); + printf("\n"); + printf("MIMEType all application/octet-stream\n"); + printf("MIMEType .html text/html\n"); + printf("MIMEType .txt text/plain\n"); + printf("MIMEType .png image/png\n"); + printf("\n"); + printf("Icon all /icons/unknown.png\n"); + printf("Icon text/* /icons/text.png\n"); + printf("Icon image/* /icons/image.png\n"); + printf("Icon misc/dir /icons/folder.png\n"); + printf("Icon misc/parent /icons/parent.png\n"); + printf("DirectoryIndex index.html\n"); + printf("\n"); + printf("Readme README\n"); + printf("\n"); + printf("DocumentRoot %s/www\n", argv[1]); + printf("\n"); + printf("BeginDirectory %s/www\n", argv[1]); + printf("\tAllow all\n"); + printf("EndDirectory\n", argv[1]); +} diff --git a/Server/option.c b/Tool/option.c similarity index 100% rename from Server/option.c rename to Tool/option.c diff --git a/config.h.tmpl b/config.h.tmpl index c22dabc..86b8513 100644 --- a/config.h.tmpl +++ b/config.h.tmpl @@ -3,6 +3,8 @@ #ifndef __CONFIG_H__ #define __CONFIG_H__ +#define SERVER_ADMIN "webmaster@domain" + #undef NO_SSL #define USE_POLL diff --git a/example-win.conf b/example-win.conf deleted file mode 100644 index 490402a..0000000 --- a/example-win.conf +++ /dev/null @@ -1,31 +0,0 @@ -# $Id$ -# This is an example config - -ServerRoot C:/Tewi - -Listen 80 -#ListenSSL 443 - -#SSLKey key.pem -#SSLCertificate cert.pem - -MIMEType all application/octet-stream -MIMEType .html text/html -MIMEType .txt text/plain -MIMEType .png image/png - -Icon all /icons/unknown.png -Icon text/* /icons/text.png -Icon image/* /icons/image.png -Icon misc/dir /icons/folder.png -Icon misc/parent /icons/parent.png - -DirectoryIndex index.html - -Readme README - -DocumentRoot C:/Tewi/www - -BeginDirectory C:/Tewi/www - Allow all -EndDirectory diff --git a/installer.sh b/installer.sh index 1427a0d..dea0117 100755 --- a/installer.sh +++ b/installer.sh @@ -4,6 +4,8 @@ fail() { rm -f tewi-service.exe rm -f tewi.exe + rm -f generated.conf + rm -f itworks.html mv config.h.bak config.h exit 1 } @@ -21,6 +23,8 @@ make clean || fail make PLATFORM=$1-service -j4 || fail cp Server/tewi.exe tewi-service.exe cd Server +../Tool/genconf > ../generated.conf +../Tool/itworks > ../itworks.html makensis -DVERSION=$VERSION install.nsi cp install.exe ../install-nossl.exe rm -f tewi.exe tewi-service.exe @@ -35,7 +39,12 @@ make clean || fail make PLATFORM=$1-service -j4 || fail cp Server/tewi.exe tewi-service.exe cd Server +../Tool/genconf > ../generated.conf +../Tool/itworks > ../itworks.html makensis -DVERSION=$VERSION install.nsi cp install.exe ../install-ssl.exe rm -f tewi.exe tewi-service.exe cd .. + +rm itworks.html +rm generated.conf diff --git a/itworks.html b/itworks.html deleted file mode 100644 index 62a11d3..0000000 --- a/itworks.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - It Works - - -

It Works!

-
- Congratulations - If you can see this page, it means Tewi HTTPd has been configured successfully! - - -- 2.43.0