diff options
author | Dan Winship <danw@gnome.org> | 2013-02-23 02:13:26 +0100 |
---|---|---|
committer | Dan Winship <danw@gnome.org> | 2013-02-23 12:01:01 +0100 |
commit | 4c7d4c4cd46f64538ca0b3e186b52bdfcaa97e29 (patch) | |
tree | e5424bbcd415f737f970bd5842f5add2fa1d0fe4 | |
parent | 4e9713343934fc2aba5d81ab12fccd64cc24a99f (diff) | |
download | libsoup-4c7d4c4cd46f64538ca0b3e186b52bdfcaa97e29.tar.gz libsoup-4c7d4c4cd46f64538ca0b3e186b52bdfcaa97e29.tar.bz2 libsoup-4c7d4c4cd46f64538ca0b3e186b52bdfcaa97e29.zip |
examples: move examples from tests/ to examples/
get, simple-httpd, and simple-proxy are more example code than test
programs, so move them into a separate directory.
Also, remove "dns", which was once a sort-of test of SoupAddress, but
is now just a redundant sort-of test of GResolver.
-rw-r--r-- | .gitignore | 7 | ||||
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | configure.ac | 1 | ||||
-rw-r--r-- | examples/Makefile.am | 14 | ||||
-rw-r--r-- | examples/get.c (renamed from tests/get.c) | 4 | ||||
-rw-r--r-- | examples/simple-httpd.c (renamed from tests/simple-httpd.c) | 6 | ||||
-rw-r--r-- | examples/simple-proxy.c (renamed from tests/simple-proxy.c) | 5 | ||||
-rw-r--r-- | tests/Makefile.am | 6 | ||||
-rw-r--r-- | tests/dns.c | 60 |
9 files changed, 31 insertions, 74 deletions
@@ -36,6 +36,9 @@ docs/reference/libsoup-2.4.signals docs/reference/libsoup-2.4.types docs/reference/tmpl docs/reference/xml +examples/get +examples/simple-httpd +examples/simple-proxy gtk-doc.make install-sh libsoup-zip @@ -68,14 +71,10 @@ tests/*.log tests/*.trs tests/*-test tests/date -tests/dns -tests/get tests/getbug tests/header-parsing tests/httpd.conf tests/ntlm-test-helper tests/pull-api -tests/simple-httpd -tests/simple-proxy tests/soup-tests.gresource tests/uri-parsing diff --git a/Makefile.am b/Makefile.am index 18bf80af..66992d93 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,7 +1,7 @@ ## Process this file with automake to produce Makefile.in ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS} -SUBDIRS = libsoup po tests docs +SUBDIRS = libsoup po tests examples docs EXTRA_DIST = \ data/effective_tld_names.dat \ diff --git a/configure.ac b/configure.ac index 68293d39..36a16878 100644 --- a/configure.ac +++ b/configure.ac @@ -361,6 +361,7 @@ AC_CONFIG_FILES([ po/Makefile.in po/Makefile tests/Makefile + examples/Makefile docs/Makefile docs/reference/Makefile libsoup/soup-version.h diff --git a/examples/Makefile.am b/examples/Makefile.am new file mode 100644 index 00000000..69e5b550 --- /dev/null +++ b/examples/Makefile.am @@ -0,0 +1,14 @@ +INCLUDES = \ + -I$(top_srcdir) \ + -DSRCDIR=\""$(abs_srcdir)"\" \ + -DBUILDDIR=\""$(builddir)"\" \ + $(GLIB_CFLAGS) + +LIBS = \ + $(top_builddir)/libsoup/libsoup-2.4.la \ + $(GLIB_LIBS) + +noinst_PROGRAMS = \ + get \ + simple-httpd \ + simple-proxy diff --git a/tests/get.c b/examples/get.c index 15d69033..f28e5357 100644 --- a/tests/get.c +++ b/examples/get.c @@ -3,13 +3,15 @@ * Copyright (C) 2001-2003, Ximian, Inc. */ -#include "test-utils.h" #include <stdio.h> +#include <stdlib.h> #ifdef G_OS_WIN32 #include <getopt.h> #endif +#include <libsoup/soup.h> + static SoupSession *session; static GMainLoop *loop; static gboolean debug = FALSE, quiet = FALSE; diff --git a/tests/simple-httpd.c b/examples/simple-httpd.c index 75b7cd4a..3d05c2a1 100644 --- a/tests/simple-httpd.c +++ b/examples/simple-httpd.c @@ -3,18 +3,20 @@ * Copyright (C) 2001-2003, Ximian, Inc. */ -#include "test-utils.h" - #include <dirent.h> #include <errno.h> #include <fcntl.h> #include <stdio.h> +#include <stdlib.h> +#include <string.h> #include <sys/stat.h> #ifdef G_OS_WIN32 #include <getopt.h> #endif +#include <libsoup/soup.h> + static int compare_strings (gconstpointer a, gconstpointer b) { diff --git a/tests/simple-proxy.c b/examples/simple-proxy.c index 765fa5e7..1a9e0ed3 100644 --- a/tests/simple-proxy.c +++ b/examples/simple-proxy.c @@ -3,12 +3,15 @@ * Copyright (C) 2001-2003, Ximian, Inc. */ -#include "test-utils.h" +#include <stdlib.h> +#include <string.h> #ifdef G_OS_WIN32 #include <getopt.h> #endif +#include <libsoup/soup.h> + /* WARNING: this is really really really not especially compliant with * RFC 2616. But it does work for basic stuff. */ diff --git a/tests/Makefile.am b/tests/Makefile.am index 5bbcba8e..417b04c7 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -42,12 +42,8 @@ TESTS = \ xmlrpc-test noinst_PROGRAMS = \ - $(TESTS) \ - dns \ - get \ ntlm-test-helper \ - simple-httpd \ - simple-proxy + $(TESTS) noinst_DATA = soup-tests.gresource diff --git a/tests/dns.c b/tests/dns.c deleted file mode 100644 index ee9108e6..00000000 --- a/tests/dns.c +++ /dev/null @@ -1,60 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -#include "test-utils.h" - -static GMainLoop *loop; -static int nlookups = 0; - -static void -resolve_callback (SoupAddress *addr, guint status, gpointer data) -{ - if (status == SOUP_STATUS_OK) { - g_print ("Name: %s\n", soup_address_get_name (addr)); - g_print ("Address: %s\n", soup_address_get_physical (addr)); - } else { - g_print ("Name: %s\n", soup_address_get_name (addr)); - g_print ("Error: %s\n", soup_status_get_phrase (status)); - } - g_print ("\n"); - - g_object_unref (addr); - - nlookups--; - if (nlookups == 0) - g_main_loop_quit (loop); -} - -static void -usage (void) -{ - g_printerr ("Usage: dns hostname ...\n"); - exit (1); -} - -int -main (int argc, char **argv) -{ - SoupAddress *addr; - int i; - - if (argc < 2) - usage (); - - for (i = 1; i < argc; i++) { - addr = soup_address_new (argv[i], 0); - if (!addr) { - g_printerr ("Could not parse address %s\n", argv[1]); - exit (1); - } - - soup_address_resolve_async (addr, NULL, NULL, - resolve_callback, NULL); - nlookups++; - } - - loop = g_main_loop_new (NULL, TRUE); - g_main_loop_run (loop); - g_main_loop_unref (loop); - - return 0; -} |