aboutsummaryrefslogtreecommitdiffstats
path: root/vncviewer/vncviewer.cxx
diff options
context:
space:
mode:
authorMathias Jonsson <math.jonsson@gmail.com>2018-04-22 19:10:30 +0200
committerMathias Jonsson <math.jonsson@gmail.com>2018-05-22 22:48:41 +0200
commit50439d78fae2828356bfde789ec5c4fd0911ae09 (patch)
tree5b7828255715e8073b259cb39e110fb59dfceb4a /vncviewer/vncviewer.cxx
parent105177fc07d07521eafdcf373c1825a59b9c554d (diff)
downloadtigervnc-50439d78fae2828356bfde789ec5c4fd0911ae09.tar.gz
tigervnc-50439d78fae2828356bfde789ec5c4fd0911ae09.zip
Accept a cfg as an argument as an alt way to start the viewer
The user can specify a tigervnc configuration file as an argument to the viewer. Previously the viewer assumed this to be a server, but now we will first check if there is any file matching the given argument. If so, try to load the content of that file, like we normally do. Fixes issue #38.
Diffstat (limited to 'vncviewer/vncviewer.cxx')
-rw-r--r--vncviewer/vncviewer.cxx33
1 files changed, 31 insertions, 2 deletions
diff --git a/vncviewer/vncviewer.cxx b/vncviewer/vncviewer.cxx
index 413260d9..fabd665a 100644
--- a/vncviewer/vncviewer.cxx
+++ b/vncviewer/vncviewer.cxx
@@ -349,8 +349,9 @@ static void usage(const char *programName)
fprintf(stderr,
"\nusage: %s [parameters] [host:displayNum] [parameters]\n"
- " %s [parameters] -listen [port] [parameters]\n",
- programName, programName);
+ " %s [parameters] -listen [port] [parameters]\n"
+ " %s [parameters] [.tigervnc file]\n",
+ programName, programName, programName);
fprintf(stderr,"\n"
"Parameters can be turned on with -<param> or off with -<param>=0\n"
"Parameters which take a value can be specified as "
@@ -368,6 +369,31 @@ static void usage(const char *programName)
exit(1);
}
+static void
+potentiallyLoadConfigurationFile(char *vncServerName)
+{
+ const bool hasPathSeparator = (strchr(vncServerName, '/') != NULL ||
+ (strchr(vncServerName, '\\')) != NULL);
+
+ if (hasPathSeparator) {
+ try {
+ strncpy(vncServerName, loadViewerParameters(vncServerName),
+ VNCSERVERNAMELEN);
+ if (vncServerName[0] == '\0') {
+ vlog.error("Unable to load the server name from given file");
+ if (alertOnFatalError)
+ fl_alert("Unable to load the server name from given file");
+ exit(EXIT_FAILURE);
+ }
+ } catch (rfb::Exception& e) {
+ vlog.error("%s", e.str());
+ if (alertOnFatalError)
+ fl_alert("%s", e.str());
+ exit(EXIT_FAILURE);
+ }
+ }
+}
+
#ifndef WIN32
static int
interpretViaParam(char *remoteHost, int *remotePort, int localPort)
@@ -516,6 +542,9 @@ int main(int argc, char** argv)
i++;
}
+ // Check if the server name in reality is a configuration file
+ potentiallyLoadConfigurationFile(vncServerName);
+
mkvnchomedir();
#if !defined(WIN32) && !defined(__APPLE__)