wineconsole: command line option output / default user backend

Ekkehard Morgenstern ekkehard.morgenstern at onlinehome.de
Sun Aug 6 16:00:50 CDT 2006


This small patch provides command line option output, a "--help" option 
and a default user backend ("--backend=user" is default) to "wineconsole".

Index: wineconsole.c
===================================================================
RCS file: /home/wine/wine/programs/wineconsole/wineconsole.c,v
retrieving revision 1.44
diff -u -r1.44 wineconsole.c
--- wineconsole.c    7 Jun 2006 12:51:16 -0000    1.44
+++ wineconsole.c    6 Aug 2006 20:50:12 -0000
@@ -730,6 +730,18 @@
 };
 
 /******************************************************************
+ *         WINECON_OutputHelp
+ *
+ * Outputs help text.
+ */
+
+static void WINECON_OutputHelp( void ) {
+    WINE_MESSAGE(
+        "Usage: wineconsole PROGRAM [ARGUMENTS...]  Run the specified 
console program\n""       wineconsole --help                  Display 
this help and exit\n"       "       wineconsole --backend=user PROGRAM  
Run the program in its own window\n""       wineconsole --backend=curses 
PROGR  Run the program in this terminal\n" "       wineconsole 
--use-event=HNDDEC      Signal specified event after launch\nThe default 
for the backend option is 'user'.\n"
+    );
+}
+
+/******************************************************************
  *         WINECON_ParseOptions
  *
  *
@@ -739,7 +751,7 @@
     memset(wci, 0, sizeof(*wci));
     wci->ptr = lpCmdLine;
     wci->mode = from_process_name;
-    wci->backend = WCCURSES_InitBackend;
+    wci->backend = WCUSER_InitBackend;
 
     for (;;)
     {
@@ -763,11 +775,16 @@
             }
             else if (strncmp(wci->ptr + 10, "curses", 6) == 0)
             {
+                wci->backend = WCCURSES_InitBackend;
                 wci->ptr += 16;
             }
             else
                 return FALSE;
         }
+        else if ( strncmp( wci->ptr, "--help", 6 ) == 0 ) {
+                while ( *wci->ptr != '\0' ) ++wci->ptr;
+                return TRUE;
+        }
         else
             return FALSE;
     }
@@ -793,6 +810,12 @@
     if (!WINECON_ParseOptions(lpCmdLine, &wci))
     {
         WINE_ERR("Wrong command line options\n");
+        WINECON_OutputHelp();
+        return 0;
+    }
+
+    if ( *wci.ptr == '\0' ) {
+        WINECON_OutputHelp();
         return 0;
     }
 
@@ -813,8 +836,10 @@
             if (!(data = WINECON_Init(hInst, GetCurrentProcessId(), 
buffer, wci.backend, nCmdShow)))
                 return 0;
             ret = WINECON_Spawn(data, buffer);
-            if (!ret)
+            if (!ret) {
                 WINE_MESSAGE("wineconsole: spawning client program 
failed (%s), invalid/missing command line arguments ?\n", 
wine_dbgstr_w(buffer));
+                WINECON_OutputHelp();
+            }
         }
         break;
     default:




More information about the wine-patches mailing list