aboutsummaryrefslogtreecommitdiffstats
path: root/mdns-browser.c
diff options
context:
space:
mode:
authorkraxel <kraxel>2006-01-26 16:27:01 +0000
committerkraxel <kraxel>2006-01-26 16:27:01 +0000
commit8cefbcf1e028004efa70f2f1956fbc9d25c8b372 (patch)
tree03331d899793e543d06e6e3239bf67981ccae1a1 /mdns-browser.c
parent2bc71f882724947307fadcf5f3c7cee81191acb2 (diff)
downloadxenwatch-8cefbcf1e028004efa70f2f1956fbc9d25c8b372.tar.gz
- more mdns bits.
Diffstat (limited to 'mdns-browser.c')
-rw-r--r--mdns-browser.c81
1 files changed, 81 insertions, 0 deletions
diff --git a/mdns-browser.c b/mdns-browser.c
new file mode 100644
index 0000000..9f004b7
--- /dev/null
+++ b/mdns-browser.c
@@ -0,0 +1,81 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <locale.h>
+#include <signal.h>
+
+#include <gdk/gdk.h>
+#include <gdk/gdkx.h>
+#include <gtk/gtk.h>
+
+#include "mdns.h"
+
+/* ------------------------------------------------------------------ */
+
+static Display *dpy;
+static struct mdns_window *mdns;
+
+static char *service = "_ssh._tcp";
+static char *domain = NULL;
+
+/* ------------------------------------------------------------------ */
+
+static void usage(FILE *fp)
+{
+ fprintf(fp,
+ "This is a mDNS browser\n"
+ "\n"
+ "usage: mdns-browser [options]\n"
+ "options:\n"
+ " -h print this text\n"
+ " -s <service> specify service [%s]\n"
+ " -d <domain> specify domain\n"
+ "\n"
+ "-- \n"
+ "(c) 2006 Gerd Hoffmann <kraxel@suse.de>\n",
+ service);
+}
+
+int
+main(int argc, char *argv[])
+{
+ int c;
+
+ gtk_init(&argc, &argv);
+ for (;;) {
+ if (-1 == (c = getopt(argc, argv, "hs:d:")))
+ break;
+ switch (c) {
+ case 's':
+ service = optarg;
+ break;
+ case 'd':
+ domain = optarg;
+ break;
+ case 'h':
+ usage(stdout);
+ exit(0);
+ default:
+ usage(stderr);
+ exit(1);
+ }
+ }
+
+ dpy = gdk_x11_display_get_xdisplay(gdk_display_get_default());
+ fcntl(ConnectionNumber(dpy),F_SETFD,FD_CLOEXEC);
+
+ mdns = mdns_create_window(1);
+ if (NULL == mdns) {
+ fprintf(stderr,"Oops: mDNS did't initialize ok\n");
+ exit(1);
+ }
+ mdns_show_window(mdns);
+ mdns_browse(mdns, service, domain);
+
+ gtk_main();
+ fprintf(stderr,"bye...\n");
+ exit(0);
+}