VirtualBox

Changeset 26322 in vbox for trunk/src/VBox/Frontends/VBoxSDL


Ignore:
Timestamp:
Feb 8, 2010 11:08:02 AM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
57403
Message:

Frontends/VBoxSDL+VBoxHeadless: code cleanup, reorganize code a little.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxSDL/VBoxSDL.cpp

    r26089 r26322  
    991991    }
    992992
    993     rc = com::Initialize();
    994     if (FAILED(rc))
    995     {
    996         RTPrintf("Error: COM initialization failed, rc = 0x%x!\n", rc);
    997         return 1;
    998     }
    999 
    1000     do
    1001     {
    1002     // scopes all the stuff till shutdown
    1003     ////////////////////////////////////////////////////////////////////////////
    1004 
    1005     ComPtr <IVirtualBox> virtualBox;
    1006     ComPtr <ISession> session;
    1007     bool sessionOpened = false;
    1008 
    1009     rc = virtualBox.createLocalObject (CLSID_VirtualBox);
    1010     if (FAILED(rc))
    1011     {
    1012         com::ErrorInfo info;
    1013         if (info.isFullAvailable())
    1014             PrintError("Failed to create VirtualBox object",
    1015                        info.getText().raw(), info.getComponent().raw());
    1016         else
    1017             RTPrintf("Failed to create VirtualBox object! No error information available (rc = 0x%x).\n", rc);
    1018         break;
    1019     }
    1020     rc = session.createInprocObject (CLSID_Session);
    1021     if (FAILED(rc))
    1022     {
    1023         RTPrintf("Failed to create session object, rc = 0x%x!\n", rc);
    1024         break;
    1025     }
    1026 
    1027     EventQueue* eventQ = com::EventQueue::getMainEventQueue();
    1028 
    1029     /* Get the number of network adapters */
    1030     ULONG NetworkAdapterCount = 0;
    1031     ComPtr <ISystemProperties> sysInfo;
    1032     virtualBox->COMGETTER(SystemProperties) (sysInfo.asOutParam());
    1033     sysInfo->COMGETTER (NetworkAdapterCount) (&NetworkAdapterCount);
    1034 
    1035993    // command line argument parsing stuff
    1036994    for (int curArg = 1; curArg < argc; curArg++)
     
    10461004            {
    10471005                RTPrintf("Error: VM not specified (UUID or name)!\n");
    1048                 rc = E_FAIL;
    1049                 break;
     1006                return 1;
    10501007            }
    10511008            // first check if a UUID was supplied
     
    10621019            {
    10631020                RTPrintf("Error: missing argument for comment!\n");
    1064                 rc = E_FAIL;
    1065                 break;
     1021                return 1;
    10661022            }
    10671023        }
     
    10721028            {
    10731029                RTPrintf("Error: missing argument for boot drive!\n");
    1074                 rc = E_FAIL;
    1075                 break;
     1030                return 1;
    10761031            }
    10771032            switch (argv[curArg][0])
     
    11041059                {
    11051060                    RTPrintf("Error: wrong argument for boot drive!\n");
    1106                     rc = E_FAIL;
    1107                     break;
     1061                    return 1;
    11081062                }
    11091063            }
    1110             if (FAILED (rc))
    1111                 break;
    11121064        }
    11131065        else if (   !strcmp(argv[curArg], "--memory")
     
    11181070            {
    11191071                RTPrintf("Error: missing argument for memory size!\n");
    1120                 rc = E_FAIL;
    1121                 break;
     1072                return 1;
    11221073            }
    11231074            memorySize = atoi(argv[curArg]);
     
    11291080            {
    11301081                RTPrintf("Error: missing argument for vram size!\n");
    1131                 rc = E_FAIL;
    1132                 break;
     1082                return 1;
    11331083            }
    11341084            vramSize = atoi(argv[curArg]);
     
    11541104            {
    11551105                RTPrintf("Error: missing arguments for fixed video mode!\n");
    1156                 rc = E_FAIL;
    1157                 break;
     1106                return 1;
    11581107            }
    11591108            fixedWidth  = atoi(argv[++curArg]);
     
    11831132            {
    11841133                RTPrintf("Error: missing a string of disabled hostkey combinations\n");
    1185                 rc = E_FAIL;
    1186                 break;
     1134                return 1;
    11871135            }
    11881136            gHostKeyDisabledCombinations = argv[curArg];
     
    11941142                    RTPrintf("Error: <hostkey> + '%c' is not a valid combination\n",
    11951143                             gHostKeyDisabledCombinations[i]);
    1196                     rc = E_FAIL;
    1197                     break;
     1144                    return 1;
    11981145                }
    11991146            }
    1200             if (rc == E_FAIL)
    1201                 break;
    12021147        }
    12031148        else if (   !strcmp(argv[curArg], "--nograbonclick")
     
    12171162            {
    12181163                RTPrintf("Error: missing file name for --pidfile!\n");
    1219                 rc = E_FAIL;
    1220                 break;
     1164                return 1;
    12211165            }
    12221166            gpszPidFile = argv[curArg];
     
    12281172            {
    12291173                RTPrintf("Error: missing file name for first hard disk!\n");
    1230                 rc = E_FAIL;
    1231                 break;
     1174                return 1;
    12321175            }
    12331176            /* resolve it. */
     
    12371180            {
    12381181                RTPrintf("Error: The path to the specified harddisk, '%s', could not be resolved.\n", argv[curArg]);
    1239                 rc = E_FAIL;
    1240                 break;
     1182                return 1;
    12411183            }
    12421184        }
     
    12471189            {
    12481190                RTPrintf("Error: missing file/device name for first floppy disk!\n");
    1249                 rc = E_FAIL;
    1250                 break;
     1191                return 1;
    12511192            }
    12521193            /* resolve it. */
     
    12561197            {
    12571198                RTPrintf("Error: The path to the specified floppy disk, '%s', could not be resolved.\n", argv[curArg]);
    1258                 rc = E_FAIL;
    1259                 break;
     1199                return 1;
    12601200            }
    12611201        }
     
    12661206            {
    12671207                RTPrintf("Error: missing file/device name for cdrom!\n");
    1268                 rc = E_FAIL;
    1269                 break;
     1208                return 1;
    12701209            }
    12711210            /* resolve it. */
     
    12751214            {
    12761215                RTPrintf("Error: The path to the specified cdrom, '%s', could not be resolved.\n", argv[curArg]);
    1277                 rc = E_FAIL;
    1278                 break;
     1216                return 1;
    12791217            }
    12801218        }
     
    13201258            {
    13211259                RTPrintf("Error: missing font file name for secure label!\n");
    1322                 rc = E_FAIL;
    1323                 break;
     1260                return 1;
    13241261            }
    13251262            secureLabelFontFile = argv[curArg];
     
    13311268            {
    13321269                RTPrintf("Error: missing font point size for secure label!\n");
    1333                 rc = E_FAIL;
    1334                 break;
     1270                return 1;
    13351271            }
    13361272            secureLabelPointSize = atoi(argv[curArg]);
     
    13421278            {
    13431279                RTPrintf("Error: missing font pixel offset for secure label!\n");
    1344                 rc = E_FAIL;
    1345                 break;
     1280                return 1;
    13461281            }
    13471282            secureLabelFontOffs = atoi(argv[curArg]);
     
    13531288            {
    13541289                RTPrintf("Error: missing text color value for secure label!\n");
    1355                 rc = E_FAIL;
    1356                 break;
     1290                return 1;
    13571291            }
    13581292            sscanf(argv[curArg], "%X", &secureLabelColorFG);
     
    13641298            {
    13651299                RTPrintf("Error: missing background color value for secure label!\n");
    1366                 rc = E_FAIL;
    1367                 break;
     1300                return 1;
    13681301            }
    13691302            sscanf(argv[curArg], "%X", &secureLabelColorBG);
     
    14071340            {
    14081341                RTPrintf("Error: missing the rate value for the --warpdrive option!\n");
    1409                 rc = E_FAIL;
    1410                 break;
     1342                return 1;
    14111343            }
    14121344            u32WarpDrive = RTStrToUInt32(argv[curArg]);
     
    14141346            {
    14151347                RTPrintf("Error: the warp drive rate is restricted to [2..20000]. (%d)\n", u32WarpDrive);
    1416                 rc = E_FAIL;
    1417                 break;
     1348                return 1;
    14181349            }
    14191350        }
     
    14331364            {
    14341365                RTPrintf("Error: not enough arguments for host keys!\n");
    1435                 rc = E_FAIL;
    1436                 break;
     1366                return 1;
    14371367            }
    14381368            gHostKeySym1 = atoi(argv[curArg++]);
     
    14551385        }
    14561386    }
     1387
     1388    rc = com::Initialize();
    14571389    if (FAILED(rc))
     1390    {
     1391        RTPrintf("Error: COM initialization failed, rc = 0x%x!\n", rc);
     1392        return 1;
     1393    }
     1394
     1395    do
     1396    {
     1397    // scopes all the stuff till shutdown
     1398    ////////////////////////////////////////////////////////////////////////////
     1399
     1400    ComPtr <IVirtualBox> virtualBox;
     1401    ComPtr <ISession> session;
     1402    bool sessionOpened = false;
     1403
     1404    rc = virtualBox.createLocalObject (CLSID_VirtualBox);
     1405    if (FAILED(rc))
     1406    {
     1407        com::ErrorInfo info;
     1408        if (info.isFullAvailable())
     1409            PrintError("Failed to create VirtualBox object",
     1410                       info.getText().raw(), info.getComponent().raw());
     1411        else
     1412            RTPrintf("Failed to create VirtualBox object! No error information available (rc = 0x%x).\n", rc);
    14581413        break;
     1414    }
     1415    rc = session.createInprocObject (CLSID_Session);
     1416    if (FAILED(rc))
     1417    {
     1418        RTPrintf("Failed to create session object, rc = 0x%x!\n", rc);
     1419        break;
     1420    }
     1421
     1422    EventQueue* eventQ = com::EventQueue::getMainEventQueue();
    14591423
    14601424    /*
     
    29222886    LogFlow(("Returning from main()!\n"));
    29232887    RTLogFlush(NULL);
    2924     return FAILED (rc) ? 1 : 0;
     2888    return FAILED(rc) ? 1 : 0;
    29252889}
    29262890
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