Fossil

Changes On Branch berner-nt4
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Changes In Branch berner-nt4 Excluding Merge-Ins

This is equivalent to a diff from d9aa512e20 to 8a84c6e82e

2013-02-18
08:30
merge trunk check-in: fdd51b617c user: jan.nijtmans tags: ticket-d17d6e5b17
2013-01-29
08:52
Patch from Edward Berner for Windows NT 4.0 (derived from wrong branch) Closed-Leaf check-in: 8a84c6e82e user: jan.nijtmans tags: berner-nt4
2013-01-28
13:09
win32: files with invalid chars were not deleted sometimes with "fossil update" check-in: d9aa512e20 user: jan.nijtmans tags: ticket-d17d6e5b17
2013-01-27
21:56
Fix file_simplify_name and file_is_absolute_path for cygwin check-in: b293b744db user: jan.nijtmans tags: ticket-d17d6e5b17

Changes to src/winhttp.c.

453
454
455
456
457
458
459









460
461
462
463
464
465
466
    }else{
      fossil_fatal("error from StartServiceCtrlDispatcher()");
    }
  }
  return 0;
}










/* dupe ifdef needed for mkindex
** COMMAND: winsrv*
** Usage: fossil winsrv METHOD ?SERVICE-NAME? ?OPTIONS?
**
** Where METHOD is one of: create delete show start stop.
**
** The winsrv command manages Fossil as a Windows service.  This allows







>
>
>
>
>
>
>
>
>







453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
    }else{
      fossil_fatal("error from StartServiceCtrlDispatcher()");
    }
  }
  return 0;
}

/*
** The ChangeServiceConfig2W and QueryServiceConfig2W functions are
** loaded at run time in the cmd_win32_service function.  These
** typedefs provide proper types for the function pointers.
*/
typedef BOOL (WINAPI *CHANGESERVICECONFIG2W)(SC_HANDLE, DWORD, LPVOID);
typedef BOOL (WINAPI *QUERYSERVICECONFIG2W)(SC_HANDLE, DWORD, LPBYTE,
                                            DWORD, LPDWORD);

/* dupe ifdef needed for mkindex
** COMMAND: winsrv*
** Usage: fossil winsrv METHOD ?SERVICE-NAME? ?OPTIONS?
**
** Where METHOD is one of: create delete show start stop.
**
** The winsrv command manages Fossil as a Windows service.  This allows
560
561
562
563
564
565
566















567
568
569
570
571
572
573
**       requires administrative rights on the machine executed.
**
*/
void cmd_win32_service(void){
  int n;
  const char *zMethod;
  const char *zSvcName = "Fossil-DSCM";    /* Default service name */
















  if( g.argc<3 ){
    usage("create|delete|show|start|stop ...");
  }
  zMethod = g.argv[2];
  n = strlen(zMethod);








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
**       requires administrative rights on the machine executed.
**
*/
void cmd_win32_service(void){
  int n;
  const char *zMethod;
  const char *zSvcName = "Fossil-DSCM";    /* Default service name */
  HINSTANCE hinstLib = NULL;
  CHANGESERVICECONFIG2W ChangeServiceConfig2WAddr = NULL;
  QUERYSERVICECONFIG2W QueryServiceConfig2WAddr = NULL;

  /* The ChangeServiceConfig2W and QueryServiceConfig2W functions are
  ** not supported on Windows NT 4.0, so we load them at run time with
  ** GetProcAddress and only call them if they exist.
  */
  hinstLib = LoadLibrary(TEXT("advapi32.dll"));
  if( NULL != hinstLib ){
    ChangeServiceConfig2WAddr =
      (CHANGESERVICECONFIG2W) GetProcAddress(hinstLib, "ChangeServiceConfig2W");
    QueryServiceConfig2WAddr =
      (QUERYSERVICECONFIG2W) GetProcAddress(hinstLib, "QueryServiceConfig2W");
  }

  if( g.argc<3 ){
    usage("create|delete|show|start|stop ...");
  }
  zMethod = g.argv[2];
  n = strlen(zMethod);

647
648
649
650
651
652
653

654

655
656
657
658
659
660
661
             NULL,                                    /* Tag value */
             NULL,                                    /* Service dependencies */
             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. */

    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 ){
    SC_HANDLE hScm;
    SC_HANDLE hSvc;







>
|
>







671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
             NULL,                                    /* Tag value */
             NULL,                                    /* Service dependencies */
             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. */
    if( ChangeServiceConfig2WAddr ){
      ChangeServiceConfig2WAddr(hSvc, SERVICE_CONFIG_DESCRIPTION, &svcDescr);
    }
    fossil_print("Service '%s' successfully created.\n", zSvcName);
    CloseServiceHandle(hSvc);
    CloseServiceHandle(hScm);
  }else
  if( strncmp(zMethod, "delete", n)==0 ){
    SC_HANDLE hScm;
    SC_HANDLE hSvc;
762
763
764
765
766
767
768

769
770
771
772
773
774
775
776
777




778
779
780
781
782
783
784
      case SERVICE_BOOT_START:    zSvcStartType = zSvcStartTypes[0]; break;
      case SERVICE_SYSTEM_START:  zSvcStartType = zSvcStartTypes[1]; break;
      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 = 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 = 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());
    /* Translate the current state. */
    switch( sstat.dwCurrentState ){
      case SERVICE_STOPPED:          zSvcState = zSvcStates[0]; break;
      case SERVICE_START_PENDING:    zSvcState = zSvcStates[1]; break;







>
|
|
|
|
|
|
|
|
|
>
>
>
>







788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
      case SERVICE_BOOT_START:    zSvcStartType = zSvcStartTypes[0]; break;
      case SERVICE_SYSTEM_START:  zSvcStartType = zSvcStartTypes[1]; break;
      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. */
    if( QueryServiceConfig2WAddr ){
      bStatus = QueryServiceConfig2WAddr(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 = QueryServiceConfig2WAddr(hSvc, SERVICE_CONFIG_DESCRIPTION,
                                    (LPBYTE)pSvcDescr, nRequired, &nRequired);
      if( !bStatus ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
    }else{
      pSvcDescr = fossil_malloc(sizeof(SERVICE_DESCRIPTIONW));
      pSvcDescr->lpDescription = L"";
    }
    /* Retrieves the current status of the specified service. */
    bStatus = QueryServiceStatus(hSvc, &sstat);
    if( !bStatus ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
    /* Translate the current state. */
    switch( sstat.dwCurrentState ){
      case SERVICE_STOPPED:          zSvcState = zSvcStates[0]; break;
      case SERVICE_START_PENDING:    zSvcState = zSvcStates[1]; break;
881
882
883
884
885
886
887



888
889
890
    CloseServiceHandle(hSvc);
    CloseServiceHandle(hScm);
  }else
  {
    fossil_fatal("METHOD should be one of:"
                 " create delete show start stop");
  }



  return;
}
#endif /* _WIN32  -- This code is for win32 only */







>
>
>



912
913
914
915
916
917
918
919
920
921
922
923
924
    CloseServiceHandle(hSvc);
    CloseServiceHandle(hScm);
  }else
  {
    fossil_fatal("METHOD should be one of:"
                 " create delete show start stop");
  }
  if( NULL != hinstLib ){
    FreeLibrary(hinstLib);
  }
  return;
}
#endif /* _WIN32  -- This code is for win32 only */