wineconsole: [RESEND] command line option output / configurable default backend

Ekkehard Morgenstern ekkehard.morgenstern at onlinehome.de
Wed Aug 9 04:16:48 CDT 2006


RESEND, now honors original coding style in all places.

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    9 Aug 2006 09:14:58 -0000
@@ -730,6 +730,44 @@
 };
 
 /******************************************************************
+ *         WINECON_GetEnv
+ *
+ *
+ */
+
+static const char* WINECON_GetEnv(const char* lpName)
+{
+    static char buf[1024];
+    buf[0] = '\0';
+    GetEnvironmentVariableA(lpName, buf, sizeof(buf));
+    return buf;
+}
+
+/******************************************************************
+ *         WINECON_OutputHelp
+ *
+ * Outputs help text.
+ */
+
+static void WINECON_OutputHelp(void)
+{
+    const char* backend;
+    if (lstrcmpiA(WINECON_GetEnv("WINECONBACKEND"), "user") == 0)
+        backend = "user";
+    else
+        backend = "curses";
+    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\n"
+"The default for the backend option is '%s'.\n"
+"Set environment variable WINECONBACKEND to change this behavior.\n", 
backend
+    );
+}
+
+/******************************************************************
  *         WINECON_ParseOptions
  *
  *
@@ -739,7 +777,11 @@
     memset(wci, 0, sizeof(*wci));
     wci->ptr = lpCmdLine;
     wci->mode = from_process_name;
-    wci->backend = WCCURSES_InitBackend;
+
+    if (lstrcmpiA(WINECON_GetEnv("WINECONBACKEND"), "user") == 0)
+        wci->backend = WCUSER_InitBackend;
+    else
+        wci->backend = WCCURSES_InitBackend;
 
     for (;;)
     {
@@ -763,11 +805,17 @@
             }
             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 +841,13 @@
     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 +868,11 @@
             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