src/lib/service.h
author Tero Marttila <terom@fixme.fi>
Thu, 28 May 2009 01:17:36 +0300
branchnew-lib-errors
changeset 219 cefec18b8268
parent 175 src/service.h@a816950a6548
permissions -rw-r--r--
some of the lib/transport stuff compiles
#ifndef LIBQMSK_SERVICE_H
#define LIBQMSK_SERVICE_H

/**
 * @file
 *
 * Defines a simple interface for creating services, which listen for connections and create transport_t's.
 */
#include "transport.h"

/**
 * Opaque state struct.
 */
typedef struct service service_t;

/**
 * User callbacks for services.
 */
struct service_callbacks {
    /**
     * The service broke.
     *
     * This is only called for errors which occur when called directly from the event loop, and never for errors that
     * occur inside of calls to service_*.
     */
    void (*on_error) (service_t *service, const error_t *err, void *arg);
};

/**
 * User info required to build a service
 */
struct service_info {
    /** Callback table */
    const struct service_callbacks *cb_tbl;

    /** Callback context arg */
    void *cb_arg;

    /** Settings for the service's client transports */
    struct transport_info trans_info;
};

/**
 * Destroy a service to stop accepting any connections and release all resources.
 *
 * Any connected client transports should stay intact (?)
 */
void service_destroy (service_t *service);

#endif