From fd243a8d3ae8e776fb2af1136feee7f8c083d2da Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Mon, 23 Jan 2023 20:15:28 +0100 Subject: [PATCH] Remove "str" prefix from string helpers This matches the naming in STL, which is what we are mostly mimicing now that we are using std::string for these functions. --- common/network/TcpSocket.cxx | 4 +- common/rfb/CSecurityRSAAES.cxx | 2 +- common/rfb/CSecurityTLS.cxx | 89 ++++++++++++++++----------------- common/rfb/LogWriter.cxx | 4 +- common/rfb/SSecurityPlain.cxx | 2 +- common/rfb/Security.cxx | 2 +- common/rfb/util.cxx | 6 +-- common/rfb/util.h | 6 +-- win/rfb_win32/Service.cxx | 2 +- win/rfb_win32/Win32Util.cxx | 2 +- win/vncconfig/Connections.h | 2 +- win/vncconfig/Legacy.cxx | 4 +- win/winvnc/VNCServerService.cxx | 2 +- win/winvnc/winvnc.cxx | 6 +-- 14 files changed, 66 insertions(+), 67 deletions(-) diff --git a/common/network/TcpSocket.cxx b/common/network/TcpSocket.cxx index 87f2e757..462b8a7b 100644 --- a/common/network/TcpSocket.cxx +++ b/common/network/TcpSocket.cxx @@ -507,7 +507,7 @@ void network::createTcpListeners(std::list *listeners, TcpFilter::TcpFilter(const char* spec) { std::vector patterns; - patterns = rfb::strSplit(spec, ','); + patterns = rfb::split(spec, ','); for (size_t i = 0; i < patterns.size(); i++) { if (!patterns[i].empty()) @@ -609,7 +609,7 @@ TcpFilter::Pattern TcpFilter::parsePattern(const char* p) { initSockets(); - parts = rfb::strSplit(&p[1], '/'); + parts = rfb::split(&p[1], '/'); if (parts.size() > 2) throw Exception("invalid filter specified"); diff --git a/common/rfb/CSecurityRSAAES.cxx b/common/rfb/CSecurityRSAAES.cxx index 24d1a9fe..bff088ad 100644 --- a/common/rfb/CSecurityRSAAES.cxx +++ b/common/rfb/CSecurityRSAAES.cxx @@ -208,7 +208,7 @@ void CSecurityRSAAES::verifyServer() sha1_update(&ctx, serverKey.size, serverKeyE); sha1_digest(&ctx, sizeof(f), f); const char *title = "Server key fingerprint"; - std::string text = strFormat( + std::string text = format( "The server has provided the following identifying information:\n" "Fingerprint: %02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x\n" "Please verify that the information is correct and press \"Yes\". " diff --git a/common/rfb/CSecurityTLS.cxx b/common/rfb/CSecurityTLS.cxx index 92a89193..58794e89 100644 --- a/common/rfb/CSecurityTLS.cxx +++ b/common/rfb/CSecurityTLS.cxx @@ -356,9 +356,9 @@ void CSecurityTLS::checkSession() if (gnutls_x509_crt_check_hostname(crt, client->getServerName()) == 0) { std::string text; vlog.debug("hostname mismatch"); - text = strFormat("Hostname (%s) does not match the server " - "certificate, do you want to continue?", - client->getServerName()); + text = format("Hostname (%s) does not match the server " + "certificate, do you want to continue?", + client->getServerName()); if (!msg->showMsgBox(UserMsgBox::M_YESNO, "Certificate hostname mismatch", text.c_str())) @@ -434,16 +434,16 @@ void CSecurityTLS::checkSession() if (status & (GNUTLS_CERT_SIGNER_NOT_FOUND | GNUTLS_CERT_SIGNER_NOT_CA)) { - text = strFormat("This certificate has been signed by an " - "unknown authority:\n" - "\n" - "%s\n" - "\n" - "Someone could be trying to impersonate the " - "site and you should not continue.\n" - "\n" - "Do you want to make an exception for this " - "server?", info.data); + text = format("This certificate has been signed by an unknown " + "authority:\n" + "\n" + "%s\n" + "\n" + "Someone could be trying to impersonate the site " + "and you should not continue.\n" + "\n" + "Do you want to make an exception for this " + "server?", info.data); if (!msg->showMsgBox(UserMsgBox::M_YESNO, "Unknown certificate issuer", @@ -452,15 +452,15 @@ void CSecurityTLS::checkSession() } if (status & GNUTLS_CERT_EXPIRED) { - text = strFormat("This certificate has expired:\n" - "\n" - "%s\n" - "\n" - "Someone could be trying to impersonate the " - "site and you should not continue.\n" - "\n" - "Do you want to make an exception for this " - "server?", info.data); + text = format("This certificate has expired:\n" + "\n" + "%s\n" + "\n" + "Someone could be trying to impersonate the site " + "and you should not continue.\n" + "\n" + "Do you want to make an exception for this " + "server?", info.data); if (!msg->showMsgBox(UserMsgBox::M_YESNO, "Expired certificate", @@ -475,18 +475,17 @@ void CSecurityTLS::checkSession() if (status & (GNUTLS_CERT_SIGNER_NOT_FOUND | GNUTLS_CERT_SIGNER_NOT_CA)) { - text = strFormat("This host is previously known with a " - "different certificate, and the new " - "certificate has been signed by an " - "unknown authority:\n" - "\n" - "%s\n" - "\n" - "Someone could be trying to impersonate the " - "site and you should not continue.\n" - "\n" - "Do you want to make an exception for this " - "server?", info.data); + text = format("This host is previously known with a different " + "certificate, and the new certificate has been " + "signed by an unknown authority:\n" + "\n" + "%s\n" + "\n" + "Someone could be trying to impersonate the site " + "and you should not continue.\n" + "\n" + "Do you want to make an exception for this " + "server?", info.data); if (!msg->showMsgBox(UserMsgBox::M_YESNO, "Unexpected server certificate", @@ -495,17 +494,17 @@ void CSecurityTLS::checkSession() } if (status & GNUTLS_CERT_EXPIRED) { - text = strFormat("This host is previously known with a " - "different certificate, and the new " - "certificate has expired:\n" - "\n" - "%s\n" - "\n" - "Someone could be trying to impersonate the " - "site and you should not continue.\n" - "\n" - "Do you want to make an exception for this " - "server?", info.data); + text = format("This host is previously known with a different " + "certificate, and the new certificate has " + "expired:\n" + "\n" + "%s\n" + "\n" + "Someone could be trying to impersonate the site " + "and you should not continue.\n" + "\n" + "Do you want to make an exception for this " + "server?", info.data); if (!msg->showMsgBox(UserMsgBox::M_YESNO, "Unexpected server certificate", diff --git a/common/rfb/LogWriter.cxx b/common/rfb/LogWriter.cxx index 398d3872..dc9db9d1 100644 --- a/common/rfb/LogWriter.cxx +++ b/common/rfb/LogWriter.cxx @@ -77,7 +77,7 @@ LogWriter::getLogWriter(const char* name) { bool LogWriter::setLogParams(const char* params) { std::vector parts; - parts = strSplit(params, ':'); + parts = split(params, ':'); if (parts.size() != 3) { fprintf(stderr,"failed to parse log params:%s\n",params); return false; @@ -124,7 +124,7 @@ bool LogParameter::setParam(const char* v) { LogWriter::setLogParams("*::0"); StringParameter::setParam(v); std::vector parts; - parts = strSplit(v, ','); + parts = split(v, ','); for (size_t i = 0; i < parts.size(); i++) { if (parts[i].empty()) continue; diff --git a/common/rfb/SSecurityPlain.cxx b/common/rfb/SSecurityPlain.cxx index 8bef8d8c..5124a08e 100644 --- a/common/rfb/SSecurityPlain.cxx +++ b/common/rfb/SSecurityPlain.cxx @@ -47,7 +47,7 @@ bool PasswordValidator::validUser(const char* username) { std::vector users; - users = strSplit(plainUsers, ','); + users = split(plainUsers, ','); for (size_t i = 0; i < users.size(); i++) { if (users[i] == "*") diff --git a/common/rfb/Security.cxx b/common/rfb/Security.cxx index be07bae3..caf6420f 100644 --- a/common/rfb/Security.cxx +++ b/common/rfb/Security.cxx @@ -207,7 +207,7 @@ std::list rfb::parseSecTypes(const char* types_) { std::list result; std::vector types; - types = strSplit(types_, ','); + types = split(types_, ','); for (size_t i = 0; i < types.size(); i++) { uint32_t typeNum = secTypeNum(types[i].c_str()); if (typeNum != secTypeInvalid) diff --git a/common/rfb/util.cxx b/common/rfb/util.cxx index 22918cf9..c5c00bbd 100644 --- a/common/rfb/util.cxx +++ b/common/rfb/util.cxx @@ -32,7 +32,7 @@ namespace rfb { - std::string strFormat(const char *fmt, ...) + std::string format(const char *fmt, ...) { va_list ap; int len; @@ -59,8 +59,8 @@ namespace rfb { return out; } - std::vector strSplit(const char* src, - const char delimiter) + std::vector split(const char* src, + const char delimiter) { std::vector out; const char *start, *stop; diff --git a/common/rfb/util.h b/common/rfb/util.h index 1e59de62..34811e3f 100644 --- a/common/rfb/util.h +++ b/common/rfb/util.h @@ -35,12 +35,12 @@ struct timeval; namespace rfb { // Formats according to printf(), with a dynamic allocation - std::string strFormat(const char *fmt, ...) + std::string format(const char *fmt, ...) __attribute__((__format__ (__printf__, 1, 2))); // Splits a string with the specified delimiter - std::vector strSplit(const char* src, - const char delimiter); + std::vector split(const char* src, + const char delimiter); // Conversion to and from a hex string diff --git a/win/rfb_win32/Service.cxx b/win/rfb_win32/Service.cxx index 259eb762..62230b07 100644 --- a/win/rfb_win32/Service.cxx +++ b/win/rfb_win32/Service.cxx @@ -323,7 +323,7 @@ bool rfb::win32::registerService(const char* name, // - Add the supplied extra parameters to the command line std::string cmdline; - cmdline = strFormat("\"%s\" %s", buffer.buf, defaultcmdline); + cmdline = format("\"%s\" %s", buffer.buf, defaultcmdline); for (i=0; i hostv; - hostv = strSplit(hosts, ','); + hostv = split(hosts, ','); for (size_t i = 0; i < hostv.size(); i++) { if (!hostv[i].empty()) SendMessage(listBox, LB_ADDSTRING, 0, (LPARAM)hostv[i].c_str()); diff --git a/win/vncconfig/Legacy.cxx b/win/vncconfig/Legacy.cxx index b21bccd7..7703c3a3 100644 --- a/win/vncconfig/Legacy.cxx +++ b/win/vncconfig/Legacy.cxx @@ -69,7 +69,7 @@ void LegacyPage::LoadPrefs() try { // Split the AuthHosts string into patterns to match std::vector patterns; - patterns = rfb::strSplit(authHosts.c_str(), ':'); + patterns = rfb::split(authHosts.c_str(), ':'); for (size_t i = 0; i < patterns.size(); i++) { if (!patterns[i].empty()) { int bits = 0; @@ -79,7 +79,7 @@ void LegacyPage::LoadPrefs() // Split the pattern into IP address parts and process std::vector parts; - parts = rfb::strSplit(&patterns[i][1], '.'); + parts = rfb::split(&patterns[i][1], '.'); for (size_t j = 0; j < parts.size(); j++) { if (bits) strcat(pattern, "."); diff --git a/win/winvnc/VNCServerService.cxx b/win/winvnc/VNCServerService.cxx index d2a994aa..4754d720 100644 --- a/win/winvnc/VNCServerService.cxx +++ b/win/winvnc/VNCServerService.cxx @@ -109,7 +109,7 @@ HANDLE LaunchProcessWin(DWORD /*dwSessionId*/) { ModuleFileName filename; std::string cmdLine; - cmdLine = strFormat("\"%s\" -noconsole -service_run", filename.buf); + cmdLine = format("\"%s\" -noconsole -service_run", filename.buf); STARTUPINFO si; ZeroMemory(&si, sizeof si); si.cb = sizeof si; diff --git a/win/winvnc/winvnc.cxx b/win/winvnc/winvnc.cxx index 2e705bf0..604df12e 100644 --- a/win/winvnc/winvnc.cxx +++ b/win/winvnc/winvnc.cxx @@ -154,9 +154,9 @@ static void processParams(int argc, char** argv) { runServer = false; std::string result; DWORD state = rfb::win32::getServiceState(VNCServerService::Name); - result = strFormat("The %s Service is in the %s state.", - VNCServerService::Name, - rfb::win32::serviceStateName(state)); + result = format("The %s Service is in the %s state.", + VNCServerService::Name, + rfb::win32::serviceStateName(state)); MsgBoxOrLog(result.c_str()); } else if (strcasecmp(argv[i], "-service") == 0) { printf("Run in service mode\n"); -- 2.39.5