avahi  0.7
client.h File Reference

Definitions and functions for the client API over D-Bus. More...

#include <inttypes.h>
#include <avahi-common/cdecl.h>
#include <avahi-common/address.h>
#include <avahi-common/strlst.h>
#include <avahi-common/defs.h>
#include <avahi-common/watch.h>
#include <avahi-common/gccmacro.h>

Go to the source code of this file.

Typedefs

typedef struct AvahiClient AvahiClient
 A connection context. More...
 
typedef void(* AvahiClientCallback) (AvahiClient *s, AvahiClientState state, void *userdata)
 The function prototype for the callback of an AvahiClient. More...
 

Enumerations

enum  AvahiClientState {
  AVAHI_CLIENT_S_REGISTERING = AVAHI_SERVER_REGISTERING,
  AVAHI_CLIENT_S_RUNNING = AVAHI_SERVER_RUNNING,
  AVAHI_CLIENT_S_COLLISION = AVAHI_SERVER_COLLISION,
  AVAHI_CLIENT_FAILURE = 100,
  AVAHI_CLIENT_CONNECTING = 101
}
 States of a client object, a superset of AvahiServerState. More...
 
enum  AvahiClientFlags {
  AVAHI_CLIENT_IGNORE_USER_CONFIG = 1,
  AVAHI_CLIENT_NO_FAIL = 2
}
 

Functions

Construction and destruction
AvahiClientavahi_client_new (const AvahiPoll *poll_api, AvahiClientFlags flags, AvahiClientCallback callback, void *userdata, int *error)
 Creates a new client instance. More...
 
void avahi_client_free (AvahiClient *client)
 Free a client instance. More...
 
Properties
const char * avahi_client_get_version_string (AvahiClient *)
 Get the version of the server. More...
 
const char * avahi_client_get_host_name (AvahiClient *)
 Get host name. More...
 
int avahi_client_set_host_name (AvahiClient *, const char *name)
 Set host name. More...
 
const char * avahi_client_get_domain_name (AvahiClient *)
 Get domain name. More...
 
const char * avahi_client_get_host_name_fqdn (AvahiClient *)
 Get FQDN domain name. More...
 
AvahiClientState avahi_client_get_state (AvahiClient *client)
 Get state. More...
 
Error Handling
int avahi_client_errno (AvahiClient *)
 Get the last error number. More...
 
Libc NSS Support
int avahi_nss_support (void)
 Return 1 if gethostbyname() supports mDNS lookups, 0 otherwise. More...
 

Detailed Description

Definitions and functions for the client API over D-Bus.

Definition in file client.h.

Typedef Documentation

◆ AvahiClient

typedef struct AvahiClient AvahiClient

A connection context.

Definition at line 37 of file client.h.

◆ AvahiClientCallback

typedef void(* AvahiClientCallback) (AvahiClient *s, AvahiClientState state, void *userdata)

The function prototype for the callback of an AvahiClient.

Definition at line 54 of file client.h.

Enumeration Type Documentation

◆ AvahiClientFlags

Enumerator
AVAHI_CLIENT_IGNORE_USER_CONFIG 

Don't read user configuration.

AVAHI_CLIENT_NO_FAIL 

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.

Definition at line 48 of file client.h.

◆ AvahiClientState

States of a client object, a superset of AvahiServerState.

Enumerator
AVAHI_CLIENT_S_REGISTERING 

Server state: REGISTERING.

AVAHI_CLIENT_S_RUNNING 

Server state: RUNNING.

AVAHI_CLIENT_S_COLLISION 

Server state: COLLISION.

AVAHI_CLIENT_FAILURE 

Some kind of error happened on the client side.

AVAHI_CLIENT_CONNECTING 

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.

Definition at line 40 of file client.h.

Function Documentation

◆ avahi_client_errno()

int avahi_client_errno ( AvahiClient )

Get the last error number.

See avahi_strerror() for converting this error code into a human readable string.

Examples:
client-browse-services.c, client-publish-service.c, and glib-integration.c.

◆ avahi_client_free()

void avahi_client_free ( AvahiClient client)

Free a client instance.

This will automatically free all associated browser, resolve and entry group objects. All pointers to such objects become invalid!

Examples:
client-browse-services.c, client-publish-service.c, and glib-integration.c.

◆ avahi_client_get_domain_name()

const char* avahi_client_get_domain_name ( AvahiClient )

Get domain name.

◆ avahi_client_get_host_name()

const char* avahi_client_get_host_name ( AvahiClient )

Get host name.

◆ avahi_client_get_host_name_fqdn()

const char* avahi_client_get_host_name_fqdn ( AvahiClient )

Get FQDN domain name.

◆ avahi_client_get_state()

AvahiClientState avahi_client_get_state ( AvahiClient client)

Get state.

Examples:
client-publish-service.c.

◆ avahi_client_get_version_string()

const char* avahi_client_get_version_string ( AvahiClient )

Get the version of the server.

Examples:
glib-integration.c.

◆ avahi_client_new()

AvahiClient* avahi_client_new ( const AvahiPoll poll_api,
AvahiClientFlags  flags,
AvahiClientCallback  callback,
void *  userdata,
int *  error 
)

Creates a new client instance.

Parameters
poll_apiThe abstract event loop API to use
flagsSome flags to modify the behaviour of the client library
callbackA 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.
userdataSome arbitrary user data pointer that will be passed to the callback function
errorIf 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.
Examples:
client-browse-services.c, client-publish-service.c, and glib-integration.c.

◆ avahi_client_set_host_name()

int avahi_client_set_host_name ( AvahiClient ,
const char *  name 
)

Set host name.

Since
0.6.13

◆ avahi_nss_support()

int avahi_nss_support ( void  )

Return 1 if gethostbyname() supports mDNS lookups, 0 otherwise.

Since
0.6.5