1301169Slidl/*	$NetBSD: state.h,v 1.5 2015/01/27 19:40:37 christos Exp $	*/
2301169Slidl
3301169Slidl/*-
4301169Slidl * Copyright (c) 2015 The NetBSD Foundation, Inc.
5301169Slidl * All rights reserved.
6301169Slidl *
7301169Slidl * This code is derived from software contributed to The NetBSD Foundation
8301169Slidl * by Christos Zoulas.
9301169Slidl *
10301169Slidl * Redistribution and use in source and binary forms, with or without
11301169Slidl * modification, are permitted provided that the following conditions
12301169Slidl * are met:
13301169Slidl * 1. Redistributions of source code must retain the above copyright
14301169Slidl *    notice, this list of conditions and the following disclaimer.
15301169Slidl * 2. Redistributions in binary form must reproduce the above copyright
16301169Slidl *    notice, this list of conditions and the following disclaimer in the
17301169Slidl *    documentation and/or other materials provided with the distribution.
18301169Slidl *
19301169Slidl * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20301169Slidl * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21301169Slidl * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22301169Slidl * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23301169Slidl * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24301169Slidl * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25301169Slidl * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26301169Slidl * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27301169Slidl * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28301169Slidl * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29301169Slidl * POSSIBILITY OF SUCH DAMAGE.
30301169Slidl */
31301169Slidl#ifndef _STATE_H
32301169Slidl#define _STATE_H
33301169Slidl
34301169Slidl#ifdef HAVE_DB_185_H
35301169Slidl#include <db_185.h>
36301169Slidl#elif HAVE_DB_H
37301169Slidl#include <db.h>
38301169Slidl#else
39301169Slidl#error "no db.h"
40301169Slidl#endif
41301169Slidl#include <time.h>
42301169Slidl
43301169Slidlstruct dbinfo {
44301169Slidl	int count;
45301169Slidl	time_t last;
46301169Slidl	char id[64];
47301169Slidl};
48301169Slidl
49301169Slidl__BEGIN_DECLS
50301169Slidlstruct sockaddr_storage;
51301169Slidlstruct conf;
52301169Slidl
53301169SlidlDB *state_open(const char *, int, mode_t);
54301169Slidlint state_close(DB *);
55301169Slidlint state_get(DB *, const struct conf *, struct dbinfo *);
56301169Slidlint state_put(DB *, const struct conf *, const struct dbinfo *);
57301169Slidlint state_del(DB *, const struct conf *);
58301169Slidlint state_iterate(DB *, struct conf *, struct dbinfo *, unsigned int);
59301169Slidlint state_sync(DB *);
60301169Slidl__END_DECLS
61301169Slidl
62301169Slidl#endif /* _STATE_H */
63