VirtualBox

Ignore:
Timestamp:
Oct 22, 2014 8:43:04 PM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
96652
Message:

Main/HostDnsService: revert r96327 and follow-up r96329 and r96331 to
revert conversion of HostDnsInformation to Unicode.

HostDnsServiceWin.cpp behavioral changes will be redone as a separate
commit against old definition of HostDnsInformation.

Intervening SafeArray cleanup in r96372 is preserved, hopefully
without errors. Please review.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-server/darwin/HostDnsServiceDarwin.cpp

    r52901 r53122  
    1818#include <VBox/com/string.h>
    1919#include <VBox/com/ptr.h>
    20 #include <VBox/log.h>
    2120
    2221
     
    163162
    164163    return VINF_SUCCESS;
    165 }
    166 
    167 
    168 static wchar_t *darwinCFStringToUtf16(CFStringRef pStringRef)
    169 {
    170     /* Number of characters (UTF16 encoded, 2 bytes) in the pStringRef. */
    171     CFIndex ccStringRef = CFStringGetLength(pStringRef);
    172 
    173     if (ccStringRef > 0)
    174     {
    175         size_t  cbTmpBuf = (size_t)ccStringRef * sizeof(wchar_t) + 1 /* end of string */;
    176         wchar_t *pTmpBuf = (wchar_t *)RTMemAlloc(cbTmpBuf);
    177         if (pTmpBuf)
    178         {
    179             CFIndex ccConverted = CFStringGetBytes(pStringRef,
    180                                                    CFRangeMake(0, ccStringRef),
    181                                                    kCFStringEncodingUTF16,
    182                                                    0,
    183                                                    false,
    184                                                    (UInt8 *)pTmpBuf,
    185                                                    (CFIndex)cbTmpBuf - 1 /* w/o end of string */,
    186                                                    NULL);
    187             if (ccConverted > 0)
    188             {
    189                 /* Set end of string. */
    190                 pTmpBuf[ccConverted] = 0;
    191                 return pTmpBuf;
    192             }
    193 
    194             RTMemFree(pTmpBuf);
    195         }
    196     }
    197 
    198     return NULL;
    199164}
    200165
     
    230195    if (domainNameRef)
    231196    {
    232         wchar_t *pwszDomainName = darwinCFStringToUtf16(domainNameRef);
    233         if (pwszDomainName)
    234         {
    235             info.domain = std::wstring(pwszDomainName);
    236             RTMemFree(pwszDomainName);
    237         }
     197        const char *pszDomainName = CFStringGetCStringPtr(domainNameRef,
     198                                                    CFStringGetSystemEncoding());
     199        if (pszDomainName)
     200            info.domain = pszDomainName;
    238201    }
    239202
     
    250213                continue;
    251214
    252             wchar_t *pwszServerAddress = darwinCFStringToUtf16(serverAddressRef);
    253             if (!pwszServerAddress)
    254                 continue;
    255 
    256             info.servers.push_back(std::wstring(pwszServerAddress));
    257             RTMemFree(pwszServerAddress);
     215            const char *pszServerAddress = CFStringGetCStringPtr(serverAddressRef,
     216                                                           CFStringGetSystemEncoding());
     217            if (!pszServerAddress)
     218                continue;
     219
     220            info.servers.push_back(std::string(pszServerAddress));
    258221        }
    259222    }
     
    271234                continue;
    272235
    273             wchar_t *pwszSearchString = darwinCFStringToUtf16(searchStringRef);
    274             if (!pwszSearchString)
    275                 continue;
    276 
    277             info.searchList.push_back(std::wstring(pwszSearchString));
    278             RTMemFree(pwszSearchString);
     236            const char *pszSearchString = CFStringGetCStringPtr(searchStringRef,
     237                                                          CFStringGetSystemEncoding());
     238            if (!pszSearchString)
     239                continue;
     240
     241            info.searchList.push_back(std::string(pszSearchString));
    279242        }
    280243    }
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