Index: src/cgi.c ================================================================== --- src/cgi.c +++ src/cgi.c @@ -24,12 +24,10 @@ #include "config.h" #ifdef _WIN32 # if defined(__MINGW32__) # include # endif -# include /* for Sleep once server works again */ -# define sleep Sleep /* windows does not have sleep, but Sleep */ #else # include # include # include # include Index: src/file.c ================================================================== --- src/file.c +++ src/file.c @@ -1147,11 +1147,11 @@ if( nChar==0 ){ free(zUnicode); return 0; } zUnicode[nChar] = '\0'; - WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE - toStdErr), zUnicode, nChar, &dummy, 0); + WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE - toStdErr), zUnicode, nChar, &dummy, 0); return nChar; #else return -1; /* No-op on unix */ #endif } Index: src/http_socket.c ================================================================== --- src/http_socket.c +++ src/http_socket.c @@ -30,12 +30,11 @@ #include "http_socket.h" #if defined(_WIN32) # if defined(__MINGW32__) # include # endif -# include /* for Sleep once server works again */ -# define sleep Sleep /* windows does not have sleep, but Sleep */ +# include #else # include # include # include # include Index: src/main.c ================================================================== --- src/main.c +++ src/main.c @@ -359,80 +359,79 @@ ** ** Results: ** Fills argcPtr with the number of arguments and argvPtr with the array ** of arguments. */ -#include -#define tchar_isspace(X) ((X)==TEXT(' ') || (X)==TEXT('\t')) +#define wchar_isspace(X) ((X)==L' ' || (X)==L'\t') static void parse_windows_command_line( int *argcPtr, /* Filled with number of argument strings. */ void *argvPtr /* Filled with argument strings (malloc'd). */ ){ - TCHAR *cmdLine, *p, *arg, *argSpace; - TCHAR **argv; + WCHAR *cmdLine, *p, *arg, *argSpace; + WCHAR **argv; int argc, size, inquote, copy, slashes; - cmdLine = GetCommandLine(); + cmdLine = GetCommandLineW(); /* ** Precompute an overly pessimistic guess at the number of arguments in ** the command line by counting non-space spans. */ size = 2; - for(p=cmdLine; *p!=TEXT('\0'); p++){ - if( tchar_isspace(*p) ){ + for(p=cmdLine; *p!=L'\0'; p++){ + if( wchar_isspace(*p) ){ size++; - while( tchar_isspace(*p) ){ + while( wchar_isspace(*p) ){ p++; } - if( *p==TEXT('\0') ){ + if( *p==L'\0' ){ break; } } } argSpace = fossil_malloc(size * sizeof(char*) - + (_tcslen(cmdLine) * sizeof(TCHAR)) + sizeof(TCHAR)); - argv = (TCHAR**)argSpace; - argSpace += size*(sizeof(char*)/sizeof(TCHAR)); + + (wcslen(cmdLine) * sizeof(WCHAR)) + sizeof(WCHAR)); + argv = (WCHAR**)argSpace; + argSpace += size*(sizeof(char*)/sizeof(WCHAR)); size--; p = cmdLine; for(argc=0; argc>= 1; } while( slashes ){ - *arg = TEXT('\\'); + *arg = L'\\'; arg++; slashes--; } - if( *p==TEXT('\0') || (!inquote && tchar_isspace(*p)) ){ + if( *p==L'\0' || (!inquote && wchar_isspace(*p)) ){ break; } if( copy!=0 ){ *arg = *p; arg++; @@ -442,11 +441,11 @@ *arg = '\0'; argSpace = arg + 1; } argv[argc] = NULL; *argcPtr = argc; - *((TCHAR ***)argvPtr) = argv; + *((WCHAR ***)argvPtr) = argv; } #endif /* defined(_WIN32) */ /* Index: src/makemake.tcl ================================================================== --- src/makemake.tcl +++ src/makemake.tcl @@ -432,11 +432,11 @@ # will run on the target platform. This is usually the same # as BCC, unless you are cross-compiling. This C compiler builds # the finished binary for fossil. The BCC compiler above is used # for building intermediate code-generator tools. # -TCC = $(PREFIX)gcc -Os -Wall -DUNICODE -D_UNICODE -L$(ZLIBDIR) -I$(ZINCDIR) +TCC = $(PREFIX)gcc -Os -Wall -L$(ZLIBDIR) -I$(ZINCDIR) #### Compile resources for use in building executables that will run # on the target platform. # RCC = $(PREFIX)windres -I$(SRCDIR) -I$(ZINCDIR) @@ -903,11 +903,11 @@ INCL = -I. -I$(SRCDIR) -I$B\win\include -I$(MSCDIR)\extra\include -I$(ZINCDIR) CFLAGS = -nologo -MT -O2 BCC = $(CC) $(CFLAGS) -TCC = $(CC) -c $(CFLAGS) -DUNICODE -D_UNICODE $(MSCDEF) $(SSL) $(INCL) +TCC = $(CC) -c $(CFLAGS) $(MSCDEF) $(SSL) $(INCL) LIBS = $(ZLIB) ws2_32.lib advapi32.lib $(SSLLIB) LIBDIR = -LIBPATH:$(MSCDIR)\extra\lib -LIBPATH:$(ZLIBDIR) } regsub -all {[-]D} $SQLITE_OPTIONS {/D} MSC_SQLITE_OPTIONS writeln "SQLITE_OPTIONS = $MSC_SQLITE_OPTIONS\n" Index: src/winhttp.c ================================================================== --- src/winhttp.c +++ src/winhttp.c @@ -146,11 +146,11 @@ SOCKET s = INVALID_SOCKET; SOCKADDR_IN addr; int idCnt = 0; int iPort = mnPort; Blob options; - TCHAR zTmpPath[MAX_PATH]; + WCHAR zTmpPath[MAX_PATH]; if( zStopper ) file_delete(zStopper); blob_zero(&options); if( zNotFound ){ blob_appendf(&options, " --notfound %s", zNotFound); @@ -191,11 +191,11 @@ }else{ fossil_fatal("unable to open listening socket on any" " port in the range %d..%d", mnPort, mxPort); } } - if( !GetTempPath(MAX_PATH, zTmpPath) ){ + if( !GetTempPathW(MAX_PATH, zTmpPath) ){ fossil_fatal("unable to get path to the temporary directory."); } zTempPrefix = mprintf("%sfossil_server_P%d_", fossil_unicode_to_utf8(zTmpPath), iPort); fossil_print("Listening for HTTP requests on TCP port %d\n", iPort); if( zBrowser ){ @@ -249,11 +249,11 @@ struct HttpService { int port; /* Port on which the http server should run */ const char *zNotFound; /* The --notfound option, or NULL */ int flags; /* One or more HTTP_SERVER_ flags */ int isRunningAsService; /* Are we running as a service ? */ - const TCHAR *zServiceName;/* Name of the service */ + const WCHAR *zServiceName;/* Name of the service */ SOCKET s; /* Socket on which the http server listens */ }; /* ** Variables used for running as windows service. @@ -268,35 +268,35 @@ ** to store the message string when done. */ static char *win32_get_last_errmsg(void){ DWORD nMsg; DWORD nErr = GetLastError(); - LPTSTR tmp = NULL; + LPWSTR tmp = NULL; char *zMsg = NULL; /* Try first to get the error text in english. */ - nMsg = FormatMessage( + nMsg = FormatMessageW( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, nErr, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), - (LPTSTR) &tmp, + (LPWSTR) &tmp, 0, NULL ); if( !nMsg ){ /* No english, get what the system has available. */ - nMsg = FormatMessage( + nMsg = FormatMessageW( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, nErr, 0, - (LPTSTR) &tmp, + (LPWSTR) &tmp, 0, NULL ); } if( nMsg ){ @@ -374,21 +374,21 @@ ** creates a new thread to execute the ServiceMain function (this function) ** of the service being started. */ static void WINAPI win32_http_service_main( DWORD argc, /* Number of arguments in argv */ - LPTSTR *argv /* Arguments passed */ + LPWSTR *argv /* Arguments passed */ ){ /* Update the service information. */ hsData.isRunningAsService = 1; if( argc>0 ){ hsData.zServiceName = argv[0]; } /* Register the service control handler function */ - sshStatusHandle = RegisterServiceCtrlHandler(TEXT(""), win32_http_service_ctrl); + sshStatusHandle = RegisterServiceCtrlHandlerW(L"", win32_http_service_ctrl); if( !sshStatusHandle ){ win32_report_service_status(SERVICE_STOPPED, NO_ERROR, 0); return; } @@ -428,30 +428,29 @@ int nPort, /* TCP port number */ const char *zNotFound, /* The --notfound option, or NULL */ int flags /* One or more HTTP_SERVER_ flags */ ){ /* Define the service table. */ - SERVICE_TABLE_ENTRY ServiceTable[] = - {{TEXT(""), (LPSERVICE_MAIN_FUNCTION)win32_http_service_main}, {NULL, NULL}}; + SERVICE_TABLE_ENTRYW ServiceTable[] = + {{L"", (LPSERVICE_MAIN_FUNCTIONW)win32_http_service_main}, {NULL, NULL}}; /* Initialize the HttpService structure. */ hsData.port = nPort; hsData.zNotFound = zNotFound; hsData.flags = flags; /* Try to start the control dispatcher thread for the service. */ - if( !StartServiceCtrlDispatcher(ServiceTable) ){ + if( !StartServiceCtrlDispatcherW(ServiceTable) ){ if( GetLastError()==ERROR_FAILED_SERVICE_CONTROLLER_CONNECT ){ return 1; }else{ fossil_fatal("error from StartServiceCtrlDispatcher()"); } } return 0; } -#ifdef _WIN32 /* dupe ifdef needed for mkindex ** COMMAND: winsrv* ** Usage: fossil winsrv METHOD ?SERVICE-NAME? ?OPTIONS? ** ** Where METHOD is one of: create delete show start stop. @@ -565,12 +564,12 @@ n = strlen(zMethod); if( strncmp(zMethod, "create", n)==0 ){ SC_HANDLE hScm; SC_HANDLE hSvc; - SERVICE_DESCRIPTION - svcDescr = {TEXT("Fossil - Distributed Software Configuration Management")}; + SERVICE_DESCRIPTIONW + svcDescr = {L"Fossil - Distributed Software Configuration Management"}; char *zErrFmt = "unable to create service '%s': %s"; DWORD dwStartType = SERVICE_DEMAND_START; const char *zDisplay = find_option("display", "D", 1); const char *zStart = find_option("start", "S", 1); const char *zUsername = find_option("username", "U", 1); @@ -621,13 +620,13 @@ if( zPort ) blob_appendf(&binPath, " --port %s", zPort); if( zNotFound ) blob_appendf(&binPath, " --notfound \"%s\"", zNotFound); if( zLocalAuth ) blob_append(&binPath, " --localauth", -1); blob_appendf(&binPath, " \"%s\"", g.zRepositoryName); /* Create the service. */ - hScm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); + hScm = OpenSCManagerW(NULL, NULL, SC_MANAGER_ALL_ACCESS); if( !hScm ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg()); - hSvc = CreateService( + hSvc = CreateServiceW( hScm, /* Handle to the SCM */ fossil_utf8_to_unicode(zSvcName), /* Name of the service */ fossil_utf8_to_unicode(zDisplay), /* Display name */ SERVICE_ALL_ACCESS, /* Desired access */ SERVICE_WIN32_OWN_PROCESS, /* Service type */ @@ -640,11 +639,11 @@ fossil_utf8_to_unicode(zUsername), /* Service account */ fossil_utf8_to_unicode(zPassword) /* Account password */ ); if( !hSvc ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg()); /* Set the service description. */ - ChangeServiceConfig2(hSvc, SERVICE_CONFIG_DESCRIPTION, &svcDescr); + ChangeServiceConfig2W(hSvc, SERVICE_CONFIG_DESCRIPTION, &svcDescr); fossil_print("Service '%s' successfully created.\n", zSvcName); CloseServiceHandle(hSvc); CloseServiceHandle(hScm); }else if( strncmp(zMethod, "delete", n)==0 ){ @@ -657,13 +656,13 @@ if( g.argc==4 ){ zSvcName = g.argv[3]; }else if( g.argc>4 ){ fossil_fatal("to much arguments for delete method."); } - hScm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); + hScm = OpenSCManagerW(NULL, NULL, SC_MANAGER_ALL_ACCESS); if( !hScm ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg()); - hSvc = OpenService(hScm, fossil_utf8_to_unicode(zSvcName), SERVICE_ALL_ACCESS); + hSvc = OpenServiceW(hScm, fossil_utf8_to_unicode(zSvcName), SERVICE_ALL_ACCESS); if( !hSvc ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg()); QueryServiceStatus(hSvc, &sstat); if( sstat.dwCurrentState!=SERVICE_STOPPED ){ fossil_print("Stopping service '%s'", zSvcName); if( sstat.dwCurrentState!=SERVICE_STOP_PENDING ){ @@ -692,12 +691,12 @@ }else if( strncmp(zMethod, "show", n)==0 ){ SC_HANDLE hScm; SC_HANDLE hSvc; SERVICE_STATUS sstat; - LPQUERY_SERVICE_CONFIG pSvcConfig; - LPSERVICE_DESCRIPTION pSvcDescr; + LPQUERY_SERVICE_CONFIGW pSvcConfig; + LPSERVICE_DESCRIPTIONW pSvcDescr; BOOL bStatus; DWORD nRequired; const char *zErrFmt = "unable to show service '%s': %s"; static const char *const zSvcTypes[] = { "Driver service", @@ -725,21 +724,21 @@ if( g.argc==4 ){ zSvcName = g.argv[3]; }else if( g.argc>4 ){ fossil_fatal("to much arguments for show method."); } - hScm = OpenSCManager(NULL, NULL, GENERIC_READ); + hScm = OpenSCManagerW(NULL, NULL, GENERIC_READ); if( !hScm ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg()); - hSvc = OpenService(hScm, fossil_utf8_to_unicode(zSvcName), GENERIC_READ); + hSvc = OpenServiceW(hScm, fossil_utf8_to_unicode(zSvcName), GENERIC_READ); if( !hSvc ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg()); /* Get the service configuration */ - bStatus = QueryServiceConfig(hSvc, NULL, 0, &nRequired); + bStatus = QueryServiceConfigW(hSvc, NULL, 0, &nRequired); if( !bStatus && GetLastError()!=ERROR_INSUFFICIENT_BUFFER ){ fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg()); } pSvcConfig = fossil_malloc(nRequired); - bStatus = QueryServiceConfig(hSvc, pSvcConfig, nRequired, &nRequired); + bStatus = QueryServiceConfigW(hSvc, pSvcConfig, nRequired, &nRequired); if( !bStatus ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg()); /* Translate the service type */ switch( pSvcConfig->dwServiceType ){ case SERVICE_KERNEL_DRIVER: zSvcType = zSvcTypes[0]; break; case SERVICE_FILE_SYSTEM_DRIVER: zSvcType = zSvcTypes[1]; break; @@ -754,17 +753,17 @@ case SERVICE_AUTO_START: zSvcStartType = zSvcStartTypes[2]; break; case SERVICE_DEMAND_START: zSvcStartType = zSvcStartTypes[3]; break; case SERVICE_DISABLED: zSvcStartType = zSvcStartTypes[4]; break; } /* Get the service description. */ - bStatus = QueryServiceConfig2(hSvc, SERVICE_CONFIG_DESCRIPTION, + bStatus = QueryServiceConfig2W(hSvc, SERVICE_CONFIG_DESCRIPTION, NULL, 0, &nRequired); if( !bStatus && GetLastError()!=ERROR_INSUFFICIENT_BUFFER ){ fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg()); } pSvcDescr = fossil_malloc(nRequired); - bStatus = QueryServiceConfig2(hSvc, SERVICE_CONFIG_DESCRIPTION, + bStatus = QueryServiceConfig2W(hSvc, SERVICE_CONFIG_DESCRIPTION, (LPBYTE)pSvcDescr, nRequired, &nRequired); if( !bStatus ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg()); /* Retrieves the current status of the specified service. */ bStatus = QueryServiceStatus(hSvc, &sstat); if( !bStatus ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg()); @@ -807,19 +806,19 @@ if( g.argc==4 ){ zSvcName = g.argv[3]; }else if( g.argc>4 ){ fossil_fatal("to much arguments for start method."); } - hScm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); + hScm = OpenSCManagerW(NULL, NULL, SC_MANAGER_ALL_ACCESS); if( !hScm ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg()); - hSvc = OpenService(hScm, fossil_utf8_to_unicode(zSvcName), SERVICE_ALL_ACCESS); + hSvc = OpenServiceW(hScm, fossil_utf8_to_unicode(zSvcName), SERVICE_ALL_ACCESS); if( !hSvc ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg()); QueryServiceStatus(hSvc, &sstat); if( sstat.dwCurrentState!=SERVICE_RUNNING ){ fossil_print("Starting service '%s'", zSvcName); if( sstat.dwCurrentState!=SERVICE_START_PENDING ){ - if( !StartService(hSvc, 0, NULL) ){ + if( !StartServiceW(hSvc, 0, NULL) ){ fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg()); } } while( sstat.dwCurrentState!=SERVICE_RUNNING ){ Sleep(100); @@ -843,13 +842,13 @@ if( g.argc==4 ){ zSvcName = g.argv[3]; }else if( g.argc>4 ){ fossil_fatal("to much arguments for stop method."); } - hScm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); + hScm = OpenSCManagerW(NULL, NULL, SC_MANAGER_ALL_ACCESS); if( !hScm ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg()); - hSvc = OpenService(hScm, fossil_utf8_to_unicode(zSvcName), SERVICE_ALL_ACCESS); + hSvc = OpenServiceW(hScm, fossil_utf8_to_unicode(zSvcName), SERVICE_ALL_ACCESS); if( !hSvc ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg()); QueryServiceStatus(hSvc, &sstat); if( sstat.dwCurrentState!=SERVICE_STOPPED ){ fossil_print("Stopping service '%s'", zSvcName); if( sstat.dwCurrentState!=SERVICE_STOP_PENDING ){ @@ -873,8 +872,6 @@ fossil_fatal("METHOD should be one of:" " create delete show start stop"); } return; } -#endif /* _WIN32 */ - #endif /* _WIN32 -- This code is for win32 only */ Index: win/Makefile.mingw ================================================================== --- win/Makefile.mingw +++ win/Makefile.mingw @@ -104,11 +104,11 @@ # will run on the target platform. This is usually the same # as BCC, unless you are cross-compiling. This C compiler builds # the finished binary for fossil. The BCC compiler above is used # for building intermediate code-generator tools. # -TCC = $(PREFIX)gcc -Os -Wall -DUNICODE -D_UNICODE -L$(ZLIBDIR) -I$(ZINCDIR) +TCC = $(PREFIX)gcc -Os -Wall -L$(ZLIBDIR) -I$(ZINCDIR) #### Compile resources for use in building executables that will run # on the target platform. # RCC = $(PREFIX)windres -I$(SRCDIR) -I$(ZINCDIR) Index: win/Makefile.mingw.mistachkin ================================================================== --- win/Makefile.mingw.mistachkin +++ win/Makefile.mingw.mistachkin @@ -104,11 +104,11 @@ # will run on the target platform. This is usually the same # as BCC, unless you are cross-compiling. This C compiler builds # the finished binary for fossil. The BCC compiler above is used # for building intermediate code-generator tools. # -TCC = $(PREFIX)gcc -Os -Wall -DUNICODE -D_UNICODE -L$(ZLIBDIR) -I$(ZINCDIR) +TCC = $(PREFIX)gcc -Os -Wall -L$(ZLIBDIR) -I$(ZINCDIR) #### Compile resources for use in building executables that will run # on the target platform. # RCC = $(PREFIX)windres -I$(SRCDIR) -I$(ZINCDIR) Index: win/Makefile.msc ================================================================== --- win/Makefile.msc +++ win/Makefile.msc @@ -34,11 +34,11 @@ INCL = -I. -I$(SRCDIR) -I$B\win\include -I$(MSCDIR)\extra\include -I$(ZINCDIR) CFLAGS = -nologo -MT -O2 BCC = $(CC) $(CFLAGS) -TCC = $(CC) -c $(CFLAGS) -DUNICODE -D_UNICODE $(MSCDEF) $(SSL) $(INCL) +TCC = $(CC) -c $(CFLAGS) $(MSCDEF) $(SSL) $(INCL) LIBS = $(ZLIB) ws2_32.lib advapi32.lib $(SSLLIB) LIBDIR = -LIBPATH:$(MSCDIR)\extra\lib -LIBPATH:$(ZLIBDIR) SQLITE_OPTIONS = /DSQLITE_OMIT_LOAD_EXTENSION=1 /DSQLITE_THREADSAFE=0 /DSQLITE_DEFAULT_FILE_FORMAT=4 /DSQLITE_ENABLE_STAT3 /Dlocaltime=fossil_localtime /DSQLITE_ENABLE_LOCKING_STYLE=0