]> Git repositories of Nishi - tewi.git/commitdiff
release 1.04
authorNishi <nishi@nishi.boats>
Mon, 23 Sep 2024 10:19:19 +0000 (10:19 +0000)
committerNishi <nishi@nishi.boats>
Mon, 23 Sep 2024 10:19:19 +0000 (10:19 +0000)
git-svn-id: file:///raid/svn-personal/tewi/trunk@128 8739d7e6-ffea-ec47-b151-bdff447c6205

16 files changed:
Binary/pbtewi.gif [moved from Server/powered.gif with 100% similarity]
Binary/tewi-install.ico [moved from Server/tewi-install.ico with 100% similarity]
Binary/tewi.ico [moved from Server/tewi.ico with 100% similarity]
Makefile
Server/Makefile
Server/config.c
Server/install.nsi
Server/tewi.rc
Server/tw_config.h
Server/tw_version.h
Tool/genconf.c [new file with mode: 0644]
Tool/option.c [moved from Server/option.c with 100% similarity]
config.h.tmpl
example-win.conf [deleted file]
installer.sh
itworks.html [deleted file]

similarity index 100%
rename from Server/powered.gif
rename to Binary/pbtewi.gif
similarity index 100%
rename from Server/tewi.ico
rename to Binary/tewi.ico
index 1379f31f9b4ff0e784b4a1b215c106f4e646a1ad..f026bba3f66bf6eada96e0af41344c3821e11d18 100644 (file)
--- 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
index 43b0e0e61fb4602a55b589d161ce2a137a84c475..be2ec178cde6f1d336518433a287eed5ad4fccf0 100644 (file)
@@ -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:
index 1eb7cb9822e9ae0986cf848a32315825e8270a43..5fdf216a0c6b7d0b150eb33cb71d55851253bded 100644 (file)
@@ -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);
index dc6b82efe5382a0eae4fa07286ba11f8ebc561a8..d98f24b753bf1deaee076fc97604cb6055becec3 100644 (file)
@@ -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
index 68b8ad75a99c09d7b3be7689c5112b125e2523e6..4bb31087627e943853b86f712e1d4f4728f4d710 100644 (file)
@@ -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
index 1ba9826ccacc9c3a51c890c0c0f7db6cd9bb26a7..e405419dfadb19970c9dc2fcf43f0332f4f1b4ea 100644 (file)
@@ -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;
 };
index e6d133507e51520806ea542964fafa65604181a0..2e64060489896c58d6d21346546c2d0e0996e010 100644 (file)
@@ -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 (file)
index 0000000..6a9a9a6
--- /dev/null
@@ -0,0 +1,49 @@
+/* $Id$ */
+
+#include "../config.h"
+
+#include <stdio.h>
+
+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]);
+}
similarity index 100%
rename from Server/option.c
rename to Tool/option.c
index c22dabca7efdfd16824acc5b7d6f7855d7f037db..86b851373b76f2b578ade1d4295fefed40f71c1b 100644 (file)
@@ -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 (file)
index 490402a..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-# $Id$\r
-# This is an example config\r
-\r
-ServerRoot C:/Tewi\r
-\r
-Listen 80\r
-#ListenSSL 443\r
-\r
-#SSLKey key.pem\r
-#SSLCertificate cert.pem\r
-\r
-MIMEType all application/octet-stream\r
-MIMEType .html text/html\r
-MIMEType .txt text/plain\r
-MIMEType .png image/png\r
-\r
-Icon all /icons/unknown.png\r
-Icon text/* /icons/text.png\r
-Icon image/* /icons/image.png\r
-Icon misc/dir /icons/folder.png\r
-Icon misc/parent /icons/parent.png\r
-\r
-DirectoryIndex index.html\r
-\r
-Readme README\r
-\r
-DocumentRoot C:/Tewi/www\r
-\r
-BeginDirectory C:/Tewi/www\r
-       Allow all\r
-EndDirectory\r
index 1427a0dafc583bfb77a106711541d9436139e83f..dea0117cad644a0d8d129d2659e37e2ce1686866 100755 (executable)
@@ -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 (file)
index 62a11d3..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
-<html>
-       <head>
-               <title>It Works</title>
-       </head>
-       <body>
-               <h1>It Works!</h1>
-               <hr>
-               Congratulations - If you can see this page, it means Tewi HTTPd has been configured successfully!
-       </body>
-</html>