/*
* ckpass.h
*
* Heath Caldwell
* hncaldwell@gmail.com
*/
#ifndef CKPASS_H
#define CKPASS_H
#include <ncurses.h>
#include <kpass.h>
#include "bindings.h"
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define WIN_GROUPS 0
#define WIN_ENTRIES 1
#define MAX_PASSWORD_LENGTH 256
#define MAX_FILENAME_LENGTH 2048
WINDOW *_groups_super_win = 0;
WINDOW *_groups_win = 0;
WINDOW *_entries_super_win = 0;
WINDOW *_entries_win = 0;
WINDOW *_top_bar = 0;
WINDOW *_bottom_bar = 0;
int _entry_widths[] = {25, 17, 33, 128};
struct binding *_groups_bindings;
struct binding *_entries_bindings;
void show_header(WINDOW *win, kpass_db *db);
void fatal(const char *message);
void error_dialog(char *s);
int open_db(kpass_db *db, const char *filename);
int read_db(kpass_db *db, const char *filename);
int decrypt_db(kpass_db *db, const char *password);
void init_windows();
void draw_groups(const kpass_db *, int, int, bool);
void draw_entries(const kpass_db *, int, int, int, bool, bool);
void draw_top_bar(const char *);
void draw_bottom_bar(int mode);
int entries_in_group(const kpass_db *, int);
struct kpass_entry *nth_entry_in_group(const kpass_db *, int, int);
int find_groups_win_width(const kpass_db *);
int pipeout(const char *command, const char *s);
void init_bindings();
#endif //CKPASS_H