VirtualBox

Ignore:
Timestamp:
Jul 3, 2008 9:26:28 AM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
32673
Message:

Frontends/VBoxManage: make the guest property functions utf8-safe

File:
1 edited

Legend:

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

    r10002 r10147  
    74977497    if (machine)
    74987498    {
    7499 #if 0
    7500         /* enumeration? */
    7501         if (strcmp(argv[1], "enumerate") == 0)
    7502         {
    7503             Bstr extraDataKey;
    7504 
    7505             do
    7506             {
    7507                 Bstr nextExtraDataKey;
    7508                 Bstr nextExtraDataValue;
    7509                 HRESULT rcEnum = machine->GetNextExtraDataKey(extraDataKey, nextExtraDataKey.asOutParam(),
    7510                                                               nextExtraDataValue.asOutParam());
    7511                 extraDataKey = nextExtraDataKey;
    7512 
    7513                 if (SUCCEEDED(rcEnum) && extraDataKey)
    7514                 {
    7515                     RTPrintf("Key: %lS, Value: %lS\n", nextExtraDataKey.raw(), nextExtraDataValue.raw());
    7516                 }
    7517             } while (extraDataKey);
    7518         }
    7519         else
    7520 #endif /* 0 */
     7499        char *pszKey = NULL;
     7500        int rrc = RTStrCurrentCPToUtf8(&pszKey, argv[1]);
     7501        if (RT_SUCCESS(rrc))
    75217502        {
    75227503            Bstr value;
    7523             CHECK_ERROR(machine, GetGuestProperty(Bstr(argv[1]), value.asOutParam()));
     7504            CHECK_ERROR(machine, GetGuestProperty(Bstr(pszKey), value.asOutParam()));
    75247505            if (value)
    75257506                RTPrintf("Value: %lS\n", value.raw());
    75267507            else
    75277508                RTPrintf("No value set!\n");
    7528         }
     7509            RTStrFree(pszKey);
     7510        }
     7511        else
     7512            rc = E_INVALIDARG;
    75297513    }
    75307514    return SUCCEEDED(rc) ? 0 : 1;
     
    75507534    if (machine)
    75517535    {
    7552         if (argc < 3)
    7553             CHECK_ERROR(machine, SetGuestProperty(Bstr(argv[1]), NULL));
    7554         else if (argc == 3)
    7555             CHECK_ERROR(machine, SetGuestProperty(Bstr(argv[1]), Bstr(argv[2])));
     7536        char *pszKey = NULL;
     7537        int rrc = RTStrCurrentCPToUtf8(&pszKey, argv[1]);
     7538        if (RT_SUCCESS(rrc))
     7539        {
     7540            if (argc < 3)
     7541                CHECK_ERROR(machine, SetGuestProperty(Bstr(argv[1]), NULL));
     7542            else if (argc == 3)
     7543            {
     7544                char *pszValue = NULL;
     7545                rrc = RTStrCurrentCPToUtf8(&pszKey, argv[1]);
     7546                if (RT_SUCCESS(rrc))
     7547                    CHECK_ERROR(machine, SetGuestProperty(Bstr(argv[1]), Bstr(argv[2])));
     7548                else
     7549                    rc = E_INVALIDARG;
     7550                RTStrFree(pszValue);
     7551            }
     7552            else
     7553                return errorSyntax(USAGE_SETGUESTPROPERTY, "Too many parameters");
     7554            RTStrFree(pszKey);
     7555        }
    75567556        else
    7557             return errorSyntax(USAGE_SETGUESTPROPERTY, "Too many parameters");
     7557            rc = E_INVALIDARG;
    75587558    }
    75597559    return SUCCEEDED(rc) ? 0 : 1;
Note: See TracChangeset for help on using the changeset viewer.

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