commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r1197900 - in /commons/proper/daemon/trunk/src/native/windows: apps/prunmgr/prunmgr.c apps/prunsrv/prunsrv.c include/cmdline.h src/cmdline.c
Date Sat, 05 Nov 2011 08:41:00 GMT
Author: mturk
Date: Sat Nov  5 08:40:59 2011
New Revision: 1197900

URL: http://svn.apache.org/viewvc?rev=1197900&view=rev
Log:
Instead awkward procxxx.exe //CMD[//ServiceName ..., allow procxx.exe CMD ServiceName ...

Modified:
    commons/proper/daemon/trunk/src/native/windows/apps/prunmgr/prunmgr.c
    commons/proper/daemon/trunk/src/native/windows/apps/prunsrv/prunsrv.c
    commons/proper/daemon/trunk/src/native/windows/include/cmdline.h
    commons/proper/daemon/trunk/src/native/windows/src/cmdline.c

Modified: commons/proper/daemon/trunk/src/native/windows/apps/prunmgr/prunmgr.c
URL: http://svn.apache.org/viewvc/commons/proper/daemon/trunk/src/native/windows/apps/prunmgr/prunmgr.c?rev=1197900&r1=1197899&r2=1197900&view=diff
==============================================================================
--- commons/proper/daemon/trunk/src/native/windows/apps/prunmgr/prunmgr.c (original)
+++ commons/proper/daemon/trunk/src/native/windows/apps/prunmgr/prunmgr.c Sat Nov  5 08:40:59
2011
@@ -89,6 +89,15 @@ static LPCWSTR _commands[] = {
     NULL
 };
 
+static LPCWSTR _altcmds[] = {
+    L"manage",      /* 1 Manage Service (default)*/
+    L"monitor",     /* 2 Monitor Service */
+    L"start",       /* 3 Monitor Service and start if not runing */
+    L"quit",        /* 4 Quit all running Monitor applications */
+    NULL
+};
+
+
 /* Allowed procrun parameters */
 static APXCMDLINEOPT _options[] = {
 /* 0  */    { L"AllowMultiInstances", NULL, NULL,   APXCMDOPT_INT, NULL, 0},
@@ -1622,7 +1631,7 @@ int WINAPI WinMain(HINSTANCE hInstance,
     hPool     = apxPoolCreate(NULL, 0);
 
     /* Parse the command line */
-    if ((lpCmdline = apxCmdlineParse(hPool, _options, _commands)) == NULL) {
+    if ((lpCmdline = apxCmdlineParse(hPool, _options, _commands, _altcmds)) == NULL) {
         /* TODO: dispalay error message */
         apxDisplayError(TRUE, NULL, 0, "Error parsing command line");
         goto cleanup;

Modified: commons/proper/daemon/trunk/src/native/windows/apps/prunsrv/prunsrv.c
URL: http://svn.apache.org/viewvc/commons/proper/daemon/trunk/src/native/windows/apps/prunsrv/prunsrv.c?rev=1197900&r1=1197899&r2=1197900&view=diff
==============================================================================
--- commons/proper/daemon/trunk/src/native/windows/apps/prunsrv/prunsrv.c (original)
+++ commons/proper/daemon/trunk/src/native/windows/apps/prunsrv/prunsrv.c Sat Nov  5 08:40:59
2011
@@ -84,6 +84,18 @@ static LPCWSTR _commands[] = {
     NULL
 };
 
+static LPCWSTR _altcmds[] = {
+    L"run",         /* 1 Run Service as console application (default)*/
+    L"start",       /* 2 Run Service */
+    L"stop",        /* 3 Stop Service */
+    L"update",      /* 4 Update Service parameters */
+    L"install",     /* 5 Install Service */
+    L"delete",      /* 6 Delete Service */
+    L"help",        /* 7 Help */
+    L"version",     /* 8 Version */
+    NULL
+};
+
 /* Allowed procrun parameters */
 static APXCMDLINEOPT _options[] = {
 
@@ -1537,7 +1549,7 @@ void __cdecl main(int argc, char **argv)
     gPool = apxPoolCreate(NULL, 0);
 
     /* Parse the command line */
-    if ((lpCmdline = apxCmdlineParse(gPool, _options, _commands)) == NULL) {
+    if ((lpCmdline = apxCmdlineParse(gPool, _options, _commands, _altcmds)) == NULL) {
         apxLogWrite(APXLOG_MARK_ERROR "Invalid command line arguments");
         rv = 1;
         goto cleanup;

Modified: commons/proper/daemon/trunk/src/native/windows/include/cmdline.h
URL: http://svn.apache.org/viewvc/commons/proper/daemon/trunk/src/native/windows/include/cmdline.h?rev=1197900&r1=1197899&r2=1197900&view=diff
==============================================================================
--- commons/proper/daemon/trunk/src/native/windows/include/cmdline.h (original)
+++ commons/proper/daemon/trunk/src/native/windows/include/cmdline.h Sat Nov  5 08:40:59 2011
@@ -60,7 +60,8 @@ typedef struct APXCMDLINE {
 LPAPXCMDLINE apxCmdlineParse(
     APXHANDLE hPool,
     APXCMDLINEOPT   *lpOptions,
-    LPCWSTR         *lpszCommands
+    LPCWSTR         *lpszCommands,
+    LPCWSTR         *lpszAltcmds
 );
 
 void apxCmdlineLoadEnvVars(

Modified: commons/proper/daemon/trunk/src/native/windows/src/cmdline.c
URL: http://svn.apache.org/viewvc/commons/proper/daemon/trunk/src/native/windows/src/cmdline.c?rev=1197900&r1=1197899&r2=1197900&view=diff
==============================================================================
--- commons/proper/daemon/trunk/src/native/windows/src/cmdline.c (original)
+++ commons/proper/daemon/trunk/src/native/windows/src/cmdline.c Sat Nov  5 08:40:59 2011
@@ -40,11 +40,12 @@ static WCHAR    _st_sys_appexe[MAX_PATH]
 LPAPXCMDLINE apxCmdlineParse(
     APXHANDLE hPool,
     APXCMDLINEOPT   *lpOptions,
-    LPCWSTR         *lpszCommands)
+    LPCWSTR         *lpszCommands,
+    LPCWSTR         *lpszAltcmds)
 {
 
     LPAPXCMDLINE lpCmdline = NULL;
-    DWORD l, i = 0, s = 1;
+    DWORD l, i, s = 1;
     LPWSTR p;
     WCHAR  cmd[4];
     DWORD  match;
@@ -105,6 +106,7 @@ LPAPXCMDLINE apxCmdlineParse(
     }
     if (lpszCommands && _st_sys_argc > 1 && lstrlenW(_st_sys_argvw[1])
> 2) {
         LPWSTR ca = _st_sys_argvw[1];
+        i = 0;
         if (ca[0] == L'/' && ca[1] == L'/') {
             l   = 0;
             ca += 2;
@@ -130,13 +132,38 @@ LPAPXCMDLINE apxCmdlineParse(
                     lpCmdline->szApplication = _st_sys_argvw[0];
                 else
                     lpCmdline->szApplication = ca;
+                s = 2;
             }
-            else {
+            else if (!lpszAltcmds) {
                 apxLogWrite(APXLOG_MARK_ERROR "Unrecognized cmd option %S",
                             _st_sys_argvw[1]);
                 return NULL;
             }
+        }
+    }
+    if (lpszAltcmds && _st_sys_argc > 1 && lstrlenW(_st_sys_argvw[1])
> 2 &&
+        _st_sys_argvw[1][0] != L'-') {
+        LPWSTR ca = _st_sys_argvw[1];
+        i = 0;
+        while (lpszAltcmds[i]) {
+            if (lstrcmpW(lpszAltcmds[i++], ca) == 0) {
+                lpCmdline->dwCmdIndex = i;
+                break;
+            }
+        }
+        if (lpCmdline->dwCmdIndex) {
             s = 2;
+            if (_st_sys_argc > 2 && _st_sys_argvw[2][0] != L'-') {
+                s++;
+                lpCmdline->szApplication = _st_sys_argvw[2];
+            }
+            else
+                lpCmdline->szApplication = _st_sys_argvw[0];
+        }
+        else {
+            apxLogWrite(APXLOG_MARK_ERROR "Unrecognized cmd option %S",
+                        _st_sys_argvw[1]);
+            return NULL;
         }
     }
     else {



Mime
View raw message