handle quoting on the command line in uninstaller

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




ChangeLog: * handle quoting on the command line in uninstaller
Index: programs/uninstaller/main.c
===================================================================
RCS file: /home/wine/wine/programs/uninstaller/main.c,v
retrieving revision 1.12
diff -u -r1.12 main.c
--- programs/uninstaller/main.c	25 Sep 2003 20:21:47 -0000	1.12
+++ programs/uninstaller/main.c	5 Oct 2003 19:18:14 -0000
@@ -121,32 +121,80 @@
     }
 }
 
+static CHAR *next_token( LPSTR *p )
+{
+    LPSTR token = NULL, t = *p;
+
+    if( !t )
+        return NULL;
+
+    while( t && !token )
+    {
+        switch( *t )
+        {
+        case ' ':
+            t++;
+            continue;
+        case '"':
+            /* unquote the token */
+            token = ++t;
+            t = strchr( token, '"' );
+            if( t )
+                 *t++ = 0;
+            break;
+        case 0:
+            t = NULL;
+            break;
+        default:
+            token = t;
+            t = strchr( token, ' ' );
+            if( t )
+                 *t++ = 0;
+            break;
+        }
+    }
+    *p = t;
+    return token;
+}
 
 int WINAPI WinMain( HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR cmdline, int cmdshow )
 {
     MSG msg;
     WNDCLASS wc;
     HWND hWnd;
+    LPSTR token = NULL, p;
 
-    /*------------------------------------------------------------------------
-    ** Handle requests just to list the programs
-    **----------------------------------------------------------------------*/
-    if (cmdline && strlen(cmdline) >= 6 && memcmp(cmdline, "--list", 6) == 0)
+    for( p = cmdline; p && *p; )
     {
-        ListUninstallPrograms();
-        return(0);
-    }
+        token = next_token( &p );
+        if( !token )
+            break;
 
-    /*------------------------------------------------------------------------
-    ** Handle requests to remove one program
-    **----------------------------------------------------------------------*/
-    if (cmdline && strlen(cmdline) > 9 && memcmp(cmdline, "--remove ", 9) == 0)
-    {
-        RemoveSpecificProgram(cmdline + 9);
-        return(0);
-    }
+        /* Handle requests just to list the programs */
+        if( !lstrcmpA( token, "--list" ) )
+        {
+            ListUninstallPrograms();
+            return 0;
+        }
+        else if( !lstrcmpA( token, "--remove" ) )
+        {
+            LPSTR szKey = next_token( &p );
 
+            if( !szKey )
+            {
+                WINE_ERR( "The remove option requires a parameter.\n");
+                return 1;
+            }
 
+            RemoveSpecificProgram( szKey );
+            return 0;
+        }
+        else 
+        {
+            WINE_ERR( "unknown option %s\n",token);
+            return 1;
+        }
+    }
 
     LoadString( hInst, IDS_APPNAME, appname, sizeof(appname));
 

[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux