Fossil SCM

Merge the autosetup and winsrv branches into trunk.

drh 2012-06-10 22:31 trunk merge
Commit 1ac9cece64349afca313a63de0f64662a3e9e3f9
--- autosetup/local.tcl
+++ autosetup/local.tcl
@@ -20,10 +20,11 @@
2020
}
2121
2222
proc parse-tclconfig-sh-file {filename} {
2323
foreach line [split [readfile $filename] \n] {
2424
if {[regexp {^(TCL_[^=]*)=(.*)$} $line -> name value]} {
25
+ set value [regsub -all {\$\{.*\}} $value ""]
2526
set tclconfig($name) [string trim $value ']
2627
}
2728
}
2829
return [array get tclconfig]
2930
}
3031
--- autosetup/local.tcl
+++ autosetup/local.tcl
@@ -20,10 +20,11 @@
20 }
21
22 proc parse-tclconfig-sh-file {filename} {
23 foreach line [split [readfile $filename] \n] {
24 if {[regexp {^(TCL_[^=]*)=(.*)$} $line -> name value]} {
 
25 set tclconfig($name) [string trim $value ']
26 }
27 }
28 return [array get tclconfig]
29 }
30
--- autosetup/local.tcl
+++ autosetup/local.tcl
@@ -20,10 +20,11 @@
20 }
21
22 proc parse-tclconfig-sh-file {filename} {
23 foreach line [split [readfile $filename] \n] {
24 if {[regexp {^(TCL_[^=]*)=(.*)$} $line -> name value]} {
25 set value [regsub -all {\$\{.*\}} $value ""]
26 set tclconfig($name) [string trim $value ']
27 }
28 }
29 return [array get tclconfig]
30 }
31
--- autosetup/local.tcl
+++ autosetup/local.tcl
@@ -20,10 +20,11 @@
2020
}
2121
2222
proc parse-tclconfig-sh-file {filename} {
2323
foreach line [split [readfile $filename] \n] {
2424
if {[regexp {^(TCL_[^=]*)=(.*)$} $line -> name value]} {
25
+ set value [regsub -all {\$\{.*\}} $value ""]
2526
set tclconfig($name) [string trim $value ']
2627
}
2728
}
2829
return [array get tclconfig]
2930
}
3031
--- autosetup/local.tcl
+++ autosetup/local.tcl
@@ -20,10 +20,11 @@
20 }
21
22 proc parse-tclconfig-sh-file {filename} {
23 foreach line [split [readfile $filename] \n] {
24 if {[regexp {^(TCL_[^=]*)=(.*)$} $line -> name value]} {
 
25 set tclconfig($name) [string trim $value ']
26 }
27 }
28 return [array get tclconfig]
29 }
30
--- autosetup/local.tcl
+++ autosetup/local.tcl
@@ -20,10 +20,11 @@
20 }
21
22 proc parse-tclconfig-sh-file {filename} {
23 foreach line [split [readfile $filename] \n] {
24 if {[regexp {^(TCL_[^=]*)=(.*)$} $line -> name value]} {
25 set value [regsub -all {\$\{.*\}} $value ""]
26 set tclconfig($name) [string trim $value ']
27 }
28 }
29 return [array get tclconfig]
30 }
31
+54 -29
--- src/winhttp.c
+++ src/winhttp.c
@@ -267,24 +267,40 @@
267267
** message string. Call fossil_mbcs_free() to deallocate any memory used
268268
** to store the message string when done.
269269
*/
270270
static char *win32_get_last_errmsg(void){
271271
DWORD nMsg;
272
+ DWORD nErr = GetLastError();
272273
LPTSTR tmp = NULL;
273274
char *zMsg = NULL;
274275
276
+ /* Try first to get the error text in english. */
275277
nMsg = FormatMessage(
276278
FORMAT_MESSAGE_ALLOCATE_BUFFER |
277279
FORMAT_MESSAGE_FROM_SYSTEM |
278280
FORMAT_MESSAGE_IGNORE_INSERTS,
279281
NULL,
280
- GetLastError(),
282
+ nErr,
281283
MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),
282284
(LPTSTR) &tmp,
283285
0,
284286
NULL
285287
);
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
+ }
286302
if( nMsg ){
287303
zMsg = fossil_mbcs_to_utf8(tmp);
288304
}else{
289305
fossil_fatal("unable to get system error message.");
290306
}
@@ -301,11 +317,11 @@
301317
static void win32_report_service_status(
302318
DWORD dwCurrentState, /* The current state of the service */
303319
DWORD dwWin32ExitCode, /* The error code to report */
304320
DWORD dwWaitHint /* The estimated time for a pending operation */
305321
){
306
- if( dwCurrentState==SERVICE_START_PENDING) {
322
+ if( dwCurrentState==SERVICE_START_PENDING ){
307323
ssStatus.dwControlsAccepted = 0;
308324
}else{
309325
ssStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP;
310326
}
311327
ssStatus.dwCurrentState = dwCurrentState;
@@ -477,11 +493,11 @@
477493
** Password for the user account.
478494
**
479495
** The following options are more or less the same as for the "server"
480496
** command and influence the behaviour of the http server:
481497
**
482
-** -p|--port TCPPORT
498
+** -P|--port TCPPORT
483499
**
484500
** Specifies the TCP port (default port is 8080) on which the
485501
** server should listen.
486502
**
487503
** -R|--repository REPOSITORY
@@ -544,69 +560,62 @@
544560
if( g.argc<3 ){
545561
usage("create|delete|show|start|stop ...");
546562
}
547563
zMethod = g.argv[2];
548564
n = strlen(zMethod);
549
- if( g.argc==4 ){
550
- zSvcName = g.argv[3];
551
- }
552565
553566
if( strncmp(zMethod, "create", n)==0 ){
554567
SC_HANDLE hScm;
555568
SC_HANDLE hSvc;
556569
SERVICE_DESCRIPTION
557570
svcDescr = {"Fossil - Distributed Software Configuration Management"};
558571
char *zErrFmt = "unable to create service '%s': %s";
559572
DWORD dwStartType = SERVICE_DEMAND_START;
560
- const char *zDisplay;
561
- const char *zStart;
562
- const char *zUsername;
563
- const char *zPassword;
564
- const char *zPort;
565
- const char *zNotFound;
566
- const char *zLocalAuth;
567
- const char *zRepository;
573
+ const char *zDisplay = find_option("display", "D", 1);
574
+ const char *zStart = find_option("start", "S", 1);
575
+ const char *zUsername = find_option("username", "U", 1);
576
+ const char *zPassword = find_option("password", "W", 1);
577
+ const char *zPort = find_option("port", "P", 1);
578
+ const char *zNotFound = find_option("notfound", 0, 1);
579
+ const char *zLocalAuth = find_option("localauth", 0, 0);
580
+ const char *zRepository = find_option("repository", "R", 1);
568581
Blob binPath;
569582
583
+ verify_all_options();
584
+ if( g.argc==4 ){
585
+ zSvcName = g.argv[3];
586
+ }else if( g.argc>4 ){
587
+ fossil_fatal("to much arguments for create method.");
588
+ }
570589
/* Process service creation specific options. */
571
- zDisplay = find_option("display", "D", 1);
572590
if( !zDisplay ){
573591
zDisplay = zSvcName;
574592
}
575
- zStart = find_option("start", "S", 1);
576593
if( zStart ){
577594
if( strncmp(zStart, "auto", strlen(zStart))==0 ){
578595
dwStartType = SERVICE_AUTO_START;
579
- }else if( strncmp(zStart, "manual", strlen(zStart))==0 ){
596
+ }else if( strncmp(zStart, "manual", strlen(zStart))==0 ){
580597
dwStartType = SERVICE_DEMAND_START;
581598
}else{
582599
fossil_fatal(zErrFmt, zSvcName,
583600
"specify 'auto' or 'manual' for the '-S|--start' option");
584601
}
585602
}
586
- zUsername = find_option("username", "U", 1);
587
- zPassword = find_option("password", "W", 1);
588603
/* Process options for Fossil running as server. */
589
- zPort = find_option("port", "P", 1);
590604
if( zPort && (atoi(zPort)<=0) ){
591605
fossil_fatal(zErrFmt, zSvcName,
592606
"port number must be in the range 1 - 65535.");
593607
}
594
- zNotFound = find_option("notfound", 0, 1);
595
- zLocalAuth = find_option("localauth", 0, 0);
596
- zRepository = find_option("repository", "R", 1);
597608
if( !zRepository ){
598609
db_must_be_within_tree();
599610
}else if( file_isdir(zRepository)==1 ){
600611
g.zRepositoryName = mprintf("%s", zRepository);
601612
file_simplify_name(g.zRepositoryName, -1, 0);
602613
}else{
603614
db_open_repository(zRepository);
604615
}
605616
db_close(0);
606
- verify_all_options();
607
- if( g.argc>4 ) fossil_fatal("to much arguments for create method.");
608617
/* Build the fully-qualified path to the service binary file. */
609618
blob_zero(&binPath);
610619
blob_appendf(&binPath, "\"%s\" server", fossil_nameofexe());
611620
if( zPort ) blob_appendf(&binPath, " --port %s", zPort);
612621
if( zNotFound ) blob_appendf(&binPath, " --notfound \"%s\"", zNotFound);
@@ -642,11 +651,15 @@
642651
SC_HANDLE hSvc;
643652
SERVICE_STATUS sstat;
644653
char *zErrFmt = "unable to delete service '%s': %s";
645654
646655
verify_all_options();
647
- if( g.argc>4 ) fossil_fatal("to much arguments for delete method.");
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
+ }
648661
hScm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
649662
if( !hScm ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
650663
hSvc = OpenService(hScm, fossil_utf8_to_mbcs(zSvcName), SERVICE_ALL_ACCESS);
651664
if( !hSvc ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
652665
QueryServiceStatus(hSvc, &sstat);
@@ -706,11 +719,15 @@
706719
"Continue pending", "Pause pending", "Paused"
707720
};
708721
const char *zSvcState = "";
709722
710723
verify_all_options();
711
- if( g.argc>4 ) fossil_fatal("to much arguments for show method.");
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
+ }
712729
hScm = OpenSCManager(NULL, NULL, GENERIC_READ);
713730
if( !hScm ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
714731
hSvc = OpenService(hScm, fossil_utf8_to_mbcs(zSvcName), GENERIC_READ);
715732
if( !hSvc ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
716733
/* Get the service configuration */
@@ -784,11 +801,15 @@
784801
SC_HANDLE hSvc;
785802
SERVICE_STATUS sstat;
786803
char *zErrFmt = "unable to start service '%s': %s";
787804
788805
verify_all_options();
789
- if( g.argc>4 ) fossil_fatal("to much arguments for start method.");
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
+ }
790811
hScm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
791812
if( !hScm ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
792813
hSvc = OpenService(hScm, fossil_utf8_to_mbcs(zSvcName), SERVICE_ALL_ACCESS);
793814
if( !hSvc ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
794815
QueryServiceStatus(hSvc, &sstat);
@@ -816,11 +837,15 @@
816837
SC_HANDLE hSvc;
817838
SERVICE_STATUS sstat;
818839
char *zErrFmt = "unable to stop service '%s': %s";
819840
820841
verify_all_options();
821
- if( g.argc>4 ) fossil_fatal("to much arguments for stop method.");
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
+ }
822847
hScm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
823848
if( !hScm ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
824849
hSvc = OpenService(hScm, fossil_utf8_to_mbcs(zSvcName), SERVICE_ALL_ACCESS);
825850
if( !hSvc ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
826851
QueryServiceStatus(hSvc, &sstat);
827852
--- src/winhttp.c
+++ src/winhttp.c
@@ -267,24 +267,40 @@
267 ** message string. Call fossil_mbcs_free() to deallocate any memory used
268 ** to store the message string when done.
269 */
270 static char *win32_get_last_errmsg(void){
271 DWORD nMsg;
 
272 LPTSTR tmp = NULL;
273 char *zMsg = NULL;
274
 
275 nMsg = FormatMessage(
276 FORMAT_MESSAGE_ALLOCATE_BUFFER |
277 FORMAT_MESSAGE_FROM_SYSTEM |
278 FORMAT_MESSAGE_IGNORE_INSERTS,
279 NULL,
280 GetLastError(),
281 MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),
282 (LPTSTR) &tmp,
283 0,
284 NULL
285 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
286 if( nMsg ){
287 zMsg = fossil_mbcs_to_utf8(tmp);
288 }else{
289 fossil_fatal("unable to get system error message.");
290 }
@@ -301,11 +317,11 @@
301 static void win32_report_service_status(
302 DWORD dwCurrentState, /* The current state of the service */
303 DWORD dwWin32ExitCode, /* The error code to report */
304 DWORD dwWaitHint /* The estimated time for a pending operation */
305 ){
306 if( dwCurrentState==SERVICE_START_PENDING) {
307 ssStatus.dwControlsAccepted = 0;
308 }else{
309 ssStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP;
310 }
311 ssStatus.dwCurrentState = dwCurrentState;
@@ -477,11 +493,11 @@
477 ** Password for the user account.
478 **
479 ** The following options are more or less the same as for the "server"
480 ** command and influence the behaviour of the http server:
481 **
482 ** -p|--port TCPPORT
483 **
484 ** Specifies the TCP port (default port is 8080) on which the
485 ** server should listen.
486 **
487 ** -R|--repository REPOSITORY
@@ -544,69 +560,62 @@
544 if( g.argc<3 ){
545 usage("create|delete|show|start|stop ...");
546 }
547 zMethod = g.argv[2];
548 n = strlen(zMethod);
549 if( g.argc==4 ){
550 zSvcName = g.argv[3];
551 }
552
553 if( strncmp(zMethod, "create", n)==0 ){
554 SC_HANDLE hScm;
555 SC_HANDLE hSvc;
556 SERVICE_DESCRIPTION
557 svcDescr = {"Fossil - Distributed Software Configuration Management"};
558 char *zErrFmt = "unable to create service '%s': %s";
559 DWORD dwStartType = SERVICE_DEMAND_START;
560 const char *zDisplay;
561 const char *zStart;
562 const char *zUsername;
563 const char *zPassword;
564 const char *zPort;
565 const char *zNotFound;
566 const char *zLocalAuth;
567 const char *zRepository;
568 Blob binPath;
569
 
 
 
 
 
 
570 /* Process service creation specific options. */
571 zDisplay = find_option("display", "D", 1);
572 if( !zDisplay ){
573 zDisplay = zSvcName;
574 }
575 zStart = find_option("start", "S", 1);
576 if( zStart ){
577 if( strncmp(zStart, "auto", strlen(zStart))==0 ){
578 dwStartType = SERVICE_AUTO_START;
579 }else if( strncmp(zStart, "manual", strlen(zStart))==0 ){
580 dwStartType = SERVICE_DEMAND_START;
581 }else{
582 fossil_fatal(zErrFmt, zSvcName,
583 "specify 'auto' or 'manual' for the '-S|--start' option");
584 }
585 }
586 zUsername = find_option("username", "U", 1);
587 zPassword = find_option("password", "W", 1);
588 /* Process options for Fossil running as server. */
589 zPort = find_option("port", "P", 1);
590 if( zPort && (atoi(zPort)<=0) ){
591 fossil_fatal(zErrFmt, zSvcName,
592 "port number must be in the range 1 - 65535.");
593 }
594 zNotFound = find_option("notfound", 0, 1);
595 zLocalAuth = find_option("localauth", 0, 0);
596 zRepository = find_option("repository", "R", 1);
597 if( !zRepository ){
598 db_must_be_within_tree();
599 }else if( file_isdir(zRepository)==1 ){
600 g.zRepositoryName = mprintf("%s", zRepository);
601 file_simplify_name(g.zRepositoryName, -1, 0);
602 }else{
603 db_open_repository(zRepository);
604 }
605 db_close(0);
606 verify_all_options();
607 if( g.argc>4 ) fossil_fatal("to much arguments for create method.");
608 /* Build the fully-qualified path to the service binary file. */
609 blob_zero(&binPath);
610 blob_appendf(&binPath, "\"%s\" server", fossil_nameofexe());
611 if( zPort ) blob_appendf(&binPath, " --port %s", zPort);
612 if( zNotFound ) blob_appendf(&binPath, " --notfound \"%s\"", zNotFound);
@@ -642,11 +651,15 @@
642 SC_HANDLE hSvc;
643 SERVICE_STATUS sstat;
644 char *zErrFmt = "unable to delete service '%s': %s";
645
646 verify_all_options();
647 if( g.argc>4 ) fossil_fatal("to much arguments for delete method.");
 
 
 
 
648 hScm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
649 if( !hScm ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
650 hSvc = OpenService(hScm, fossil_utf8_to_mbcs(zSvcName), SERVICE_ALL_ACCESS);
651 if( !hSvc ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
652 QueryServiceStatus(hSvc, &sstat);
@@ -706,11 +719,15 @@
706 "Continue pending", "Pause pending", "Paused"
707 };
708 const char *zSvcState = "";
709
710 verify_all_options();
711 if( g.argc>4 ) fossil_fatal("to much arguments for show method.");
 
 
 
 
712 hScm = OpenSCManager(NULL, NULL, GENERIC_READ);
713 if( !hScm ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
714 hSvc = OpenService(hScm, fossil_utf8_to_mbcs(zSvcName), GENERIC_READ);
715 if( !hSvc ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
716 /* Get the service configuration */
@@ -784,11 +801,15 @@
784 SC_HANDLE hSvc;
785 SERVICE_STATUS sstat;
786 char *zErrFmt = "unable to start service '%s': %s";
787
788 verify_all_options();
789 if( g.argc>4 ) fossil_fatal("to much arguments for start method.");
 
 
 
 
790 hScm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
791 if( !hScm ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
792 hSvc = OpenService(hScm, fossil_utf8_to_mbcs(zSvcName), SERVICE_ALL_ACCESS);
793 if( !hSvc ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
794 QueryServiceStatus(hSvc, &sstat);
@@ -816,11 +837,15 @@
816 SC_HANDLE hSvc;
817 SERVICE_STATUS sstat;
818 char *zErrFmt = "unable to stop service '%s': %s";
819
820 verify_all_options();
821 if( g.argc>4 ) fossil_fatal("to much arguments for stop method.");
 
 
 
 
822 hScm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
823 if( !hScm ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
824 hSvc = OpenService(hScm, fossil_utf8_to_mbcs(zSvcName), SERVICE_ALL_ACCESS);
825 if( !hSvc ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
826 QueryServiceStatus(hSvc, &sstat);
827
--- src/winhttp.c
+++ src/winhttp.c
@@ -267,24 +267,40 @@
267 ** message string. Call fossil_mbcs_free() to deallocate any memory used
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 ){
303 zMsg = fossil_mbcs_to_utf8(tmp);
304 }else{
305 fossil_fatal("unable to get system error message.");
306 }
@@ -301,11 +317,11 @@
317 static void win32_report_service_status(
318 DWORD dwCurrentState, /* The current state of the service */
319 DWORD dwWin32ExitCode, /* The error code to report */
320 DWORD dwWaitHint /* The estimated time for a pending operation */
321 ){
322 if( dwCurrentState==SERVICE_START_PENDING ){
323 ssStatus.dwControlsAccepted = 0;
324 }else{
325 ssStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP;
326 }
327 ssStatus.dwCurrentState = dwCurrentState;
@@ -477,11 +493,11 @@
493 ** Password for the user account.
494 **
495 ** The following options are more or less the same as for the "server"
496 ** command and influence the behaviour of the http server:
497 **
498 ** -P|--port TCPPORT
499 **
500 ** Specifies the TCP port (default port is 8080) on which the
501 ** server should listen.
502 **
503 ** -R|--repository REPOSITORY
@@ -544,69 +560,62 @@
560 if( g.argc<3 ){
561 usage("create|delete|show|start|stop ...");
562 }
563 zMethod = g.argv[2];
564 n = strlen(zMethod);
 
 
 
565
566 if( strncmp(zMethod, "create", n)==0 ){
567 SC_HANDLE hScm;
568 SC_HANDLE hSvc;
569 SERVICE_DESCRIPTION
570 svcDescr = {"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);
575 const char *zUsername = find_option("username", "U", 1);
576 const char *zPassword = find_option("password", "W", 1);
577 const char *zPort = find_option("port", "P", 1);
578 const char *zNotFound = find_option("notfound", 0, 1);
579 const char *zLocalAuth = find_option("localauth", 0, 0);
580 const char *zRepository = find_option("repository", "R", 1);
581 Blob binPath;
582
583 verify_all_options();
584 if( g.argc==4 ){
585 zSvcName = g.argv[3];
586 }else if( g.argc>4 ){
587 fossil_fatal("to much arguments for create method.");
588 }
589 /* Process service creation specific options. */
 
590 if( !zDisplay ){
591 zDisplay = zSvcName;
592 }
 
593 if( zStart ){
594 if( strncmp(zStart, "auto", strlen(zStart))==0 ){
595 dwStartType = SERVICE_AUTO_START;
596 }else if( strncmp(zStart, "manual", strlen(zStart))==0 ){
597 dwStartType = SERVICE_DEMAND_START;
598 }else{
599 fossil_fatal(zErrFmt, zSvcName,
600 "specify 'auto' or 'manual' for the '-S|--start' option");
601 }
602 }
 
 
603 /* Process options for Fossil running as server. */
 
604 if( zPort && (atoi(zPort)<=0) ){
605 fossil_fatal(zErrFmt, zSvcName,
606 "port number must be in the range 1 - 65535.");
607 }
 
 
 
608 if( !zRepository ){
609 db_must_be_within_tree();
610 }else if( file_isdir(zRepository)==1 ){
611 g.zRepositoryName = mprintf("%s", zRepository);
612 file_simplify_name(g.zRepositoryName, -1, 0);
613 }else{
614 db_open_repository(zRepository);
615 }
616 db_close(0);
 
 
617 /* Build the fully-qualified path to the service binary file. */
618 blob_zero(&binPath);
619 blob_appendf(&binPath, "\"%s\" server", fossil_nameofexe());
620 if( zPort ) blob_appendf(&binPath, " --port %s", zPort);
621 if( zNotFound ) blob_appendf(&binPath, " --notfound \"%s\"", zNotFound);
@@ -642,11 +651,15 @@
651 SC_HANDLE hSvc;
652 SERVICE_STATUS sstat;
653 char *zErrFmt = "unable to delete service '%s': %s";
654
655 verify_all_options();
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 = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
662 if( !hScm ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
663 hSvc = OpenService(hScm, fossil_utf8_to_mbcs(zSvcName), SERVICE_ALL_ACCESS);
664 if( !hSvc ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
665 QueryServiceStatus(hSvc, &sstat);
@@ -706,11 +719,15 @@
719 "Continue pending", "Pause pending", "Paused"
720 };
721 const char *zSvcState = "";
722
723 verify_all_options();
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 = OpenSCManager(NULL, NULL, GENERIC_READ);
730 if( !hScm ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
731 hSvc = OpenService(hScm, fossil_utf8_to_mbcs(zSvcName), GENERIC_READ);
732 if( !hSvc ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
733 /* Get the service configuration */
@@ -784,11 +801,15 @@
801 SC_HANDLE hSvc;
802 SERVICE_STATUS sstat;
803 char *zErrFmt = "unable to start service '%s': %s";
804
805 verify_all_options();
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 = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
812 if( !hScm ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
813 hSvc = OpenService(hScm, fossil_utf8_to_mbcs(zSvcName), SERVICE_ALL_ACCESS);
814 if( !hSvc ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
815 QueryServiceStatus(hSvc, &sstat);
@@ -816,11 +837,15 @@
837 SC_HANDLE hSvc;
838 SERVICE_STATUS sstat;
839 char *zErrFmt = "unable to stop service '%s': %s";
840
841 verify_all_options();
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 = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
848 if( !hScm ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
849 hSvc = OpenService(hScm, fossil_utf8_to_mbcs(zSvcName), SERVICE_ALL_ACCESS);
850 if( !hSvc ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
851 QueryServiceStatus(hSvc, &sstat);
852
+54 -29
--- src/winhttp.c
+++ src/winhttp.c
@@ -267,24 +267,40 @@
267267
** message string. Call fossil_mbcs_free() to deallocate any memory used
268268
** to store the message string when done.
269269
*/
270270
static char *win32_get_last_errmsg(void){
271271
DWORD nMsg;
272
+ DWORD nErr = GetLastError();
272273
LPTSTR tmp = NULL;
273274
char *zMsg = NULL;
274275
276
+ /* Try first to get the error text in english. */
275277
nMsg = FormatMessage(
276278
FORMAT_MESSAGE_ALLOCATE_BUFFER |
277279
FORMAT_MESSAGE_FROM_SYSTEM |
278280
FORMAT_MESSAGE_IGNORE_INSERTS,
279281
NULL,
280
- GetLastError(),
282
+ nErr,
281283
MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),
282284
(LPTSTR) &tmp,
283285
0,
284286
NULL
285287
);
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
+ }
286302
if( nMsg ){
287303
zMsg = fossil_mbcs_to_utf8(tmp);
288304
}else{
289305
fossil_fatal("unable to get system error message.");
290306
}
@@ -301,11 +317,11 @@
301317
static void win32_report_service_status(
302318
DWORD dwCurrentState, /* The current state of the service */
303319
DWORD dwWin32ExitCode, /* The error code to report */
304320
DWORD dwWaitHint /* The estimated time for a pending operation */
305321
){
306
- if( dwCurrentState==SERVICE_START_PENDING) {
322
+ if( dwCurrentState==SERVICE_START_PENDING ){
307323
ssStatus.dwControlsAccepted = 0;
308324
}else{
309325
ssStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP;
310326
}
311327
ssStatus.dwCurrentState = dwCurrentState;
@@ -477,11 +493,11 @@
477493
** Password for the user account.
478494
**
479495
** The following options are more or less the same as for the "server"
480496
** command and influence the behaviour of the http server:
481497
**
482
-** -p|--port TCPPORT
498
+** -P|--port TCPPORT
483499
**
484500
** Specifies the TCP port (default port is 8080) on which the
485501
** server should listen.
486502
**
487503
** -R|--repository REPOSITORY
@@ -544,69 +560,62 @@
544560
if( g.argc<3 ){
545561
usage("create|delete|show|start|stop ...");
546562
}
547563
zMethod = g.argv[2];
548564
n = strlen(zMethod);
549
- if( g.argc==4 ){
550
- zSvcName = g.argv[3];
551
- }
552565
553566
if( strncmp(zMethod, "create", n)==0 ){
554567
SC_HANDLE hScm;
555568
SC_HANDLE hSvc;
556569
SERVICE_DESCRIPTION
557570
svcDescr = {"Fossil - Distributed Software Configuration Management"};
558571
char *zErrFmt = "unable to create service '%s': %s";
559572
DWORD dwStartType = SERVICE_DEMAND_START;
560
- const char *zDisplay;
561
- const char *zStart;
562
- const char *zUsername;
563
- const char *zPassword;
564
- const char *zPort;
565
- const char *zNotFound;
566
- const char *zLocalAuth;
567
- const char *zRepository;
573
+ const char *zDisplay = find_option("display", "D", 1);
574
+ const char *zStart = find_option("start", "S", 1);
575
+ const char *zUsername = find_option("username", "U", 1);
576
+ const char *zPassword = find_option("password", "W", 1);
577
+ const char *zPort = find_option("port", "P", 1);
578
+ const char *zNotFound = find_option("notfound", 0, 1);
579
+ const char *zLocalAuth = find_option("localauth", 0, 0);
580
+ const char *zRepository = find_option("repository", "R", 1);
568581
Blob binPath;
569582
583
+ verify_all_options();
584
+ if( g.argc==4 ){
585
+ zSvcName = g.argv[3];
586
+ }else if( g.argc>4 ){
587
+ fossil_fatal("to much arguments for create method.");
588
+ }
570589
/* Process service creation specific options. */
571
- zDisplay = find_option("display", "D", 1);
572590
if( !zDisplay ){
573591
zDisplay = zSvcName;
574592
}
575
- zStart = find_option("start", "S", 1);
576593
if( zStart ){
577594
if( strncmp(zStart, "auto", strlen(zStart))==0 ){
578595
dwStartType = SERVICE_AUTO_START;
579
- }else if( strncmp(zStart, "manual", strlen(zStart))==0 ){
596
+ }else if( strncmp(zStart, "manual", strlen(zStart))==0 ){
580597
dwStartType = SERVICE_DEMAND_START;
581598
}else{
582599
fossil_fatal(zErrFmt, zSvcName,
583600
"specify 'auto' or 'manual' for the '-S|--start' option");
584601
}
585602
}
586
- zUsername = find_option("username", "U", 1);
587
- zPassword = find_option("password", "W", 1);
588603
/* Process options for Fossil running as server. */
589
- zPort = find_option("port", "P", 1);
590604
if( zPort && (atoi(zPort)<=0) ){
591605
fossil_fatal(zErrFmt, zSvcName,
592606
"port number must be in the range 1 - 65535.");
593607
}
594
- zNotFound = find_option("notfound", 0, 1);
595
- zLocalAuth = find_option("localauth", 0, 0);
596
- zRepository = find_option("repository", "R", 1);
597608
if( !zRepository ){
598609
db_must_be_within_tree();
599610
}else if( file_isdir(zRepository)==1 ){
600611
g.zRepositoryName = mprintf("%s", zRepository);
601612
file_simplify_name(g.zRepositoryName, -1, 0);
602613
}else{
603614
db_open_repository(zRepository);
604615
}
605616
db_close(0);
606
- verify_all_options();
607
- if( g.argc>4 ) fossil_fatal("to much arguments for create method.");
608617
/* Build the fully-qualified path to the service binary file. */
609618
blob_zero(&binPath);
610619
blob_appendf(&binPath, "\"%s\" server", fossil_nameofexe());
611620
if( zPort ) blob_appendf(&binPath, " --port %s", zPort);
612621
if( zNotFound ) blob_appendf(&binPath, " --notfound \"%s\"", zNotFound);
@@ -642,11 +651,15 @@
642651
SC_HANDLE hSvc;
643652
SERVICE_STATUS sstat;
644653
char *zErrFmt = "unable to delete service '%s': %s";
645654
646655
verify_all_options();
647
- if( g.argc>4 ) fossil_fatal("to much arguments for delete method.");
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
+ }
648661
hScm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
649662
if( !hScm ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
650663
hSvc = OpenService(hScm, fossil_utf8_to_mbcs(zSvcName), SERVICE_ALL_ACCESS);
651664
if( !hSvc ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
652665
QueryServiceStatus(hSvc, &sstat);
@@ -706,11 +719,15 @@
706719
"Continue pending", "Pause pending", "Paused"
707720
};
708721
const char *zSvcState = "";
709722
710723
verify_all_options();
711
- if( g.argc>4 ) fossil_fatal("to much arguments for show method.");
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
+ }
712729
hScm = OpenSCManager(NULL, NULL, GENERIC_READ);
713730
if( !hScm ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
714731
hSvc = OpenService(hScm, fossil_utf8_to_mbcs(zSvcName), GENERIC_READ);
715732
if( !hSvc ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
716733
/* Get the service configuration */
@@ -784,11 +801,15 @@
784801
SC_HANDLE hSvc;
785802
SERVICE_STATUS sstat;
786803
char *zErrFmt = "unable to start service '%s': %s";
787804
788805
verify_all_options();
789
- if( g.argc>4 ) fossil_fatal("to much arguments for start method.");
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
+ }
790811
hScm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
791812
if( !hScm ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
792813
hSvc = OpenService(hScm, fossil_utf8_to_mbcs(zSvcName), SERVICE_ALL_ACCESS);
793814
if( !hSvc ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
794815
QueryServiceStatus(hSvc, &sstat);
@@ -816,11 +837,15 @@
816837
SC_HANDLE hSvc;
817838
SERVICE_STATUS sstat;
818839
char *zErrFmt = "unable to stop service '%s': %s";
819840
820841
verify_all_options();
821
- if( g.argc>4 ) fossil_fatal("to much arguments for stop method.");
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
+ }
822847
hScm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
823848
if( !hScm ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
824849
hSvc = OpenService(hScm, fossil_utf8_to_mbcs(zSvcName), SERVICE_ALL_ACCESS);
825850
if( !hSvc ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
826851
QueryServiceStatus(hSvc, &sstat);
827852
--- src/winhttp.c
+++ src/winhttp.c
@@ -267,24 +267,40 @@
267 ** message string. Call fossil_mbcs_free() to deallocate any memory used
268 ** to store the message string when done.
269 */
270 static char *win32_get_last_errmsg(void){
271 DWORD nMsg;
 
272 LPTSTR tmp = NULL;
273 char *zMsg = NULL;
274
 
275 nMsg = FormatMessage(
276 FORMAT_MESSAGE_ALLOCATE_BUFFER |
277 FORMAT_MESSAGE_FROM_SYSTEM |
278 FORMAT_MESSAGE_IGNORE_INSERTS,
279 NULL,
280 GetLastError(),
281 MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),
282 (LPTSTR) &tmp,
283 0,
284 NULL
285 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
286 if( nMsg ){
287 zMsg = fossil_mbcs_to_utf8(tmp);
288 }else{
289 fossil_fatal("unable to get system error message.");
290 }
@@ -301,11 +317,11 @@
301 static void win32_report_service_status(
302 DWORD dwCurrentState, /* The current state of the service */
303 DWORD dwWin32ExitCode, /* The error code to report */
304 DWORD dwWaitHint /* The estimated time for a pending operation */
305 ){
306 if( dwCurrentState==SERVICE_START_PENDING) {
307 ssStatus.dwControlsAccepted = 0;
308 }else{
309 ssStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP;
310 }
311 ssStatus.dwCurrentState = dwCurrentState;
@@ -477,11 +493,11 @@
477 ** Password for the user account.
478 **
479 ** The following options are more or less the same as for the "server"
480 ** command and influence the behaviour of the http server:
481 **
482 ** -p|--port TCPPORT
483 **
484 ** Specifies the TCP port (default port is 8080) on which the
485 ** server should listen.
486 **
487 ** -R|--repository REPOSITORY
@@ -544,69 +560,62 @@
544 if( g.argc<3 ){
545 usage("create|delete|show|start|stop ...");
546 }
547 zMethod = g.argv[2];
548 n = strlen(zMethod);
549 if( g.argc==4 ){
550 zSvcName = g.argv[3];
551 }
552
553 if( strncmp(zMethod, "create", n)==0 ){
554 SC_HANDLE hScm;
555 SC_HANDLE hSvc;
556 SERVICE_DESCRIPTION
557 svcDescr = {"Fossil - Distributed Software Configuration Management"};
558 char *zErrFmt = "unable to create service '%s': %s";
559 DWORD dwStartType = SERVICE_DEMAND_START;
560 const char *zDisplay;
561 const char *zStart;
562 const char *zUsername;
563 const char *zPassword;
564 const char *zPort;
565 const char *zNotFound;
566 const char *zLocalAuth;
567 const char *zRepository;
568 Blob binPath;
569
 
 
 
 
 
 
570 /* Process service creation specific options. */
571 zDisplay = find_option("display", "D", 1);
572 if( !zDisplay ){
573 zDisplay = zSvcName;
574 }
575 zStart = find_option("start", "S", 1);
576 if( zStart ){
577 if( strncmp(zStart, "auto", strlen(zStart))==0 ){
578 dwStartType = SERVICE_AUTO_START;
579 }else if( strncmp(zStart, "manual", strlen(zStart))==0 ){
580 dwStartType = SERVICE_DEMAND_START;
581 }else{
582 fossil_fatal(zErrFmt, zSvcName,
583 "specify 'auto' or 'manual' for the '-S|--start' option");
584 }
585 }
586 zUsername = find_option("username", "U", 1);
587 zPassword = find_option("password", "W", 1);
588 /* Process options for Fossil running as server. */
589 zPort = find_option("port", "P", 1);
590 if( zPort && (atoi(zPort)<=0) ){
591 fossil_fatal(zErrFmt, zSvcName,
592 "port number must be in the range 1 - 65535.");
593 }
594 zNotFound = find_option("notfound", 0, 1);
595 zLocalAuth = find_option("localauth", 0, 0);
596 zRepository = find_option("repository", "R", 1);
597 if( !zRepository ){
598 db_must_be_within_tree();
599 }else if( file_isdir(zRepository)==1 ){
600 g.zRepositoryName = mprintf("%s", zRepository);
601 file_simplify_name(g.zRepositoryName, -1, 0);
602 }else{
603 db_open_repository(zRepository);
604 }
605 db_close(0);
606 verify_all_options();
607 if( g.argc>4 ) fossil_fatal("to much arguments for create method.");
608 /* Build the fully-qualified path to the service binary file. */
609 blob_zero(&binPath);
610 blob_appendf(&binPath, "\"%s\" server", fossil_nameofexe());
611 if( zPort ) blob_appendf(&binPath, " --port %s", zPort);
612 if( zNotFound ) blob_appendf(&binPath, " --notfound \"%s\"", zNotFound);
@@ -642,11 +651,15 @@
642 SC_HANDLE hSvc;
643 SERVICE_STATUS sstat;
644 char *zErrFmt = "unable to delete service '%s': %s";
645
646 verify_all_options();
647 if( g.argc>4 ) fossil_fatal("to much arguments for delete method.");
 
 
 
 
648 hScm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
649 if( !hScm ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
650 hSvc = OpenService(hScm, fossil_utf8_to_mbcs(zSvcName), SERVICE_ALL_ACCESS);
651 if( !hSvc ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
652 QueryServiceStatus(hSvc, &sstat);
@@ -706,11 +719,15 @@
706 "Continue pending", "Pause pending", "Paused"
707 };
708 const char *zSvcState = "";
709
710 verify_all_options();
711 if( g.argc>4 ) fossil_fatal("to much arguments for show method.");
 
 
 
 
712 hScm = OpenSCManager(NULL, NULL, GENERIC_READ);
713 if( !hScm ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
714 hSvc = OpenService(hScm, fossil_utf8_to_mbcs(zSvcName), GENERIC_READ);
715 if( !hSvc ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
716 /* Get the service configuration */
@@ -784,11 +801,15 @@
784 SC_HANDLE hSvc;
785 SERVICE_STATUS sstat;
786 char *zErrFmt = "unable to start service '%s': %s";
787
788 verify_all_options();
789 if( g.argc>4 ) fossil_fatal("to much arguments for start method.");
 
 
 
 
790 hScm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
791 if( !hScm ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
792 hSvc = OpenService(hScm, fossil_utf8_to_mbcs(zSvcName), SERVICE_ALL_ACCESS);
793 if( !hSvc ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
794 QueryServiceStatus(hSvc, &sstat);
@@ -816,11 +837,15 @@
816 SC_HANDLE hSvc;
817 SERVICE_STATUS sstat;
818 char *zErrFmt = "unable to stop service '%s': %s";
819
820 verify_all_options();
821 if( g.argc>4 ) fossil_fatal("to much arguments for stop method.");
 
 
 
 
822 hScm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
823 if( !hScm ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
824 hSvc = OpenService(hScm, fossil_utf8_to_mbcs(zSvcName), SERVICE_ALL_ACCESS);
825 if( !hSvc ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
826 QueryServiceStatus(hSvc, &sstat);
827
--- src/winhttp.c
+++ src/winhttp.c
@@ -267,24 +267,40 @@
267 ** message string. Call fossil_mbcs_free() to deallocate any memory used
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 ){
303 zMsg = fossil_mbcs_to_utf8(tmp);
304 }else{
305 fossil_fatal("unable to get system error message.");
306 }
@@ -301,11 +317,11 @@
317 static void win32_report_service_status(
318 DWORD dwCurrentState, /* The current state of the service */
319 DWORD dwWin32ExitCode, /* The error code to report */
320 DWORD dwWaitHint /* The estimated time for a pending operation */
321 ){
322 if( dwCurrentState==SERVICE_START_PENDING ){
323 ssStatus.dwControlsAccepted = 0;
324 }else{
325 ssStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP;
326 }
327 ssStatus.dwCurrentState = dwCurrentState;
@@ -477,11 +493,11 @@
493 ** Password for the user account.
494 **
495 ** The following options are more or less the same as for the "server"
496 ** command and influence the behaviour of the http server:
497 **
498 ** -P|--port TCPPORT
499 **
500 ** Specifies the TCP port (default port is 8080) on which the
501 ** server should listen.
502 **
503 ** -R|--repository REPOSITORY
@@ -544,69 +560,62 @@
560 if( g.argc<3 ){
561 usage("create|delete|show|start|stop ...");
562 }
563 zMethod = g.argv[2];
564 n = strlen(zMethod);
 
 
 
565
566 if( strncmp(zMethod, "create", n)==0 ){
567 SC_HANDLE hScm;
568 SC_HANDLE hSvc;
569 SERVICE_DESCRIPTION
570 svcDescr = {"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);
575 const char *zUsername = find_option("username", "U", 1);
576 const char *zPassword = find_option("password", "W", 1);
577 const char *zPort = find_option("port", "P", 1);
578 const char *zNotFound = find_option("notfound", 0, 1);
579 const char *zLocalAuth = find_option("localauth", 0, 0);
580 const char *zRepository = find_option("repository", "R", 1);
581 Blob binPath;
582
583 verify_all_options();
584 if( g.argc==4 ){
585 zSvcName = g.argv[3];
586 }else if( g.argc>4 ){
587 fossil_fatal("to much arguments for create method.");
588 }
589 /* Process service creation specific options. */
 
590 if( !zDisplay ){
591 zDisplay = zSvcName;
592 }
 
593 if( zStart ){
594 if( strncmp(zStart, "auto", strlen(zStart))==0 ){
595 dwStartType = SERVICE_AUTO_START;
596 }else if( strncmp(zStart, "manual", strlen(zStart))==0 ){
597 dwStartType = SERVICE_DEMAND_START;
598 }else{
599 fossil_fatal(zErrFmt, zSvcName,
600 "specify 'auto' or 'manual' for the '-S|--start' option");
601 }
602 }
 
 
603 /* Process options for Fossil running as server. */
 
604 if( zPort && (atoi(zPort)<=0) ){
605 fossil_fatal(zErrFmt, zSvcName,
606 "port number must be in the range 1 - 65535.");
607 }
 
 
 
608 if( !zRepository ){
609 db_must_be_within_tree();
610 }else if( file_isdir(zRepository)==1 ){
611 g.zRepositoryName = mprintf("%s", zRepository);
612 file_simplify_name(g.zRepositoryName, -1, 0);
613 }else{
614 db_open_repository(zRepository);
615 }
616 db_close(0);
 
 
617 /* Build the fully-qualified path to the service binary file. */
618 blob_zero(&binPath);
619 blob_appendf(&binPath, "\"%s\" server", fossil_nameofexe());
620 if( zPort ) blob_appendf(&binPath, " --port %s", zPort);
621 if( zNotFound ) blob_appendf(&binPath, " --notfound \"%s\"", zNotFound);
@@ -642,11 +651,15 @@
651 SC_HANDLE hSvc;
652 SERVICE_STATUS sstat;
653 char *zErrFmt = "unable to delete service '%s': %s";
654
655 verify_all_options();
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 = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
662 if( !hScm ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
663 hSvc = OpenService(hScm, fossil_utf8_to_mbcs(zSvcName), SERVICE_ALL_ACCESS);
664 if( !hSvc ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
665 QueryServiceStatus(hSvc, &sstat);
@@ -706,11 +719,15 @@
719 "Continue pending", "Pause pending", "Paused"
720 };
721 const char *zSvcState = "";
722
723 verify_all_options();
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 = OpenSCManager(NULL, NULL, GENERIC_READ);
730 if( !hScm ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
731 hSvc = OpenService(hScm, fossil_utf8_to_mbcs(zSvcName), GENERIC_READ);
732 if( !hSvc ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
733 /* Get the service configuration */
@@ -784,11 +801,15 @@
801 SC_HANDLE hSvc;
802 SERVICE_STATUS sstat;
803 char *zErrFmt = "unable to start service '%s': %s";
804
805 verify_all_options();
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 = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
812 if( !hScm ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
813 hSvc = OpenService(hScm, fossil_utf8_to_mbcs(zSvcName), SERVICE_ALL_ACCESS);
814 if( !hSvc ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
815 QueryServiceStatus(hSvc, &sstat);
@@ -816,11 +837,15 @@
837 SC_HANDLE hSvc;
838 SERVICE_STATUS sstat;
839 char *zErrFmt = "unable to stop service '%s': %s";
840
841 verify_all_options();
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 = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
848 if( !hScm ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
849 hSvc = OpenService(hScm, fossil_utf8_to_mbcs(zSvcName), SERVICE_ALL_ACCESS);
850 if( !hSvc ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
851 QueryServiceStatus(hSvc, &sstat);
852

Keyboard Shortcuts

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