backend.h 2.06 KB
Newer Older
Dustin Lundquist's avatar
Dustin Lundquist committed
1 2 3 4 5
/*
 * Copyright (c) 2011 and 2012, Dustin Lundquist <dustin@null-ptr.net>
 * Copyright (c) 2011 Manuel Kasper <mk@neon1.net>
 * All rights reserved.
 *
Dustin Lundquist's avatar
Dustin Lundquist committed
6
 * Redistribution and use in source and binary forms, with or without
Dustin Lundquist's avatar
Dustin Lundquist committed
7 8
 * modification, are permitted provided that the following conditions are met:
 *
Dustin Lundquist's avatar
Dustin Lundquist committed
9
 * 1. Redistributions of source code must retain the above copyright notice,
Dustin Lundquist's avatar
Dustin Lundquist committed
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
 *    this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */
Dustin Lundquist's avatar
Dustin Lundquist committed
27 28 29 30
#ifndef BACKEND_H
#define BACKEND_H

#include <sys/queue.h>
31
#include <pcre.h>
Dustin Lundquist's avatar
Dustin Lundquist committed
32

33
STAILQ_HEAD(Backend_head, Backend);
Dustin Lundquist's avatar
Dustin Lundquist committed
34 35

struct Backend {
36 37
    char *hostname;
    char *address;
Dustin Lundquist's avatar
Dustin Lundquist committed
38
    int port;
Dustin Lundquist's avatar
Dustin Lundquist committed
39

Dustin Lundquist's avatar
Dustin Lundquist committed
40 41
    /* Runtime fields */
    pcre *hostname_re;
42
    STAILQ_ENTRY(Backend) entries;
Dustin Lundquist's avatar
Dustin Lundquist committed
43 44
};

Dustin Lundquist's avatar
Dustin Lundquist committed
45
void add_backend(struct Backend_head *, struct Backend *);
Dustin Lundquist's avatar
Dustin Lundquist committed
46
int init_backend(struct Backend *);
47
struct Backend *lookup_backend(const struct Backend_head *, const char *);
Dustin Lundquist's avatar
Dustin Lundquist committed
48
int open_backend_socket(struct Backend *, const char *);
49
void remove_backend(struct Backend_head *, struct Backend *);
Dustin Lundquist's avatar
Dustin Lundquist committed
50 51 52
struct Backend *new_backend();
int accept_backend_arg(struct Backend *, char *);

Dustin Lundquist's avatar
Dustin Lundquist committed
53 54

#endif