[gtk-vnc] Set a default hostname in viewer demo program



commit 9b2211ade949a0498b2ba820c9daee376833a71b
Author: Michal Suchanek <hramrach centrum cz>
Date:   Tue Aug 25 11:51:22 2009 +0100

    Set a default hostname in viewer demo program
    
    * examples/gvncviewer.c: Set a default hostname of 127.0.0.1
      if only a port number is given

 examples/gvncviewer.c |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)
---
diff --git a/examples/gvncviewer.c b/examples/gvncviewer.c
index 6373564..28b0fb8 100644
--- a/examples/gvncviewer.c
+++ b/examples/gvncviewer.c
@@ -34,10 +34,10 @@
 static gchar **args = NULL;
 static const GOptionEntry options [] =
 {
-  {
-    G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_STRING_ARRAY, &args,
-    NULL, "hostname[:display]" },
-  { NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, 0 }
+	{
+		G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_STRING_ARRAY, &args,
+		NULL, "[hostname][:display]" },
+	{ NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, 0 }
 };
 
 
@@ -377,7 +377,7 @@ int main(int argc, char **argv)
 		return 1;
 	}
 	if (!args || (g_strv_length(args) != 1)) {
-		fprintf(stderr, "Usage: gvncviewer hostname[:display]\n%s\n", help_msg);
+		fprintf(stderr, "Usage: gvncviewer [hostname][:display]\n%s\n", help_msg);
 		return 1;
 	}
 
@@ -455,6 +455,8 @@ int main(int argc, char **argv)
 	} else
 		snprintf(port, sizeof(port), "%d", 5900);
 
+	if (!*hostname) 
+		snprintf(hostname, sizeof(hostname), "%s", "127.0.0.1");
 	vnc_display_open_host(VNC_DISPLAY(vnc), hostname, port);
 	vnc_display_set_keyboard_grab(VNC_DISPLAY(vnc), TRUE);
 	vnc_display_set_pointer_grab(VNC_DISPLAY(vnc), TRUE);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]