Changeset 253 in Main
- Timestamp:
- Oct 4, 2024, 12:13:36 PM (6 weeks ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Common/log.c
r212 r253 3 3 #include "cm_log.h" 4 4 5 #include "../config.h" 5 6 #include "cm_string.h" 6 7 … … 26 27 #define LOGNAME_LENGTH 12 27 28 29 #ifdef BUILD_GUI_VALID 30 void AddLog(const char* str); 31 #endif 32 28 33 void cm_force_log(const char* log) { 29 34 time_t t = time(NULL); 30 35 struct tm* tm = localtime(&t); 31 36 char date[513]; 37 char* str; 32 38 strftime(date, 512, "%a %b %d %H:%M:%S %Z %Y", tm); 33 39 #ifdef _PSP … … 35 41 #elif defined(__PPU__) 36 42 tt_printf("[%s] %s\n", date, log); 43 #elif defined(BUILD_GUI_VALID) 44 str = malloc(strlen(date) + strlen(log) + 3 + 1); 45 str[strlen(date) + strlen(log) + 3] = 0; 46 sprintf(str, "[%s] %s", date, log); 47 AddLog(str); 48 free(str); 37 49 #else 38 50 fprintf(logfile, "[%s] %s\n", date, log); 51 fflush(logfile); 39 52 #endif 40 fflush(logfile);41 53 } 42 54 -
trunk/Platform/watcom.mk
r244 r253 14 14 LIBSUF = .dll 15 15 OBJ = obj 16 SERVADD = wrc -bt=nt -i=$(WATCOM)/h/nt tewi.rc tewi.exe && wrc -bt=nt -i=$(WATCOM)/h/nt gui.rc tewi.exe 16 REQOBJS = concat.rc 17 SERVADD = wrc -bt=nt -i=$(WATCOM)/h/nt concat.rc tewi.exe -
trunk/Server/Makefile
r249 r253 46 46 $(CC) $(CFLAGS) $(EXTCFLAGS) -c -o $@ $< 47 47 48 tewi.res: tewi.rc ../Binary/tewi.ico49 $(WINDRES) tewi.rc -O coff -o $@48 tewi.res: concat.rc ../Binary/tewi.ico 49 $(WINDRES) concat.rc -O coff -o $@ 50 50 51 tewi_bcc.res: tewi.rc ../Binary/tewi.ico52 brc32 -r -fo$@ tewi.rc51 tewi_bcc.res: concat.rc ../Binary/tewi.ico 52 brc32 -r -fo$@ concat.rc 53 53 54 gui.res: gui.rc gui.h55 $(WINDRES) gui.rc -O coff -o $@54 gui.res: concat.rc gui.h 55 $(WINDRES) concat.rc -O coff -o $@ 56 56 57 gui_bcc.res: gui.rc gui.h58 brc32 -r -fo$@ gui.rc57 gui_bcc.res: concat.rc gui.h 58 brc32 -r -fo$@ concat.rc 59 59 60 vc6.res: tewi.rc gui.rc 61 cat tewi.rc gui.rc > concat.rc 60 vc6.res: concat.rc 62 61 rc /fo$@ concat.rc 63 62 rm -f concat.rc 64 63 64 concat.rc: tewi.rc gui.rc 65 cat tewi.rc gui.rc > concat.rc 66 65 67 clean: 66 68 rm -f *.o tewi *.exe *.res *.elf *.sfo *.pbp *.self *.pkg *.obj concat.rc -
trunk/Server/config.c
r240 r253 132 132 int ifbr = 0; 133 133 int ignore = -1; 134 int portcount; 134 135 FILE* f; 135 136 cm_log("Config", "Reading %s", path); … … 488 489 free(line); 489 490 fclose(f); 490 return stop; 491 for(portcount = 0; config.ports[portcount] != -1; portcount++); 492 if(portcount == 0){ 493 return 1; 494 }else{ 495 return stop; 496 } 491 497 } else { 492 498 cm_log("Config", "Could not open the file"); -
trunk/Server/gui.c
r249 r253 4 4 5 5 #include "gui.h" 6 6 #include "tw_server.h" 7 8 #include <cm_log.h> 9 10 #include <stdio.h> 7 11 #include <windows.h> 12 #include <process.h> 8 13 #include <commctrl.h> 9 14 … … 15 20 HWND button_about; 16 21 HWND status; 22 HFONT monospace; 17 23 BOOL tewi_alive; 18 24 BOOL was_starting; 19 25 BOOL exiting; 26 BOOL idle; 27 extern FILE* logfile; 28 extern int running; 20 29 21 30 #define WINWIDTH(rc) (rc.right - rc.left) 22 31 #define WINHEIGHT(rc) (rc.bottom - rc.top) 23 32 24 #define DIALOG_X(n) (HIWORD(GetDialogBaseUnits()) * n) 25 #define DIALOG_Y(n) (LOWORD(GetDialogBaseUnits()) * n) 33 int startup(int argc, char** argv); 26 34 27 35 void ShowBitmapSize(HWND hWnd, HDC hdc, const char* name, int x, int y, int w, int h){ … … 45 53 } 46 54 55 int max = 0; 56 void AddLog(const char* str){ 57 HDC hdc; 58 PAINTSTRUCT ps; 59 SIZE sz; 60 61 SendMessage(logarea, LB_ADDSTRING, 0, (LPARAM)str); 62 63 hdc = CreateCompatibleDC(NULL); 64 SelectObject(hdc, monospace); 65 GetTextExtentPoint32(hdc, str, strlen(str), &sz); 66 DeleteDC(hdc); 67 68 if(max < sz.cx){ 69 max = sz.cx; 70 SendMessage(logarea, LB_SETHORIZONTALEXTENT, max, 0); 71 } 72 } 73 47 74 LRESULT CALLBACK VersionDialog(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp){ 48 75 if(msg == WM_COMMAND){ … … 63 90 HDC dc = (HDC)wp; 64 91 SetBkMode(dc, TRANSPARENT); 65 return GetSysColorBrush(COLOR_MENU);92 return (LRESULT)GetSysColorBrush(COLOR_MENU); 66 93 }else{ 67 94 return FALSE; … … 70 97 } 71 98 99 void tewi_thread(void* ptr){ 100 int st = startup(0, NULL); 101 was_starting = TRUE; 102 if(st == -1){ 103 tewi_alive = TRUE; 104 idle = FALSE; 105 }else{ 106 cm_force_log("Config error"); 107 idle = FALSE; 108 _endthread(); 109 } 110 running = 1; 111 tw_server_loop(); 112 tewi_alive = FALSE; 113 was_starting = TRUE; 114 idle = FALSE; 115 _endthread(); 116 } 117 72 118 void StartTewi(void){ 73 was_starting = TRUE; 119 EnableWindow(button_start, FALSE); 120 EnableWindow(button_stop, FALSE); 121 _beginthread(tewi_thread, 0, NULL); 74 122 } 75 123 76 124 void StopTewi(void){ 77 was_starting = TRUE; 125 EnableWindow(button_start, FALSE); 126 EnableWindow(button_stop, FALSE); 127 running = 0; 78 128 } 79 129 … … 119 169 InitCommonControls(); 120 170 171 monospace = (HFONT)GetStockObject(SYSTEM_FIXED_FONT); 172 121 173 status = CreateStatusWindow(WS_CHILD | WS_VISIBLE | CCS_BOTTOM, NULL, hWnd, GUI_STATUS); 122 174 SendMessage(status, SB_SIMPLE, 0, 0); … … 129 181 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); 130 182 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); 131 logarea = CreateWindow("LISTBOX", NULL, WS_CHILD | WS_VISIBLE | WS_VSCROLL, 0, 40, WINWIDTH(rc) - 100, WINHEIGHT(rc) - 40 - WINHEIGHT(src), hWnd, (HMENU)GUI_LOG, hInst, NULL); 183 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); 184 185 SendMessage(logarea, WM_SETFONT, (WPARAM)monospace, TRUE); 186 132 187 SetTimer(hWnd, TIMER_WATCH_TEWI, 100, NULL); 133 188 }else if(msg == WM_TIMER){ 134 189 if(wp == TIMER_WATCH_TEWI){ 135 if(tewi_alive){ 190 if(idle){ 191 }else if(tewi_alive){ 136 192 if(was_starting){ 137 193 was_starting = FALSE; … … 140 196 EnableWindow(button_start, FALSE); 141 197 EnableWindow(button_stop, TRUE); 198 idle = TRUE; 142 199 }else{ 143 200 if(was_starting){ … … 151 208 SendMessage(hWnd, WM_CLOSE, 0, 0); 152 209 } 210 idle = TRUE; 153 211 } 154 212 } … … 172 230 173 231 BOOL InitApp(void){ 174 WNDCLASS wc; 232 WNDCLASSEX wc; 233 wc.cbSize = sizeof(WNDCLASSEX); 175 234 wc.style = CS_HREDRAW | CS_VREDRAW; 176 235 wc.lpfnWndProc = WndProc; … … 183 242 wc.lpszMenuName = NULL; 184 243 wc.lpszClassName = "tewihttpd"; 185 return RegisterClass(&wc); 244 wc.hIconSm = LoadIcon(hInst, "TEWI"); 245 return RegisterClassEx(&wc); 186 246 } 187 247 … … 191 251 HWND hDeskWnd = GetDesktopWindow(); 192 252 GetWindowRect(hDeskWnd, &deskrc); 193 hWnd = CreateWindow("tewihttpd", "Tewi HTTPd", (WS_OVERLAPPEDWINDOW ^ WS_THICKFRAME) ^ WS_MAXIMIZEBOX, 0, 0, 600, 200, NULL, 0, hInst, NULL);253 hWnd = CreateWindow("tewihttpd", "Tewi HTTPd", (WS_OVERLAPPEDWINDOW ^ WS_THICKFRAME) ^ WS_MAXIMIZEBOX, 0, 0, 600, 400, NULL, 0, hInst, NULL); 194 254 195 255 if(!hWnd){ … … 210 270 was_starting = FALSE; 211 271 exiting = FALSE; 272 idle = TRUE; 273 logfile = stderr; 212 274 if(!InitApp()){ 213 275 return FALSE; -
trunk/Server/main.c
r249 r253 527 527 #endif 528 528 529 #if !defined(BUILD_GUI ) || !(defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__))529 #if !defined(BUILD_GUI_VALID) 530 530 int main(int argc, char** argv) { 531 531 int st; … … 797 797 signal(SIGCHLD, SIG_IGN); 798 798 signal(SIGPIPE, SIG_IGN); 799 #el se799 #elif !defined(BUILD_GUI) 800 800 SetConsoleTitle(tw_server); 801 801 #endif -
trunk/Server/server.c
r240 r253 1050 1050 } 1051 1051 } 1052 } 1052 for(i = 0; i < sockcount; i++){ 1053 close_socket(sockets[i]); 1054 } 1055 cm_force_log("Server is down"); 1056 } -
trunk/config.h.tmpl
r244 r253 18 18 #ifdef NO_SSL 19 19 #define SSL void 20 #endif 21 22 #if (defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__)) && defined(USE_POLL) 23 #define BUILD_GUI_VALID 20 24 #endif 21 25 -
trunk/make-installer.sh
r222 r253 24 24 ../Tool/genconf "C:/Tewi" modules dll > ../generated.conf 25 25 ../Tool/itworks > ../itworks.html 26 makensis /inputcharset utf8-DVERSION=$VERSION -DONLY_EXEC install.nsi26 makensis -DVERSION=$VERSION -DONLY_EXEC install.nsi 27 27 cp install.exe ../install.exe 28 28 cd ..
Note:
See TracChangeset
for help on using the changeset viewer.