xref: /freebsd/contrib/blocklist/bin/state.h (revision 5f4c09dd)
15f4c09ddSEd Maste /*	$NetBSD: state.h,v 1.5 2015/01/27 19:40:37 christos Exp $	*/
25f4c09ddSEd Maste 
35f4c09ddSEd Maste /*-
45f4c09ddSEd Maste  * Copyright (c) 2015 The NetBSD Foundation, Inc.
55f4c09ddSEd Maste  * All rights reserved.
65f4c09ddSEd Maste  *
75f4c09ddSEd Maste  * This code is derived from software contributed to The NetBSD Foundation
85f4c09ddSEd Maste  * by Christos Zoulas.
95f4c09ddSEd Maste  *
105f4c09ddSEd Maste  * Redistribution and use in source and binary forms, with or without
115f4c09ddSEd Maste  * modification, are permitted provided that the following conditions
125f4c09ddSEd Maste  * are met:
135f4c09ddSEd Maste  * 1. Redistributions of source code must retain the above copyright
145f4c09ddSEd Maste  *    notice, this list of conditions and the following disclaimer.
155f4c09ddSEd Maste  * 2. Redistributions in binary form must reproduce the above copyright
165f4c09ddSEd Maste  *    notice, this list of conditions and the following disclaimer in the
175f4c09ddSEd Maste  *    documentation and/or other materials provided with the distribution.
185f4c09ddSEd Maste  *
195f4c09ddSEd Maste  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
205f4c09ddSEd Maste  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
215f4c09ddSEd Maste  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
225f4c09ddSEd Maste  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
235f4c09ddSEd Maste  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
245f4c09ddSEd Maste  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
255f4c09ddSEd Maste  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
265f4c09ddSEd Maste  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
275f4c09ddSEd Maste  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
285f4c09ddSEd Maste  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
295f4c09ddSEd Maste  * POSSIBILITY OF SUCH DAMAGE.
305f4c09ddSEd Maste  */
315f4c09ddSEd Maste #ifndef _STATE_H
325f4c09ddSEd Maste #define _STATE_H
335f4c09ddSEd Maste 
345f4c09ddSEd Maste #ifdef HAVE_DB_185_H
355f4c09ddSEd Maste #include <db_185.h>
365f4c09ddSEd Maste #elif HAVE_DB_H
375f4c09ddSEd Maste #include <db.h>
385f4c09ddSEd Maste #else
395f4c09ddSEd Maste #error "no db.h"
405f4c09ddSEd Maste #endif
415f4c09ddSEd Maste #include <time.h>
425f4c09ddSEd Maste 
435f4c09ddSEd Maste struct dbinfo {
445f4c09ddSEd Maste 	int count;
455f4c09ddSEd Maste 	time_t last;
465f4c09ddSEd Maste 	char id[64];
475f4c09ddSEd Maste };
485f4c09ddSEd Maste 
495f4c09ddSEd Maste __BEGIN_DECLS
505f4c09ddSEd Maste struct sockaddr_storage;
515f4c09ddSEd Maste struct conf;
525f4c09ddSEd Maste 
535f4c09ddSEd Maste DB *state_open(const char *, int, mode_t);
545f4c09ddSEd Maste int state_close(DB *);
555f4c09ddSEd Maste int state_get(DB *, const struct conf *, struct dbinfo *);
565f4c09ddSEd Maste int state_put(DB *, const struct conf *, const struct dbinfo *);
575f4c09ddSEd Maste int state_del(DB *, const struct conf *);
585f4c09ddSEd Maste int state_iterate(DB *, struct conf *, struct dbinfo *, unsigned int);
595f4c09ddSEd Maste int state_sync(DB *);
605f4c09ddSEd Maste __END_DECLS
615f4c09ddSEd Maste 
625f4c09ddSEd Maste #endif /* _STATE_H */
63