VirtualBox

Changeset 73196 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Jul 18, 2018 10:45:52 AM (7 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
123800
Message:

Fe/Qt: some more option parsing updates.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/globals
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp

    r73193 r73196  
    38143814#endif
    38153815
     3816    /*
     3817     * Parse the command line options.
     3818     *
     3819     * This is a little sloppy but we're trying to tighten it up.  Unfortuately,
     3820     * both on X11 and darwin (IIRC) there might be additional arguments aimed
     3821     * for client libraries with GUI processes.  So, using RTGetOpt or similar
     3822     * is a bit hard since we have to cope with unknown options.
     3823     */
    38163824    m_fShowStartVMErrors = true;
    38173825    bool startVM = false;
     
    38263834        const QByteArray &argBytes = arguments.at(i).toUtf8();
    38273835        const char *arg = argBytes.constData();
    3828         enum { OptType_Unknown, OptType_VMRunner, OptType_VMSelector } enmOptType = OptType_Unknown;
     3836        enum { OptType_Unknown, OptType_VMRunner, OptType_VMSelector, OptType_MaybeBoth } enmOptType = OptType_Unknown;
    38293837        /* NOTE: the check here must match the corresponding check for the
    38303838         * options to start a VM in main.cpp and hardenedmain.cpp exactly,
     
    38483856        else if (!::strcmp(arg, "-pidfile") || !::strcmp(arg, "--pidfile"))
    38493857        {
     3858            enmOptType = OptType_MaybeBoth;
    38503859            if (++i < argc)
    38513860                m_strPidFile = arguments.at(i);
     
    38543863        /* Visual state type options: */
    38553864        else if (!::strcmp(arg, "-normal") || !::strcmp(arg, "--normal"))
     3865        {
     3866            enmOptType = OptType_MaybeBoth;
    38563867            visualStateType = UIVisualStateType_Normal;
     3868        }
    38573869        else if (!::strcmp(arg, "-fullscreen") || !::strcmp(arg, "--fullscreen"))
     3870        {
     3871            enmOptType = OptType_MaybeBoth;
    38583872            visualStateType = UIVisualStateType_Fullscreen;
     3873        }
    38593874        else if (!::strcmp(arg, "-seamless") || !::strcmp(arg, "--seamless"))
     3875        {
     3876            enmOptType = OptType_MaybeBoth;
    38603877            visualStateType = UIVisualStateType_Seamless;
     3878        }
    38613879        else if (!::strcmp(arg, "-scale") || !::strcmp(arg, "--scale"))
     3880        {
     3881            enmOptType = OptType_MaybeBoth;
    38623882            visualStateType = UIVisualStateType_Scale;
     3883        }
    38633884        /* Passwords: */
    38643885        else if (!::strcmp(arg, "--settingspw"))
    38653886        {
     3887            enmOptType = OptType_MaybeBoth;
    38663888            if (++i < argc)
    38673889            {
     
    38723894        else if (!::strcmp(arg, "--settingspwfile"))
    38733895        {
     3896            enmOptType = OptType_MaybeBoth;
    38743897            if (++i < argc)
    38753898            {
    3876                 size_t cbFile;
    38773899                const QByteArray &argFileBytes = arguments.at(i).toLocal8Bit();
    38783900                const char *pszFile = argFileBytes.constData();
     
    38863908                if (RT_SUCCESS(vrc))
    38873909                {
    3888                     vrc = RTStrmReadEx(pStrm, m_astrSettingsPw, sizeof(m_astrSettingsPw)-1, &cbFile);
     3910                    size_t cbFile;
     3911                    vrc = RTStrmReadEx(pStrm, m_astrSettingsPw, sizeof(m_astrSettingsPw) - 1, &cbFile);
    38893912                    if (RT_SUCCESS(vrc))
    38903913                    {
    3891                         if (cbFile >= sizeof(m_astrSettingsPw)-1)
    3892                             continue;
    3893                         else
    3894                         {
    3895                             unsigned i;
    3896                             for (i = 0; i < cbFile && !RT_C_IS_CNTRL(m_astrSettingsPw[i]); i++)
    3897                                 ;
    3898                             m_astrSettingsPw[i] = '\0';
    3899                             m_fSettingsPwSet = true;
    3900                         }
     3914                        if (cbFile >= sizeof(m_astrSettingsPw) - 1)
     3915                            cbFile = sizeof(m_astrSettingsPw) - 1;
     3916                        unsigned i;
     3917                        for (i = 0; i < cbFile && !RT_C_IS_CNTRL(m_astrSettingsPw[i]); i++)
     3918                            ;
     3919                        m_astrSettingsPw[i] = '\0';
     3920                        m_fSettingsPwSet = true;
    39013921                    }
    39023922                    if (!fStdIn)
     
    39073927        /* Misc options: */
    39083928        else if (!::strcmp(arg, "-comment") || !::strcmp(arg, "--comment"))
     3929        {
     3930            enmOptType = OptType_MaybeBoth;
    39093931            ++i;
     3932        }
    39103933        else if (!::strcmp(arg, "--no-startvm-errormsgbox"))
    39113934        {
     
    39143937        }
    39153938        else if (!::strcmp(arg, "--aggressive-caching"))
     3939        {
     3940            enmOptType = OptType_MaybeBoth;
    39163941            m_fAgressiveCaching = true;
     3942        }
    39173943        else if (!::strcmp(arg, "--no-aggressive-caching"))
     3944        {
     3945            enmOptType = OptType_MaybeBoth;
    39183946            m_fAgressiveCaching = false;
     3947        }
    39193948        else if (!::strcmp(arg, "--restore-current"))
    39203949        {
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h

    r73119 r73196  
    802802#endif
    803803
    804         /** Holds the --settingspw option value. */
     804        /** Holds the --settingspw option value or the content of --settingspwfile. */
    805805        char  m_astrSettingsPw[256];
    806806        /** Holds the --settingspwfile option value. */
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