summaryrefslogtreecommitdiffstats
path: root/examples/publish-service.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2005-08-05 18:59:21 +0000
committerLennart Poettering <lennart@poettering.net>2005-08-05 18:59:21 +0000
commit0632e854728e8e64552ae08f90852d4a2658539e (patch)
tree0fab7d52e01da7ab9b81b8409dcf70cceb7d2852 /examples/publish-service.c
parentd76069e946b4e89c828c96340677e40f583080c9 (diff)
* add proper error codes and patch everything to make use of it
* parameter validity checkin in all user visible functions of libavahi-core * two new python tools/examples avahi-resolve-host-name and avahi-resolve-address git-svn-id: file:///home/lennart/svn/public/avahi/trunk@238 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe
Diffstat (limited to 'examples/publish-service.c')
-rw-r--r--examples/publish-service.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/examples/publish-service.c b/examples/publish-service.c
index 7c9879c..a936147 100644
--- a/examples/publish-service.c
+++ b/examples/publish-service.c
@@ -121,7 +121,9 @@ static void server_callback(AvahiServer *s, AvahiServerState state, gpointer use
int main(int argc, char*argv[]) {
AvahiServerConfig config;
AvahiServer *server = NULL;
-
+ gint error;
+ int ret = 1;
+
srand(time(NULL));
name = g_strdup("MegaPrinter");
@@ -132,15 +134,25 @@ int main(int argc, char*argv[]) {
config.publish_workstation = FALSE;
/* Allocate a new server */
- server = avahi_server_new(NULL, &config, server_callback, NULL);
+ server = avahi_server_new(NULL, &config, server_callback, NULL, &error);
/* Free the configuration data */
avahi_server_config_free(&config);
+
+ /* Check wether creating the server object succeeded */
+ if (!server) {
+ g_message("Failed to create server: %s", avahi_strerror(error));
+ goto fail;
+ }
/* Run the main loop */
main_loop = g_main_loop_new(NULL, FALSE);
g_main_loop_run(main_loop);
+ ret = 0;
+
+fail:
+
/* Cleanup things */
if (group)
avahi_entry_group_free(group);
@@ -153,5 +165,5 @@ int main(int argc, char*argv[]) {
g_free(name);
- return 0;
+ return ret;
}