/* * Copyright (c) 2018 Markus Hennecke * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef __SESSION_H__ #define __SESSION_H__ #include #include #include struct session_data { time_t timeout; int loggedin; char username[32]; }; struct session { struct session_data data; char *sid; }; struct session_store { DB *db; char *filename; }; struct session_data *session_data_new(void); bool session_data_timeout(struct session_data *); struct session *session_new(void); void session_free(struct session *); bool session_save(struct session *, struct session_store *, bool); struct session *session_load(char *, struct session_store *); struct session_store *session_store_new(const char *); void session_store_free(struct session_store *); void session_store_cleanup(struct session_store *); #endif // __SESSION_H__