| | @@ -191,11 +191,11 @@ |
| 191 | 191 | }else{ |
| 192 | 192 | fossil_fatal("unable to open listening socket on any" |
| 193 | 193 | " port in the range %d..%d", mnPort, mxPort); |
| 194 | 194 | } |
| 195 | 195 | } |
| 196 | | - if( !GetTempPath(MAX_PATH, zTmpPath) ){ |
| 196 | + if( !GetTempPathW(MAX_PATH, zTmpPath) ){ |
| 197 | 197 | fossil_fatal("unable to get path to the temporary directory."); |
| 198 | 198 | } |
| 199 | 199 | zTempPrefix = mprintf("%sfossil_server_P%d_", fossil_unicode_to_utf8(zTmpPath), iPort); |
| 200 | 200 | fossil_print("Listening for HTTP requests on TCP port %d\n", iPort); |
| 201 | 201 | if( zBrowser ){ |
| | @@ -268,35 +268,35 @@ |
| 268 | 268 | ** to store the message string when done. |
| 269 | 269 | */ |
| 270 | 270 | static char *win32_get_last_errmsg(void){ |
| 271 | 271 | DWORD nMsg; |
| 272 | 272 | DWORD nErr = GetLastError(); |
| 273 | | - LPTSTR tmp = NULL; |
| 273 | + LPWSTR tmp = NULL; |
| 274 | 274 | char *zMsg = NULL; |
| 275 | 275 | |
| 276 | 276 | /* Try first to get the error text in english. */ |
| 277 | | - nMsg = FormatMessage( |
| 277 | + nMsg = FormatMessageW( |
| 278 | 278 | FORMAT_MESSAGE_ALLOCATE_BUFFER | |
| 279 | 279 | FORMAT_MESSAGE_FROM_SYSTEM | |
| 280 | 280 | FORMAT_MESSAGE_IGNORE_INSERTS, |
| 281 | 281 | NULL, |
| 282 | 282 | nErr, |
| 283 | 283 | MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), |
| 284 | | - (LPTSTR) &tmp, |
| 284 | + (LPWSTR) &tmp, |
| 285 | 285 | 0, |
| 286 | 286 | NULL |
| 287 | 287 | ); |
| 288 | 288 | if( !nMsg ){ |
| 289 | 289 | /* No english, get what the system has available. */ |
| 290 | | - nMsg = FormatMessage( |
| 290 | + nMsg = FormatMessageW( |
| 291 | 291 | FORMAT_MESSAGE_ALLOCATE_BUFFER | |
| 292 | 292 | FORMAT_MESSAGE_FROM_SYSTEM | |
| 293 | 293 | FORMAT_MESSAGE_IGNORE_INSERTS, |
| 294 | 294 | NULL, |
| 295 | 295 | nErr, |
| 296 | 296 | 0, |
| 297 | | - (LPTSTR) &tmp, |
| 297 | + (LPWSTR) &tmp, |
| 298 | 298 | 0, |
| 299 | 299 | NULL |
| 300 | 300 | ); |
| 301 | 301 | } |
| 302 | 302 | if( nMsg ){ |
| | @@ -374,21 +374,21 @@ |
| 374 | 374 | ** creates a new thread to execute the ServiceMain function (this function) |
| 375 | 375 | ** of the service being started. |
| 376 | 376 | */ |
| 377 | 377 | static void WINAPI win32_http_service_main( |
| 378 | 378 | DWORD argc, /* Number of arguments in argv */ |
| 379 | | - LPTSTR *argv /* Arguments passed */ |
| 379 | + LPWSTR *argv /* Arguments passed */ |
| 380 | 380 | ){ |
| 381 | 381 | |
| 382 | 382 | /* Update the service information. */ |
| 383 | 383 | hsData.isRunningAsService = 1; |
| 384 | 384 | if( argc>0 ){ |
| 385 | 385 | hsData.zServiceName = argv[0]; |
| 386 | 386 | } |
| 387 | 387 | |
| 388 | 388 | /* Register the service control handler function */ |
| 389 | | - sshStatusHandle = RegisterServiceCtrlHandler(L"", win32_http_service_ctrl); |
| 389 | + sshStatusHandle = RegisterServiceCtrlHandlerW(L"", win32_http_service_ctrl); |
| 390 | 390 | if( !sshStatusHandle ){ |
| 391 | 391 | win32_report_service_status(SERVICE_STOPPED, NO_ERROR, 0); |
| 392 | 392 | return; |
| 393 | 393 | } |
| 394 | 394 | |
| | @@ -428,30 +428,29 @@ |
| 428 | 428 | int nPort, /* TCP port number */ |
| 429 | 429 | const char *zNotFound, /* The --notfound option, or NULL */ |
| 430 | 430 | int flags /* One or more HTTP_SERVER_ flags */ |
| 431 | 431 | ){ |
| 432 | 432 | /* 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}}; |
| 435 | 435 | |
| 436 | 436 | /* Initialize the HttpService structure. */ |
| 437 | 437 | hsData.port = nPort; |
| 438 | 438 | hsData.zNotFound = zNotFound; |
| 439 | 439 | hsData.flags = flags; |
| 440 | 440 | |
| 441 | 441 | /* Try to start the control dispatcher thread for the service. */ |
| 442 | | - if( !StartServiceCtrlDispatcher(ServiceTable) ){ |
| 442 | + if( !StartServiceCtrlDispatcherW(ServiceTable) ){ |
| 443 | 443 | if( GetLastError()==ERROR_FAILED_SERVICE_CONTROLLER_CONNECT ){ |
| 444 | 444 | return 1; |
| 445 | 445 | }else{ |
| 446 | 446 | fossil_fatal("error from StartServiceCtrlDispatcher()"); |
| 447 | 447 | } |
| 448 | 448 | } |
| 449 | 449 | return 0; |
| 450 | 450 | } |
| 451 | 451 | |
| 452 | | -#ifdef _WIN32 |
| 453 | 452 | /* dupe ifdef needed for mkindex |
| 454 | 453 | ** COMMAND: winsrv* |
| 455 | 454 | ** Usage: fossil winsrv METHOD ?SERVICE-NAME? ?OPTIONS? |
| 456 | 455 | ** |
| 457 | 456 | ** Where METHOD is one of: create delete show start stop. |
| | @@ -565,11 +564,11 @@ |
| 565 | 564 | n = strlen(zMethod); |
| 566 | 565 | |
| 567 | 566 | if( strncmp(zMethod, "create", n)==0 ){ |
| 568 | 567 | SC_HANDLE hScm; |
| 569 | 568 | SC_HANDLE hSvc; |
| 570 | | - SERVICE_DESCRIPTION |
| 569 | + SERVICE_DESCRIPTIONW |
| 571 | 570 | svcDescr = {L"Fossil - Distributed Software Configuration Management"}; |
| 572 | 571 | char *zErrFmt = "unable to create service '%s': %s"; |
| 573 | 572 | DWORD dwStartType = SERVICE_DEMAND_START; |
| 574 | 573 | const char *zDisplay = find_option("display", "D", 1); |
| 575 | 574 | const char *zStart = find_option("start", "S", 1); |
| | @@ -621,13 +620,13 @@ |
| 621 | 620 | if( zPort ) blob_appendf(&binPath, " --port %s", zPort); |
| 622 | 621 | if( zNotFound ) blob_appendf(&binPath, " --notfound \"%s\"", zNotFound); |
| 623 | 622 | if( zLocalAuth ) blob_append(&binPath, " --localauth", -1); |
| 624 | 623 | blob_appendf(&binPath, " \"%s\"", g.zRepositoryName); |
| 625 | 624 | /* Create the service. */ |
| 626 | | - hScm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); |
| 625 | + hScm = OpenSCManagerW(NULL, NULL, SC_MANAGER_ALL_ACCESS); |
| 627 | 626 | if( !hScm ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg()); |
| 628 | | - hSvc = CreateService( |
| 627 | + hSvc = CreateServiceW( |
| 629 | 628 | hScm, /* Handle to the SCM */ |
| 630 | 629 | fossil_utf8_to_unicode(zSvcName), /* Name of the service */ |
| 631 | 630 | fossil_utf8_to_unicode(zDisplay), /* Display name */ |
| 632 | 631 | SERVICE_ALL_ACCESS, /* Desired access */ |
| 633 | 632 | SERVICE_WIN32_OWN_PROCESS, /* Service type */ |
| | @@ -640,11 +639,11 @@ |
| 640 | 639 | fossil_utf8_to_unicode(zUsername), /* Service account */ |
| 641 | 640 | fossil_utf8_to_unicode(zPassword) /* Account password */ |
| 642 | 641 | ); |
| 643 | 642 | if( !hSvc ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg()); |
| 644 | 643 | /* Set the service description. */ |
| 645 | | - ChangeServiceConfig2(hSvc, SERVICE_CONFIG_DESCRIPTION, &svcDescr); |
| 644 | + ChangeServiceConfig2W(hSvc, SERVICE_CONFIG_DESCRIPTION, &svcDescr); |
| 646 | 645 | fossil_print("Service '%s' successfully created.\n", zSvcName); |
| 647 | 646 | CloseServiceHandle(hSvc); |
| 648 | 647 | CloseServiceHandle(hScm); |
| 649 | 648 | }else |
| 650 | 649 | if( strncmp(zMethod, "delete", n)==0 ){ |
| | @@ -657,13 +656,13 @@ |
| 657 | 656 | if( g.argc==4 ){ |
| 658 | 657 | zSvcName = g.argv[3]; |
| 659 | 658 | }else if( g.argc>4 ){ |
| 660 | 659 | fossil_fatal("to much arguments for delete method."); |
| 661 | 660 | } |
| 662 | | - hScm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); |
| 661 | + hScm = OpenSCManagerW(NULL, NULL, SC_MANAGER_ALL_ACCESS); |
| 663 | 662 | 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); |
| 665 | 664 | if( !hSvc ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg()); |
| 666 | 665 | QueryServiceStatus(hSvc, &sstat); |
| 667 | 666 | if( sstat.dwCurrentState!=SERVICE_STOPPED ){ |
| 668 | 667 | fossil_print("Stopping service '%s'", zSvcName); |
| 669 | 668 | if( sstat.dwCurrentState!=SERVICE_STOP_PENDING ){ |
| | @@ -692,12 +691,12 @@ |
| 692 | 691 | }else |
| 693 | 692 | if( strncmp(zMethod, "show", n)==0 ){ |
| 694 | 693 | SC_HANDLE hScm; |
| 695 | 694 | SC_HANDLE hSvc; |
| 696 | 695 | SERVICE_STATUS sstat; |
| 697 | | - LPQUERY_SERVICE_CONFIG pSvcConfig; |
| 698 | | - LPSERVICE_DESCRIPTION pSvcDescr; |
| 696 | + LPQUERY_SERVICE_CONFIGW pSvcConfig; |
| 697 | + LPSERVICE_DESCRIPTIONW pSvcDescr; |
| 699 | 698 | BOOL bStatus; |
| 700 | 699 | DWORD nRequired; |
| 701 | 700 | const char *zErrFmt = "unable to show service '%s': %s"; |
| 702 | 701 | static const char *const zSvcTypes[] = { |
| 703 | 702 | "Driver service", |
| | @@ -725,21 +724,21 @@ |
| 725 | 724 | if( g.argc==4 ){ |
| 726 | 725 | zSvcName = g.argv[3]; |
| 727 | 726 | }else if( g.argc>4 ){ |
| 728 | 727 | fossil_fatal("to much arguments for show method."); |
| 729 | 728 | } |
| 730 | | - hScm = OpenSCManager(NULL, NULL, GENERIC_READ); |
| 729 | + hScm = OpenSCManagerW(NULL, NULL, GENERIC_READ); |
| 731 | 730 | 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); |
| 733 | 732 | if( !hSvc ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg()); |
| 734 | 733 | /* Get the service configuration */ |
| 735 | | - bStatus = QueryServiceConfig(hSvc, NULL, 0, &nRequired); |
| 734 | + bStatus = QueryServiceConfigW(hSvc, NULL, 0, &nRequired); |
| 736 | 735 | if( !bStatus && GetLastError()!=ERROR_INSUFFICIENT_BUFFER ){ |
| 737 | 736 | fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg()); |
| 738 | 737 | } |
| 739 | 738 | pSvcConfig = fossil_malloc(nRequired); |
| 740 | | - bStatus = QueryServiceConfig(hSvc, pSvcConfig, nRequired, &nRequired); |
| 739 | + bStatus = QueryServiceConfigW(hSvc, pSvcConfig, nRequired, &nRequired); |
| 741 | 740 | if( !bStatus ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg()); |
| 742 | 741 | /* Translate the service type */ |
| 743 | 742 | switch( pSvcConfig->dwServiceType ){ |
| 744 | 743 | case SERVICE_KERNEL_DRIVER: zSvcType = zSvcTypes[0]; break; |
| 745 | 744 | case SERVICE_FILE_SYSTEM_DRIVER: zSvcType = zSvcTypes[1]; break; |
| | @@ -754,17 +753,17 @@ |
| 754 | 753 | case SERVICE_AUTO_START: zSvcStartType = zSvcStartTypes[2]; break; |
| 755 | 754 | case SERVICE_DEMAND_START: zSvcStartType = zSvcStartTypes[3]; break; |
| 756 | 755 | case SERVICE_DISABLED: zSvcStartType = zSvcStartTypes[4]; break; |
| 757 | 756 | } |
| 758 | 757 | /* Get the service description. */ |
| 759 | | - bStatus = QueryServiceConfig2(hSvc, SERVICE_CONFIG_DESCRIPTION, |
| 758 | + bStatus = QueryServiceConfig2W(hSvc, SERVICE_CONFIG_DESCRIPTION, |
| 760 | 759 | NULL, 0, &nRequired); |
| 761 | 760 | if( !bStatus && GetLastError()!=ERROR_INSUFFICIENT_BUFFER ){ |
| 762 | 761 | fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg()); |
| 763 | 762 | } |
| 764 | 763 | pSvcDescr = fossil_malloc(nRequired); |
| 765 | | - bStatus = QueryServiceConfig2(hSvc, SERVICE_CONFIG_DESCRIPTION, |
| 764 | + bStatus = QueryServiceConfig2W(hSvc, SERVICE_CONFIG_DESCRIPTION, |
| 766 | 765 | (LPBYTE)pSvcDescr, nRequired, &nRequired); |
| 767 | 766 | if( !bStatus ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg()); |
| 768 | 767 | /* Retrieves the current status of the specified service. */ |
| 769 | 768 | bStatus = QueryServiceStatus(hSvc, &sstat); |
| 770 | 769 | if( !bStatus ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg()); |
| | @@ -807,19 +806,19 @@ |
| 807 | 806 | if( g.argc==4 ){ |
| 808 | 807 | zSvcName = g.argv[3]; |
| 809 | 808 | }else if( g.argc>4 ){ |
| 810 | 809 | fossil_fatal("to much arguments for start method."); |
| 811 | 810 | } |
| 812 | | - hScm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); |
| 811 | + hScm = OpenSCManagerW(NULL, NULL, SC_MANAGER_ALL_ACCESS); |
| 813 | 812 | 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); |
| 815 | 814 | if( !hSvc ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg()); |
| 816 | 815 | QueryServiceStatus(hSvc, &sstat); |
| 817 | 816 | if( sstat.dwCurrentState!=SERVICE_RUNNING ){ |
| 818 | 817 | fossil_print("Starting service '%s'", zSvcName); |
| 819 | 818 | if( sstat.dwCurrentState!=SERVICE_START_PENDING ){ |
| 820 | | - if( !StartService(hSvc, 0, NULL) ){ |
| 819 | + if( !StartServiceW(hSvc, 0, NULL) ){ |
| 821 | 820 | fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg()); |
| 822 | 821 | } |
| 823 | 822 | } |
| 824 | 823 | while( sstat.dwCurrentState!=SERVICE_RUNNING ){ |
| 825 | 824 | Sleep(100); |
| | @@ -843,13 +842,13 @@ |
| 843 | 842 | if( g.argc==4 ){ |
| 844 | 843 | zSvcName = g.argv[3]; |
| 845 | 844 | }else if( g.argc>4 ){ |
| 846 | 845 | fossil_fatal("to much arguments for stop method."); |
| 847 | 846 | } |
| 848 | | - hScm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); |
| 847 | + hScm = OpenSCManagerW(NULL, NULL, SC_MANAGER_ALL_ACCESS); |
| 849 | 848 | 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); |
| 851 | 850 | if( !hSvc ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg()); |
| 852 | 851 | QueryServiceStatus(hSvc, &sstat); |
| 853 | 852 | if( sstat.dwCurrentState!=SERVICE_STOPPED ){ |
| 854 | 853 | fossil_print("Stopping service '%s'", zSvcName); |
| 855 | 854 | if( sstat.dwCurrentState!=SERVICE_STOP_PENDING ){ |
| | @@ -873,8 +872,6 @@ |
| 873 | 872 | fossil_fatal("METHOD should be one of:" |
| 874 | 873 | " create delete show start stop"); |
| 875 | 874 | } |
| 876 | 875 | return; |
| 877 | 876 | } |
| 878 | | -#endif /* _WIN32 */ |
| 879 | | - |
| 880 | 877 | #endif /* _WIN32 -- This code is for win32 only */ |
| 881 | 878 | |