From: Pierre Ossman Date: Tue, 17 Jan 2023 18:03:25 +0000 (+0100) Subject: Namespace directory functions X-Git-Tag: v1.13.90~87^2~18 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=803a6ae087331d2701daf608128c2e5ff1d596a7;p=tigervnc.git Namespace directory functions All library functions should be in a proper namespace. --- diff --git a/common/os/os.cxx b/common/os/os.cxx index 1e00b92f..5492c55e 100644 --- a/common/os/os.cxx +++ b/common/os/os.cxx @@ -90,12 +90,12 @@ static const char* gethomedir(bool userDir) #endif } -const char* getvnchomedir() +const char* os::getvnchomedir() { return gethomedir(false); } -const char* getuserhomedir() +const char* os::getuserhomedir() { return gethomedir(true); } diff --git a/common/os/os.h b/common/os/os.h index ff6dcd01..5f927fef 100644 --- a/common/os/os.h +++ b/common/os/os.h @@ -20,22 +20,26 @@ #ifndef OS_OS_H #define OS_OS_H -/* - * Get VNC home directory ($HOME/.vnc or %APPDATA%/vnc/). - * If HOME environment variable is set then it is used. - * Otherwise home directory is obtained via getpwuid function. - * - * Returns NULL on failure. - */ -const char* getvnchomedir(); +namespace os { -/* - * Get user home directory. - * If HOME environment variable is set then it is used. - * Otherwise home directory is obtained via getpwuid function. - * - * Returns NULL on failure. - */ -const char* getuserhomedir(); + /* + * Get VNC home directory ($HOME/.vnc or %APPDATA%/vnc/). + * If HOME environment variable is set then it is used. + * Otherwise home directory is obtained via getpwuid function. + * + * Returns NULL on failure. + */ + const char* getvnchomedir(); + + /* + * Get user home directory. + * If HOME environment variable is set then it is used. + * Otherwise home directory is obtained via getpwuid function. + * + * Returns NULL on failure. + */ + const char* getuserhomedir(); + +} #endif /* OS_OS_H */ diff --git a/common/rfb/CSecurityTLS.cxx b/common/rfb/CSecurityTLS.cxx index dd4a5282..a8ef779d 100644 --- a/common/rfb/CSecurityTLS.cxx +++ b/common/rfb/CSecurityTLS.cxx @@ -78,7 +78,7 @@ static const char* homedirfn(const char* fn) static char full_path[PATH_MAX]; const char* homedir; - homedir = getvnchomedir(); + homedir = os::getvnchomedir(); if (homedir == NULL) return ""; @@ -389,7 +389,7 @@ void CSecurityTLS::checkSession() /* Certificate is fine, except we don't know the issuer, so TOFU time */ - homeDir = getvnchomedir(); + homeDir = os::getvnchomedir(); if (homeDir == NULL) { throw AuthFailureException("Could not obtain VNC home directory " "path for known hosts storage"); diff --git a/unix/vncpasswd/vncpasswd.cxx b/unix/vncpasswd/vncpasswd.cxx index c7af2588..66c82144 100644 --- a/unix/vncpasswd/vncpasswd.cxx +++ b/unix/vncpasswd/vncpasswd.cxx @@ -146,7 +146,7 @@ int main(int argc, char** argv) } if (!fname) { - const char *homeDir = getvnchomedir(); + const char *homeDir = os::getvnchomedir(); if (homeDir == NULL) { fprintf(stderr, "Can't obtain VNC home directory\n"); exit(1); diff --git a/vncviewer/ServerDialog.cxx b/vncviewer/ServerDialog.cxx index 3e3ddead..a6b0e80f 100644 --- a/vncviewer/ServerDialog.cxx +++ b/vncviewer/ServerDialog.cxx @@ -168,7 +168,7 @@ void ServerDialog::handleLoad(Fl_Widget* /*widget*/, void* data) ServerDialog *dialog = (ServerDialog*)data; if (!dialog->usedDir) - dialog->usedDir = strDup(getuserhomedir()); + dialog->usedDir = strDup(os::getuserhomedir()); Fl_File_Chooser* file_chooser = new Fl_File_Chooser(dialog->usedDir, _("TigerVNC configuration (*.tigervnc)"), 0, _("Select a TigerVNC configuration file")); @@ -207,7 +207,7 @@ void ServerDialog::handleSaveAs(Fl_Widget* /*widget*/, void* data) const char* servername = dialog->serverName->value(); const char* filename; if (!dialog->usedDir) - dialog->usedDir = strDup(getuserhomedir()); + dialog->usedDir = strDup(os::getuserhomedir()); Fl_File_Chooser* file_chooser = new Fl_File_Chooser(dialog->usedDir, _("TigerVNC configuration (*.tigervnc)"), 2, _("Save the TigerVNC configuration to file")); @@ -315,7 +315,7 @@ void ServerDialog::loadServerHistory() return; #endif - const char* homeDir = getvnchomedir(); + const char* homeDir = os::getvnchomedir(); if (homeDir == NULL) throw Exception(_("Could not obtain the home directory path")); @@ -381,7 +381,7 @@ void ServerDialog::saveServerHistory() return; #endif - const char* homeDir = getvnchomedir(); + const char* homeDir = os::getvnchomedir(); if (homeDir == NULL) throw Exception(_("Could not obtain the home directory path")); diff --git a/vncviewer/parameters.cxx b/vncviewer/parameters.cxx index 8d0616d3..03f2b145 100644 --- a/vncviewer/parameters.cxx +++ b/vncviewer/parameters.cxx @@ -629,7 +629,7 @@ void saveViewerParameters(const char *filename, const char *servername) { return; #endif - const char* homeDir = getvnchomedir(); + const char* homeDir = os::getvnchomedir(); if (homeDir == NULL) throw Exception(_("Could not obtain the home directory path")); @@ -733,7 +733,7 @@ char* loadViewerParameters(const char *filename) { return loadFromReg(); #endif - const char* homeDir = getvnchomedir(); + const char* homeDir = os::getvnchomedir(); if (homeDir == NULL) throw Exception(_("Could not obtain the home directory path")); diff --git a/vncviewer/vncviewer.cxx b/vncviewer/vncviewer.cxx index 7d87ab44..9db94ffd 100644 --- a/vncviewer/vncviewer.cxx +++ b/vncviewer/vncviewer.cxx @@ -433,7 +433,7 @@ static void init_fltk() static void mkvnchomedir() { // Create .vnc in the user's home directory if it doesn't already exist - const char* homeDir = getvnchomedir(); + const char* homeDir = os::getvnchomedir(); if (homeDir == NULL) { vlog.error(_("Could not obtain the home directory path")); } else {