state.h revision 301169
190075Sobrien/* $NetBSD: state.h,v 1.5 2015/01/27 19:40:37 christos Exp $ */ 2169689Skan 390075Sobrien/*- 490075Sobrien * Copyright (c) 2015 The NetBSD Foundation, Inc. 5132718Skan * All rights reserved. 690075Sobrien * 7132718Skan * This code is derived from software contributed to The NetBSD Foundation 890075Sobrien * by Christos Zoulas. 990075Sobrien * 1090075Sobrien * Redistribution and use in source and binary forms, with or without 1190075Sobrien * modification, are permitted provided that the following conditions 12132718Skan * are met: 1390075Sobrien * 1. Redistributions of source code must retain the above copyright 1490075Sobrien * notice, this list of conditions and the following disclaimer. 1590075Sobrien * 2. Redistributions in binary form must reproduce the above copyright 1690075Sobrien * notice, this list of conditions and the following disclaimer in the 1790075Sobrien * documentation and/or other materials provided with the distribution. 18132718Skan * 19169689Skan * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20169689Skan * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 2190075Sobrien * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 2290075Sobrien * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 2390075Sobrien * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24132718Skan * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25132718Skan * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 2690075Sobrien * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 2790075Sobrien * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 2890075Sobrien * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 2990075Sobrien * POSSIBILITY OF SUCH DAMAGE. 3090075Sobrien */ 3190075Sobrien#ifndef _STATE_H 32132718Skan#define _STATE_H 33169689Skan 34169689Skan#ifdef HAVE_DB_185_H 35169689Skan#include <db_185.h> 3690075Sobrien#elif HAVE_DB_H 37132718Skan#include <db.h> 38169689Skan#else 3990075Sobrien#error "no db.h" 40169689Skan#endif 41169689Skan#include <time.h> 42132718Skan 4390075Sobrienstruct dbinfo { 4490075Sobrien int count; 4590075Sobrien time_t last; 4690075Sobrien char id[64]; 47259268Spfg}; 48259268Spfg 49117395Skan__BEGIN_DECLS 50117395Skanstruct sockaddr_storage; 51169689Skanstruct conf; 52169689Skan 53169689SkanDB *state_open(const char *, int, mode_t); 54169689Skanint state_close(DB *); 5590075Sobrienint state_get(DB *, const struct conf *, struct dbinfo *); 56169689Skanint state_put(DB *, const struct conf *, const struct dbinfo *); 5790075Sobrienint state_del(DB *, const struct conf *); 5890075Sobrienint state_iterate(DB *, struct conf *, struct dbinfo *, unsigned int); 59117395Skanint state_sync(DB *); 60117395Skan__END_DECLS 61117395Skan 62117395Skan#endif /* _STATE_H */ 63169689Skan