add ServerRoot

git-svn-id: file:///raid/svn-personal/tewi/trunk@61 8739d7e6-ffea-ec47-b151-bdff447c6205
This commit is contained in:
Nishi 2024-09-18 12:45:02 +00:00
parent b3622fefc5
commit 88f3bf7750
4 changed files with 48 additions and 32 deletions

View File

@ -232,6 +232,13 @@ int tw_config_read(const char* path) {
if(current->sslcert != NULL) free(current->sslcert);
current->sslcert = cm_strdup(r[1]);
}
} else if(cm_strcaseequ(r[0], "ServerRoot")) {
if(r[1] == NULL) {
cm_log("Config", "Missing path at line %d", ln);
stop = 1;
} else {
chdir(r[1]);
}
} else if(cm_strcaseequ(r[0], "DocumentRoot")) {
if(r[1] == NULL) {
cm_log("Config", "Missing path at line %d", ln);

View File

@ -13,17 +13,25 @@ Section
CreateDirectory "$INSTDIR\etc"
CreateDirectory "$INSTDIR\www"
CreateDirectory "$INSTDIR\www\icons"
CreateDirectory "$INSTDIR\modules"
CreateDirectory "$INSTDIR\bin"
SetOutPath "$INSTDIR"
File /oname=LICENSE.txt "../LICENSE"
SetOutPath "$INSTDIR\bin"
File "tewi.exe"
SetOutPath "$INSTDIR\modules"
File "../Module/*.dll"
SetOutPath "$INSTDIR\etc"
File /oname=tewi.conf.default "../example-win.conf"
SetOverWrite off
File /oname=tewi.conf "../example-win.conf"
SetOutPath "$INSTDIR\www"
File /oname=index.html "../itworks.html"
SetOutPath "$INSTDIR\www\icons"
File "../Icons/*.png"
SetOverWrite on
CreateDirectory "$SMPROGRAMS\Tewi HTTPd"
CreateShortcut "$SMPROGRAMS\Tewi HTTPd\License.lnk" "$INSTDIR\LICENSE.txt" ""
CreateShortcut "$SMPROGRAMS\Tewi HTTPd\Start Tewi HTTPd.lnk" "$INSTDIR\bin\tewi.exe" ""
CreateShortcut "$SMPROGRAMS\Tewi HTTPd\Start Tewi HTTPd (verbose).lnk" "$INSTDIR\bin\tewi.exe" "-v"
CreateShortcut "$SMPROGRAMS\Tewi HTTPd\Uninstall Tewi HTTPd.lnk" "$INSTDIR\uninstall.exe" ""
@ -32,8 +40,6 @@ Section
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Tewi HTTPd" "UninstallString" '"$INSTDIR\uninstall.exe"'
WriteUninstaller "$INSTDIR\uninstall.exe"
MessageBox MB_ICONEXCLAMATION|MB_OK "Example config is installed as $INSTDIR\etc\tewi.conf.default,$\r$\nBut Tewi HTTPd will try to use $INSTDIR\etc\tewi.conf."
SectionEnd
Section "Uninstall"

View File

@ -482,6 +482,7 @@ void tw_server_pass(int sock, bool ssl, int port, SOCKADDR addr) {
tw_http_error(s, sock, 403, name, port);
} else if(S_ISDIR(st.st_mode)) {
if(req.path[strlen(req.path) - 1] != '/') {
cm_log("Server", "Accessing directory without the slash at the end");
char* headers[3] = {"Location", cm_strcat(req.path, "/"), NULL};
_tw_process_page(s, sock, tw_http_status(308), NULL, NULL, NULL, 0, headers, 0, 0);
free(headers[1]);

View File

@ -1,6 +1,8 @@
# $Id$
# This is an example config
ServerRoot C:/Tewi
Listen 80
#ListenSSL 443