[farsight2/master] Add object test

Olivier Crête olivier.crete at collabora.co.uk
Tue Dec 23 15:24:36 PST 2008


---
 Makefile |    2 +-
 test.c   |   47 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 48 insertions(+), 1 deletions(-)
 create mode 100644 test.c

diff --git a/Makefile b/Makefile
index 6424740..7d35823 100644
--- a/Makefile
+++ b/Makefile
@@ -6,7 +6,7 @@ LDFLAGS =  `pkg-config --libs gupnp-1.0`
 
 test-bare: test-bare.o
 
-test: fs-upnp-simple-igd.o
+test: fs-upnp-simple-igd.o test.o
 
 clean:
 	rm -f *.o test test-bare
diff --git a/test.c b/test.c
new file mode 100644
index 0000000..6355ba4
--- /dev/null
+++ b/test.c
@@ -0,0 +1,47 @@
+
+#include <glib.h>
+
+#include "fs-upnp-simple-igd.h"
+
+GMainLoop *loop = NULL;
+
+static void
+_new_external_ip (FsUpnpSimpleIgd *igd, gchar *ip, gpointer user_data)
+{
+  g_debug ("ip: %s", ip);
+
+  g_main_loop_quit (loop);
+}
+
+
+static void
+_error (FsUpnpSimpleIgd *igd, GError *error, gpointer user_data)
+{
+  g_error ("error: %s", error->message);
+}
+int
+main (int argc, char **argv)
+{
+  FsUpnpSimpleIgd *igd = NULL;
+
+  g_type_init ();
+  g_thread_init (NULL);
+
+  loop = g_main_loop_new (NULL, FALSE);
+
+  igd = fs_upnp_simple_igd_new (NULL);
+
+  g_signal_connect (igd, "new-external-ip", G_CALLBACK (_new_external_ip),
+      NULL);
+  g_signal_connect (igd, "error", G_CALLBACK (_error),
+      NULL);
+
+  fs_upnp_simple_igd_gather (igd, TRUE);
+
+  g_main_loop_run (loop);
+
+  g_main_loop_unref (loop);
+  g_free (igd);
+
+  return 0;
+}
-- 
1.5.6.5




More information about the farsight-commits mailing list