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
219
cefec18b8268 some of the lib/transport stuff compiles
Tero Marttila <terom@fixme.fi>
parents: 175
diff changeset
     1
#ifndef LIBQMSK_SERVICE_H
cefec18b8268 some of the lib/transport stuff compiles
Tero Marttila <terom@fixme.fi>
parents: 175
diff changeset
     2
#define LIBQMSK_SERVICE_H
175
a816950a6548 implement a new 'service' interface that's similar to the transport interface
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     3
a816950a6548 implement a new 'service' interface that's similar to the transport interface
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     4
/**
a816950a6548 implement a new 'service' interface that's similar to the transport interface
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     5
 * @file
a816950a6548 implement a new 'service' interface that's similar to the transport interface
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     6
 *
a816950a6548 implement a new 'service' interface that's similar to the transport interface
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     7
 * Defines a simple interface for creating services, which listen for connections and create transport_t's.
a816950a6548 implement a new 'service' interface that's similar to the transport interface
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     8
 */
a816950a6548 implement a new 'service' interface that's similar to the transport interface
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     9
#include "transport.h"
a816950a6548 implement a new 'service' interface that's similar to the transport interface
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    10
a816950a6548 implement a new 'service' interface that's similar to the transport interface
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    11
/**
a816950a6548 implement a new 'service' interface that's similar to the transport interface
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    12
 * Opaque state struct.
a816950a6548 implement a new 'service' interface that's similar to the transport interface
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    13
 */
a816950a6548 implement a new 'service' interface that's similar to the transport interface
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    14
typedef struct service service_t;
a816950a6548 implement a new 'service' interface that's similar to the transport interface
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    15
a816950a6548 implement a new 'service' interface that's similar to the transport interface
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    16
/**
a816950a6548 implement a new 'service' interface that's similar to the transport interface
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    17
 * User callbacks for services.
a816950a6548 implement a new 'service' interface that's similar to the transport interface
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    18
 */
a816950a6548 implement a new 'service' interface that's similar to the transport interface
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    19
struct service_callbacks {
a816950a6548 implement a new 'service' interface that's similar to the transport interface
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    20
    /**
a816950a6548 implement a new 'service' interface that's similar to the transport interface
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    21
     * The service broke.
a816950a6548 implement a new 'service' interface that's similar to the transport interface
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    22
     *
a816950a6548 implement a new 'service' interface that's similar to the transport interface
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    23
     * This is only called for errors which occur when called directly from the event loop, and never for errors that
a816950a6548 implement a new 'service' interface that's similar to the transport interface
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    24
     * occur inside of calls to service_*.
a816950a6548 implement a new 'service' interface that's similar to the transport interface
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    25
     */
a816950a6548 implement a new 'service' interface that's similar to the transport interface
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    26
    void (*on_error) (service_t *service, const error_t *err, void *arg);
a816950a6548 implement a new 'service' interface that's similar to the transport interface
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    27
};
a816950a6548 implement a new 'service' interface that's similar to the transport interface
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    28
a816950a6548 implement a new 'service' interface that's similar to the transport interface
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    29
/**
a816950a6548 implement a new 'service' interface that's similar to the transport interface
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    30
 * User info required to build a service
a816950a6548 implement a new 'service' interface that's similar to the transport interface
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    31
 */
a816950a6548 implement a new 'service' interface that's similar to the transport interface
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    32
struct service_info {
a816950a6548 implement a new 'service' interface that's similar to the transport interface
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    33
    /** Callback table */
a816950a6548 implement a new 'service' interface that's similar to the transport interface
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    34
    const struct service_callbacks *cb_tbl;
a816950a6548 implement a new 'service' interface that's similar to the transport interface
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    35
a816950a6548 implement a new 'service' interface that's similar to the transport interface
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    36
    /** Callback context arg */
a816950a6548 implement a new 'service' interface that's similar to the transport interface
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    37
    void *cb_arg;
a816950a6548 implement a new 'service' interface that's similar to the transport interface
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    38
a816950a6548 implement a new 'service' interface that's similar to the transport interface
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    39
    /** Settings for the service's client transports */
a816950a6548 implement a new 'service' interface that's similar to the transport interface
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    40
    struct transport_info trans_info;
a816950a6548 implement a new 'service' interface that's similar to the transport interface
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    41
};
a816950a6548 implement a new 'service' interface that's similar to the transport interface
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    42
a816950a6548 implement a new 'service' interface that's similar to the transport interface
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    43
/**
a816950a6548 implement a new 'service' interface that's similar to the transport interface
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    44
 * Destroy a service to stop accepting any connections and release all resources.
a816950a6548 implement a new 'service' interface that's similar to the transport interface
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    45
 *
a816950a6548 implement a new 'service' interface that's similar to the transport interface
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    46
 * Any connected client transports should stay intact (?)
a816950a6548 implement a new 'service' interface that's similar to the transport interface
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    47
 */
a816950a6548 implement a new 'service' interface that's similar to the transport interface
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    48
void service_destroy (service_t *service);
a816950a6548 implement a new 'service' interface that's similar to the transport interface
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    49
219
cefec18b8268 some of the lib/transport stuff compiles
Tero Marttila <terom@fixme.fi>
parents: 175
diff changeset
    50
#endif