VirtualBox

Ignore:
Timestamp:
Aug 14, 2020 9:04:40 PM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
139935
Message:

VBoxManage/showvminfo: Use Utf8Str::printf and appendPrintf instead of Utf8StrFmt.

File:
1 edited

Legend:

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

    r85769 r85779  
    115115                Utf8Str newPrefix;
    116116                if (details == VMINFO_MACHINEREADABLE)
    117                     newPrefix = Utf8StrFmt("%s-%d", prefix.c_str(), index + 1);
     117                    newPrefix.printf("%s-%d", prefix.c_str(), index + 1);
    118118                else
    119                 {
    120                     newPrefix = Utf8StrFmt("%s   ", prefix.c_str());
    121                 }
     119                    newPrefix.printf("%s   ", prefix.c_str());
    122120
    123121                /* recursive call */
     
    12171215                nic->COMGETTER(MACAddress)(strMACAddress.asOutParam());
    12181216                Utf8Str strAttachment;
    1219                 Utf8Str strNatSettings = "";
    1220                 Utf8Str strNatForwardings = "";
     1217                Utf8Str strNatSettings;
     1218                Utf8Str strNatForwardings;
    12211219                NetworkAttachmentType_T attachment;
    12221220                nic->COMGETTER(AttachmentType)(&attachment);
     
    12521250                            size_t pos, ppos;
    12531251                            pos = ppos = 0;
    1254                             #define ITERATE_TO_NEXT_TERM(res, str, pos, ppos)   \
     1252#define ITERATE_TO_NEXT_TERM(res, str, pos, ppos)   \
    12551253                            do {                                                \
    12561254                                pos = str.find(",", ppos);                      \
     
    12751273                            if (fSkip) continue;
    12761274                            strGuestPort = utf.substr(ppos, utf.length() - ppos);
    1277                             #undef ITERATE_TO_NEXT_TERM
     1275#undef ITERATE_TO_NEXT_TERM
    12781276                            switch (strProto.toUInt32())
    12791277                            {
     
    12891287                            }
    12901288                            if (details == VMINFO_MACHINEREADABLE)
    1291                             {
    1292                                 strNatForwardings = Utf8StrFmt("%sForwarding(%d)=\"%s,%s,%s,%s,%s,%s\"\n",
    1293                                     strNatForwardings.c_str(), i, strName.c_str(), strProto.c_str(),
    1294                                     strHostIP.c_str(), strHostPort.c_str(),
    1295                                     strGuestIP.c_str(), strGuestPort.c_str());
    1296                             }
     1289                                /** @todo r=bird: This probably isn't good enough wrt escaping. */
     1290                                strNatForwardings.printf("%sForwarding(%d)=\"%s,%s,%s,%s,%s,%s\"\n",
     1291                                                         strNatForwardings.c_str(), i, strName.c_str(), strProto.c_str(),
     1292                                                         strHostIP.c_str(), strHostPort.c_str(),
     1293                                                         strGuestIP.c_str(), strGuestPort.c_str());
    12971294                            else
    1298                             {
    1299                                 strNatForwardings = Utf8StrFmt("%sNIC %d Rule(%d):   name = %s, protocol = %s,"
    1300                                     " host ip = %s, host port = %s, guest ip = %s, guest port = %s\n",
    1301                                     strNatForwardings.c_str(), currentNIC + 1, i, strName.c_str(), strProto.c_str(),
    1302                                     strHostIP.c_str(), strHostPort.c_str(),
    1303                                     strGuestIP.c_str(), strGuestPort.c_str());
    1304                             }
     1295                                strNatForwardings.printf("%sNIC %d Rule(%d):   name = %s, protocol = %s, host ip = %s, host port = %s, guest ip = %s, guest port = %s\n",
     1296                                                         strNatForwardings.c_str(), currentNIC + 1, i, strName.c_str(),
     1297                                                         strProto.c_str(), strHostIP.c_str(), strHostPort.c_str(),
     1298                                                         strGuestIP.c_str(), strGuestPort.c_str());
    13051299                        }
    13061300                        ULONG mtu = 0;
     
    13161310                            RTPrintf("natnet%d=\"%ls\"\n", currentNIC + 1, strNetwork.length() ? strNetwork.raw(): Bstr("nat").raw());
    13171311                            strAttachment = "nat";
    1318                             strNatSettings = Utf8StrFmt("mtu=\"%d\"\nsockSnd=\"%d\"\nsockRcv=\"%d\"\ntcpWndSnd=\"%d\"\ntcpWndRcv=\"%d\"\n",
    1319                                 mtu, sockSnd ? sockSnd : 64, sockRcv ? sockRcv : 64, tcpSnd ? tcpSnd : 64, tcpRcv ? tcpRcv : 64);
     1312                            strNatSettings.printf("mtu=\"%d\"\nsockSnd=\"%d\"\nsockRcv=\"%d\"\ntcpWndSnd=\"%d\"\ntcpWndRcv=\"%d\"\n",
     1313                                                  mtu, sockSnd ? sockSnd : 64, sockRcv ? sockRcv : 64, tcpSnd ? tcpSnd : 64, tcpRcv ? tcpRcv : 64);
    13201314                        }
    13211315                        else
    13221316                        {
    13231317                            strAttachment = "NAT";
    1324                             strNatSettings = Utf8StrFmt("NIC %d Settings:  MTU: %d, Socket (send: %d, receive: %d), TCP Window (send:%d, receive: %d)\n",
    1325                                 currentNIC + 1, mtu, sockSnd ? sockSnd : 64, sockRcv ? sockRcv : 64, tcpSnd ? tcpSnd : 64, tcpRcv ? tcpRcv : 64);
     1318                            strNatSettings.printf("NIC %d Settings:  MTU: %d, Socket (send: %d, receive: %d), TCP Window (send:%d, receive: %d)\n",
     1319                                                  currentNIC + 1, mtu, sockSnd ? sockSnd : 64, sockRcv ? sockRcv : 64, tcpSnd ? tcpSnd : 64, tcpRcv ? tcpRcv : 64);
    13261320                        }
    13271321                        break;
     
    13381332                        }
    13391333                        else
    1340                             strAttachment = Utf8StrFmt("Bridged Interface '%ls'", strBridgeAdp.raw());
     1334                            strAttachment.printf("Bridged Interface '%ls'", strBridgeAdp.raw());
    13411335                        break;
    13421336                    }
     
    13521346                        }
    13531347                        else
    1354                             strAttachment = Utf8StrFmt("Internal Network '%s'", Utf8Str(strNetwork).c_str());
     1348                            strAttachment.printf("Internal Network '%s'", Utf8Str(strNetwork).c_str());
    13551349                        break;
    13561350                    }
     
    13661360                        }
    13671361                        else
    1368                             strAttachment = Utf8StrFmt("Host-only Interface '%ls'", strHostonlyAdp.raw());
     1362                            strAttachment.printf("Host-only Interface '%ls'", strHostonlyAdp.raw());
    13691363                        break;
    13701364                    }
     
    13811375                        else
    13821376                        {
    1383                             strAttachment = Utf8StrFmt("Generic '%ls'", strGenericDriver.raw());
     1377                            strAttachment.printf("Generic '%ls'", strGenericDriver.raw());
    13841378
    13851379                            // show the generic properties
     
    13931387                                strAttachment += " { ";
    13941388                                for (unsigned i = 0; i < aProperties.size(); ++i)
    1395                                     strAttachment += Utf8StrFmt(!i ? "%ls='%ls'" : ", %ls='%ls'",
    1396                                                                 aProperties[i], aValues[i]);
     1389                                    strAttachment.appendPrintf(!i ? "%ls='%ls'" : ", %ls='%ls'", aProperties[i], aValues[i]);
    13971390                                strAttachment += " }";
    13981391                            }
     
    14111404                        }
    14121405                        else
    1413                             strAttachment = Utf8StrFmt("NAT Network '%s'", Utf8Str(strNetwork).c_str());
     1406                            strAttachment.printf("NAT Network '%s'", Utf8Str(strNetwork).c_str());
    14141407                        break;
    14151408                    }
     
    14261419                        }
    14271420                        else
    1428                             strAttachment = Utf8StrFmt("Cloud Network '%s'", Utf8Str(strNetwork).c_str());
     1421                            strAttachment.printf("Cloud Network '%s'", Utf8Str(strNetwork).c_str());
    14291422                        break;
    14301423                    }
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