.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)
./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/
$(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
.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:
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) {
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);
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"
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
#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
void* modules[MAX_MODULES];
int module_count;
int vhost_count;
+ char* server_admin;
char* server_root;
char* extension;
};
#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);
--- /dev/null
+/* $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]);
+}
#ifndef __CONFIG_H__
#define __CONFIG_H__
+#define SERVER_ADMIN "webmaster@domain"
+
#undef NO_SSL
#define USE_POLL
+++ /dev/null
-# $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
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
}
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
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
+++ /dev/null
-<!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>