1 /*
2  * ckpass.h
3  *
4  * Header for main program and support functions.
5  *
6  * This file is part of the ckpass project.
7  *
8  * Copyright (C) 2009  Heath N. Caldwell <hncaldwell@gmail.com>
9  *
10  * This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation, either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
22  *
23  */
24 
25 #ifndef CKPASS_H
26 #define CKPASS_H
27 
28 #include <ncurses.h>
29 #include <kpass.h>
30 #include "bindings.h"
31 
32 #define MAX(a, b) ((a) > (b) ? (a) : (b))
33 #define MIN(a, b) ((a) < (b) ? (a) : (b))
34 
35 #define WIN_GROUPS 0
36 #define WIN_ENTRIES 1
37 
38 #define MAX_PASSWORD_LENGTH 256
39 #define MAX_FILENAME_LENGTH 2048
40 
41 WINDOW *_groups_super_win = 0;
42 WINDOW *_groups_win = 0;
43 WINDOW *_entries_super_win = 0;
44 WINDOW *_entries_win = 0;
45 WINDOW *_top_bar = 0;
46 WINDOW *_bottom_bar = 0;
47 
48 int _entry_widths[] = {25, 17, 33, 128};
49 
50 struct binding *_groups_bindings;
51 struct binding *_entries_bindings;
52 
53 void show_header(WINDOW *win, kpass_db *db);
54 void fatal(const char *message);
55 void error_dialog(char *s);
56 int open_db(kpass_db *db, const char *filename);
57 int read_db(kpass_db *db, const char *filename);
58 int decrypt_db(kpass_db *db, const char *password);
59 void init_windows();
60 void draw_groups(const kpass_db *, int, int, bool);
61 void draw_entries(const kpass_db *, int, int, int, bool, bool);
62 void draw_top_bar(const char *);
63 void draw_bottom_bar(int mode);
64 int entries_in_group(const kpass_db *, int);
65 struct kpass_entry *nth_entry_in_group(const kpass_db *, int, int);
66 int find_groups_win_width(const kpass_db *);
67 int pipeout(const char *command, const char *s);
68 void init_bindings();
69 
70 #endif //CKPASS_H
71 
72