Fossil SCM

Merge the remaining Win32 TCHAR cleanup to trunk.

mistachkin 2012-09-23 04:41 trunk merge
Commit 33fb8891375fc74291e1e2726e8079d378733e4d
-2
--- src/cgi.c
+++ src/cgi.c
@@ -24,12 +24,10 @@
2424
#include "config.h"
2525
#ifdef _WIN32
2626
# if defined(__MINGW32__)
2727
# include <ws2tcpip.h>
2828
# endif
29
-# include <windows.h> /* for Sleep once server works again */
30
-# define sleep Sleep /* windows does not have sleep, but Sleep */
3129
#else
3230
# include <sys/socket.h>
3331
# include <netinet/in.h>
3432
# include <arpa/inet.h>
3533
# include <sys/times.h>
3634
--- src/cgi.c
+++ src/cgi.c
@@ -24,12 +24,10 @@
24 #include "config.h"
25 #ifdef _WIN32
26 # if defined(__MINGW32__)
27 # include <ws2tcpip.h>
28 # endif
29 # include <windows.h> /* for Sleep once server works again */
30 # define sleep Sleep /* windows does not have sleep, but Sleep */
31 #else
32 # include <sys/socket.h>
33 # include <netinet/in.h>
34 # include <arpa/inet.h>
35 # include <sys/times.h>
36
--- src/cgi.c
+++ src/cgi.c
@@ -24,12 +24,10 @@
24 #include "config.h"
25 #ifdef _WIN32
26 # if defined(__MINGW32__)
27 # include <ws2tcpip.h>
28 # endif
 
 
29 #else
30 # include <sys/socket.h>
31 # include <netinet/in.h>
32 # include <arpa/inet.h>
33 # include <sys/times.h>
34
+1 -1
--- src/file.c
+++ src/file.c
@@ -1147,11 +1147,11 @@
11471147
if( nChar==0 ){
11481148
free(zUnicode);
11491149
return 0;
11501150
}
11511151
zUnicode[nChar] = '\0';
1152
- WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE - toStdErr), zUnicode, nChar, &dummy, 0);
1152
+ WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE - toStdErr), zUnicode, nChar, &dummy, 0);
11531153
return nChar;
11541154
#else
11551155
return -1; /* No-op on unix */
11561156
#endif
11571157
}
11581158
--- src/file.c
+++ src/file.c
@@ -1147,11 +1147,11 @@
1147 if( nChar==0 ){
1148 free(zUnicode);
1149 return 0;
1150 }
1151 zUnicode[nChar] = '\0';
1152 WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE - toStdErr), zUnicode, nChar, &dummy, 0);
1153 return nChar;
1154 #else
1155 return -1; /* No-op on unix */
1156 #endif
1157 }
1158
--- src/file.c
+++ src/file.c
@@ -1147,11 +1147,11 @@
1147 if( nChar==0 ){
1148 free(zUnicode);
1149 return 0;
1150 }
1151 zUnicode[nChar] = '\0';
1152 WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE - toStdErr), zUnicode, nChar, &dummy, 0);
1153 return nChar;
1154 #else
1155 return -1; /* No-op on unix */
1156 #endif
1157 }
1158
--- src/http_socket.c
+++ src/http_socket.c
@@ -30,12 +30,11 @@
3030
#include "http_socket.h"
3131
#if defined(_WIN32)
3232
# if defined(__MINGW32__)
3333
# include <ws2tcpip.h>
3434
# endif
35
-# include <windows.h> /* for Sleep once server works again */
36
-# define sleep Sleep /* windows does not have sleep, but Sleep */
35
+# include <windows.h>
3736
#else
3837
# include <netinet/in.h>
3938
# include <arpa/inet.h>
4039
# include <sys/socket.h>
4140
# include <netdb.h>
4241
--- src/http_socket.c
+++ src/http_socket.c
@@ -30,12 +30,11 @@
30 #include "http_socket.h"
31 #if defined(_WIN32)
32 # if defined(__MINGW32__)
33 # include <ws2tcpip.h>
34 # endif
35 # include <windows.h> /* for Sleep once server works again */
36 # define sleep Sleep /* windows does not have sleep, but Sleep */
37 #else
38 # include <netinet/in.h>
39 # include <arpa/inet.h>
40 # include <sys/socket.h>
41 # include <netdb.h>
42
--- src/http_socket.c
+++ src/http_socket.c
@@ -30,12 +30,11 @@
30 #include "http_socket.h"
31 #if defined(_WIN32)
32 # if defined(__MINGW32__)
33 # include <ws2tcpip.h>
34 # endif
35 # include <windows.h>
 
36 #else
37 # include <netinet/in.h>
38 # include <arpa/inet.h>
39 # include <sys/socket.h>
40 # include <netdb.h>
41
+1 -1
--- src/main.c
+++ src/main.c
@@ -368,11 +368,11 @@
368368
){
369369
WCHAR *cmdLine, *p, *arg, *argSpace;
370370
WCHAR **argv;
371371
int argc, size, inquote, copy, slashes;
372372
373
- cmdLine = GetCommandLine();
373
+ cmdLine = GetCommandLineW();
374374
375375
/*
376376
** Precompute an overly pessimistic guess at the number of arguments in
377377
** the command line by counting non-space spans.
378378
*/
379379
--- src/main.c
+++ src/main.c
@@ -368,11 +368,11 @@
368 ){
369 WCHAR *cmdLine, *p, *arg, *argSpace;
370 WCHAR **argv;
371 int argc, size, inquote, copy, slashes;
372
373 cmdLine = GetCommandLine();
374
375 /*
376 ** Precompute an overly pessimistic guess at the number of arguments in
377 ** the command line by counting non-space spans.
378 */
379
--- src/main.c
+++ src/main.c
@@ -368,11 +368,11 @@
368 ){
369 WCHAR *cmdLine, *p, *arg, *argSpace;
370 WCHAR **argv;
371 int argc, size, inquote, copy, slashes;
372
373 cmdLine = GetCommandLineW();
374
375 /*
376 ** Precompute an overly pessimistic guess at the number of arguments in
377 ** the command line by counting non-space spans.
378 */
379
+1 -1
--- src/main.c
+++ src/main.c
@@ -368,11 +368,11 @@
368368
){
369369
WCHAR *cmdLine, *p, *arg, *argSpace;
370370
WCHAR **argv;
371371
int argc, size, inquote, copy, slashes;
372372
373
- cmdLine = GetCommandLine();
373
+ cmdLine = GetCommandLineW();
374374
375375
/*
376376
** Precompute an overly pessimistic guess at the number of arguments in
377377
** the command line by counting non-space spans.
378378
*/
379379
--- src/main.c
+++ src/main.c
@@ -368,11 +368,11 @@
368 ){
369 WCHAR *cmdLine, *p, *arg, *argSpace;
370 WCHAR **argv;
371 int argc, size, inquote, copy, slashes;
372
373 cmdLine = GetCommandLine();
374
375 /*
376 ** Precompute an overly pessimistic guess at the number of arguments in
377 ** the command line by counting non-space spans.
378 */
379
--- src/main.c
+++ src/main.c
@@ -368,11 +368,11 @@
368 ){
369 WCHAR *cmdLine, *p, *arg, *argSpace;
370 WCHAR **argv;
371 int argc, size, inquote, copy, slashes;
372
373 cmdLine = GetCommandLineW();
374
375 /*
376 ** Precompute an overly pessimistic guess at the number of arguments in
377 ** the command line by counting non-space spans.
378 */
379
--- src/makemake.tcl
+++ src/makemake.tcl
@@ -432,11 +432,11 @@
432432
# will run on the target platform. This is usually the same
433433
# as BCC, unless you are cross-compiling. This C compiler builds
434434
# the finished binary for fossil. The BCC compiler above is used
435435
# for building intermediate code-generator tools.
436436
#
437
-TCC = $(PREFIX)gcc -Os -Wall -DUNICODE -D_UNICODE -L$(ZLIBDIR) -I$(ZINCDIR)
437
+TCC = $(PREFIX)gcc -Os -Wall -L$(ZLIBDIR) -I$(ZINCDIR)
438438
439439
#### Compile resources for use in building executables that will run
440440
# on the target platform.
441441
#
442442
RCC = $(PREFIX)windres -I$(SRCDIR) -I$(ZINCDIR)
@@ -903,11 +903,11 @@
903903
904904
INCL = -I. -I$(SRCDIR) -I$B\win\include -I$(MSCDIR)\extra\include -I$(ZINCDIR)
905905
906906
CFLAGS = -nologo -MT -O2
907907
BCC = $(CC) $(CFLAGS)
908
-TCC = $(CC) -c $(CFLAGS) -DUNICODE -D_UNICODE $(MSCDEF) $(SSL) $(INCL)
908
+TCC = $(CC) -c $(CFLAGS) $(MSCDEF) $(SSL) $(INCL)
909909
LIBS = $(ZLIB) ws2_32.lib advapi32.lib $(SSLLIB)
910910
LIBDIR = -LIBPATH:$(MSCDIR)\extra\lib -LIBPATH:$(ZLIBDIR)
911911
}
912912
regsub -all {[-]D} $SQLITE_OPTIONS {/D} MSC_SQLITE_OPTIONS
913913
writeln "SQLITE_OPTIONS = $MSC_SQLITE_OPTIONS\n"
914914
--- src/makemake.tcl
+++ src/makemake.tcl
@@ -432,11 +432,11 @@
432 # will run on the target platform. This is usually the same
433 # as BCC, unless you are cross-compiling. This C compiler builds
434 # the finished binary for fossil. The BCC compiler above is used
435 # for building intermediate code-generator tools.
436 #
437 TCC = $(PREFIX)gcc -Os -Wall -DUNICODE -D_UNICODE -L$(ZLIBDIR) -I$(ZINCDIR)
438
439 #### Compile resources for use in building executables that will run
440 # on the target platform.
441 #
442 RCC = $(PREFIX)windres -I$(SRCDIR) -I$(ZINCDIR)
@@ -903,11 +903,11 @@
903
904 INCL = -I. -I$(SRCDIR) -I$B\win\include -I$(MSCDIR)\extra\include -I$(ZINCDIR)
905
906 CFLAGS = -nologo -MT -O2
907 BCC = $(CC) $(CFLAGS)
908 TCC = $(CC) -c $(CFLAGS) -DUNICODE -D_UNICODE $(MSCDEF) $(SSL) $(INCL)
909 LIBS = $(ZLIB) ws2_32.lib advapi32.lib $(SSLLIB)
910 LIBDIR = -LIBPATH:$(MSCDIR)\extra\lib -LIBPATH:$(ZLIBDIR)
911 }
912 regsub -all {[-]D} $SQLITE_OPTIONS {/D} MSC_SQLITE_OPTIONS
913 writeln "SQLITE_OPTIONS = $MSC_SQLITE_OPTIONS\n"
914
--- src/makemake.tcl
+++ src/makemake.tcl
@@ -432,11 +432,11 @@
432 # will run on the target platform. This is usually the same
433 # as BCC, unless you are cross-compiling. This C compiler builds
434 # the finished binary for fossil. The BCC compiler above is used
435 # for building intermediate code-generator tools.
436 #
437 TCC = $(PREFIX)gcc -Os -Wall -L$(ZLIBDIR) -I$(ZINCDIR)
438
439 #### Compile resources for use in building executables that will run
440 # on the target platform.
441 #
442 RCC = $(PREFIX)windres -I$(SRCDIR) -I$(ZINCDIR)
@@ -903,11 +903,11 @@
903
904 INCL = -I. -I$(SRCDIR) -I$B\win\include -I$(MSCDIR)\extra\include -I$(ZINCDIR)
905
906 CFLAGS = -nologo -MT -O2
907 BCC = $(CC) $(CFLAGS)
908 TCC = $(CC) -c $(CFLAGS) $(MSCDEF) $(SSL) $(INCL)
909 LIBS = $(ZLIB) ws2_32.lib advapi32.lib $(SSLLIB)
910 LIBDIR = -LIBPATH:$(MSCDIR)\extra\lib -LIBPATH:$(ZLIBDIR)
911 }
912 regsub -all {[-]D} $SQLITE_OPTIONS {/D} MSC_SQLITE_OPTIONS
913 writeln "SQLITE_OPTIONS = $MSC_SQLITE_OPTIONS\n"
914
+30 -33
--- src/winhttp.c
+++ src/winhttp.c
@@ -191,11 +191,11 @@
191191
}else{
192192
fossil_fatal("unable to open listening socket on any"
193193
" port in the range %d..%d", mnPort, mxPort);
194194
}
195195
}
196
- if( !GetTempPath(MAX_PATH, zTmpPath) ){
196
+ if( !GetTempPathW(MAX_PATH, zTmpPath) ){
197197
fossil_fatal("unable to get path to the temporary directory.");
198198
}
199199
zTempPrefix = mprintf("%sfossil_server_P%d_", fossil_unicode_to_utf8(zTmpPath), iPort);
200200
fossil_print("Listening for HTTP requests on TCP port %d\n", iPort);
201201
if( zBrowser ){
@@ -268,35 +268,35 @@
268268
** to store the message string when done.
269269
*/
270270
static char *win32_get_last_errmsg(void){
271271
DWORD nMsg;
272272
DWORD nErr = GetLastError();
273
- LPTSTR tmp = NULL;
273
+ LPWSTR tmp = NULL;
274274
char *zMsg = NULL;
275275
276276
/* Try first to get the error text in english. */
277
- nMsg = FormatMessage(
277
+ nMsg = FormatMessageW(
278278
FORMAT_MESSAGE_ALLOCATE_BUFFER |
279279
FORMAT_MESSAGE_FROM_SYSTEM |
280280
FORMAT_MESSAGE_IGNORE_INSERTS,
281281
NULL,
282282
nErr,
283283
MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),
284
- (LPTSTR) &tmp,
284
+ (LPWSTR) &tmp,
285285
0,
286286
NULL
287287
);
288288
if( !nMsg ){
289289
/* No english, get what the system has available. */
290
- nMsg = FormatMessage(
290
+ nMsg = FormatMessageW(
291291
FORMAT_MESSAGE_ALLOCATE_BUFFER |
292292
FORMAT_MESSAGE_FROM_SYSTEM |
293293
FORMAT_MESSAGE_IGNORE_INSERTS,
294294
NULL,
295295
nErr,
296296
0,
297
- (LPTSTR) &tmp,
297
+ (LPWSTR) &tmp,
298298
0,
299299
NULL
300300
);
301301
}
302302
if( nMsg ){
@@ -374,21 +374,21 @@
374374
** creates a new thread to execute the ServiceMain function (this function)
375375
** of the service being started.
376376
*/
377377
static void WINAPI win32_http_service_main(
378378
DWORD argc, /* Number of arguments in argv */
379
- LPTSTR *argv /* Arguments passed */
379
+ LPWSTR *argv /* Arguments passed */
380380
){
381381
382382
/* Update the service information. */
383383
hsData.isRunningAsService = 1;
384384
if( argc>0 ){
385385
hsData.zServiceName = argv[0];
386386
}
387387
388388
/* Register the service control handler function */
389
- sshStatusHandle = RegisterServiceCtrlHandler(L"", win32_http_service_ctrl);
389
+ sshStatusHandle = RegisterServiceCtrlHandlerW(L"", win32_http_service_ctrl);
390390
if( !sshStatusHandle ){
391391
win32_report_service_status(SERVICE_STOPPED, NO_ERROR, 0);
392392
return;
393393
}
394394
@@ -428,30 +428,29 @@
428428
int nPort, /* TCP port number */
429429
const char *zNotFound, /* The --notfound option, or NULL */
430430
int flags /* One or more HTTP_SERVER_ flags */
431431
){
432432
/* Define the service table. */
433
- SERVICE_TABLE_ENTRY ServiceTable[] =
434
- {{L"", (LPSERVICE_MAIN_FUNCTION)win32_http_service_main}, {NULL, NULL}};
433
+ SERVICE_TABLE_ENTRYW ServiceTable[] =
434
+ {{L"", (LPSERVICE_MAIN_FUNCTIONW)win32_http_service_main}, {NULL, NULL}};
435435
436436
/* Initialize the HttpService structure. */
437437
hsData.port = nPort;
438438
hsData.zNotFound = zNotFound;
439439
hsData.flags = flags;
440440
441441
/* Try to start the control dispatcher thread for the service. */
442
- if( !StartServiceCtrlDispatcher(ServiceTable) ){
442
+ if( !StartServiceCtrlDispatcherW(ServiceTable) ){
443443
if( GetLastError()==ERROR_FAILED_SERVICE_CONTROLLER_CONNECT ){
444444
return 1;
445445
}else{
446446
fossil_fatal("error from StartServiceCtrlDispatcher()");
447447
}
448448
}
449449
return 0;
450450
}
451451
452
-#ifdef _WIN32
453452
/* dupe ifdef needed for mkindex
454453
** COMMAND: winsrv*
455454
** Usage: fossil winsrv METHOD ?SERVICE-NAME? ?OPTIONS?
456455
**
457456
** Where METHOD is one of: create delete show start stop.
@@ -565,11 +564,11 @@
565564
n = strlen(zMethod);
566565
567566
if( strncmp(zMethod, "create", n)==0 ){
568567
SC_HANDLE hScm;
569568
SC_HANDLE hSvc;
570
- SERVICE_DESCRIPTION
569
+ SERVICE_DESCRIPTIONW
571570
svcDescr = {L"Fossil - Distributed Software Configuration Management"};
572571
char *zErrFmt = "unable to create service '%s': %s";
573572
DWORD dwStartType = SERVICE_DEMAND_START;
574573
const char *zDisplay = find_option("display", "D", 1);
575574
const char *zStart = find_option("start", "S", 1);
@@ -621,13 +620,13 @@
621620
if( zPort ) blob_appendf(&binPath, " --port %s", zPort);
622621
if( zNotFound ) blob_appendf(&binPath, " --notfound \"%s\"", zNotFound);
623622
if( zLocalAuth ) blob_append(&binPath, " --localauth", -1);
624623
blob_appendf(&binPath, " \"%s\"", g.zRepositoryName);
625624
/* Create the service. */
626
- hScm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
625
+ hScm = OpenSCManagerW(NULL, NULL, SC_MANAGER_ALL_ACCESS);
627626
if( !hScm ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
628
- hSvc = CreateService(
627
+ hSvc = CreateServiceW(
629628
hScm, /* Handle to the SCM */
630629
fossil_utf8_to_unicode(zSvcName), /* Name of the service */
631630
fossil_utf8_to_unicode(zDisplay), /* Display name */
632631
SERVICE_ALL_ACCESS, /* Desired access */
633632
SERVICE_WIN32_OWN_PROCESS, /* Service type */
@@ -640,11 +639,11 @@
640639
fossil_utf8_to_unicode(zUsername), /* Service account */
641640
fossil_utf8_to_unicode(zPassword) /* Account password */
642641
);
643642
if( !hSvc ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
644643
/* Set the service description. */
645
- ChangeServiceConfig2(hSvc, SERVICE_CONFIG_DESCRIPTION, &svcDescr);
644
+ ChangeServiceConfig2W(hSvc, SERVICE_CONFIG_DESCRIPTION, &svcDescr);
646645
fossil_print("Service '%s' successfully created.\n", zSvcName);
647646
CloseServiceHandle(hSvc);
648647
CloseServiceHandle(hScm);
649648
}else
650649
if( strncmp(zMethod, "delete", n)==0 ){
@@ -657,13 +656,13 @@
657656
if( g.argc==4 ){
658657
zSvcName = g.argv[3];
659658
}else if( g.argc>4 ){
660659
fossil_fatal("to much arguments for delete method.");
661660
}
662
- hScm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
661
+ hScm = OpenSCManagerW(NULL, NULL, SC_MANAGER_ALL_ACCESS);
663662
if( !hScm ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
664
- hSvc = OpenService(hScm, fossil_utf8_to_unicode(zSvcName), SERVICE_ALL_ACCESS);
663
+ hSvc = OpenServiceW(hScm, fossil_utf8_to_unicode(zSvcName), SERVICE_ALL_ACCESS);
665664
if( !hSvc ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
666665
QueryServiceStatus(hSvc, &sstat);
667666
if( sstat.dwCurrentState!=SERVICE_STOPPED ){
668667
fossil_print("Stopping service '%s'", zSvcName);
669668
if( sstat.dwCurrentState!=SERVICE_STOP_PENDING ){
@@ -692,12 +691,12 @@
692691
}else
693692
if( strncmp(zMethod, "show", n)==0 ){
694693
SC_HANDLE hScm;
695694
SC_HANDLE hSvc;
696695
SERVICE_STATUS sstat;
697
- LPQUERY_SERVICE_CONFIG pSvcConfig;
698
- LPSERVICE_DESCRIPTION pSvcDescr;
696
+ LPQUERY_SERVICE_CONFIGW pSvcConfig;
697
+ LPSERVICE_DESCRIPTIONW pSvcDescr;
699698
BOOL bStatus;
700699
DWORD nRequired;
701700
const char *zErrFmt = "unable to show service '%s': %s";
702701
static const char *const zSvcTypes[] = {
703702
"Driver service",
@@ -725,21 +724,21 @@
725724
if( g.argc==4 ){
726725
zSvcName = g.argv[3];
727726
}else if( g.argc>4 ){
728727
fossil_fatal("to much arguments for show method.");
729728
}
730
- hScm = OpenSCManager(NULL, NULL, GENERIC_READ);
729
+ hScm = OpenSCManagerW(NULL, NULL, GENERIC_READ);
731730
if( !hScm ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
732
- hSvc = OpenService(hScm, fossil_utf8_to_unicode(zSvcName), GENERIC_READ);
731
+ hSvc = OpenServiceW(hScm, fossil_utf8_to_unicode(zSvcName), GENERIC_READ);
733732
if( !hSvc ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
734733
/* Get the service configuration */
735
- bStatus = QueryServiceConfig(hSvc, NULL, 0, &nRequired);
734
+ bStatus = QueryServiceConfigW(hSvc, NULL, 0, &nRequired);
736735
if( !bStatus && GetLastError()!=ERROR_INSUFFICIENT_BUFFER ){
737736
fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
738737
}
739738
pSvcConfig = fossil_malloc(nRequired);
740
- bStatus = QueryServiceConfig(hSvc, pSvcConfig, nRequired, &nRequired);
739
+ bStatus = QueryServiceConfigW(hSvc, pSvcConfig, nRequired, &nRequired);
741740
if( !bStatus ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
742741
/* Translate the service type */
743742
switch( pSvcConfig->dwServiceType ){
744743
case SERVICE_KERNEL_DRIVER: zSvcType = zSvcTypes[0]; break;
745744
case SERVICE_FILE_SYSTEM_DRIVER: zSvcType = zSvcTypes[1]; break;
@@ -754,17 +753,17 @@
754753
case SERVICE_AUTO_START: zSvcStartType = zSvcStartTypes[2]; break;
755754
case SERVICE_DEMAND_START: zSvcStartType = zSvcStartTypes[3]; break;
756755
case SERVICE_DISABLED: zSvcStartType = zSvcStartTypes[4]; break;
757756
}
758757
/* Get the service description. */
759
- bStatus = QueryServiceConfig2(hSvc, SERVICE_CONFIG_DESCRIPTION,
758
+ bStatus = QueryServiceConfig2W(hSvc, SERVICE_CONFIG_DESCRIPTION,
760759
NULL, 0, &nRequired);
761760
if( !bStatus && GetLastError()!=ERROR_INSUFFICIENT_BUFFER ){
762761
fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
763762
}
764763
pSvcDescr = fossil_malloc(nRequired);
765
- bStatus = QueryServiceConfig2(hSvc, SERVICE_CONFIG_DESCRIPTION,
764
+ bStatus = QueryServiceConfig2W(hSvc, SERVICE_CONFIG_DESCRIPTION,
766765
(LPBYTE)pSvcDescr, nRequired, &nRequired);
767766
if( !bStatus ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
768767
/* Retrieves the current status of the specified service. */
769768
bStatus = QueryServiceStatus(hSvc, &sstat);
770769
if( !bStatus ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
@@ -807,19 +806,19 @@
807806
if( g.argc==4 ){
808807
zSvcName = g.argv[3];
809808
}else if( g.argc>4 ){
810809
fossil_fatal("to much arguments for start method.");
811810
}
812
- hScm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
811
+ hScm = OpenSCManagerW(NULL, NULL, SC_MANAGER_ALL_ACCESS);
813812
if( !hScm ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
814
- hSvc = OpenService(hScm, fossil_utf8_to_unicode(zSvcName), SERVICE_ALL_ACCESS);
813
+ hSvc = OpenServiceW(hScm, fossil_utf8_to_unicode(zSvcName), SERVICE_ALL_ACCESS);
815814
if( !hSvc ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
816815
QueryServiceStatus(hSvc, &sstat);
817816
if( sstat.dwCurrentState!=SERVICE_RUNNING ){
818817
fossil_print("Starting service '%s'", zSvcName);
819818
if( sstat.dwCurrentState!=SERVICE_START_PENDING ){
820
- if( !StartService(hSvc, 0, NULL) ){
819
+ if( !StartServiceW(hSvc, 0, NULL) ){
821820
fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
822821
}
823822
}
824823
while( sstat.dwCurrentState!=SERVICE_RUNNING ){
825824
Sleep(100);
@@ -843,13 +842,13 @@
843842
if( g.argc==4 ){
844843
zSvcName = g.argv[3];
845844
}else if( g.argc>4 ){
846845
fossil_fatal("to much arguments for stop method.");
847846
}
848
- hScm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
847
+ hScm = OpenSCManagerW(NULL, NULL, SC_MANAGER_ALL_ACCESS);
849848
if( !hScm ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
850
- hSvc = OpenService(hScm, fossil_utf8_to_unicode(zSvcName), SERVICE_ALL_ACCESS);
849
+ hSvc = OpenServiceW(hScm, fossil_utf8_to_unicode(zSvcName), SERVICE_ALL_ACCESS);
851850
if( !hSvc ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
852851
QueryServiceStatus(hSvc, &sstat);
853852
if( sstat.dwCurrentState!=SERVICE_STOPPED ){
854853
fossil_print("Stopping service '%s'", zSvcName);
855854
if( sstat.dwCurrentState!=SERVICE_STOP_PENDING ){
@@ -873,8 +872,6 @@
873872
fossil_fatal("METHOD should be one of:"
874873
" create delete show start stop");
875874
}
876875
return;
877876
}
878
-#endif /* _WIN32 */
879
-
880877
#endif /* _WIN32 -- This code is for win32 only */
881878
--- src/winhttp.c
+++ src/winhttp.c
@@ -191,11 +191,11 @@
191 }else{
192 fossil_fatal("unable to open listening socket on any"
193 " port in the range %d..%d", mnPort, mxPort);
194 }
195 }
196 if( !GetTempPath(MAX_PATH, zTmpPath) ){
197 fossil_fatal("unable to get path to the temporary directory.");
198 }
199 zTempPrefix = mprintf("%sfossil_server_P%d_", fossil_unicode_to_utf8(zTmpPath), iPort);
200 fossil_print("Listening for HTTP requests on TCP port %d\n", iPort);
201 if( zBrowser ){
@@ -268,35 +268,35 @@
268 ** to store the message string when done.
269 */
270 static char *win32_get_last_errmsg(void){
271 DWORD nMsg;
272 DWORD nErr = GetLastError();
273 LPTSTR tmp = NULL;
274 char *zMsg = NULL;
275
276 /* Try first to get the error text in english. */
277 nMsg = FormatMessage(
278 FORMAT_MESSAGE_ALLOCATE_BUFFER |
279 FORMAT_MESSAGE_FROM_SYSTEM |
280 FORMAT_MESSAGE_IGNORE_INSERTS,
281 NULL,
282 nErr,
283 MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),
284 (LPTSTR) &tmp,
285 0,
286 NULL
287 );
288 if( !nMsg ){
289 /* No english, get what the system has available. */
290 nMsg = FormatMessage(
291 FORMAT_MESSAGE_ALLOCATE_BUFFER |
292 FORMAT_MESSAGE_FROM_SYSTEM |
293 FORMAT_MESSAGE_IGNORE_INSERTS,
294 NULL,
295 nErr,
296 0,
297 (LPTSTR) &tmp,
298 0,
299 NULL
300 );
301 }
302 if( nMsg ){
@@ -374,21 +374,21 @@
374 ** creates a new thread to execute the ServiceMain function (this function)
375 ** of the service being started.
376 */
377 static void WINAPI win32_http_service_main(
378 DWORD argc, /* Number of arguments in argv */
379 LPTSTR *argv /* Arguments passed */
380 ){
381
382 /* Update the service information. */
383 hsData.isRunningAsService = 1;
384 if( argc>0 ){
385 hsData.zServiceName = argv[0];
386 }
387
388 /* Register the service control handler function */
389 sshStatusHandle = RegisterServiceCtrlHandler(L"", win32_http_service_ctrl);
390 if( !sshStatusHandle ){
391 win32_report_service_status(SERVICE_STOPPED, NO_ERROR, 0);
392 return;
393 }
394
@@ -428,30 +428,29 @@
428 int nPort, /* TCP port number */
429 const char *zNotFound, /* The --notfound option, or NULL */
430 int flags /* One or more HTTP_SERVER_ flags */
431 ){
432 /* Define the service table. */
433 SERVICE_TABLE_ENTRY ServiceTable[] =
434 {{L"", (LPSERVICE_MAIN_FUNCTION)win32_http_service_main}, {NULL, NULL}};
435
436 /* Initialize the HttpService structure. */
437 hsData.port = nPort;
438 hsData.zNotFound = zNotFound;
439 hsData.flags = flags;
440
441 /* Try to start the control dispatcher thread for the service. */
442 if( !StartServiceCtrlDispatcher(ServiceTable) ){
443 if( GetLastError()==ERROR_FAILED_SERVICE_CONTROLLER_CONNECT ){
444 return 1;
445 }else{
446 fossil_fatal("error from StartServiceCtrlDispatcher()");
447 }
448 }
449 return 0;
450 }
451
452 #ifdef _WIN32
453 /* dupe ifdef needed for mkindex
454 ** COMMAND: winsrv*
455 ** Usage: fossil winsrv METHOD ?SERVICE-NAME? ?OPTIONS?
456 **
457 ** Where METHOD is one of: create delete show start stop.
@@ -565,11 +564,11 @@
565 n = strlen(zMethod);
566
567 if( strncmp(zMethod, "create", n)==0 ){
568 SC_HANDLE hScm;
569 SC_HANDLE hSvc;
570 SERVICE_DESCRIPTION
571 svcDescr = {L"Fossil - Distributed Software Configuration Management"};
572 char *zErrFmt = "unable to create service '%s': %s";
573 DWORD dwStartType = SERVICE_DEMAND_START;
574 const char *zDisplay = find_option("display", "D", 1);
575 const char *zStart = find_option("start", "S", 1);
@@ -621,13 +620,13 @@
621 if( zPort ) blob_appendf(&binPath, " --port %s", zPort);
622 if( zNotFound ) blob_appendf(&binPath, " --notfound \"%s\"", zNotFound);
623 if( zLocalAuth ) blob_append(&binPath, " --localauth", -1);
624 blob_appendf(&binPath, " \"%s\"", g.zRepositoryName);
625 /* Create the service. */
626 hScm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
627 if( !hScm ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
628 hSvc = CreateService(
629 hScm, /* Handle to the SCM */
630 fossil_utf8_to_unicode(zSvcName), /* Name of the service */
631 fossil_utf8_to_unicode(zDisplay), /* Display name */
632 SERVICE_ALL_ACCESS, /* Desired access */
633 SERVICE_WIN32_OWN_PROCESS, /* Service type */
@@ -640,11 +639,11 @@
640 fossil_utf8_to_unicode(zUsername), /* Service account */
641 fossil_utf8_to_unicode(zPassword) /* Account password */
642 );
643 if( !hSvc ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
644 /* Set the service description. */
645 ChangeServiceConfig2(hSvc, SERVICE_CONFIG_DESCRIPTION, &svcDescr);
646 fossil_print("Service '%s' successfully created.\n", zSvcName);
647 CloseServiceHandle(hSvc);
648 CloseServiceHandle(hScm);
649 }else
650 if( strncmp(zMethod, "delete", n)==0 ){
@@ -657,13 +656,13 @@
657 if( g.argc==4 ){
658 zSvcName = g.argv[3];
659 }else if( g.argc>4 ){
660 fossil_fatal("to much arguments for delete method.");
661 }
662 hScm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
663 if( !hScm ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
664 hSvc = OpenService(hScm, fossil_utf8_to_unicode(zSvcName), SERVICE_ALL_ACCESS);
665 if( !hSvc ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
666 QueryServiceStatus(hSvc, &sstat);
667 if( sstat.dwCurrentState!=SERVICE_STOPPED ){
668 fossil_print("Stopping service '%s'", zSvcName);
669 if( sstat.dwCurrentState!=SERVICE_STOP_PENDING ){
@@ -692,12 +691,12 @@
692 }else
693 if( strncmp(zMethod, "show", n)==0 ){
694 SC_HANDLE hScm;
695 SC_HANDLE hSvc;
696 SERVICE_STATUS sstat;
697 LPQUERY_SERVICE_CONFIG pSvcConfig;
698 LPSERVICE_DESCRIPTION pSvcDescr;
699 BOOL bStatus;
700 DWORD nRequired;
701 const char *zErrFmt = "unable to show service '%s': %s";
702 static const char *const zSvcTypes[] = {
703 "Driver service",
@@ -725,21 +724,21 @@
725 if( g.argc==4 ){
726 zSvcName = g.argv[3];
727 }else if( g.argc>4 ){
728 fossil_fatal("to much arguments for show method.");
729 }
730 hScm = OpenSCManager(NULL, NULL, GENERIC_READ);
731 if( !hScm ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
732 hSvc = OpenService(hScm, fossil_utf8_to_unicode(zSvcName), GENERIC_READ);
733 if( !hSvc ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
734 /* Get the service configuration */
735 bStatus = QueryServiceConfig(hSvc, NULL, 0, &nRequired);
736 if( !bStatus && GetLastError()!=ERROR_INSUFFICIENT_BUFFER ){
737 fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
738 }
739 pSvcConfig = fossil_malloc(nRequired);
740 bStatus = QueryServiceConfig(hSvc, pSvcConfig, nRequired, &nRequired);
741 if( !bStatus ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
742 /* Translate the service type */
743 switch( pSvcConfig->dwServiceType ){
744 case SERVICE_KERNEL_DRIVER: zSvcType = zSvcTypes[0]; break;
745 case SERVICE_FILE_SYSTEM_DRIVER: zSvcType = zSvcTypes[1]; break;
@@ -754,17 +753,17 @@
754 case SERVICE_AUTO_START: zSvcStartType = zSvcStartTypes[2]; break;
755 case SERVICE_DEMAND_START: zSvcStartType = zSvcStartTypes[3]; break;
756 case SERVICE_DISABLED: zSvcStartType = zSvcStartTypes[4]; break;
757 }
758 /* Get the service description. */
759 bStatus = QueryServiceConfig2(hSvc, SERVICE_CONFIG_DESCRIPTION,
760 NULL, 0, &nRequired);
761 if( !bStatus && GetLastError()!=ERROR_INSUFFICIENT_BUFFER ){
762 fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
763 }
764 pSvcDescr = fossil_malloc(nRequired);
765 bStatus = QueryServiceConfig2(hSvc, SERVICE_CONFIG_DESCRIPTION,
766 (LPBYTE)pSvcDescr, nRequired, &nRequired);
767 if( !bStatus ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
768 /* Retrieves the current status of the specified service. */
769 bStatus = QueryServiceStatus(hSvc, &sstat);
770 if( !bStatus ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
@@ -807,19 +806,19 @@
807 if( g.argc==4 ){
808 zSvcName = g.argv[3];
809 }else if( g.argc>4 ){
810 fossil_fatal("to much arguments for start method.");
811 }
812 hScm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
813 if( !hScm ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
814 hSvc = OpenService(hScm, fossil_utf8_to_unicode(zSvcName), SERVICE_ALL_ACCESS);
815 if( !hSvc ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
816 QueryServiceStatus(hSvc, &sstat);
817 if( sstat.dwCurrentState!=SERVICE_RUNNING ){
818 fossil_print("Starting service '%s'", zSvcName);
819 if( sstat.dwCurrentState!=SERVICE_START_PENDING ){
820 if( !StartService(hSvc, 0, NULL) ){
821 fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
822 }
823 }
824 while( sstat.dwCurrentState!=SERVICE_RUNNING ){
825 Sleep(100);
@@ -843,13 +842,13 @@
843 if( g.argc==4 ){
844 zSvcName = g.argv[3];
845 }else if( g.argc>4 ){
846 fossil_fatal("to much arguments for stop method.");
847 }
848 hScm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
849 if( !hScm ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
850 hSvc = OpenService(hScm, fossil_utf8_to_unicode(zSvcName), SERVICE_ALL_ACCESS);
851 if( !hSvc ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
852 QueryServiceStatus(hSvc, &sstat);
853 if( sstat.dwCurrentState!=SERVICE_STOPPED ){
854 fossil_print("Stopping service '%s'", zSvcName);
855 if( sstat.dwCurrentState!=SERVICE_STOP_PENDING ){
@@ -873,8 +872,6 @@
873 fossil_fatal("METHOD should be one of:"
874 " create delete show start stop");
875 }
876 return;
877 }
878 #endif /* _WIN32 */
879
880 #endif /* _WIN32 -- This code is for win32 only */
881
--- src/winhttp.c
+++ src/winhttp.c
@@ -191,11 +191,11 @@
191 }else{
192 fossil_fatal("unable to open listening socket on any"
193 " port in the range %d..%d", mnPort, mxPort);
194 }
195 }
196 if( !GetTempPathW(MAX_PATH, zTmpPath) ){
197 fossil_fatal("unable to get path to the temporary directory.");
198 }
199 zTempPrefix = mprintf("%sfossil_server_P%d_", fossil_unicode_to_utf8(zTmpPath), iPort);
200 fossil_print("Listening for HTTP requests on TCP port %d\n", iPort);
201 if( zBrowser ){
@@ -268,35 +268,35 @@
268 ** to store the message string when done.
269 */
270 static char *win32_get_last_errmsg(void){
271 DWORD nMsg;
272 DWORD nErr = GetLastError();
273 LPWSTR tmp = NULL;
274 char *zMsg = NULL;
275
276 /* Try first to get the error text in english. */
277 nMsg = FormatMessageW(
278 FORMAT_MESSAGE_ALLOCATE_BUFFER |
279 FORMAT_MESSAGE_FROM_SYSTEM |
280 FORMAT_MESSAGE_IGNORE_INSERTS,
281 NULL,
282 nErr,
283 MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),
284 (LPWSTR) &tmp,
285 0,
286 NULL
287 );
288 if( !nMsg ){
289 /* No english, get what the system has available. */
290 nMsg = FormatMessageW(
291 FORMAT_MESSAGE_ALLOCATE_BUFFER |
292 FORMAT_MESSAGE_FROM_SYSTEM |
293 FORMAT_MESSAGE_IGNORE_INSERTS,
294 NULL,
295 nErr,
296 0,
297 (LPWSTR) &tmp,
298 0,
299 NULL
300 );
301 }
302 if( nMsg ){
@@ -374,21 +374,21 @@
374 ** creates a new thread to execute the ServiceMain function (this function)
375 ** of the service being started.
376 */
377 static void WINAPI win32_http_service_main(
378 DWORD argc, /* Number of arguments in argv */
379 LPWSTR *argv /* Arguments passed */
380 ){
381
382 /* Update the service information. */
383 hsData.isRunningAsService = 1;
384 if( argc>0 ){
385 hsData.zServiceName = argv[0];
386 }
387
388 /* Register the service control handler function */
389 sshStatusHandle = RegisterServiceCtrlHandlerW(L"", win32_http_service_ctrl);
390 if( !sshStatusHandle ){
391 win32_report_service_status(SERVICE_STOPPED, NO_ERROR, 0);
392 return;
393 }
394
@@ -428,30 +428,29 @@
428 int nPort, /* TCP port number */
429 const char *zNotFound, /* The --notfound option, or NULL */
430 int flags /* One or more HTTP_SERVER_ flags */
431 ){
432 /* Define the service table. */
433 SERVICE_TABLE_ENTRYW ServiceTable[] =
434 {{L"", (LPSERVICE_MAIN_FUNCTIONW)win32_http_service_main}, {NULL, NULL}};
435
436 /* Initialize the HttpService structure. */
437 hsData.port = nPort;
438 hsData.zNotFound = zNotFound;
439 hsData.flags = flags;
440
441 /* Try to start the control dispatcher thread for the service. */
442 if( !StartServiceCtrlDispatcherW(ServiceTable) ){
443 if( GetLastError()==ERROR_FAILED_SERVICE_CONTROLLER_CONNECT ){
444 return 1;
445 }else{
446 fossil_fatal("error from StartServiceCtrlDispatcher()");
447 }
448 }
449 return 0;
450 }
451
 
452 /* dupe ifdef needed for mkindex
453 ** COMMAND: winsrv*
454 ** Usage: fossil winsrv METHOD ?SERVICE-NAME? ?OPTIONS?
455 **
456 ** Where METHOD is one of: create delete show start stop.
@@ -565,11 +564,11 @@
564 n = strlen(zMethod);
565
566 if( strncmp(zMethod, "create", n)==0 ){
567 SC_HANDLE hScm;
568 SC_HANDLE hSvc;
569 SERVICE_DESCRIPTIONW
570 svcDescr = {L"Fossil - Distributed Software Configuration Management"};
571 char *zErrFmt = "unable to create service '%s': %s";
572 DWORD dwStartType = SERVICE_DEMAND_START;
573 const char *zDisplay = find_option("display", "D", 1);
574 const char *zStart = find_option("start", "S", 1);
@@ -621,13 +620,13 @@
620 if( zPort ) blob_appendf(&binPath, " --port %s", zPort);
621 if( zNotFound ) blob_appendf(&binPath, " --notfound \"%s\"", zNotFound);
622 if( zLocalAuth ) blob_append(&binPath, " --localauth", -1);
623 blob_appendf(&binPath, " \"%s\"", g.zRepositoryName);
624 /* Create the service. */
625 hScm = OpenSCManagerW(NULL, NULL, SC_MANAGER_ALL_ACCESS);
626 if( !hScm ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
627 hSvc = CreateServiceW(
628 hScm, /* Handle to the SCM */
629 fossil_utf8_to_unicode(zSvcName), /* Name of the service */
630 fossil_utf8_to_unicode(zDisplay), /* Display name */
631 SERVICE_ALL_ACCESS, /* Desired access */
632 SERVICE_WIN32_OWN_PROCESS, /* Service type */
@@ -640,11 +639,11 @@
639 fossil_utf8_to_unicode(zUsername), /* Service account */
640 fossil_utf8_to_unicode(zPassword) /* Account password */
641 );
642 if( !hSvc ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
643 /* Set the service description. */
644 ChangeServiceConfig2W(hSvc, SERVICE_CONFIG_DESCRIPTION, &svcDescr);
645 fossil_print("Service '%s' successfully created.\n", zSvcName);
646 CloseServiceHandle(hSvc);
647 CloseServiceHandle(hScm);
648 }else
649 if( strncmp(zMethod, "delete", n)==0 ){
@@ -657,13 +656,13 @@
656 if( g.argc==4 ){
657 zSvcName = g.argv[3];
658 }else if( g.argc>4 ){
659 fossil_fatal("to much arguments for delete method.");
660 }
661 hScm = OpenSCManagerW(NULL, NULL, SC_MANAGER_ALL_ACCESS);
662 if( !hScm ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
663 hSvc = OpenServiceW(hScm, fossil_utf8_to_unicode(zSvcName), SERVICE_ALL_ACCESS);
664 if( !hSvc ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
665 QueryServiceStatus(hSvc, &sstat);
666 if( sstat.dwCurrentState!=SERVICE_STOPPED ){
667 fossil_print("Stopping service '%s'", zSvcName);
668 if( sstat.dwCurrentState!=SERVICE_STOP_PENDING ){
@@ -692,12 +691,12 @@
691 }else
692 if( strncmp(zMethod, "show", n)==0 ){
693 SC_HANDLE hScm;
694 SC_HANDLE hSvc;
695 SERVICE_STATUS sstat;
696 LPQUERY_SERVICE_CONFIGW pSvcConfig;
697 LPSERVICE_DESCRIPTIONW pSvcDescr;
698 BOOL bStatus;
699 DWORD nRequired;
700 const char *zErrFmt = "unable to show service '%s': %s";
701 static const char *const zSvcTypes[] = {
702 "Driver service",
@@ -725,21 +724,21 @@
724 if( g.argc==4 ){
725 zSvcName = g.argv[3];
726 }else if( g.argc>4 ){
727 fossil_fatal("to much arguments for show method.");
728 }
729 hScm = OpenSCManagerW(NULL, NULL, GENERIC_READ);
730 if( !hScm ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
731 hSvc = OpenServiceW(hScm, fossil_utf8_to_unicode(zSvcName), GENERIC_READ);
732 if( !hSvc ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
733 /* Get the service configuration */
734 bStatus = QueryServiceConfigW(hSvc, NULL, 0, &nRequired);
735 if( !bStatus && GetLastError()!=ERROR_INSUFFICIENT_BUFFER ){
736 fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
737 }
738 pSvcConfig = fossil_malloc(nRequired);
739 bStatus = QueryServiceConfigW(hSvc, pSvcConfig, nRequired, &nRequired);
740 if( !bStatus ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
741 /* Translate the service type */
742 switch( pSvcConfig->dwServiceType ){
743 case SERVICE_KERNEL_DRIVER: zSvcType = zSvcTypes[0]; break;
744 case SERVICE_FILE_SYSTEM_DRIVER: zSvcType = zSvcTypes[1]; break;
@@ -754,17 +753,17 @@
753 case SERVICE_AUTO_START: zSvcStartType = zSvcStartTypes[2]; break;
754 case SERVICE_DEMAND_START: zSvcStartType = zSvcStartTypes[3]; break;
755 case SERVICE_DISABLED: zSvcStartType = zSvcStartTypes[4]; break;
756 }
757 /* Get the service description. */
758 bStatus = QueryServiceConfig2W(hSvc, SERVICE_CONFIG_DESCRIPTION,
759 NULL, 0, &nRequired);
760 if( !bStatus && GetLastError()!=ERROR_INSUFFICIENT_BUFFER ){
761 fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
762 }
763 pSvcDescr = fossil_malloc(nRequired);
764 bStatus = QueryServiceConfig2W(hSvc, SERVICE_CONFIG_DESCRIPTION,
765 (LPBYTE)pSvcDescr, nRequired, &nRequired);
766 if( !bStatus ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
767 /* Retrieves the current status of the specified service. */
768 bStatus = QueryServiceStatus(hSvc, &sstat);
769 if( !bStatus ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
@@ -807,19 +806,19 @@
806 if( g.argc==4 ){
807 zSvcName = g.argv[3];
808 }else if( g.argc>4 ){
809 fossil_fatal("to much arguments for start method.");
810 }
811 hScm = OpenSCManagerW(NULL, NULL, SC_MANAGER_ALL_ACCESS);
812 if( !hScm ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
813 hSvc = OpenServiceW(hScm, fossil_utf8_to_unicode(zSvcName), SERVICE_ALL_ACCESS);
814 if( !hSvc ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
815 QueryServiceStatus(hSvc, &sstat);
816 if( sstat.dwCurrentState!=SERVICE_RUNNING ){
817 fossil_print("Starting service '%s'", zSvcName);
818 if( sstat.dwCurrentState!=SERVICE_START_PENDING ){
819 if( !StartServiceW(hSvc, 0, NULL) ){
820 fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
821 }
822 }
823 while( sstat.dwCurrentState!=SERVICE_RUNNING ){
824 Sleep(100);
@@ -843,13 +842,13 @@
842 if( g.argc==4 ){
843 zSvcName = g.argv[3];
844 }else if( g.argc>4 ){
845 fossil_fatal("to much arguments for stop method.");
846 }
847 hScm = OpenSCManagerW(NULL, NULL, SC_MANAGER_ALL_ACCESS);
848 if( !hScm ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
849 hSvc = OpenServiceW(hScm, fossil_utf8_to_unicode(zSvcName), SERVICE_ALL_ACCESS);
850 if( !hSvc ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
851 QueryServiceStatus(hSvc, &sstat);
852 if( sstat.dwCurrentState!=SERVICE_STOPPED ){
853 fossil_print("Stopping service '%s'", zSvcName);
854 if( sstat.dwCurrentState!=SERVICE_STOP_PENDING ){
@@ -873,8 +872,6 @@
872 fossil_fatal("METHOD should be one of:"
873 " create delete show start stop");
874 }
875 return;
876 }
 
 
877 #endif /* _WIN32 -- This code is for win32 only */
878
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -104,11 +104,11 @@
104104
# will run on the target platform. This is usually the same
105105
# as BCC, unless you are cross-compiling. This C compiler builds
106106
# the finished binary for fossil. The BCC compiler above is used
107107
# for building intermediate code-generator tools.
108108
#
109
-TCC = $(PREFIX)gcc -Os -Wall -DUNICODE -D_UNICODE -L$(ZLIBDIR) -I$(ZINCDIR)
109
+TCC = $(PREFIX)gcc -Os -Wall -L$(ZLIBDIR) -I$(ZINCDIR)
110110
111111
#### Compile resources for use in building executables that will run
112112
# on the target platform.
113113
#
114114
RCC = $(PREFIX)windres -I$(SRCDIR) -I$(ZINCDIR)
115115
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -104,11 +104,11 @@
104 # will run on the target platform. This is usually the same
105 # as BCC, unless you are cross-compiling. This C compiler builds
106 # the finished binary for fossil. The BCC compiler above is used
107 # for building intermediate code-generator tools.
108 #
109 TCC = $(PREFIX)gcc -Os -Wall -DUNICODE -D_UNICODE -L$(ZLIBDIR) -I$(ZINCDIR)
110
111 #### Compile resources for use in building executables that will run
112 # on the target platform.
113 #
114 RCC = $(PREFIX)windres -I$(SRCDIR) -I$(ZINCDIR)
115
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -104,11 +104,11 @@
104 # will run on the target platform. This is usually the same
105 # as BCC, unless you are cross-compiling. This C compiler builds
106 # the finished binary for fossil. The BCC compiler above is used
107 # for building intermediate code-generator tools.
108 #
109 TCC = $(PREFIX)gcc -Os -Wall -L$(ZLIBDIR) -I$(ZINCDIR)
110
111 #### Compile resources for use in building executables that will run
112 # on the target platform.
113 #
114 RCC = $(PREFIX)windres -I$(SRCDIR) -I$(ZINCDIR)
115
--- win/Makefile.mingw.mistachkin
+++ win/Makefile.mingw.mistachkin
@@ -104,11 +104,11 @@
104104
# will run on the target platform. This is usually the same
105105
# as BCC, unless you are cross-compiling. This C compiler builds
106106
# the finished binary for fossil. The BCC compiler above is used
107107
# for building intermediate code-generator tools.
108108
#
109
-TCC = $(PREFIX)gcc -Os -Wall -DUNICODE -D_UNICODE -L$(ZLIBDIR) -I$(ZINCDIR)
109
+TCC = $(PREFIX)gcc -Os -Wall -L$(ZLIBDIR) -I$(ZINCDIR)
110110
111111
#### Compile resources for use in building executables that will run
112112
# on the target platform.
113113
#
114114
RCC = $(PREFIX)windres -I$(SRCDIR) -I$(ZINCDIR)
115115
--- win/Makefile.mingw.mistachkin
+++ win/Makefile.mingw.mistachkin
@@ -104,11 +104,11 @@
104 # will run on the target platform. This is usually the same
105 # as BCC, unless you are cross-compiling. This C compiler builds
106 # the finished binary for fossil. The BCC compiler above is used
107 # for building intermediate code-generator tools.
108 #
109 TCC = $(PREFIX)gcc -Os -Wall -DUNICODE -D_UNICODE -L$(ZLIBDIR) -I$(ZINCDIR)
110
111 #### Compile resources for use in building executables that will run
112 # on the target platform.
113 #
114 RCC = $(PREFIX)windres -I$(SRCDIR) -I$(ZINCDIR)
115
--- win/Makefile.mingw.mistachkin
+++ win/Makefile.mingw.mistachkin
@@ -104,11 +104,11 @@
104 # will run on the target platform. This is usually the same
105 # as BCC, unless you are cross-compiling. This C compiler builds
106 # the finished binary for fossil. The BCC compiler above is used
107 # for building intermediate code-generator tools.
108 #
109 TCC = $(PREFIX)gcc -Os -Wall -L$(ZLIBDIR) -I$(ZINCDIR)
110
111 #### Compile resources for use in building executables that will run
112 # on the target platform.
113 #
114 RCC = $(PREFIX)windres -I$(SRCDIR) -I$(ZINCDIR)
115
--- win/Makefile.msc
+++ win/Makefile.msc
@@ -34,11 +34,11 @@
3434
3535
INCL = -I. -I$(SRCDIR) -I$B\win\include -I$(MSCDIR)\extra\include -I$(ZINCDIR)
3636
3737
CFLAGS = -nologo -MT -O2
3838
BCC = $(CC) $(CFLAGS)
39
-TCC = $(CC) -c $(CFLAGS) -DUNICODE -D_UNICODE $(MSCDEF) $(SSL) $(INCL)
39
+TCC = $(CC) -c $(CFLAGS) $(MSCDEF) $(SSL) $(INCL)
4040
LIBS = $(ZLIB) ws2_32.lib advapi32.lib $(SSLLIB)
4141
LIBDIR = -LIBPATH:$(MSCDIR)\extra\lib -LIBPATH:$(ZLIBDIR)
4242
4343
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
4444
4545
--- win/Makefile.msc
+++ win/Makefile.msc
@@ -34,11 +34,11 @@
34
35 INCL = -I. -I$(SRCDIR) -I$B\win\include -I$(MSCDIR)\extra\include -I$(ZINCDIR)
36
37 CFLAGS = -nologo -MT -O2
38 BCC = $(CC) $(CFLAGS)
39 TCC = $(CC) -c $(CFLAGS) -DUNICODE -D_UNICODE $(MSCDEF) $(SSL) $(INCL)
40 LIBS = $(ZLIB) ws2_32.lib advapi32.lib $(SSLLIB)
41 LIBDIR = -LIBPATH:$(MSCDIR)\extra\lib -LIBPATH:$(ZLIBDIR)
42
43 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
44
45
--- win/Makefile.msc
+++ win/Makefile.msc
@@ -34,11 +34,11 @@
34
35 INCL = -I. -I$(SRCDIR) -I$B\win\include -I$(MSCDIR)\extra\include -I$(ZINCDIR)
36
37 CFLAGS = -nologo -MT -O2
38 BCC = $(CC) $(CFLAGS)
39 TCC = $(CC) -c $(CFLAGS) $(MSCDEF) $(SSL) $(INCL)
40 LIBS = $(ZLIB) ws2_32.lib advapi32.lib $(SSLLIB)
41 LIBDIR = -LIBPATH:$(MSCDIR)\extra\lib -LIBPATH:$(ZLIBDIR)
42
43 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
44
45

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button