1#ifndef fooclienthfoo 2#define fooclienthfoo 3 4/*** 5 This file is part of avahi. 6 7 avahi is free software; you can redistribute it and/or modify it 8 under the terms of the GNU Lesser General Public License as 9 published by the Free Software Foundation; either version 2.1 of the 10 License, or (at your option) any later version. 11 12 avahi is distributed in the hope that it will be useful, but WITHOUT 13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General 15 Public License for more details. 16 17 You should have received a copy of the GNU Lesser General Public 18 License along with avahi; if not, write to the Free Software 19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 20 USA. 21***/ 22 23#include <inttypes.h> 24 25#include <avahi-common/cdecl.h> 26#include <avahi-common/address.h> 27#include <avahi-common/strlst.h> 28#include <avahi-common/defs.h> 29#include <avahi-common/watch.h> 30#include <avahi-common/gccmacro.h> 31 32/** \file client.h Definitions and functions for the client API over D-Bus */ 33 34AVAHI_C_DECL_BEGIN 35 36/** A connection context */ 37typedef struct AvahiClient AvahiClient; 38 39/** States of a client object, a superset of AvahiServerState */ 40typedef enum { 41 AVAHI_CLIENT_S_REGISTERING = AVAHI_SERVER_REGISTERING, /**< Server state: REGISTERING */ 42 AVAHI_CLIENT_S_RUNNING = AVAHI_SERVER_RUNNING, /**< Server state: RUNNING */ 43 AVAHI_CLIENT_S_COLLISION = AVAHI_SERVER_COLLISION, /**< Server state: COLLISION */ 44 AVAHI_CLIENT_FAILURE = 100, /**< Some kind of error happened on the client side */ 45 AVAHI_CLIENT_CONNECTING = 101 /**< We're still connecting. This state is only entered when AVAHI_CLIENT_NO_FAIL has been passed to avahi_client_new() and the daemon is not yet available. */ 46} AvahiClientState; 47 48typedef enum { 49 AVAHI_CLIENT_IGNORE_USER_CONFIG = 1, /**< Don't read user configuration */ 50 AVAHI_CLIENT_NO_FAIL = 2 /**< Don't fail if the daemon is not available when avahi_client_new() is called, instead enter AVAHI_CLIENT_CONNECTING state and wait for the daemon to appear */ 51} AvahiClientFlags; 52 53/** The function prototype for the callback of an AvahiClient */ 54typedef void (*AvahiClientCallback) ( 55 AvahiClient *s, 56 AvahiClientState state /**< The new state of the client */, 57 void* userdata /**< The user data that was passed to avahi_client_new() */); 58 59/** @{ \name Construction and destruction */ 60 61/** Creates a new client instance */ 62AvahiClient* avahi_client_new ( 63 const AvahiPoll *poll_api /**< The abstract event loop API to use */, 64 AvahiClientFlags flags /**< Some flags to modify the behaviour of the client library */, 65 AvahiClientCallback callback /**< A callback that is called whenever the state of the client changes. This may be NULL. Please note that this function is called for the first time from within the avahi_client_new() context! Thus, in the callback you should not make use of global variables that are initialized only after your call to avahi_client_new(). A common mistake is to store the AvahiClient pointer returned by avahi_client_new() in a global variable and assume that this global variable already contains the valid pointer when the callback is called for the first time. A work-around for this is to always use the AvahiClient pointer passed to the callback function instead of the global pointer. */, 66 void *userdata /**< Some arbitrary user data pointer that will be passed to the callback function */, 67 int *error /**< If creation of the client fails, this integer will contain the error cause. May be NULL if you aren't interested in the reason why avahi_client_new() failed. */); 68 69/** Free a client instance. This will automatically free all 70 * associated browser, resolve and entry group objects. All pointers 71 * to such objects become invalid! */ 72void avahi_client_free(AvahiClient *client); 73 74/** @} */ 75 76/** @{ \name Properties */ 77 78/** Get the version of the server */ 79const char* avahi_client_get_version_string (AvahiClient*); 80 81/** Get host name */ 82const char* avahi_client_get_host_name (AvahiClient*); 83 84/** Set host name. \since 0.6.13 */ 85int avahi_client_set_host_name(AvahiClient*, const char *name); 86 87/** Get domain name */ 88const char* avahi_client_get_domain_name (AvahiClient*); 89 90/** Get FQDN domain name */ 91const char* avahi_client_get_host_name_fqdn (AvahiClient*); 92 93/** Get state */ 94AvahiClientState avahi_client_get_state(AvahiClient *client); 95 96/** @{ \name Error Handling */ 97 98/** Get the last error number. See avahi_strerror() for converting this error code into a human readable string. */ 99int avahi_client_errno (AvahiClient*); 100 101/** @} */ 102 103/** \cond fulldocs */ 104/** Return the local service cookie. returns AVAHI_SERVICE_COOKIE_INVALID on failure. */ 105uint32_t avahi_client_get_local_service_cookie(AvahiClient *client); 106/** \endcond */ 107 108/** @{ \name Libc NSS Support */ 109 110/** Return 1 if gethostbyname() supports mDNS lookups, 0 otherwise. \since 0.6.5 */ 111int avahi_nss_support(void); 112 113/** @} */ 114 115AVAHI_C_DECL_END 116 117#endif 118