1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
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
26 #ifndef CHEROKEE_HANDLER_CLUSTERSTATS_H
27 #define CHEROKEE_HANDLER_CLUSTERSTATS_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>
42 cherokee_module_props_t base
;
44 /* A table to store all our output */
45 cherokee_avl_r_t entries
;
48 AvahiServiceBrowser
*sb
;
49 AvahiThreadedPoll
*threaded_poll
;
51 /* Configuration parameters */
52 cherokee_buffer_t service_type
;
53 } cherokee_handler_clusterstats_props_t
;
56 /* Shared structures */
57 cherokee_handler_t handler
;
59 /* A buffer is your output 'to be' */
60 cherokee_buffer_t buffer
;
64 send_yourmother
/* not advised but possible */
65 } action
; /* this could implement a state machine */
66 } cherokee_handler_clusterstats_t
;
68 #define HDL_CLUSTERSTATS(x) ((cherokee_handler_clusterstats_t *)(x))
69 #define PROP_CLUSTERSTATS(x) ((cherokee_handler_clusterstats_props_t *)(x))
70 #define HDL_CLUSTERSTATS_PROPS(x) (PROP_CLUSTERSTATS(MODULE(x)->props))
73 /* Library init function
75 void PLUGIN_INIT_NAME(avahi
) (cherokee_plugin_loader_t
*loader
);
76 ret_t
cherokee_handler_clusterstats_new (cherokee_handler_t
**hdl
, cherokee_connection_t
*cnt
, cherokee_module_props_t
*props
);
78 /* virtual methods implementation
80 ret_t
cherokee_handler_clusterstats_init (cherokee_handler_clusterstats_t
*hdl
);
81 ret_t
cherokee_handler_clusterstats_free (cherokee_handler_clusterstats_t
*hdl
);
82 ret_t
cherokee_handler_clusterstats_step (cherokee_handler_clusterstats_t
*hdl
, cherokee_buffer_t
*buffer
);
83 ret_t
cherokee_handler_clusterstats_add_headers (cherokee_handler_clusterstats_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
);
88 ret_t
cherokee_handler_clusterstats_while_func_entries (cherokee_buffer_t
*key
, void *value
, void *param
);
90 #endif /* CHEROKEE_HANDLER_CLUSTERSTATS_H */