aboutsummaryrefslogtreecommitdiffstats
path: root/vnc-client.c
diff options
context:
space:
mode:
authorkraxel <kraxel>2006-10-30 17:04:43 +0000
committerkraxel <kraxel>2006-10-30 17:04:43 +0000
commit733a1ee52f081c554788accb51d55bb8a9602560 (patch)
treea5bd699cafd20c494efc5149974078096e6616e7 /vnc-client.c
parentb0b7aac6a182502230ecadf0e37f24b220c3b450 (diff)
downloadxenwatch-733a1ee52f081c554788accb51d55bb8a9602560.tar.gz
misc
Diffstat (limited to 'vnc-client.c')
-rw-r--r--vnc-client.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/vnc-client.c b/vnc-client.c
index 479428c..94f3507 100644
--- a/vnc-client.c
+++ b/vnc-client.c
@@ -20,7 +20,7 @@ static void usage(FILE *fp)
fprintf(fp,
"This is a simple vnc client\n"
"\n"
- "usage: vnc-client [options] hostname displayno\n"
+ "usage: vnc-client [options] display\n"
"options:\n"
" -h Print this text.\n"
" -d Enable debug output.\n"
@@ -35,6 +35,8 @@ int
main(int argc, char *argv[])
{
unsigned long vnc_flags = VNC_FLAG_STANDALONE;
+ char hostname[65];
+ int displayno, port;
int debug = 0;
int c;
@@ -61,12 +63,24 @@ main(int argc, char *argv[])
}
}
- if (optind+2 > argc) {
+ if (optind+1 > argc) {
usage(stderr);
exit(1);
}
-
- if (NULL == vnc_open(argv[optind], atoi(argv[optind+1]), vnc_flags, debug))
+
+ if (2 == sscanf(argv[optind], "%64[^:]:%d", hostname, &displayno))
+ goto connect;
+ if (2 == sscanf(argv[optind], "%64[^:]::%d", hostname, &port)) {
+ displayno = port - 5900;
+ if (displayno >= 0)
+ goto connect;
+ }
+
+ usage(stderr);
+ exit(1);
+
+ connect:
+ if (NULL == vnc_open(hostname, displayno, vnc_flags, debug))
exit(1);
gtk_main();