VirtualBox

Changeset 52240 in vbox for trunk/src/VBox/Main/src-server


Ignore:
Timestamp:
Jul 31, 2014 6:26:02 AM (11 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
95319
Message:

VBoxSVC: replace complicated command line parsing looking for /Embedded with simple argv enumeration.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-server/win/svcmain.cpp

    r51737 r52240  
    141141
    142142
    143 LPCTSTR FindOneOf(LPCTSTR p1, LPCTSTR p2)
    144 {
    145     while (p1 != NULL && *p1 != NULL)
    146     {
    147         LPCTSTR p = p2;
    148         while (p != NULL && *p != NULL)
    149         {
    150             if (*p1 == *p)
    151                 return CharNext(p1);
    152             p = CharNext(p);
    153         }
    154         p1 = CharNext(p1);
    155     }
    156     return NULL;
    157 }
    158 
    159 static int WordCmpI(LPCTSTR psz1, LPCTSTR psz2) throw()
    160 {
    161     TCHAR c1 = (TCHAR)CharUpper((LPTSTR)*psz1);
    162     TCHAR c2 = (TCHAR)CharUpper((LPTSTR)*psz2);
    163     while (c1 != NULL && c1 == c2 && c1 != ' ' && c1 != '\t')
    164     {
    165         psz1 = CharNext(psz1);
    166         psz2 = CharNext(psz2);
    167         c1 = (TCHAR)CharUpper((LPTSTR)*psz1);
    168         c2 = (TCHAR)CharUpper((LPTSTR)*psz2);
    169     }
    170     if ((c1 == NULL || c1 == ' ' || c1 == '\t') && (c2 == NULL || c2 == ' ' || c2 == '\t'))
    171         return 0;
    172 
    173     return (c1 < c2) ? -1 : 1;
    174 }
    175 
    176143/////////////////////////////////////////////////////////////////////////////
    177144//
    178145int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPSTR /*lpCmdLine*/, int /*nShowCmd*/)
    179146{
    180     LPCTSTR lpCmdLine = GetCommandLine(); /* this line necessary for _ATL_MIN_CRT */
     147    int    argc = __argc;
     148    char **argv = __argv;
    181149
    182150    /*
    183      * Need to parse the command line before initializing the VBox runtime.
     151     * Need to parse the command line before initializing the VBox runtime so we can
     152     * change to the user home directory before logs are being created.
    184153     */
    185     TCHAR szTokens[] = _T("-/");
    186     LPCTSTR lpszToken = FindOneOf(lpCmdLine, szTokens);
    187     while (lpszToken != NULL)
    188     {
    189         if (WordCmpI(lpszToken, _T("Embedding")) == 0)
     154    for (int i = 1; i < argc; i++)
     155        if (   (argv[i][0] == '/' || argv[i][0] == '-')
     156            && stricmp(&argv[i][1], "embedding") == 0) /* ANSI */
    190157        {
    191158            /* %HOMEDRIVE%%HOMEPATH% */
     
    204171        }
    205172
    206         lpszToken = FindOneOf(lpszToken, szTokens);
    207     }
    208 
    209173    /*
    210174     * Initialize the VBox runtime without loading
    211175     * the support driver.
    212176     */
    213     int    argc = __argc;
    214     char **argv = __argv;
    215177    RTR3InitExe(argc, &argv, 0);
    216178
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette