commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject cvs commit: jakarta-commons/daemon/src/native/nt/procrun/apps/prunmgr prunmgr.c
Date Sat, 18 Sep 2004 19:22:09 GMT
mturk       2004/09/18 12:22:09

  Modified:    daemon/src/native/nt/procrun/apps/prunmgr prunmgr.c
  Log:
  Added //MR and //MQ command line options.
  The first behaves like MS but starts the service when run.
  The second closes all monitor applications, so that uninstaller
  doesn't complain about running applications.
  
  Revision  Changes    Path
  1.6       +31 -10    jakarta-commons/daemon/src/native/nt/procrun/apps/prunmgr/prunmgr.c
  
  Index: prunmgr.c
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/daemon/src/native/nt/procrun/apps/prunmgr/prunmgr.c,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- prunmgr.c	13 Sep 2004 06:04:17 -0000	1.5
  +++ prunmgr.c	18 Sep 2004 19:22:08 -0000	1.6
  @@ -76,6 +76,8 @@
   static LPCWSTR _commands[] = {
       L"ES",      /* 1 Manage Service (default)*/
       L"MS",      /* 2 Monitor Service */
  +    L"MR",      /* 3 Monitor Service and start if not runing */
  +    L"MQ",      /* 4 Quit all running Monitor applications */
       NULL
   };
   
  @@ -1554,6 +1556,7 @@
       MSG    msg;
       LPAPXCMDLINE lpCmdline;
       HANDLE mutex = NULL;
  +    BOOL quiet = FALSE;
   
       apxHandleManagerInitialize();
       hPool     = apxPoolCreate(NULL, 0);
  @@ -1573,11 +1576,14 @@
                           lpCmdLine);
           goto cleanup;
       }
  -    else if (lpCmdline->dwCmdIndex == 2)
  +    else if (lpCmdline->dwCmdIndex == 4)
  +        quiet = TRUE;
  +    else if (lpCmdline->dwCmdIndex >= 2)
           bEnableTry = TRUE;
       hService = apxCreateService(hPool, GENERIC_ALL, FALSE);
       if (IS_INVALID_HANDLE(hService)) {
  -        apxDisplayError(TRUE, NULL, 0, "Unable to open the Service Manager");
  +        if (!quiet)
  +            apxDisplayError(TRUE, NULL, 0, "Unable to open the Service Manager");
           goto cleanup;
       }
       /* Open the main service handle */
  @@ -1586,15 +1592,17 @@
           if (*w == L'w')
               *w = L'\0';
           if (!apxServiceOpen(hService, lpCmdline->szApplication)) {
  -            apxDisplayError(TRUE, NULL, 0, "Unable to open the service '%S'",
  -                            lpCmdline->szApplication);
  +            if (!quiet)
  +                apxDisplayError(TRUE, NULL, 0, "Unable to open the service '%S'",
  +                                lpCmdline->szApplication);
               goto cleanup;
           }
       }
       /* Obtain service parameters and status */
       if (!(_currentEntry = apxServiceEntry(hService, TRUE))) {
  -        apxDisplayError(TRUE, NULL, 0, "Unable to query the service '%S' status",
  -                        lpCmdline->szApplication);
  +        if (!quiet)
  +            apxDisplayError(TRUE, NULL, 0, "Unable to query the service '%S' status",
  +                            lpCmdline->szApplication);
           goto cleanup;
       }
   #ifdef _UNICODE
  @@ -1607,21 +1615,31 @@
       }
   #endif
       if (!_gui_store) {
  -        apxDisplayError(TRUE, NULL, 0, "Unable to initialize GUI manager");
  +        if (!quiet)
  +            apxDisplayError(TRUE, NULL, 0, "Unable to initialize GUI manager");
           goto cleanup;
       }
       hIcoRun  = LoadImage(_gui_store->hInstance, MAKEINTRESOURCE(IDI_ICONRUN),
                            IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);  
       hIcoStop = LoadImage(_gui_store->hInstance, MAKEINTRESOURCE(IDI_ICONSTOP),
                            IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);  
  +    
  +    /* Handle //MQ// option */
  +    if (lpCmdline->dwCmdIndex == 4) {
  +        HANDLE hOther = FindWindow(_gui_store->szWndClass, NULL);
  +        if (hOther)
  +            SendMessage(hOther, WM_CLOSE, 0, 0);
  +        goto cleanup;
  +    }
   
       if (!_options[0].dwValue) {
           mutex = CreateMutex(NULL, FALSE, _gui_store->szWndMutex);
           if ((mutex == NULL) || (GetLastError() == ERROR_ALREADY_EXISTS)) { 
               /* Skip sytem error message */
               SetLastError(ERROR_SUCCESS);
  -            apxDisplayError(TRUE, NULL, 0, apxLoadResourceA(IDS_ALREAY_RUNING, 0),
  -                            lpCmdline->szApplication);
  +            if (!quiet)
  +                apxDisplayError(TRUE, NULL, 0, apxLoadResourceA(IDS_ALREAY_RUNING, 0),
  +                                lpCmdline->szApplication);
               goto cleanup;
           }
       }
  @@ -1634,7 +1652,8 @@
                                     APXREG_SOFTWARE | APXREG_SERVICE);
   
       if (IS_INVALID_HANDLE(hRegserv)) {
  -        apxDisplayError(TRUE, NULL, 0, apxLoadResourceA(IDS_ERRSREG, 0));
  +        if (!quiet)
  +            apxDisplayError(TRUE, NULL, 0, apxLoadResourceA(IDS_ERRSREG, 0));
           return FALSE;
       }
       /* Create main invisible window */
  @@ -1648,6 +1667,8 @@
       if (!_gui_store->hMainWnd) {
           goto cleanup;
       }
  +    if (lpCmdline->dwCmdIndex == 3)
  +        PostMessage(_gui_store->hMainWnd, WM_COMMAND, IDM_TM_START, 0);
   
       while (GetMessage(&msg, NULL, 0, 0))  {
           if(!TranslateAccelerator(_gui_store->hMainWnd,
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message