diff options
author | Ross Burton <ross@openedhand.com> | 2008-11-18 12:13:07 +0000 |
---|---|---|
committer | Ross Burton <ross@openedhand.com> | 2008-11-18 12:13:07 +0000 |
commit | d0c252f09ab7a056057dcad1e8bda06d1a7d8efc (patch) | |
tree | 7a1901f2adb1d93c0809399a3608565b34b3a23f /examples | |
parent | 135dba9f94100dd22cb6173e1f09854eb2700869 (diff) | |
download | gupnp-d0c252f09ab7a056057dcad1e8bda06d1a7d8efc.tar.gz |
2008-11-18 Ross Burton <ross@linux.intel.com>
* tests/test-proxy.c:
* tests/test-server.c:
* tests/test-browsing.c:
* tests/test-introspection.c:
* examples/light-client.c:
* examples/light-server.c:
Don't user g_error but g_printerr (Sven Neumann).
git-svn-id: https://svn.o-hand.com/repos/gupnp/trunk/gupnp@1364 d8cb91d7-bff9-0310-92b9-80b65e4482b2
Diffstat (limited to 'examples')
-rw-r--r-- | examples/light-client.c | 14 | ||||
-rw-r--r-- | examples/light-server.c | 22 |
2 files changed, 27 insertions, 9 deletions
diff --git a/examples/light-client.c b/examples/light-client.c index 27efce5..1e6825d 100644 --- a/examples/light-client.c +++ b/examples/light-client.c @@ -10,6 +10,7 @@ */ #include <libgupnp/gupnp.h> +#include <stdlib.h> static GMainLoop *main_loop; @@ -82,7 +83,7 @@ main (int argc, char **argv) /* Check and parse command line arguments */ if (argc != 2) { usage (); - return 1; + return EXIT_FAILURE; } if (g_str_equal (argv[1], "on")) { @@ -93,17 +94,22 @@ main (int argc, char **argv) mode = TOGGLE; } else { usage (); - return 1; + return EXIT_FAILURE; } /* Create the UPnP context */ context = gupnp_context_new (NULL, NULL, 0, &error); if (error) { - g_error ("%s", error->message); + g_printerr ("Error creating the GUPnP context: %s\n", + error->message); + g_error_free (error); + + return EXIT_FAILURE; } /* Create the control point, searching for SwitchPower services */ - cp = gupnp_control_point_new (context, "urn:schemas-upnp-org:service:SwitchPower:1"); + cp = gupnp_control_point_new (context, + "urn:schemas-upnp-org:service:SwitchPower:1"); /* Connect to the service-found callback */ g_signal_connect (cp, diff --git a/examples/light-server.c b/examples/light-server.c index 1f9d109..d3da602 100644 --- a/examples/light-server.c +++ b/examples/light-server.c @@ -10,6 +10,7 @@ */ #include <libgupnp/gupnp.h> +#include <stdlib.h> static gboolean status; @@ -103,7 +104,11 @@ main (int argc, char **argv) /* Create the UPnP context */ context = gupnp_context_new (NULL, NULL, 0, &error); if (error) { - g_error ("%s", error->message); + g_printerr ("Error creating the GUPnP context: %s\n", + error->message); + g_error_free (error); + + return EXIT_FAILURE; } /* Host the device and service description files */ @@ -117,8 +122,11 @@ main (int argc, char **argv) /* Get the switch service from the root device */ service = gupnp_device_info_get_service (GUPNP_DEVICE_INFO (dev), "urn:schemas-upnp-org:service:SwitchPower:1"); - if (!service) - g_error ("Cannot get SwitchPower1 service"); + if (!service) { + g_printerr ("Cannot get SwitchPower1 service\n"); + + return EXIT_FAILURE; + } /* Autoconnect the action and state variable handlers. This connects query_target_cb and query_status_cb to the Target and Status state @@ -126,8 +134,12 @@ main (int argc, char **argv) get_status_cb to SetTarget, GetTarget and GetStatus actions respectively. */ gupnp_service_signals_autoconnect (GUPNP_SERVICE (service), NULL, &error); - if (error) - g_error ("Failed to autoconnect signals: %s", error->message); + if (error) { + g_printerr ("Failed to autoconnect signals: %s\n", error->message); + g_error_free (error); + + return EXIT_FAILURE; + } /* Run the main loop */ main_loop = g_main_loop_new (NULL, FALSE); |