SIGTERM again
[handlervirt.git] / handler_avahi.h
blob155cbd041dcf43022bf4b84be59fb4bea1059b6b
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
3 /* Cherokee
5 * Authors:
6 * Alvaro Lopez Ortega <alvaro@alobbs.com>
7 * Stefan de Konink <stefan@konink.de>
9 * Copyright (C) 2001-2008 Alvaro Lopez Ortega
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of version 2 of the GNU General Public
13 * License as published by the Free Software Foundation.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23 * USA
26 #ifndef CHEROKEE_HANDLER_AVAHI_H
27 #define CHEROKEE_HANDLER_AVAHI_H
29 #include <cherokee/cherokee.h>
31 #include <avahi-client/client.h>
32 #include <avahi-client/lookup.h>
34 #include <avahi-common/simple-watch.h>
35 #include <avahi-common/malloc.h>
36 #include <avahi-common/error.h>
37 #include <avahi-common/thread-watch.h>
39 /* Data types
41 typedef struct {
42 cherokee_module_props_t base;
44 /* A table to store all our output */
45 cherokee_avl_r_t entries;
47 AvahiClient *client;
48 AvahiServiceBrowser *sb;
49 AvahiThreadedPoll *threaded_poll;
51 /* Configuration parameters */
52 cherokee_buffer_t service_type;
53 } cherokee_handler_avahi_props_t;
55 typedef struct {
56 /* Shared structures */
57 cherokee_handler_t handler;
59 /* A buffer is your output 'to be' */
60 cherokee_buffer_t buffer;
62 enum {
63 send_page,
64 send_yourmother /* not advised but possible */
65 } action; /* this could implement a state machine */
66 } cherokee_handler_avahi_t;
68 #define HDL_AVAHI(x) ((cherokee_handler_avahi_t *)(x))
69 #define PROP_AVAHI(x) ((cherokee_handler_avahi_props_t *)(x))
70 #define HDL_AVAHI_PROPS(x) (PROP_AVAHI(MODULE(x)->props))
73 /* Library init function
75 void PLUGIN_INIT_NAME(avahi) (cherokee_plugin_loader_t *loader);
76 ret_t cherokee_handler_avahi_new (cherokee_handler_t **hdl, cherokee_connection_t *cnt, cherokee_module_props_t *props);
78 /* virtual methods implementation
80 ret_t cherokee_handler_avahi_init (cherokee_handler_avahi_t *hdl);
81 ret_t cherokee_handler_avahi_free (cherokee_handler_avahi_t *hdl);
82 ret_t cherokee_handler_avahi_step (cherokee_handler_avahi_t *hdl, cherokee_buffer_t *buffer);
83 ret_t cherokee_handler_avahi_add_headers (cherokee_handler_avahi_t *hdl, cherokee_buffer_t *buffer);
85 static void client_callback(AvahiClient *c, AvahiClientState state, AVAHI_GCC_UNUSED void * userdata);
86 static void resolve_callback(AvahiServiceResolver *r, AVAHI_GCC_UNUSED AvahiIfIndex interface, AVAHI_GCC_UNUSED AvahiProtocol protocol, AvahiResolverEvent event, const char *name, const char *type, const char *domain, const char *host_name, const AvahiAddress *address, uint16_t port, AvahiStringList *txt, AvahiLookupResultFlags flags, void* userdata);
87 static void browse_callback(AvahiServiceBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const char *name, const char *type, const char *domain, AVAHI_GCC_UNUSED AvahiLookupResultFlags flags, void* userdata);
89 #endif /* CHEROKEE_HANDLER_AVAHI_H */