diff -crN stunnel-3.11-kai/common.h stunnel-3.11-kai-gui/common.h *** stunnel-3.11-kai/common.h Mon Dec 25 19:10:42 2000 --- stunnel-3.11-kai-gui/common.h Tue Dec 26 04:11:34 2000 *************** *** 64,70 **** --- 64,77 ---- typedef unsigned char u8; typedef unsigned short u16; typedef unsigned long u32; + + #ifndef _MSC_VER typedef unsigned long long u64; + #endif + + #ifdef _MSC_VER + #define strcasecmp stricmp + #endif #define HAVE_VSNPRINTF #define vsnprintf _vsnprintf *************** *** 249,254 **** --- 256,272 ---- #define STRINGIFY_H(x) #x #define STRINGIFY(x) STRINGIFY_H(x) + #ifdef USE_WIN32UI + + static char status_string[80]; + + #define main stunnel_main + + void win32_my_exit(int); + void update_trayicon(char *); + void win32_log(char*); + void win32_log_unixlines(char*); + #endif /* End of common.h */ Binary files stunnel-3.11-kai/icon2.ico and stunnel-3.11-kai-gui/icon2.ico differ diff -crN stunnel-3.11-kai/log.c stunnel-3.11-kai-gui/log.c *** stunnel-3.11-kai/log.c Tue Dec 19 14:55:51 2000 --- stunnel-3.11-kai-gui/log.c Tue Dec 26 03:18:56 2000 *************** *** 159,166 **** --- 159,170 ---- syslog(level, "%s", text); else #endif + #ifdef USE_WIN32UI + win32_log(text); + #else fprintf(stderr, "LOG%d[%lu:%lu]: %s\n", level, process_id(), thread_id(), text); fflush(stderr); + #endif } diff -crN stunnel-3.11-kai/makefilew.w32 stunnel-3.11-kai-gui/makefilew.w32 *** stunnel-3.11-kai/makefilew.w32 Thu Jan 1 01:00:00 1970 --- stunnel-3.11-kai-gui/makefilew.w32 Wed Jan 1 00:14:04 1997 *************** *** 0 **** --- 1,58 ---- + # Simple Makefile.w32 for stunnel.exe by Michal Trojnara 1998-2000 + # + # Modified by Brian Hatch (bri@stunnel.org) + # Modified by Robert Spier (rspier@pobox.com) for Win32UI + + # This makefile is only tested on the mingw compiler. Mingw + # can successfully compile both openssl and stunnel. If you want + # to use another compiler, give it a shot, and tell us how it went. + + # Modify this to point to your actual openssl compile directory + # (You did already compile openssl, didn't you???) + SSLDIR=f:\openssl-0.9.5a + + + + DEFINES=-DUSE_WIN32 -DHAVE_OPENSSL + + # You may want to add some of the following flags + # to the DEFINES definition above. + + # Location of default certificate file for -v option + # -DCERT_FILE=\"/stunnel/certs/certs.pem\" + + # Location of default certificate directory for -v option + # -DCERT_DIR=\"/stunnel/certs\" + + # Default directory for stunnel.pem file + # -DPEM_DIR=\"/stunnel/private\" + + # Use the default certificate sources from your ssl library? (0==no, 1==yes) + # -DSSLLIB_CS=0 + + CC=gcc + CFLAGS=-O2 -Wall $(DEFINES) -I$(SSLDIR)/outinc -DUSE_WIN32UI + LDFLAGS=-s + + # LIBS=-L$(SSLDIR)/out -lssl -lcrypto -lwsock32 -lgdi32 + + LIBS=-L$(SSLDIR)/out -leay32 -lssl32 -lwsock32 -lgdi32 + OBJS=stunnel.o stunnelw.o ssl.o protocol.o sthreads.o log.o resource.o + + stunnelw.exe: $(OBJS) + $(CC) $(LDFLAGS) -o $(EXE) $(OBJS) $(LIBS) + + clean: + del *.o + del stunnel.exe + del stunnelw.exe + + # for the Win32 UI + + stunnelw.exe: $(W_OBJS) $(OBJS) + $(CC) $(LDFLAGS) -o $(EXE) $(OBJS) $(LIBS) + + stunnelw.rc: + resource.o: stunnelw.rc resource.h + windres stunnelw.rc resource.o + diff -crN stunnel-3.11-kai/protocol.c stunnel-3.11-kai-gui/protocol.c *** stunnel-3.11-kai/protocol.c Mon Dec 25 19:10:42 2000 --- stunnel-3.11-kai-gui/protocol.c Tue Dec 26 03:58:02 2000 *************** *** 27,36 **** #include #include /* for va_* */ #include /* for read(), write() */ - #include #include /* for select() */ #include /* Ultrix needs it for fd_set */ /* protocol-specific function prototypes */ static int smb_client(int, int); --- 27,39 ---- #include #include /* for va_* */ + #include + + #ifndef _MSC_VER #include /* for read(), write() */ #include /* for select() */ #include /* Ultrix needs it for fd_set */ + #endif /* protocol-specific function prototypes */ static int smb_client(int, int); diff -crN stunnel-3.11-kai/resource.h stunnel-3.11-kai-gui/resource.h *** stunnel-3.11-kai/resource.h Thu Jan 1 01:00:00 1970 --- stunnel-3.11-kai-gui/resource.h Mon Sep 4 18:57:30 2000 *************** *** 0 **** --- 1,8 ---- + #define IDR_STUNNEL_MENU 101 + #define IDR_TRAYMENU 102 + #define IDI_STUNNEL 105 + #define IDD_DIALOG1 106 + #define ID_FILE_SAVE 40001 + #define ID_FILE_EXIT 40002 + #define ID_HELP_ABOUT 40003 + #define ID_SHOW_LOGWINDOW 40004 diff -crN stunnel-3.11-kai/ssl.c stunnel-3.11-kai-gui/ssl.c *** stunnel-3.11-kai/ssl.c Sat Dec 16 15:57:52 2000 --- stunnel-3.11-kai-gui/ssl.c Tue Dec 26 04:09:58 2000 *************** *** 114,121 **** --- 114,126 ---- int allow_severity=LOG_NOTICE; int deny_severity=LOG_WARNING; #endif + + #ifdef USE_WIN32UI + #define exit win32_my_exit + #endif #endif /* defined USE_WIN32 */ + extern server_options options; diff -crN stunnel-3.11-kai/sthreads.c stunnel-3.11-kai-gui/sthreads.c *** stunnel-3.11-kai/sthreads.c Sat Dec 16 16:08:29 2000 --- stunnel-3.11-kai-gui/sthreads.c Tue Dec 26 04:10:50 2000 *************** *** 26,31 **** --- 26,35 ---- #else #include /* for CRYPTO_* */ #endif + + #ifdef USE_WIN32UI + #define exit win32_my_exit + #endif #define MAX_CRIT_SECTIONS 3 diff -crN stunnel-3.11-kai/stunnel.c stunnel-3.11-kai-gui/stunnel.c *** stunnel-3.11-kai/stunnel.c Mon Dec 25 19:10:42 2000 --- stunnel-3.11-kai-gui/stunnel.c Tue Dec 26 04:10:34 2000 *************** *** 57,62 **** --- 57,65 ---- #define Win32_Winsock #include + #ifdef USE_WIN32UI + #define exit win32_my_exit + #endif static struct WSAData wsa_state; *************** *** 170,175 **** --- 173,192 ---- } log(LOG_NOTICE, "Using '%s' as tcpwrapper service name", options.servname); + #ifdef USE_WIN32UI + { + #ifdef HAVE_SNPRINTF + snprintf(status_string,80, + #else + sprintf(status_string, + #endif + "stunnel: %d -> %s", + ntohs(options.localport), + options.servname ); + update_trayicon( status_string ); + } + #endif + /* check if certificate exists */ if(options.option&OPT_CERT) { if(stat(options.pem, &st)) { *************** *** 1048,1054 **** --- 1065,1075 ---- static void print_help() { + #ifdef USE_WIN32UI + win32_log_unixlines( + #else fprintf(stderr, + #endif /* Server execution */ "\nstunnel\t" "[-h] " diff -crN stunnel-3.11-kai/stunnel.dsp stunnel-3.11-kai-gui/stunnel.dsp *** stunnel-3.11-kai/stunnel.dsp Thu Jan 1 01:00:00 1970 --- stunnel-3.11-kai-gui/stunnel.dsp Tue Dec 26 04:30:44 2000 *************** *** 0 **** --- 1,134 ---- + # Microsoft Developer Studio Project File - Name="stunnel" - Package Owner=<4> + # Microsoft Developer Studio Generated Build File, Format Version 6.00 + # ** DO NOT EDIT ** + + # TARGTYPE "Win32 (x86) Application" 0x0101 + + CFG=stunnel - Win32 Debug + !MESSAGE This is not a valid makefile. To build this project using NMAKE, + !MESSAGE use the Export Makefile command and run + !MESSAGE + !MESSAGE NMAKE /f "stunnel.mak". + !MESSAGE + !MESSAGE You can specify a configuration when running NMAKE + !MESSAGE by defining the macro CFG on the command line. For example: + !MESSAGE + !MESSAGE NMAKE /f "stunnel.mak" CFG="stunnel - Win32 Debug" + !MESSAGE + !MESSAGE Possible choices for configuration are: + !MESSAGE + !MESSAGE "stunnel - Win32 Release" (based on "Win32 (x86) Application") + !MESSAGE "stunnel - Win32 Debug" (based on "Win32 (x86) Application") + !MESSAGE + + # Begin Project + # PROP AllowPerConfigDependencies 0 + # PROP Scc_ProjName "" + # PROP Scc_LocalPath "" + CPP=cl.exe + MTL=midl.exe + RSC=rc.exe + + !IF "$(CFG)" == "stunnel - Win32 Release" + + # PROP BASE Use_MFC 0 + # PROP BASE Use_Debug_Libraries 0 + # PROP BASE Output_Dir "Release" + # PROP BASE Intermediate_Dir "Release" + # PROP BASE Target_Dir "" + # PROP Use_MFC 0 + # PROP Use_Debug_Libraries 0 + # PROP Output_Dir "Release" + # PROP Intermediate_Dir "Release" + # PROP Ignore_Export_Lib 0 + # PROP Target_Dir "" + # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /YX /FD /c + # ADD CPP /nologo /MD /W3 /GX /O2 /I "f:\openssl-0.9.6\inc32" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "USE_WIN32" /D "HAVE_OPENSSL" /FD /c + # SUBTRACT CPP /YX /Yc /Yu + # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 + # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 + # ADD BASE RSC /l 0x407 /d "NDEBUG" + # ADD RSC /l 0x407 /d "NDEBUG" + BSC32=bscmake.exe + # ADD BASE BSC32 /nologo + # ADD BSC32 /nologo + LINK32=link.exe + # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 + # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib libeay32.lib ssleay32.lib /nologo /subsystem:console /debug /machine:I386 + + !ELSEIF "$(CFG)" == "stunnel - Win32 Debug" + + # PROP BASE Use_MFC 0 + # PROP BASE Use_Debug_Libraries 1 + # PROP BASE Output_Dir "Debug" + # PROP BASE Intermediate_Dir "Debug" + # PROP BASE Target_Dir "" + # PROP Use_MFC 0 + # PROP Use_Debug_Libraries 1 + # PROP Output_Dir "Debug" + # PROP Intermediate_Dir "Debug" + # PROP Ignore_Export_Lib 0 + # PROP Target_Dir "" + # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /YX /FD /GZ /c + # ADD CPP /nologo /MDd /W3 /GX /ZI /Od /I "f:\openssl-0.9.6\inc32" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "USE_WIN32" /D "HAVE_OPENSSL" /FD /GZ /c + # SUBTRACT CPP /YX /Yc /Yu + # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 + # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 + # ADD BASE RSC /l 0x407 /d "_DEBUG" + # ADD RSC /l 0x407 /d "_DEBUG" + BSC32=bscmake.exe + # ADD BASE BSC32 /nologo + # ADD BSC32 /nologo + LINK32=link.exe + # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept + # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib libeay32.lib ssleay32.lib /nologo /subsystem:console /incremental:no /debug /machine:I386 /pdbtype:sept + # SUBTRACT LINK32 /nodefaultlib + + !ENDIF + + # Begin Target + + # Name "stunnel - Win32 Release" + # Name "stunnel - Win32 Debug" + # Begin Group "Source Files" + + # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" + # Begin Source File + + SOURCE=.\log.c + # End Source File + # Begin Source File + + SOURCE=.\protocol.c + # End Source File + # Begin Source File + + SOURCE=.\ssl.c + # End Source File + # Begin Source File + + SOURCE=.\sthreads.c + # End Source File + # Begin Source File + + SOURCE=.\stunnel.c + # End Source File + # End Group + # Begin Group "Header Files" + + # PROP Default_Filter "h;hpp;hxx;hm;inl" + # End Group + # Begin Group "Resource Files" + + # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" + # Begin Source File + + SOURCE=.\icon2.ico + # End Source File + # Begin Source File + + SOURCE=.\stunnelw.rc + # End Source File + # End Group + # End Target + # End Project Binary files stunnel-3.11-kai/stunnel.exe and stunnel-3.11-kai-gui/stunnel.exe differ diff -crN stunnel-3.11-kai/stunnelw.c stunnel-3.11-kai-gui/stunnelw.c *** stunnel-3.11-kai/stunnelw.c Thu Jan 1 01:00:00 1970 --- stunnel-3.11-kai-gui/stunnelw.c Tue Dec 26 04:10:12 2000 *************** *** 0 **** --- 1,329 ---- + /* + * stunnelw - Win32 User Interface for Stunnel + * + * Copyright (c) 2000 Robert Spier + * All Rights Reserved + * + * see stunnel.c for more information about stunnel + * + * Special Thanks for this file: + * Ron Isaacson + * Charles Petzold + * And, Microsoft who gave me Petzold's book for free. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA + */ + + #ifdef USE_WIN32UI + #include + #include + #include + #include "resource.h" + + #include "common.h" + + #define exit win32_my_exit + + HICON hicon_stunnel; + HWND g_hwnd; + HWND g_hwndEdit; + HINSTANCE g_hinstance; + int stunnel_main(int argc, char* argv[]); + + #define IDM_LOG 1 + + /* windows provides us with a single string for the command line. + stunnel_main wants it split into argc/argv */ + void start_stunnel_main( LPSTR szCmdLine ) { + char *argvp[128]; + int i=1; + + char *p = strtok(szCmdLine," "); + while( p ) { + argvp[i++] = p; + p = strtok(NULL," "); + } + argvp[0]="stunnel"; + + stunnel_main(i,argvp); + } + + /* Win32 Message Handling Procedure */ + LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, + LPARAM lParam) { + static int toggleShow = 0; + static HWND hwndStunnelInfo; + static OPENFILENAME ofn; + static char logFileName[256]; + + switch(message) { + case WM_CREATE: + g_hwnd = hwnd; + { + DWORD threadID; + + g_hwndEdit = CreateWindow( TEXT("edit"), NULL, + WS_CHILD | WS_VISIBLE | WS_HSCROLL | + WS_VSCROLL | WS_BORDER | ES_LEFT | + ES_MULTILINE | ES_READONLY | + ES_AUTOHSCROLL | ES_AUTOVSCROLL, + 0,0,0,0, hwnd, (HMENU) IDM_LOG, + ((LPCREATESTRUCT)lParam)->hInstance, NULL ); + + hwndStunnelInfo = CreateWindow( TEXT("static"), TEXT( STUNNEL_INFO ), + WS_CHILD| WS_VISIBLE | SS_SUNKEN | SS_RIGHT, + 0,0,0,0, hwnd, NULL, + ((LPCREATESTRUCT)lParam)->hInstance, NULL ); + + update_trayicon( status_string ); + CloseHandle(CreateThread(NULL, 0, + (LPTHREAD_START_ROUTINE)start_stunnel_main, + (void *)(((LPCREATESTRUCT)lParam)->lpCreateParams), + 0, &threadID)); + + logFileName[0] = 0; + ofn.lStructSize = sizeof( OPENFILENAME); + ofn.hwndOwner = hwnd; + ofn.hInstance=NULL; + ofn.lpstrFilter = NULL; + ofn.lpstrCustomFilter = NULL; + ofn.nMaxCustFilter = 0; + ofn.nFilterIndex = 0; + ofn.lpstrFile = logFileName; + ofn.nMaxFile = 256; + ofn.lpstrFileTitle = NULL; + ofn.nMaxFileTitle = 0; + ofn.lpstrInitialDir = NULL; + ofn.lpstrTitle= NULL; + ofn.Flags = OFN_OVERWRITEPROMPT; + ofn.nFileOffset=0; + ofn.nFileExtension=0; + ofn.lpstrDefExt = TEXT("log"); + ofn.lCustData = 0; + ofn.lpfnHook = NULL; + ofn.lpTemplateName = NULL; + } + return 0; + + case WM_SETFOCUS: + SetFocus(g_hwndEdit); + + case WM_USER: /* coming from the tray icon */ + if ( lParam == WM_LBUTTONDBLCLK ) { + toggleShow = !toggleShow; + if (toggleShow) { + ShowWindow(hwnd, SW_SHOW); + SetForegroundWindow( hwnd ); + } + else + ShowWindow(hwnd, SW_HIDE); + } + + + if ( lParam == WM_RBUTTONUP ) { + POINT pt; + HMENU hMenu = LoadMenu( g_hinstance, MAKEINTRESOURCE(IDR_TRAYMENU)); + GetCursorPos(&pt); + // SetForegroundWindow( hwnd ); + TrackPopupMenu( GetSubMenu(hMenu,0), TPM_LEFTALIGN | TPM_BOTTOMALIGN | TPM_LEFTBUTTON, + pt.x, pt.y, 0, hwnd, NULL); + DestroyMenu(hMenu); + } + return 0; + case WM_SIZE: + /* we didn't set the size of the window on creation, so set it now */ + MoveWindow( g_hwndEdit, 0,0, LOWORD(lParam), HIWORD(lParam)-0, TRUE); + return 0; + + case WM_COMMAND: + switch (LOWORD (wParam)) { + case IDM_LOG: + /* Possible errors from Log Editbox */ + if (HIWORD(wParam) == EN_ERRSPACE || + HIWORD(wParam) == EN_MAXTEXT) + MessageBox(g_hwnd, TEXT("Edit control out of space."), + "stunnel", MB_OK | MB_ICONSTOP); + return 0; + + case ID_SHOW_LOGWINDOW: + SendMessage(hwnd,WM_USER,0,WM_LBUTTONDBLCLK); + return 0; + + case ID_FILE_EXIT: + SendMessage(hwnd,WM_DESTROY,0,0); + return 0; + + case ID_HELP_ABOUT: + MessageBox(g_hwnd, + STUNNEL_INFO, + "About stunnel...", + MB_OK | MB_ICONINFORMATION ); + return 0; + + case ID_FILE_SAVE: + if (!GetSaveFileName(&ofn)) + return 0; + + { + FILE *f; + SetCursor(LoadCursor(NULL,IDC_WAIT)); + ShowCursor(TRUE); + + f = fopen(logFileName,"w+"); + if (f) { + int slength = SendMessage( g_hwndEdit, WM_GETTEXTLENGTH, 0,0 ) + 1; + char *string = malloc(slength + 2); + + SendMessage( g_hwndEdit, WM_GETTEXT, slength, (int)string ); + fprintf(f,"%s",string); + free(string); + fclose(f); + } else { + MessageBox( hwnd, TEXT("Cannot save logfile..."), + "Error", MB_ICONERROR | MB_OK ); + } + ShowCursor(FALSE); + SetCursor(LoadCursor(NULL,IDC_ARROW)); + } + + } // switch + break; + + case WM_DESTROY: + { + NOTIFYICONDATA nid; + HICON icon = LoadIcon( g_hinstance, MAKEINTRESOURCE( IDI_STUNNEL )); + nid.cbSize = sizeof (NOTIFYICONDATA); + nid.hWnd = g_hwnd; + nid.uID = 0; + nid.hIcon = icon; + nid.uFlags = NIF_MESSAGE | NIF_TIP | NIF_ICON; + nid.uCallbackMessage = WM_USER; + Shell_NotifyIcon( NIM_DELETE, &nid ); + PostQuitMessage (0); + return 0; + } + } + + return DefWindowProc( hwnd, message, wParam, lParam ); + } + + /* Win32 main(), initialization and such */ + + int APIENTRY WinMain(HINSTANCE hInstance, + HINSTANCE hPrevInstance, + LPSTR lpCmdLine, + int nCmdShow) + { + + static TCHAR szAppName[] = TEXT ("stunnel"); + HWND hwnd; + MSG msg; + WNDCLASS wndclass; + + wndclass.style = CS_HREDRAW | CS_VREDRAW; + wndclass.lpfnWndProc = WndProc; + wndclass.cbClsExtra = 0; + wndclass.cbWndExtra = 0; + wndclass.hInstance = hInstance; + wndclass.hIcon = LoadIcon( hInstance, MAKEINTRESOURCE(IDI_STUNNEL)); + wndclass.hCursor = LoadCursor(NULL, IDC_ARROW); + wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH); + wndclass.lpszMenuName = TEXT("IDR_STUNNELMENU"); + wndclass.lpszClassName = szAppName; + + RegisterClass(&wndclass); + + g_hinstance = hInstance; + + strncpy(status_string,"stunnel: initalizing",80); + + hwnd = CreateWindow( szAppName, "stunnelw", + WS_OVERLAPPEDWINDOW, + CW_USEDEFAULT, CW_USEDEFAULT, + CW_USEDEFAULT, CW_USEDEFAULT, + NULL, NULL, hInstance, lpCmdLine); + + ShowWindow( hwnd, SW_HIDE); + UpdateWindow(hwnd); + + /* Win32 Message Loop */ + while( GetMessage(&msg, NULL, 0,0) ) { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + return msg.wParam; + } + + /* update the tooltip on the tray icon */ + void update_trayicon(LPSTR szIconStr) { + static DWORD nim = NIM_ADD; + HICON icon = LoadIcon(g_hinstance, MAKEINTRESOURCE(IDI_STUNNEL)); + NOTIFYICONDATA nid; + + + nid.cbSize = sizeof (NOTIFYICONDATA); + nid.hWnd = g_hwnd; + nid.uID = 0; + nid.uFlags = NIF_MESSAGE | NIF_TIP | NIF_ICON; + nid.uCallbackMessage = WM_USER; + nid.hIcon = icon; + lstrcpy (nid.szTip, szIconStr); + Shell_NotifyIcon (nim, &nid); + nim = NIM_MODIFY; + DestroyIcon( icon ); + } + + /* append a message to the log buffer */ + void win32_log(char *text) { + int slength = SendMessage( g_hwndEdit, WM_GETTEXTLENGTH, 0,0 ) + 1; + char *string = malloc(slength + strlen(text) + 4); + int offset = 0; + if (slength > 20000) /* if we're getting long, cut first 5k out */ + offset = 5000; + SendMessage( g_hwndEdit, WM_GETTEXT, slength, (int)string ); + strcat( string, text ); + strcat( string, "\r\n" ); + SendMessage( g_hwndEdit, WM_SETTEXT, strlen(string)-offset, + (int)string+offset); + free(string); + } + + /* exit the current thread and bring the log window to the front */ + void win32_my_exit(int v) { + fprintf(stderr,"exit %d",v); + win32_log(""); + win32_log("stunnel has terminated.\r\n" + "close this log window to terminate the process"); + ShowWindow( g_hwnd, SW_SHOW); + SetForegroundWindow( g_hwnd ); + ExitThread(v); + } + + /* append multiple \n seperated lines to the log buffer */ + void win32_log_unixlines(char *text) { + + char *textcopy; + char *line; + textcopy = malloc(strlen(text)+1); + strcpy(textcopy,text); + line = strtok(textcopy,"\n"); + while ( line ) { + win32_log(line); + line = strtok(NULL,"\n"); + } + free(textcopy); + } + + #endif diff -crN stunnel-3.11-kai/stunnelw.dsp stunnel-3.11-kai-gui/stunnelw.dsp *** stunnel-3.11-kai/stunnelw.dsp Thu Jan 1 01:00:00 1970 --- stunnel-3.11-kai-gui/stunnelw.dsp Tue Dec 26 04:36:52 2000 *************** *** 0 **** --- 1,138 ---- + # Microsoft Developer Studio Project File - Name="stunnelw" - Package Owner=<4> + # Microsoft Developer Studio Generated Build File, Format Version 6.00 + # ** DO NOT EDIT ** + + # TARGTYPE "Win32 (x86) Application" 0x0101 + + CFG=stunnelw - Win32 Debug + !MESSAGE This is not a valid makefile. To build this project using NMAKE, + !MESSAGE use the Export Makefile command and run + !MESSAGE + !MESSAGE NMAKE /f "stunnelw.mak". + !MESSAGE + !MESSAGE You can specify a configuration when running NMAKE + !MESSAGE by defining the macro CFG on the command line. For example: + !MESSAGE + !MESSAGE NMAKE /f "stunnelw.mak" CFG="stunnelw - Win32 Debug" + !MESSAGE + !MESSAGE Possible choices for configuration are: + !MESSAGE + !MESSAGE "stunnelw - Win32 Release" (based on "Win32 (x86) Application") + !MESSAGE "stunnelw - Win32 Debug" (based on "Win32 (x86) Application") + !MESSAGE + + # Begin Project + # PROP AllowPerConfigDependencies 0 + # PROP Scc_ProjName "" + # PROP Scc_LocalPath "" + CPP=cl.exe + MTL=midl.exe + RSC=rc.exe + + !IF "$(CFG)" == "stunnelw - Win32 Release" + + # PROP BASE Use_MFC 0 + # PROP BASE Use_Debug_Libraries 0 + # PROP BASE Output_Dir "ReleaseW" + # PROP BASE Intermediate_Dir "ReleaseW" + # PROP BASE Target_Dir "" + # PROP Use_MFC 0 + # PROP Use_Debug_Libraries 0 + # PROP Output_Dir "ReleaseW" + # PROP Intermediate_Dir "ReleaseW" + # PROP Ignore_Export_Lib 0 + # PROP Target_Dir "" + # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c + # ADD CPP /nologo /MD /W3 /GX /O2 /I "f:\openssl-0.9.6\inc32" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "USE_WIN32" /D "USE_WIN32UI" /D "HAVE_OPENSSL" /FD /c + # SUBTRACT CPP /YX /Yc /Yu + # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 + # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 + # ADD BASE RSC /l 0x407 /d "NDEBUG" + # ADD RSC /l 0x407 /d "NDEBUG" + BSC32=bscmake.exe + # ADD BASE BSC32 /nologo + # ADD BSC32 /nologo + LINK32=link.exe + # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 + # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib libeay32.lib ssleay32.lib /nologo /subsystem:windows /debug /machine:I386 + + !ELSEIF "$(CFG)" == "stunnelw - Win32 Debug" + + # PROP BASE Use_MFC 0 + # PROP BASE Use_Debug_Libraries 1 + # PROP BASE Output_Dir "DebugW" + # PROP BASE Intermediate_Dir "DebugW" + # PROP BASE Target_Dir "" + # PROP Use_MFC 0 + # PROP Use_Debug_Libraries 1 + # PROP Output_Dir "DebugW" + # PROP Intermediate_Dir "DebugW" + # PROP Ignore_Export_Lib 0 + # PROP Target_Dir "" + # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c + # ADD CPP /nologo /MDd /W3 /GX /ZI /Od /I "f:\openssl-0.9.6\inc32" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "USE_WIN32" /D "USE_WIN32UI" /D "HAVE_OPENSSL" /FD /GZ /c + # SUBTRACT CPP /YX /Yc /Yu + # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 + # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 + # ADD BASE RSC /l 0x407 /d "_DEBUG" + # ADD RSC /l 0x407 /d "_DEBUG" + BSC32=bscmake.exe + # ADD BASE BSC32 /nologo + # ADD BSC32 /nologo + LINK32=link.exe + # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept + # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib libeay32.lib ssleay32.lib /nologo /subsystem:windows /incremental:no /debug /machine:I386 /pdbtype:sept + # SUBTRACT LINK32 /nodefaultlib + + !ENDIF + + # Begin Target + + # Name "stunnelw - Win32 Release" + # Name "stunnelw - Win32 Debug" + # Begin Group "Source Files" + + # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" + # Begin Source File + + SOURCE=.\log.c + # End Source File + # Begin Source File + + SOURCE=.\protocol.c + # End Source File + # Begin Source File + + SOURCE=.\ssl.c + # End Source File + # Begin Source File + + SOURCE=.\sthreads.c + # End Source File + # Begin Source File + + SOURCE=.\stunnel.c + # End Source File + # Begin Source File + + SOURCE=.\stunnelw.c + # End Source File + # End Group + # Begin Group "Header Files" + + # PROP Default_Filter "h;hpp;hxx;hm;inl" + # End Group + # Begin Group "Resource Files" + + # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" + # Begin Source File + + SOURCE=.\icon2.ico + # End Source File + # Begin Source File + + SOURCE=.\stunnelw.rc + # End Source File + # End Group + # End Target + # End Project diff -crN stunnel-3.11-kai/stunnelw.rc stunnel-3.11-kai-gui/stunnelw.rc *** stunnel-3.11-kai/stunnelw.rc Thu Jan 1 01:00:00 1970 --- stunnel-3.11-kai-gui/stunnelw.rc Mon Sep 4 18:57:30 2000 *************** *** 0 **** --- 1,58 ---- + #include "resource.h" + + + ///////////////////////////////////////////////////////////////////////////// + // + // Menu + // + + IDR_STUNNELMENU MENU DISCARDABLE + BEGIN + POPUP "&File" + BEGIN + MENUITEM "&Save", ID_FILE_SAVE + MENUITEM "E&xit", ID_FILE_EXIT + END + POPUP "&Help" + BEGIN + MENUITEM "&About", ID_HELP_ABOUT + END + END + + IDR_TRAYMENU MENU DISCARDABLE + BEGIN + POPUP "&File" + BEGIN + MENUITEM "&About", ID_HELP_ABOUT + MENUITEM "Show &Log", ID_SHOW_LOGWINDOW + MENUITEM "E&xit", ID_FILE_EXIT + END + END + + + ///////////////////////////////////////////////////////////////////////////// + // + // Icon + // + + // Icon with lowest ID value placed first to ensure application icon + // remains consistent on all systems. + IDI_STUNNEL ICON DISCARDABLE "icon2.ico" + + + ///////////////////////////////////////////////////////////////////////////// + // + // Dialog + // + /* + IDD_DIALOG1 DIALOG DISCARDABLE 0, 0, 187, 95 + STYLE DS_MODALFRAME | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU + CAPTION "Dialog" + FONT 8, "MS Sans Serif" + BEGIN + DEFPUSHBUTTON "OK",IDOK,130,7,50,14 + PUSHBUTTON "Cancel",IDCANCEL,130,24,50,14 + END + + + */