commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r923332 - in /commons/proper/daemon/trunk/src/native/nt/procrun: apps/prunsrv/prunsrv.c src/cmdline.c
Date Mon, 15 Mar 2010 16:38:33 GMT
Author: mturk
Date: Mon Mar 15 16:38:33 2010
New Revision: 923332

URL: http://svn.apache.org/viewvc?rev=923332&view=rev
Log:
Implement DAEMON-141 by adding //? option for displaying the procrun help with version

Modified:
    commons/proper/daemon/trunk/src/native/nt/procrun/apps/prunsrv/prunsrv.c
    commons/proper/daemon/trunk/src/native/nt/procrun/src/cmdline.c

Modified: commons/proper/daemon/trunk/src/native/nt/procrun/apps/prunsrv/prunsrv.c
URL: http://svn.apache.org/viewvc/commons/proper/daemon/trunk/src/native/nt/procrun/apps/prunsrv/prunsrv.c?rev=923332&r1=923331&r2=923332&view=diff
==============================================================================
--- commons/proper/daemon/trunk/src/native/nt/procrun/apps/prunsrv/prunsrv.c (original)
+++ commons/proper/daemon/trunk/src/native/nt/procrun/apps/prunsrv/prunsrv.c Mon Mar 15 16:38:33
2010
@@ -74,6 +74,7 @@ static LPCWSTR _commands[] = {
     L"US",      /* 4 Update Service parameters */
     L"IS",      /* 5 Install Service */
     L"DS",      /* 6 Delete Service */
+    L"?",       /* 7 Help */
     NULL
 };
 
@@ -303,23 +304,27 @@ static BOOL redirectStdStreams(APX_STDWR
 }
 
 /* Debugging functions */
-static void printUsage(LPAPXCMDLINE lpCmdline)
+static void printUsage(LPAPXCMDLINE lpCmdline, BOOL isHelp)
 {
     int i = 0;
     fwprintf(stderr, L"Usage: %s //CMD//Servce [--options]\n",
              lpCmdline->szExecutable);
     fwprintf(stderr, L"  Commands:\n");
-    fwprintf(stderr, L"  //IS//ServiceName  Install Service\n");
-    fwprintf(stderr, L"  //US//ServiceName  Update Service parameters\n");
-    fwprintf(stderr, L"  //DS//ServiceName  Delete Service\n");
-    fwprintf(stderr, L"  //RS//ServiceName  Run Service\n");
-    fwprintf(stderr, L"  //SS//ServiceName  Stop Service\n");
-    fwprintf(stderr, L"  //TS//ServiceName  Run Service as console application\n");
+    if (isHelp)
+        fwprintf(stderr, L"  //?                  This page\n");        
+    fwprintf(stderr, L"  //IS[//ServiceName]  Install Service\n");
+    fwprintf(stderr, L"  //US[//ServiceName]  Update Service parameters\n");
+    fwprintf(stderr, L"  //DS[//ServiceName]  Delete Service\n");
+    fwprintf(stderr, L"  //RS[//ServiceName]  Run Service\n");
+    fwprintf(stderr, L"  //SS[//ServiceName]  Stop Service\n");
+    fwprintf(stderr, L"  //TS[//ServiceName]  Run Service as console application\n");
     fwprintf(stderr, L"  Options:\n");
     while (_options[i].szName) {
         fwprintf(stderr, L"  --%s\n", _options[i].szName);
         ++i;
     }
+    fwprintf(stderr, L"\nCommons Daemon Service Runner version %S\n", PRG_VERSION);    
+    fwprintf(stderr, L"Copyright (c) 2000-2010 The Apache Software Foundation.\n");
 }
 
 /* Display configuration parameters */
@@ -1425,10 +1430,13 @@ void __cdecl main(int argc, char **argv)
             if (!docmdDeleteService(lpCmdline))
                 rv = 8;
         break;
+        case 7: /* Help. Print version and exit */
+            printUsage(lpCmdline, TRUE);            
+        break;
         default:
             /* Unknown command option */
             apxLogWrite(APXLOG_MARK_ERROR "Unknown command line option");
-            printUsage(lpCmdline);
+            printUsage(lpCmdline, FALSE);
             rv = 99;
         break;
     }

Modified: commons/proper/daemon/trunk/src/native/nt/procrun/src/cmdline.c
URL: http://svn.apache.org/viewvc/commons/proper/daemon/trunk/src/native/nt/procrun/src/cmdline.c?rev=923332&r1=923331&r2=923332&view=diff
==============================================================================
--- commons/proper/daemon/trunk/src/native/nt/procrun/src/cmdline.c (original)
+++ commons/proper/daemon/trunk/src/native/nt/procrun/src/cmdline.c Mon Mar 15 16:38:33 2010
@@ -102,34 +102,37 @@ LPAPXCMDLINE apxCmdlineParse(
             *p = L'\0';
         }
     }
-    if (lpszCommands && _st_sys_argc > 1 && lstrlenW(_st_sys_argvw[1])
> 5) {
-        if (_st_sys_argvw[1][0] == L'/' &&
-            _st_sys_argvw[1][1] == L'/' &&
-            _st_sys_argvw[1][5] == L'/') { /* allow max tree char command */
-            l = 2;
-            while (_st_sys_argvw[1][l] != L'/') {
-                cmd[l - 2] = _st_sys_argvw[1][l];
+    if (lpszCommands && _st_sys_argc > 1 && lstrlenW(_st_sys_argvw[1])
> 2) {
+        LPWSTR ca = _st_sys_argvw[1];
+        if (ca[0] == L'/' && ca[1] == L'/') {
+            l   = 0;
+            ca += 2;
+            while (*ca && *ca != L'/') {
+                cmd[l] = *ca;
                 if (l++ > 3)
                     break;
+                ca++;
             }
-            cmd[l - 2] = L'\0';
+            cmd[l] = L'\0';
             while (lpszCommands[i]) {
                 if (lstrcmpW(lpszCommands[i++], cmd) == 0) {
                     lpCmdline->dwCmdIndex = i;
-                    s = 2;
                     break;
                 }
             }
             if (lpCmdline->dwCmdIndex) {
-                _st_sys_argvw[1][l+1] = L'\0';
-                lpCmdline->szApplication = &(_st_sys_argvw[1][l+2]);
-                if (!lstrlenW(lpCmdline->szApplication))
+                while (*ca == '/')
+                    *(ca++) = L'\0';
+                if (*ca == '\0')
                     lpCmdline->szApplication = _st_sys_argvw[0];
+                else
+                    lpCmdline->szApplication = ca;
             }
             else {
-                apxLogWrite(APXLOG_MARK_ERROR "Unrecognized cmd option %s", cmd);
-                s = 2;
+                apxLogWrite(APXLOG_MARK_ERROR "Unrecognized cmd option %S",
+                            _st_sys_argvw[1]);
             }
+            s = 2;
         }
     }
     else {



Mime
View raw message