]> Git repositories of Nishi - tewi.git/commitdiff
get listdir working [release 2.03E]
authorNishi <nishi@nishi.boats>
Fri, 4 Oct 2024 04:08:58 +0000 (04:08 +0000)
committerNishi <nishi@nishi.boats>
Fri, 4 Oct 2024 04:08:58 +0000 (04:08 +0000)
git-svn-id: file:///raid/svn-personal/tewi/trunk@255 8739d7e6-ffea-ec47-b151-bdff447c6205

19 files changed:
Common/Makefile
Common/dir.c
Module/Makefile
Platform/bcc.mk
Platform/vc6.mk
Platform/win32.mk
Platform/win64.mk
README
README.tmpl
Server/Makefile
Server/config.c
Server/gui.c
Server/gui.h
Server/main.c
Server/server.c
Server/tw_version.h
Tool/option.c
config.h.tmpl
make-installer.sh

index a6e676f8d10740ee794105b070db433e06e0d091..bcc121c34e7010a80baf1a7197585ff40adecd39 100644 (file)
@@ -14,9 +14,11 @@ OBJS = string.$(OBJ) log.$(OBJ) dir.$(OBJ)
 all: common.$(STATIC)
 
 common.a: $(OBJS)
+       rm -f common.a
        $(AR) rcs $@ `echo $(OBJS) | $(AR_PROC)`
 
 common.lib: $(OBJS)
+       rm -f common.lib
        $(AR) $(AR_FLAGS)$@ `echo $(OBJS) | $(AR_PROC)`
 
 .c.$(OBJ):
index 8ba4772838ff08cd6510ba7c2b22c9d8ed6f2120..9f8e4e167fb6823871f00513006cd1076f759bcf 100644 (file)
@@ -21,7 +21,48 @@ int cm_sort(const void* _a, const void* _b) {
 
 char** cm_scandir(const char* path) {
 #if defined(_MSC_VER) || defined(__BORLANDC__)
-       return NULL;
+       WIN32_FIND_DATA ffd;
+       HANDLE hfind;
+       char** r = malloc(sizeof(*r));
+       int len;
+       char** old;
+       int i;
+       char* p;
+       r[0] = NULL;
+
+       p = cm_strcat(path, "/*");
+       hfind = FindFirstFile(p, &ffd);
+       if(INVALID_HANDLE_VALUE == hfind) {
+               return NULL;
+       }
+       do {
+               if(strcmp(ffd.cFileName, ".") != 0 && strcmp(ffd.cFileName, "..") != 0) {
+               old = r;
+               for(i = 0; old[i] != NULL; i++)
+                       ;
+               r = malloc(sizeof(*r) * (i + 2));
+               for(i = 0; old[i] != NULL; i++) r[i] = old[i];
+               r[i] = cm_strcat(ffd.cFileName, (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? "/" : "");
+               r[i + 1] = NULL;
+               free(old);
+               }
+       } while(FindNextFile(hfind, &ffd) != 0);
+       FindClose(hfind);
+       free(p);
+       for(len = 0; r[len] != NULL; len++)
+               ;
+       qsort(r, len, sizeof(char*), cm_sort);
+
+       old = r;
+       for(i = 0; old[i] != NULL; i++)
+               ;
+       r = malloc(sizeof(*r) * (i + 2));
+       for(i = 0; old[i] != NULL; i++) r[i + 1] = old[i];
+       r[0] = cm_strdup("../");
+       r[i + 1] = NULL;
+       free(old);
+
+       return r;
 #else
        DIR* dir = opendir(path);
        if(dir != NULL) {
index 3f8cde78e2f63bf383ff7a4a4013f3a7b90603f4..1097623a34076f2ab4ea4e36f8fb2be086f47384 100644 (file)
@@ -17,4 +17,4 @@ all: mod_cgi$(LIBSUF) mod_proxy$(LIBSUF)
        $(CC) $(CFLAGS) -I ../Server -c -o $@ $<
 
 clean:
-       rm -f *.o *.so *.a *.dll
+       rm -f *.o *.so *.a *.dll *.tds
index ed96a23272d1069cc2cdac3d0a41c40a9fe3ff90..8e4373f82204f5cc7d9c0fedd39de6cc814b4728 100644 (file)
@@ -10,8 +10,8 @@ AR_PROC = grep -Eo "[^ ]+" | xargs -I {} echo + {}
 CFLAGS = -g -std=c99 -DPREFIX=\"$(PREFIX)\" -I ../Common -fPIC
 LDFLAGS =
 LIBS =
-EXEC =
+EXEC = .exe
 STATIC = lib
 LIBSUF = .dll
 OBJ = obj
-REQOBJS = tewi_bcc.res gui_bcc.res
+REQOBJS = gui_bcc.res
index e6cb67523c063b69545561915557f6dedf7c18a7..b7a6be185949035b7679617dbbff9981e063c9c9 100644 (file)
@@ -9,7 +9,7 @@ AR_FLAGS = /nologo /out:
 CFLAGS = -g -std=c99 -DPREFIX=\"$(PREFIX)\" -I ../Common -fPIC
 LDFLAGS =
 LIBS = -ladvapi32 -llibcmt
-EXEC =
+EXEC = .exe
 STATIC = lib
 LIBSUF = .dll
 OBJ = obj
index 72930211cb77cbd2e42330a168be6d0d6c4ab19c..033c631fc30ff82795897de83236c6d7d548a799 100644 (file)
@@ -11,4 +11,4 @@ LDFLAGS =
 LIBS =
 EXEC = .exe
 LIBSUF = .dll
-PREOBJS = tewi.res gui.res
+PREOBJS = gui.res
index 4976bb9c85097851cb97b6f31479ab2204c41713..ad566792c50752608071cddfcd794dce1c496459 100644 (file)
@@ -11,4 +11,4 @@ LDFLAGS =
 LIBS = 
 EXEC = .exe
 LIBSUF = .dll
-PREOBJS = tewi.res gui.res
+PREOBJS = gui.res
diff --git a/README b/README
index f58444fbd6a3ad0456861ee459cab1e38a7f61c9..38c22925613decee66aead407d72d8b35a5e2feb 100644 (file)
--- a/README
+++ b/README
@@ -37,8 +37,6 @@ Currently, these platforms are supported:
 
 Windows 9x               Working if I compile it using Borland C++ 5.x
                          or Visual C++ 6.0/Open Watcom 2.0
-                         TODO: Get directory listing working on
-                                       Borland/VC++
 Windows NT 4.0/later     Working on NT 4.0 SP6a
 Linux                    Working on Debian GNU/Linux 12 (x86_64)
 NetBSD                   Working on NetBSD/amd64 10.0
index ca7bf1f839a5475b5b442cbfc2d7843c49a9710c..338c2f344ce4557d9b2ec34421b5894d89d85416 100644 (file)
@@ -37,8 +37,6 @@ Currently, these platforms are supported:
 
 Windows 9x               Working if I compile it using Borland C++ 5.x
                          or Visual C++ 6.0/Open Watcom 2.0
-                         TODO: Get directory listing working on
-                                       Borland/VC++
 Windows NT 4.0/later     Working on NT 4.0 SP6a
 Linux                    Working on Debian GNU/Linux 12 (x86_64)
 NetBSD                   Working on NetBSD/amd64 10.0
index d408c01542ea0aa9dd1f15f5f94ff622530faabd..f9876081ff0d4ee18da496cb74ccf857f0d142bf 100644 (file)
@@ -45,13 +45,7 @@ tewi.pkg: tewi.self
 .c.$(OBJ):
        $(CC) $(CFLAGS) $(EXTCFLAGS) -c -o $@ $<
 
-tewi.res: concat.rc ../Binary/tewi.ico
-       $(WINDRES) concat.rc -O coff -o $@
-
-tewi_bcc.res: concat.rc ../Binary/tewi.ico
-       brc32 -r -fo$@ concat.rc
-
-gui.res: concat.rc gui.h
+gui.res: concat.rc ../Binary/tewi.ico
        $(WINDRES) concat.rc -O coff -o $@
 
 gui_bcc.res: concat.rc gui.h
@@ -65,4 +59,4 @@ concat.rc: tewi.rc gui.rc
        cat tewi.rc gui.rc > concat.rc
 
 clean:
-       rm -f *.o tewi *.exe *.res *.elf *.sfo *.pbp *.self *.pkg *.obj concat.rc
+       rm -f *.o tewi *.exe *.res *.elf *.sfo *.pbp *.self *.pkg *.obj concat.rc *.tds
index bedda4ec10ed5abd82ed5d9ca186c5cec7fb8fc7..c9f12f206e1c94b8dadc10dcf417b7724910f0a8 100644 (file)
@@ -488,10 +488,11 @@ int tw_config_read(const char* path) {
                }
                free(line);
                fclose(f);
-               for(portcount = 0; config.ports[portcount] != -1; portcount++);
-               if(portcount == 0){
+               for(portcount = 0; config.ports[portcount] != -1; portcount++)
+                       ;
+               if(portcount == 0) {
                        return 1;
-               }else{
+               } else {
                        return stop;
                }
        } else {
index ba7d575717fab2a50427b9fab5250a6424c69a6d..bef8ce358feb82a92a9c00d4c37d0f75982a3f0e 100644 (file)
@@ -18,6 +18,8 @@ HWND logarea;
 HWND button_start;
 HWND button_stop;
 HWND button_about;
+HWND button_reset;
+HWND button_exit;
 HWND status;
 HFONT monospace;
 BOOL tewi_alive;
@@ -32,28 +34,26 @@ extern int running;
 
 int startup(int argc, char** argv);
 
-void ShowBitmapSize(HWND hWnd, HDC hdc, const char* name, int x, int y, int w, int h){
+void ShowBitmapSize(HWND hWnd, HDC hdc, const char* name, int x, int y, int w, int h) {
        HBITMAP hBitmap = LoadBitmap(hInst, name);
        BITMAP bmp;
        HDC hmdc;
        GetObject(hBitmap, sizeof(bmp), &bmp);
        hmdc = CreateCompatibleDC(hdc);
        SelectObject(hmdc, hBitmap);
-       if(w == 0 && h == 0){
+       if(w == 0 && h == 0) {
                StretchBlt(hdc, x, y, bmp.bmWidth, bmp.bmHeight, hmdc, 0, 0, bmp.bmWidth, bmp.bmHeight, SRCCOPY);
-       }else{
+       } else {
                StretchBlt(hdc, x, y, w, h, hmdc, 0, 0, bmp.bmWidth, bmp.bmHeight, SRCCOPY);
        }
        DeleteDC(hmdc);
        DeleteObject(hBitmap);
 }
 
-void ShowBitmap(HWND hWnd, HDC hdc, const char* name, int x, int y){
-       ShowBitmapSize(hWnd, hdc, name, x, y, 0, 0);
-}
+void ShowBitmap(HWND hWnd, HDC hdc, const char* name, int x, int y) { ShowBitmapSize(hWnd, hdc, name, x, y, 0, 0); }
 
 int max = 0;
-void AddLog(const char* str){
+void AddLog(const char* str) {
        HDC hdc;
        PAINTSTRUCT ps;
        SIZE sz;
@@ -64,17 +64,17 @@ void AddLog(const char* str){
        SelectObject(hdc, monospace);
        GetTextExtentPoint32(hdc, str, strlen(str), &sz);
        DeleteDC(hdc);
-       
-       if(max < sz.cx){
+
+       if(max < sz.cx) {
                max = sz.cx;
                SendMessage(logarea, LB_SETHORIZONTALEXTENT, max, 0);
        }
 }
 
-LRESULT CALLBACK VersionDialog(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp){
-       if(msg == WM_COMMAND){
+LRESULT CALLBACK VersionDialog(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) {
+       if(msg == WM_COMMAND) {
                if(LOWORD(wp) == IDOK) EndDialog(hWnd, IDOK);
-       }else if(msg == WM_PAINT){
+       } else if(msg == WM_PAINT) {
                HDC hdc;
                PAINTSTRUCT ps;
                RECT size;
@@ -86,23 +86,23 @@ LRESULT CALLBACK VersionDialog(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp){
                hdc = BeginPaint(hWnd, &ps);
                ShowBitmapSize(hWnd, hdc, "TEWILOGO", size.left, size.top, WINWIDTH(size), WINWIDTH(size));
                EndPaint(hWnd, &ps);
-       }else if(msg == WM_CTLCOLORDLG || msg == WM_CTLCOLORSTATIC){
+       } else if(msg == WM_CTLCOLORDLG || msg == WM_CTLCOLORSTATIC) {
                HDC dc = (HDC)wp;
                SetBkMode(dc, TRANSPARENT);
                return (LRESULT)GetSysColorBrush(COLOR_MENU);
-       }else{
+       } else {
                return FALSE;
        }
        return TRUE;
 }
 
-void tewi_thread(void* ptr){
+void tewi_thread(void* ptr) {
        int st = startup(0, NULL);
        was_starting = TRUE;
-       if(st == -1){
+       if(st == -1) {
                tewi_alive = TRUE;
                idle = FALSE;
-       }else{
+       } else {
                cm_force_log("Config error");
                idle = FALSE;
                _endthread();
@@ -115,54 +115,60 @@ void tewi_thread(void* ptr){
        _endthread();
 }
 
-void StartTewi(void){
+void StartTewi(void) {
        EnableWindow(button_start, FALSE);
        EnableWindow(button_stop, FALSE);
        _beginthread(tewi_thread, 0, NULL);
 }
 
-void StopTewi(void){
+void StopTewi(void) {
        EnableWindow(button_start, FALSE);
        EnableWindow(button_stop, FALSE);
        running = 0;
 }
 
-LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp){
-       if(msg == WM_COMMAND){
+LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) {
+       if(msg == WM_COMMAND) {
                int trig = LOWORD(wp);
                int ev = HIWORD(wp);
-               if(trig == GUI_BUTTON_ABOUT){
-                       if(ev == BN_CLICKED){
+               if(trig == GUI_BUTTON_ABOUT) {
+                       if(ev == BN_CLICKED) {
                                DialogBox(hInst, "VERSIONDLG", hWnd, (DLGPROC)VersionDialog);
                        }
-               }else if(trig == GUI_BUTTON_START){
-                       if(ev == BN_CLICKED){
-                               SendMessage(status, SB_SETTEXT, 0, (LPARAM)"Starting Tewi HTTPd");
+               } else if(trig == GUI_BUTTON_START) {
+                       if(ev == BN_CLICKED) {
+                               SendMessage(status, SB_SETTEXT, 0, (LPARAM) "Starting Tewi HTTPd");
                                StartTewi();
                        }
-               }else if(trig == GUI_BUTTON_STOP){
-                       if(ev == BN_CLICKED){
-                               SendMessage(status, SB_SETTEXT, 0, (LPARAM)"Stopping Tewi HTTPd");
+               } else if(trig == GUI_BUTTON_STOP) {
+                       if(ev == BN_CLICKED) {
+                               SendMessage(status, SB_SETTEXT, 0, (LPARAM) "Stopping Tewi HTTPd");
                                StopTewi();
                        }
-               }else if(trig == GUI_BUTTON_EXIT){
-                       if(ev == BN_CLICKED){
-                               if(tewi_alive){
-                                       SendMessage(status, SB_SETTEXT, 0, (LPARAM)"Stopping Tewi HTTPd");
+               } else if(trig == GUI_BUTTON_RESET) {
+                       if(ev == BN_CLICKED) {
+                               SendMessage(logarea, LB_RESETCONTENT, 0, 0);
+                               max = 0;
+                               SendMessage(logarea, LB_SETHORIZONTALEXTENT, max, 0);
+                       }
+               } else if(trig == GUI_BUTTON_EXIT) {
+                       if(ev == BN_CLICKED) {
+                               if(tewi_alive) {
+                                       SendMessage(status, SB_SETTEXT, 0, (LPARAM) "Stopping Tewi HTTPd");
                                        StopTewi();
                                        exiting = TRUE;
-                               }else{
+                               } else {
                                        SendMessage(hWnd, WM_CLOSE, 0, 0);
                                }
                        }
-               }else if(trig == GUI_LOG){
+               } else if(trig == GUI_LOG) {
                }
-       }else if(msg == WM_CLOSE){
+       } else if(msg == WM_CLOSE) {
                DestroyWindow(hWnd);
-       }else if(msg == WM_DESTROY){
+       } else if(msg == WM_DESTROY) {
                DeleteObject(pbtewi_brush);
                PostQuitMessage(0);
-       }else if(msg == WM_CREATE){
+       } else if(msg == WM_CREATE) {
                RECT rc, src;
                GetClientRect(hWnd, &rc);
 
@@ -172,45 +178,46 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp){
 
                status = CreateStatusWindow(WS_CHILD | WS_VISIBLE | CCS_BOTTOM, NULL, hWnd, GUI_STATUS);
                SendMessage(status, SB_SIMPLE, 0, 0);
-               SendMessage(status, SB_SETTEXT, 0, (LPARAM)"Welcome to Tewi HTTPd");
+               SendMessage(status, SB_SETTEXT, 0, (LPARAM) "Welcome to Tewi HTTPd");
                SendMessage(status, SB_GETRECT, 0, (LPARAM)&src);
 
                pbtewi_brush = CreateSolidBrush(RGB(0xf7, 0xc9, 0xf3));
                button_start = CreateWindow("BUTTON", "&Start", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, WINWIDTH(rc) - 100, 20 * 0, 100, 20, hWnd, (HMENU)GUI_BUTTON_START, hInst, NULL);
                button_stop = CreateWindow("BUTTON", "S&top", WS_CHILD | WS_VISIBLE | WS_DISABLED | BS_PUSHBUTTON, WINWIDTH(rc) - 100, 20 * 1, 100, 20, hWnd, (HMENU)GUI_BUTTON_STOP, hInst, NULL);
                button_about = CreateWindow("BUTTON", "&About", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, WINWIDTH(rc) - 100, 20 * 2, 100, 20, hWnd, (HMENU)GUI_BUTTON_ABOUT, hInst, NULL);
-               button_about = CreateWindow("BUTTON", "E&xit", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, WINWIDTH(rc) - 100, WINHEIGHT(rc) - WINHEIGHT(src) - 20, 100, 20, hWnd, (HMENU)GUI_BUTTON_EXIT, hInst, NULL);
+               button_reset = CreateWindow("BUTTON", "&Reset", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, WINWIDTH(rc) - 100, WINHEIGHT(rc) - WINHEIGHT(src) - 20 - 20, 100, 20, hWnd, (HMENU)GUI_BUTTON_RESET, hInst, NULL);
+               button_exit = CreateWindow("BUTTON", "E&xit", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, WINWIDTH(rc) - 100, WINHEIGHT(rc) - WINHEIGHT(src) - 20, 100, 20, hWnd, (HMENU)GUI_BUTTON_EXIT, hInst, NULL);
                logarea = CreateWindow("LISTBOX", NULL, WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL | LBS_NOINTEGRALHEIGHT | LBS_NOSEL, 0, 40, WINWIDTH(rc) - 100, WINHEIGHT(rc) - 40 - WINHEIGHT(src), hWnd, (HMENU)GUI_LOG, hInst, NULL);
 
                SendMessage(logarea, WM_SETFONT, (WPARAM)monospace, TRUE);
 
                SetTimer(hWnd, TIMER_WATCH_TEWI, 100, NULL);
-       }else if(msg == WM_TIMER){
-               if(wp == TIMER_WATCH_TEWI){
-                       if(idle){
-                       }else if(tewi_alive){
-                               if(was_starting){
+       } else if(msg == WM_TIMER) {
+               if(wp == TIMER_WATCH_TEWI) {
+                       if(idle) {
+                       } else if(tewi_alive) {
+                               if(was_starting) {
                                        was_starting = FALSE;
-                                       SendMessage(status, SB_SETTEXT, 0, (LPARAM)"Started Tewi HTTPd");
+                                       SendMessage(status, SB_SETTEXT, 0, (LPARAM) "Started Tewi HTTPd");
                                }
                                EnableWindow(button_start, FALSE);
                                EnableWindow(button_stop, TRUE);
                                idle = TRUE;
-                       }else{
-                               if(was_starting){
+                       } else {
+                               if(was_starting) {
                                        was_starting = FALSE;
-                                       SendMessage(status, SB_SETTEXT, 0, (LPARAM)"Stopped Tewi HTTPd");
+                                       SendMessage(status, SB_SETTEXT, 0, (LPARAM) "Stopped Tewi HTTPd");
                                }
                                EnableWindow(button_start, TRUE);
                                EnableWindow(button_stop, FALSE);
-                               if(exiting){
+                               if(exiting) {
                                        KillTimer(hWnd, TIMER_WATCH_TEWI);
                                        SendMessage(hWnd, WM_CLOSE, 0, 0);
                                }
                                idle = TRUE;
                        }
                }
-       }else if(msg == WM_PAINT){
+       } else if(msg == WM_PAINT) {
                HDC hdc;
                PAINTSTRUCT ps;
                RECT rc;
@@ -222,13 +229,13 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp){
                FillRect(hdc, &fill, pbtewi_brush);
                ShowBitmap(hWnd, hdc, "PBTEWI", 0, 0);
                EndPaint(hWnd, &ps);
-       }else{
+       } else {
                return DefWindowProc(hWnd, msg, wp, lp);
        }
        return 0;
 }
 
-BOOL InitApp(void){
+BOOL InitApp(void) {
        WNDCLASSEX wc;
        wc.cbSize = sizeof(WNDCLASSEX);
        wc.style = CS_HREDRAW | CS_VREDRAW;
@@ -245,14 +252,14 @@ BOOL InitApp(void){
        return RegisterClassEx(&wc);
 }
 
-BOOL InitWindow(int nCmdShow){
+BOOL InitWindow(int nCmdShow) {
        HWND hWnd;
        RECT deskrc, rc;
        HWND hDeskWnd = GetDesktopWindow();
        GetWindowRect(hDeskWnd, &deskrc);
        hWnd = CreateWindow("tewihttpd", "Tewi HTTPd", (WS_OVERLAPPEDWINDOW ^ WS_THICKFRAME) ^ WS_MAXIMIZEBOX, 0, 0, 600, 400, NULL, 0, hInst, NULL);
 
-       if(!hWnd){
+       if(!hWnd) {
                return FALSE;
        }
        GetWindowRect(hWnd, &rc);
@@ -262,7 +269,7 @@ BOOL InitWindow(int nCmdShow){
        return TRUE;
 }
 
-int WINAPI WinMain(HINSTANCE hCurInst, HINSTANCE hPrevInst, LPSTR lpsCmdLine, int nCmdShow){
+int WINAPI WinMain(HINSTANCE hCurInst, HINSTANCE hPrevInst, LPSTR lpsCmdLine, int nCmdShow) {
        MSG msg;
        BOOL bret;
        hInst = hCurInst;
@@ -271,14 +278,14 @@ int WINAPI WinMain(HINSTANCE hCurInst, HINSTANCE hPrevInst, LPSTR lpsCmdLine, in
        exiting = FALSE;
        idle = TRUE;
        logfile = stderr;
-       if(!InitApp()){
+       if(!InitApp()) {
                return FALSE;
        }
-       if(!InitWindow(nCmdShow)){
+       if(!InitWindow(nCmdShow)) {
                return FALSE;
        }
 
-       while((bret = GetMessage(&msg, NULL, 0, 0)) != 0){
+       while((bret = GetMessage(&msg, NULL, 0, 0)) != 0) {
                if(bret == -1) {
                        break;
                } else {
index faf16078ebcec806d66331a25525622e86404149..67dec70c91a9ac00b377f85a0fea84c84eccd188 100644 (file)
@@ -14,6 +14,7 @@
 #define GUI_TEWI_DATE 108
 #define GUI_LOG 109
 #define GUI_BUTTON_EXIT 104
+#define GUI_BUTTON_RESET 105
 
 #define TIMER_WATCH_TEWI 1000
 
index 6ccd60fdb9e4779e268b324ff0edbec94e4b77f4..a92037a92d7730bd417a884b28822079aa438c25 100644 (file)
@@ -6,8 +6,6 @@
 
 #ifdef __BORLANDC__
 
-#pragma resource "tewi_bcc.res"
-
 #pragma resource "gui_bcc.res"
 
 #endif
index ef24441678bd7a59fe8232ab956ce12c36b506e0..4187a40b4ce41f2464bb483cf8b32328e9a246cf 100644 (file)
@@ -33,7 +33,7 @@
 #include <cm_dir.h>
 
 #if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__)
-#ifndef NO_GETADDRINFO
+#ifndef NO_GETNAMEINFO
 #include <ws2tcpip.h>
 #include <wspiapi.h>
 #endif
@@ -63,7 +63,7 @@ typedef int socklen_t;
 #ifndef __PPU__
 #include <netinet/tcp.h>
 #endif
-#ifndef NO_GETADDRINFO
+#ifndef NO_GETNAMEINFO
 #include <netdb.h>
 #endif
 #endif
@@ -77,7 +77,7 @@ typedef int socklen_t;
 #endif
 
 #ifndef S_ISDIR
-#define S_ISDIR(x) ((x) & _S_IFDIR)
+#define S_ISDIR(x) ((x)&_S_IFDIR)
 #endif
 
 extern struct tw_config config;
@@ -493,11 +493,14 @@ int tw_server_pass(void* ptr) {
        struct tw_http_request req;
        struct tw_http_response res;
        struct tw_tool tools;
-#ifndef NO_GETADDRINFO
+       char* addrstr;
+#ifndef NO_GETNAMEINFO
        struct sockaddr* sa = (struct sockaddr*)&addr;
        getnameinfo(sa, sizeof(addr), address, 512, NULL, 0, NI_NUMERICHOST);
 #endif
-       address[0] = 0;
+       addrstr = inet_ntoa(addr.sin_addr);
+       strcpy(address, addrstr);
+       address[strlen(addrstr)] = 0;
 #ifdef FREE_PTR
        free(ptr);
 #endif
@@ -1049,7 +1052,7 @@ void tw_server_loop(void) {
                        }
                }
        }
-       for(i = 0; i < sockcount; i++){
+       for(i = 0; i < sockcount; i++) {
                close_socket(sockets[i]);
        }
        cm_force_log("Server is down");
index cff9e077d0a70ccaa2fd28635ca0ffc24f62a344..00e38067307921027da09e6f48beca7fdc0abe3f 100644 (file)
@@ -7,8 +7,8 @@
 extern "C" {
 #endif
 
-#define TW_VERSION "2.03D\0"
-#define TW_VERSION_TEXT "Tewi HTTPd version 2.03D"
+#define TW_VERSION "2.03E\0"
+#define TW_VERSION_TEXT "Tewi HTTPd version 2.03E"
 
 const char* tw_get_version(void);
 const char* tw_get_platform(void);
index 360be8190eef895198cb86b90401c39af7a3a1b1..608003046417f5bcf4052dcd53d291aa7450e5ea 100644 (file)
@@ -15,9 +15,9 @@ int main(int argc, char** argv) {
                printf("-I %s/openssl/include", argv[2]);
 #endif
 #ifdef BUILD_GUI
-               if(strcmp(argv[3], "WINDOWS_WATCOM") == 0){
+               if(strcmp(argv[3], "WINDOWS_WATCOM") == 0) {
                        printf(" -b nt_win");
-               }else if(strcmp(argv[3], "WINDOWS") == 0){
+               } else if(strcmp(argv[3], "WINDOWS") == 0) {
                        printf(" -mwindows");
                }
 #endif
@@ -26,9 +26,9 @@ int main(int argc, char** argv) {
                printf("-L %s/openssl/lib", argv[2]);
 #endif
 #ifdef BUILD_GUI
-               if(strcmp(argv[3], "WINDOWS_WATCOM") == 0){
+               if(strcmp(argv[3], "WINDOWS_WATCOM") == 0) {
                        printf(" -b nt_win");
-               }else if(strcmp(argv[3], "WINDOWS") == 0){
+               } else if(strcmp(argv[3], "WINDOWS") == 0) {
                        printf(" -mwindows");
                }
 #endif
@@ -37,7 +37,7 @@ int main(int argc, char** argv) {
                printf("ssl.%s", argv[4]);
 #endif
 #ifdef BUILD_GUI
-               if(strcmp(argv[3], "WINDOWS") == 0 || strcmp(argv[3], "WINDOWS_WATCOM") == 0){
+               if(strcmp(argv[3], "WINDOWS") == 0 || strcmp(argv[3], "WINDOWS_WATCOM") == 0) {
                        printf(" gui.%s", argv[4]);
                }
 #endif
@@ -45,7 +45,7 @@ int main(int argc, char** argv) {
 #ifndef NO_SSL
                printf("-lssl -lcrypto");
 #endif
-               if(strcmp(argv[3], "WINDOWS") == 0){
+               if(strcmp(argv[3], "WINDOWS") == 0) {
 #ifdef USE_WINSOCK1
                        printf(" -lwsock32");
 #else
@@ -55,7 +55,7 @@ int main(int argc, char** argv) {
                        printf(" -lcomctl32");
                        printf(" -luser32");
 #endif
-               }else if(strcmp(argv[3], "WINDOWS_WATCOM") == 0){
+               } else if(strcmp(argv[3], "WINDOWS_WATCOM") == 0) {
 #ifdef USE_WINSOCK1
                        printf(" wsock32.lib");
 #else
index 4863f9e86f17a64a3780e8db5bb91e9c47abd759..4eb893f5a27f765274c2fb560e5730748633a33e 100644 (file)
@@ -9,7 +9,7 @@
 #undef NO_SSL
 #define USE_POLL
 #define HAS_CHROOT
-#undef NO_GETADDRINFO
+#undef NO_GETNAMEINFO
 #undef USE_WINSOCK1
 #undef BUILD_GUI
 
@@ -28,9 +28,9 @@
 /* Force select(2) for Windows */
 #endif
 
-#if (defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__)) && defined(USE_WINSOCK1) && !defined(NO_GETADDRINFO)
-#define NO_GETADDRINFO
-/* getaddrinfo is not on winsock 1 */
+#if (defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__)) && defined(USE_WINSOCK1) && !defined(NO_GETNAMEINFO)
+#define NO_GETNAMEINFO
+/* getnameinfo is not on winsock 1 */
 #endif
 
 #if (defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__)) && defined(HAS_CHROOT)
@@ -38,9 +38,9 @@
 /* Windows should not have chroot */
 #endif
 
-#if (defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__)) && !defined(NO_GETADDRINFO)
-#define NO_GETADDRINFO
-/* Do not use getaddrinfo */
+#if (defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__)) && !defined(NO_GETNAMEINFO)
+#define NO_GETNAMEINFO
+/* Do not use getnameinfo */
 #endif
 
 #if (defined(_PSP) || defined(__PPU__) || defined(__ps2sdk__)) && !defined(NO_IPV6)
@@ -58,9 +58,9 @@
 /* PSP/PS2/PS3 should not have chroot */
 #endif
 
-#if (defined(_PSP) || defined(__PPU__) || defined(__ps2sdk__)) && !defined(NO_GETADDRINFO)
-#define NO_GETADDRINFO
-/* PSP/PS2/PS3 should not have getaddrinfo */
+#if (defined(_PSP) || defined(__PPU__) || defined(__ps2sdk__)) && !defined(NO_GETNAMEINFO)
+#define NO_GETNAMEINFO
+/* PSP/PS2/PS3 should not have getnameinfo */
 #endif
 
 #endif
index c611712719bd5d96f031f7958b9f29c70f52e3d5..59f68b227520fb6eab8855323803131e02797937 100755 (executable)
@@ -26,6 +26,11 @@ cd Server
 makensis -DVERSION=$VERSION -DONLY_EXEC install.nsi
 cp install.exe ../install.exe
 cd ..
+rm -rf Tewi tewi.7z
+7z x -oTewi install.exe
+rm -rf Tewi/'$'*
+7z a tewi.7z Tewi
+rm -rf Tewi
 rm tewi.exe
 rm itworks.html
 rm generated.conf