diff options
author | Christian Hesse <mail@eworm.de> | 2013-11-14 21:47:15 +0100 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2013-11-14 21:47:15 +0100 |
commit | 86dea85287ab34cf67e5b69a8d1af53c5fbc325b (patch) | |
tree | b7e10645fded8ba0d8c4386c5af8e05c1f999c35 | |
parent | f14c35065b7d1d181c05f22b698fa14c78c1086b (diff) | |
download | pacredir-86dea85287ab34cf67e5b69a8d1af53c5fbc325b.tar.gz pacredir-86dea85287ab34cf67e5b69a8d1af53c5fbc325b.tar.zst |
introduce pacredir.h
-rw-r--r-- | pacredir.c | 44 | ||||
-rw-r--r-- | pacredir.h | 83 |
2 files changed, 85 insertions, 42 deletions
@@ -32,48 +32,8 @@ /* compile time configuration */ #include "config.h" -/* services */ -struct services { - /* true if host/service is online */ - uint8_t online; - /* unix timestamp of last bad request */ - __time_t bad; -}; - -/* hosts */ -struct hosts { - /* host name */ - char * host; - /* online status and bad time for services */ - struct services pacserve; - struct services pacdbserve; - /* pointer to next struct element */ - struct hosts * next; -}; - -/* ignore interfaces */ -struct ignore_interfaces { - /* interface name */ - char * interface; - /* pointer to next struct element */ - struct ignore_interfaces * next; -}; - -/* request */ -struct request { - /* host name */ - const char * host; - /* port */ - uint16_t port; - /* pointer to bad */ - __time_t * bad; - /* url */ - char * url; - /* HTTP status code */ - long http_code; - /* last modified timestamp */ - long last_modified; -}; +/* define structs and functions */ +#include "pacredir.h" /* global variables */ struct hosts * hosts = NULL; diff --git a/pacredir.h b/pacredir.h new file mode 100644 index 0000000..6922f0d --- /dev/null +++ b/pacredir.h @@ -0,0 +1,83 @@ +/* + * (C) 2013 by Christian Hesse <mail@eworm.de> + * + * This software may be used and distributed according to the terms + * of the GNU General Public License, incorporated herein by reference. + */ + +#ifndef _PACREDIR_H +#define _PACREDIR_H + +/* services */ +struct services { + /* true if host/service is online */ + uint8_t online; + /* unix timestamp of last bad request */ + __time_t bad; +}; + +/* hosts */ +struct hosts { + /* host name */ + char * host; + /* online status and bad time for services */ + struct services pacserve; + struct services pacdbserve; + /* pointer to next struct element */ + struct hosts * next; +}; + +/* ignore interfaces */ +struct ignore_interfaces { + /* interface name */ + char * interface; + /* pointer to next struct element */ + struct ignore_interfaces * next; +}; + +/* request */ +struct request { + /* host name */ + const char * host; + /* port */ + uint16_t port; + /* pointer to bad */ + __time_t * bad; + /* url */ + char * url; + /* HTTP status code */ + long http_code; + /* last modified timestamp */ + long last_modified; +}; + +/* write_log */ +int write_log(FILE *stream, const char *format, ...); +/* get_fqdn */ +char * get_fqdn(const char * hostname, const char * domainname); + +/* add_host */ +int add_host(const char * host, const char * type); +/* remove_host */ +int remove_host(const char * host, const char * type); + +/* browse_callback */ +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); +/* client_callback */ +static void client_callback(AvahiClient *c, AvahiClientState state, AVAHI_GCC_UNUSED void * userdata); + +/* get_http_code */ +static void * get_http_code(void * data); +/* ahc_echo */ +static int ahc_echo(void * cls, struct MHD_Connection * connection, const char * uri, const char * method, + const char * version, const char * upload_data, size_t * upload_data_size, void ** ptr); + +/* sig_callback */ +void sig_callback(int signal); +/* sighup_callback */ +void sighup_callback(int signal); + +#endif /* _PACREDIR_H */ + +// vim: set syntax=c: |