[stunnel-users] public domain [PATCH] to stunnel v502 for Win32: UNICODE fixes + ugly font fix for About and Password Dialog boxes

Pierre DELAAGE delaage.pierre at free.fr
Mon Jun 9 22:55:38 CEST 2014


Dear Michal, Dear All,
Please find enclosed a win32 patch for UNICODE support,
in "diff -cr orig patched" format,
applying to stunnel official v502 as found here: 
https://www.stunnel.org/downloads/stunnel-5.02.tar.gz.

This patch mainly addresses UNICODE compilation issues for Win32 target.

It is a first step in my usual port to WCE system, that I decided to 
"split" in two steps (to make it more clear for Michal code reviewing)  :
1/ fix win32 code to UNICODE support, just for win32 (ie Windows Desktop 
version)
2/ fix specific WCE issues (to come in the near future)

To compile for Win32 I use VC++ 9.0 Express Edition on an XP sp2 host 
system.


The present stunnel patch addresses the following issues :

*************
I] COMPILATION FAILURES

It is important to state that to detect more type mismatching (that can
be error prone at runtime), I delibarately use /WX option on my W32 
compiler:
this flag takes each warning as an error.

This is very useful for UNICODE clean coding as, without this option, the
compiler will just warn when seeing a short* (unicode string) used as a
char* (ansi string), which leads to big pb at run time.


1/ vc.mak :
I added a trivial support for a new "makew32" command line option to 
activate UNICODE compilation.
So that to compile for W32 WITH UNICODE, one has just to type :

makew32 "UNICODESUPPORT="

(Note : in the MS nmake world, this syntax is equivalent to 
/DUNICODESUPPORT in eg borland make.)

To compile for ANSI, just type : makew32 on the command line, as usual, 
with no option.

Added /WX flag for strict type checking (very helpful to track 
abusive/error prone casts).

Added _CRT_NON_CONFORMING_SWPRINTFS to avoid compilation errors about 
_stprintf in ui_win_gui.c:
MS has changed the prototype of the function and the FLAG is required to 
activate the old fashion interface that is used in the stunnel code.


2/ makew32.bat :
Just added a comment to mention how to call the script to compile for 
UNICODE.

makew32 "UNICODESUPPORT="


3/ resolver.c :
UNICODE strings are required for :
LoadLibrary (so use TEXT macro for literals)

4/ ui_win_gui.c
UNICODE strings are required for :

GetModuleFileName (see Winmain),
SetCurrentDirectory (so that stunnel_exe_path and "c" variable must be 
TCHAR)
so we have to use _tcsrchr instead of strchr, _tcscmp instead of strcmp
and TEXT() macro for "c" variable affectation.

_tputenv_s must also be used instead of _putenv_s


SERVICE_NAME literal must be UNICODE because of 
"serviceTable[0].lpServiceName" struct member used by 
StartServiceCtrlDispatcher.
Also for CreateService, OpenService, RegisterServiceCtrlHandler,

str_printf requires special format spec flag "%ls" for WIDE CHAR 
strings, and "%hs" for explicit ANSI CHAR strings.
It is better, for the symetry of the code, to explicitely state %ls or 
%hs for each situation.

Prototype error : service_install function HAS DIFFERENT prototypes at 
the top of the source file and in the body of the source file :
the correct prototype, considering the rest of the code using this 
function, is the... pure ANSI one ...

GetModuleFileNameEx (in enum_windows) requires that window_exe_path be 
UNICODE (TCHAR).

in edit_config function : ShellExecute requires UNICODE strings

5/ ui_win_cli.c

In main function :
UNICODE required by GetModuleFileName and SetCurrentDirectory.
then we have to use TCHAR for "c" and stunnel_exe_path variables,
and use :
_tcsrchr
_tputenv_s
accordingly.


*************
II] OPERATIONAL ERRORS or IMPROVMENTS (at run-time)

1/ MINOR IMPROVMENT : replaced some "default" win3.1 style ugly bold 
fonts by thinner fonts (as those appearing on the MAIN WINDOW MENU text 
items).
See resources.rc, About and Password dlgboxes :

Explicit use of FONT << 8, "MS Sans Serif" >>

I am not an artist but I think good to have consistant look between 
menus and dlgboxes,
and to look like a little bit different than win3.1...

**************************
III] TODO list and WISH LIST list  for win32 target :

1/ win32 makefile : _CRT_NON_CONFORMING_SWPRINTFS flag to <<avoid>> in 
makefile, so that we have to clarify the ui_win_gui.c code on that point

2/  mingw32 makefile :
2.1 add UNICODE flag support in mgw32 makefile.
2.2 check the interest of _CRT_NON_CONFORMING_SWPRINTFS

3/ ui_win_cli.c :

shoudn't we use s_log instead of fprintf(stderr)  ?


***************

I hope you will find this patch useful.

More fixes are coming very soon for WCE5.0/WM6 support (my own WCE 
version is now finished and working, but I have to clean my code a 
little before submitting it).

Yours sincerely,

Pierre Delaage
-------------- next part --------------
Seulement dans patch1: bin
Seulement dans patch1: obj
diff -cr orig/src/makew32.bat patch1/src/makew32.bat
*** orig/src/makew32.bat	2010-11-17 21:20:14.000000000 +0100
--- patch1/src/makew32.bat	2014-06-09 15:49:25.546875000 +0200
***************
*** 2,7 ****
--- 2,8 ----
  TITLE W32 STUNNEL 
  ::pdelaage 20101026: for use with MS VCexpress 2008 (v9)
  ::some trick to avoid re-pollution of env vars as much as possible
+ ::pdelaage 20140609: makew32 "UNICODESUPPORT=" to compile a UNICODE version
  
  :: In multitarget compilation environment, it is better to open a new cmd.exe window
  :: to avoid pollution of PATH from, eg, some previous WCE compilation attempts.
diff -cr orig/src/resolver.c patch1/src/resolver.c
*** orig/src/resolver.c	2014-04-11 09:44:10.000000000 +0200
--- patch1/src/resolver.c	2014-06-09 15:57:21.406250000 +0200
***************
*** 92,98 ****
  #if defined(USE_WIN32) && !defined(_WIN32_WCE)
      HINSTANCE handle;
  
!     handle=LoadLibrary("ws2_32.dll"); /* IPv6 in Windows XP or higher */
      if(handle) {
          s_getaddrinfo=(GETADDRINFO)GetProcAddress(handle, "getaddrinfo");
          s_freeaddrinfo=(FREEADDRINFO)GetProcAddress(handle, "freeaddrinfo");
--- 92,98 ----
  #if defined(USE_WIN32) && !defined(_WIN32_WCE)
      HINSTANCE handle;
  
!     handle=LoadLibrary(TEXT("ws2_32.dll")); /* IPv6 in Windows XP or higher *//* pdelaage 20140529...unicode ! */
      if(handle) {
          s_getaddrinfo=(GETADDRINFO)GetProcAddress(handle, "getaddrinfo");
          s_freeaddrinfo=(FREEADDRINFO)GetProcAddress(handle, "freeaddrinfo");
***************
*** 101,107 ****
              return; /* IPv6 detected -> OK */
          FreeLibrary(handle);
      }
!     handle=LoadLibrary("wship6.dll"); /* experimental IPv6 for Windows 2000 */
      if(handle) {
          s_getaddrinfo=(GETADDRINFO)GetProcAddress(handle, "getaddrinfo");
          s_freeaddrinfo=(FREEADDRINFO)GetProcAddress(handle, "freeaddrinfo");
--- 101,107 ----
              return; /* IPv6 detected -> OK */
          FreeLibrary(handle);
      }
!     handle=LoadLibrary(TEXT("wship6.dll")); /* experimental IPv6 for Windows 2000 *//* pdelaage 20140609...unicode ! */
      if(handle) {
          s_getaddrinfo=(GETADDRINFO)GetProcAddress(handle, "getaddrinfo");
          s_freeaddrinfo=(FREEADDRINFO)GetProcAddress(handle, "freeaddrinfo");
diff -cr orig/src/resources.rc patch1/src/resources.rc
*** orig/src/resources.rc	2014-03-06 00:27:52.000000000 +0100
--- patch1/src/resources.rc	2014-06-09 20:56:52.031250000 +0200
***************
*** 89,94 ****
--- 89,96 ----
  ABOUTBOX DIALOG DISCARDABLE  0, 0, 140, 68
  STYLE DS_MODALFRAME|DS_CENTER|WS_POPUP|WS_CAPTION|WS_SYSMENU
  CAPTION "About stunnel"
+ /* pdelaage 20140609 : no more ugly font a la windows 3.1...stunnel deserves to look more "smart" */
+ FONT 8, "MS Sans Serif"
  BEGIN
      ICON            IDI_STUNNEL_MAIN, -1,                        9,  8,  18, 20
      LTEXT           "stunnel version", -1,                      30,  4,  52,  8
***************
*** 103,108 ****
--- 105,112 ----
  PASSBOX DIALOG DISCARDABLE 0, 0, 158, 51
  STYLE DS_MODALFRAME|DS_CENTER|WS_POPUP|WS_CAPTION|WS_SYSMENU
  CAPTION ""
+ /* pdelaage 20140609 : no more ugly font a la windows 3.1...stunnel deserves to look more "smart" */
+ FONT 8, "MS Sans Serif"
  BEGIN
      ICON            IDI_STUNNEL_MAIN, -1,     8,  6, 18, 20
      LTEXT           "Pass phrase:", -1,      33,  9, 50,  8
diff -cr orig/src/ui_win_cli.c patch1/src/ui_win_cli.c
*** orig/src/ui_win_cli.c	2014-03-26 18:13:01.000000000 +0100
--- patch1/src/ui_win_cli.c	2014-06-09 22:15:17.343750000 +0200
***************
*** 40,59 ****
  
  int main(int argc, char *argv[]) {
      static struct WSAData wsa_state;
!     char *c, stunnel_exe_path[MAX_PATH];
  
      /* set current working directory and engine path */
      GetModuleFileName(0, stunnel_exe_path, MAX_PATH);
!     c=strrchr(stunnel_exe_path, '\\'); /* last backslash */
      if(c) /* found */
!         c[1]='\0'; /* truncate program name */
  #ifndef _WIN32_WCE
      if(!SetCurrentDirectory(stunnel_exe_path)) {
!         fprintf(stderr, "Cannot set directory to %s", stunnel_exe_path);
          return 1;
      }
  #endif
!     _putenv_s("OPENSSL_ENGINES", stunnel_exe_path);
  
      str_init(); /* initialize per-thread string management */
      if(WSAStartup(MAKEWORD(1, 1), &wsa_state))
--- 40,64 ----
  
  int main(int argc, char *argv[]) {
      static struct WSAData wsa_state;
!     TCHAR *c, stunnel_exe_path[MAX_PATH];/* pdelaage 20140609 UNICODE : TCHAR for both vars, because of GetModuleFileName */
  
      /* set current working directory and engine path */
      GetModuleFileName(0, stunnel_exe_path, MAX_PATH);
!     c=_tcsrchr(stunnel_exe_path, TEXT('\\')); /* last backslash *//* pdelaage 20140526 UNICODE : strrchr replaced by _tcsrchr */
      if(c) /* found */
!         c[1]=TEXT('\0'); /* truncate program name *//* pdelaage 20140526 UNICODE : strrchr replaced by _tcsrchr, because of SetCurrentDirectory and  stunnel_exe_path */
  #ifndef _WIN32_WCE
      if(!SetCurrentDirectory(stunnel_exe_path)) {
! #ifdef UNICODE	/* pdelaage 20140526 QUESTION : shoud'nt we use s_log instead of fprintf ?? */
!         fprintf(stderr, "Cannot set directory to %ls", stunnel_exe_path);/* pdelaage 20140526 UNICODE format spec support */
! #else
!         fprintf(stderr, "Cannot set directory to %hs", stunnel_exe_path);
! #endif
! 		
          return 1;
      }
  #endif
!     _tputenv_s(TEXT("OPENSSL_ENGINES"), stunnel_exe_path);/* pdelaage 20140526 UNICODE */
  
      str_init(); /* initialize per-thread string management */
      if(WSAStartup(MAKEWORD(1, 1), &wsa_state))
diff -cr orig/src/ui_win_gui.c patch1/src/ui_win_gui.c
*** orig/src/ui_win_gui.c	2014-05-12 08:31:13.000000000 +0200
--- patch1/src/ui_win_gui.c	2014-06-09 22:26:24.812500000 +0200
***************
*** 54,60 ****
  #else /* MSDN claims that _WIN32 is always defined */
  #define STUNNEL_PLATFORM "Win32"
  #endif
! #define SERVICE_NAME "stunnel"
  #endif
  
  /* mingw-Patches-1825044 is missing in Debian Squeeze */
--- 54,62 ----
  #else /* MSDN claims that _WIN32 is always defined */
  #define STUNNEL_PLATFORM "Win32"
  #endif
! 
! #define SERVICE_NAME TEXT("stunnel") /* pdelaage 20140609 UNICODE */
! 
  #endif
  
  /* mingw-Patches-1825044 is missing in Debian Squeeze */
***************
*** 89,95 ****
  /* NT Service related function */
  #ifndef _WIN32_WCE
  NOEXPORT int service_initialize(void);
! NOEXPORT int service_install(LPTSTR);
  NOEXPORT int service_uninstall(void);
  NOEXPORT int service_start(void);
  NOEXPORT int service_stop(void);
--- 91,98 ----
  /* NT Service related function */
  #ifndef _WIN32_WCE
  NOEXPORT int service_initialize(void);
! /* pdelaage 20140609 : wrong prototype, the DEFINITION code further in that file is with LPSTR only, not lpTstr...static int service_install(LPTSTR); */
! NOEXPORT int service_install(LPSTR);
  NOEXPORT int service_uninstall(void);
  NOEXPORT int service_start(void);
  NOEXPORT int service_stop(void);
***************
*** 149,155 ****
  #endif
          int nCmdShow) {
      LPSTR command_line;
!     char *c, stunnel_exe_path[MAX_PATH];
  #ifndef _WIN32_WCE
      char *errmsg;
  #endif
--- 152,159 ----
  #endif
          int nCmdShow) {
      LPSTR command_line;
!  /* 20140609 pdelaage   char *c, stunnel_exe_path[MAX_PATH]; */
!     TCHAR *c, stunnel_exe_path[MAX_PATH];/* 20140609 pdelaage : UNICODE support for GetModuleFileName on W32/WCE */
  #ifndef _WIN32_WCE
      char *errmsg;
  #endif
***************
*** 167,197 ****
  
      parse_cmdline(command_line); /* setup global cmdline structure */
  
!     GetModuleFileName(0, stunnel_exe_path, MAX_PATH);
  
  #ifndef _WIN32_WCE
      /* find previous instances of the same executable */
      if(!cmdline.service && !cmdline.install && !cmdline.uninstall &&
              !cmdline.start && !cmdline.stop) {
!         EnumWindows(enum_windows, (LPARAM)stunnel_exe_path);
          if(cmdline.exit)
              return 0; /* in case EnumWindows didn't find a previous instance */
      }
  #endif
  
      /* set current working directory and engine path */
!     c=strrchr(stunnel_exe_path, '\\'); /* last backslash */
      if(c) /* found */
!         c[1]='\0'; /* truncate program name */
  #ifndef _WIN32_WCE
      if(!SetCurrentDirectory(stunnel_exe_path)) {
!         errmsg=str_printf("Cannot set directory to %s", stunnel_exe_path);
          message_box(errmsg, MB_ICONERROR);
          str_free(errmsg);
          return 1;
      }
  #endif
!     _putenv_s("OPENSSL_ENGINES", stunnel_exe_path);
  
      if(initialize_winsock())
          return 1;
--- 171,205 ----
  
      parse_cmdline(command_line); /* setup global cmdline structure */
  
!     GetModuleFileName(0, stunnel_exe_path, MAX_PATH);/* 20140609 pdelaage : requires UNICODE strings */
  
  #ifndef _WIN32_WCE
      /* find previous instances of the same executable */
      if(!cmdline.service && !cmdline.install && !cmdline.uninstall &&
              !cmdline.start && !cmdline.stop) {
!         EnumWindows(enum_windows, (LPARAM)stunnel_exe_path);/* 20140609 pdelaage : BE CAREFUL that enum_windows will CORRECTLY CAST to UNICODE ! done by my contribution there ...*/
          if(cmdline.exit)
              return 0; /* in case EnumWindows didn't find a previous instance */
      }
  #endif
  
      /* set current working directory and engine path */
!     c=_tcsrchr(stunnel_exe_path, TEXT('\\')); /* last backslash *//* pdelaage 20140609 unicode */
      if(c) /* found */
!         c[1]=TEXT('\0'); /* truncate program name */
  #ifndef _WIN32_WCE
      if(!SetCurrentDirectory(stunnel_exe_path)) {
! #ifdef UNICODE	/*  pdelaage 20140609 : UNICODE in printf format spec */
!         errmsg=str_printf("Cannot set directory to %ls", stunnel_exe_path);
! #else
!         errmsg=str_printf("Cannot set directory to %hs", stunnel_exe_path);
! #endif		
          message_box(errmsg, MB_ICONERROR);
          str_free(errmsg);
          return 1;
      }
  #endif
!     _tputenv_s(TEXT("OPENSSL_ENGINES"), stunnel_exe_path);/*  pdelaage 20140609 : UNICODE */
  
      if(initialize_winsock())
          return 1;
***************
*** 216,224 ****
  NOEXPORT BOOL CALLBACK enum_windows(HWND other_window_handle, LPARAM lParam) {
      DWORD pid;
      HINSTANCE hInstance;
!     char window_exe_path[MAX_PATH];
      HANDLE process_handle;
!     char *stunnel_exe_path=(char *)lParam;
  
      if(!other_window_handle)
          return TRUE;
--- 224,232 ----
  NOEXPORT BOOL CALLBACK enum_windows(HWND other_window_handle, LPARAM lParam) {
      DWORD pid;
      HINSTANCE hInstance;
!     TCHAR window_exe_path[MAX_PATH];/* pdelaage 20140609 UNICODE */
      HANDLE process_handle;
!     TCHAR *stunnel_exe_path=(TCHAR *)lParam;/* pdelaage 20140529 UNICODE */
  
      if(!other_window_handle)
          return TRUE;
***************
*** 235,241 ****
          CloseHandle(process_handle);
          return TRUE;
      }
!     if(strcmp(stunnel_exe_path, window_exe_path)) {
          CloseHandle(process_handle);
          return TRUE;
      }
--- 243,249 ----
          CloseHandle(process_handle);
          return TRUE;
      }
!     if(_tcscmp(stunnel_exe_path, window_exe_path)) { /* pdelaage 20140529 UNICODE */
          CloseHandle(process_handle);
          return TRUE;
      }
***************
*** 1083,1095 ****
  }
  
  NOEXPORT void edit_config(HWND main_window_handle) {
!     char cwd[MAX_PATH], *conf_path;
! 
      /* TODO: port it to WCE */
      if(is_admin()) {
          ShellExecute(main_window_handle, TEXT("open"),
!             TEXT("notepad.exe"), configuration_file,
              NULL, SW_SHOWNORMAL);
      } else { /* UAC workaround */
          if(strchr(configuration_file, '\\')) {
              conf_path=str_dup(configuration_file);
--- 1091,1110 ----
  }
  
  NOEXPORT void edit_config(HWND main_window_handle) {
!     TCHAR cwd[MAX_PATH];/* pdelaage 20140609 : unicode because of GetCurrentDirectory */
!     char *conf_path;
! 	TCHAR *conf_string; /* pdelaage 20140609 : needed for UNICODE ShellExecute, because "configuration_file" is JUST ASCII !! */
! 	
      /* TODO: port it to WCE */
      if(is_admin()) {
+ 		conf_string = str2tstr(configuration_file);
+ 	
          ShellExecute(main_window_handle, TEXT("open"),
!             TEXT("notepad.exe"), conf_string,/* pdelaage 20140609 : now UNICODE correct */
              NULL, SW_SHOWNORMAL);
+ 
+ 		str_free(conf_string);	
+ 		
      } else { /* UAC workaround */
          if(strchr(configuration_file, '\\')) {
              conf_path=str_dup(configuration_file);
***************
*** 1097,1105 ****
              GetCurrentDirectory(MAX_PATH, cwd);
              conf_path=str_printf("%s\\%s", cwd, configuration_file);
          }
          ShellExecute(main_window_handle, TEXT("runas"),
!             TEXT("notepad.exe"), conf_path,
!             NULL, SW_SHOWNORMAL);
          str_free(conf_path);
      }
  }
--- 1112,1125 ----
              GetCurrentDirectory(MAX_PATH, cwd);
              conf_path=str_printf("%s\\%s", cwd, configuration_file);
          }
+ 		
+ 		conf_string = str2tstr(conf_path);
+ 				
          ShellExecute(main_window_handle, TEXT("runas"),
!             TEXT("notepad.exe"), conf_string, /* pdelaage 20140609 : now UNICODE correct */
!             NULL, SW_SHOWNORMAL);	
! 			
!  		str_free(conf_string);				
          str_free(conf_path);
      }
  }
***************
*** 1127,1133 ****
  NOEXPORT int service_initialize(void) {
      SERVICE_TABLE_ENTRY serviceTable[]={{0, 0}, {0, 0}};
  
!     serviceTable[0].lpServiceName=SERVICE_NAME;
      serviceTable[0].lpServiceProc=service_main;
      global_options.option.taskbar=0; /* disable taskbar for security */
      if(!StartServiceCtrlDispatcher(serviceTable)) {
--- 1147,1153 ----
  NOEXPORT int service_initialize(void) {
      SERVICE_TABLE_ENTRY serviceTable[]={{0, 0}, {0, 0}};
  
!     serviceTable[0].lpServiceName=SERVICE_NAME;/* pdelaage 20140525 : UNICODE */
      serviceTable[0].lpServiceProc=service_main;
      global_options.option.taskbar=0; /* disable taskbar for security */
      if(!StartServiceCtrlDispatcher(serviceTable)) {
***************
*** 1139,1145 ****
  
  NOEXPORT int service_install(LPSTR command_line) {
      SC_HANDLE scm, service;
!     char stunnel_exe_path[MAX_PATH], *service_path;
  
      scm=OpenSCManager(0, 0, SC_MANAGER_CREATE_SERVICE);
      if(!scm) {
--- 1159,1166 ----
  
  NOEXPORT int service_install(LPSTR command_line) {
      SC_HANDLE scm, service;
!     TCHAR stunnel_exe_path[MAX_PATH], *tservice_path;/* pdelaage 20140609: UNICODE for GetModuleFileName, CreateService */
!     char *service_path;
  
      scm=OpenSCManager(0, 0, SC_MANAGER_CREATE_SERVICE);
      if(!scm) {
***************
*** 1147,1157 ****
          return 1;
      }
      GetModuleFileName(0, stunnel_exe_path, MAX_PATH);
!     service_path=str_printf("\"%s\" -service %s", stunnel_exe_path, command_line);
      service=CreateService(scm, SERVICE_NAME, SERVICE_NAME, SERVICE_ALL_ACCESS,
          SERVICE_WIN32_OWN_PROCESS|SERVICE_INTERACTIVE_PROCESS,
!         SERVICE_AUTO_START, SERVICE_ERROR_NORMAL, service_path,
          NULL, NULL, NULL, NULL, NULL);
      str_free(service_path);
      if(!service) {
          error_box("CreateService");
--- 1168,1186 ----
          return 1;
      }
      GetModuleFileName(0, stunnel_exe_path, MAX_PATH);
! 	#ifdef UNICODE /* pdelaage 20140609 : we CAN mix TCHAR* and char* in printf...provided we use the proper h or l FORMAT SPEC */
!     service_path=str_printf("\"%ls\" -service %hs", stunnel_exe_path, command_line);
! 	#else
!     service_path=str_printf("\"%hs\" -service %hs", stunnel_exe_path, command_line);
! 	#endif	
! 
! 	tservice_path = str2tstr(service_path);
! 	
      service=CreateService(scm, SERVICE_NAME, SERVICE_NAME, SERVICE_ALL_ACCESS,
          SERVICE_WIN32_OWN_PROCESS|SERVICE_INTERACTIVE_PROCESS,
!         SERVICE_AUTO_START, SERVICE_ERROR_NORMAL, tservice_path,
          NULL, NULL, NULL, NULL, NULL);
+     str_free(tservice_path);
      str_free(service_path);
      if(!service) {
          error_box("CreateService");
diff -cr orig/src/vc.mak patch1/src/vc.mak
*** orig/src/vc.mak	2014-06-09 01:15:37.000000000 +0200
--- patch1/src/vc.mak	2014-06-09 21:32:43.031250000 +0200
***************
*** 1,6 ****
--- 1,9 ----
  # vc.mak by Michal Trojnara 1998-2014
  # with help of David Gillingham <dgillingham at gmail.com>
  # with help of Pierre Delaage <delaage.pierre at free.fr>
+ # pdelaage 20140609 : added UNICODE optional FLAG
+ # pdelaage 20140609 : added WX (fails on warning) flag to detect subtle error prone cast
+ # pdelaage 20140609 : added _CRT_NON_CONFORMING_SWPRINTFS to explicitely support old fashioned stprintf in ui_win_gui.c
  
  # the compilation requires:
  # - Visual C++ 2005 Express Edition with Platform SDK
***************
*** 8,13 ****
--- 11,18 ----
  # - Visual C++ 2005 Professional Edition
  # - Visual C++ 2008 Express Edition
  
+ 
+ 
  !IF [ml64.exe /help >NUL 2>&1]
  TARGET=win32
  !ELSE
***************
*** 24,30 ****
  #FIPSDIR=$(SSLDIR)\include
  #LIBDIR=$(SSLDIR)\lib
  # or compile one yourself
! SSLDIR=..\..\openssl-1.0.1h-$(TARGET)
  INCDIR=$(SSLDIR)\inc32
  FIPSDIR=$(SSLDIR)\inc32
  LIBDIR=$(SSLDIR)\out32dll
--- 29,36 ----
  #FIPSDIR=$(SSLDIR)\include
  #LIBDIR=$(SSLDIR)\lib
  # or compile one yourself
! # pdelaage 20140609 SSLDIR=..\..\openssl-1.0.1h-$(TARGET)
! SSLDIR=C:\Users\pdelaage\Dvts\Contrib\openssl\v1.0.2-stable-SNAP-20121213\patch1
  INCDIR=$(SSLDIR)\inc32
  FIPSDIR=$(SSLDIR)\inc32
  LIBDIR=$(SSLDIR)\out32dll
***************
*** 51,57 ****
  CC=cl
  LINK=link
  
! CFLAGS=/MD /W3 /O2 /nologo /I"$(INCDIR)" /I"$(FIPSDIR)"
  LDFLAGS=/NOLOGO
  
  SHAREDLIBS=ws2_32.lib user32.lib shell32.lib
--- 57,72 ----
  CC=cl
  LINK=link
  
! # pdelaage 20140529 added unicode flag : because w32 unicode version helps to debug...W32/WCE ansi/unicode version...
! !ifdef UNICODESUPPORT
! UNICODEFLAGS=/DUNICODE -D_UNICODE
! !else
! UNICODEFLAGS=
! !endif 
! 
! # pdelaage 20140609 WX warning as error to detect subtle cast problems in ansi/unicode management.
! MORECFLAGS=/WX $(UNICODEFLAGS) /D_CRT_NON_CONFORMING_SWPRINTFS
! CFLAGS=/MD /W3 /O2 /nologo  $(MORECFLAGS) /I"$(INCDIR)" /I"$(FIPSDIR)"
  LDFLAGS=/NOLOGO
  
  SHAREDLIBS=ws2_32.lib user32.lib shell32.lib


More information about the stunnel-users mailing list