Blob


1 /*
2 * Copyright (c) 2021 Omar Polo <op@omarpolo.com>
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
17 #ifndef SESSION_H
18 #define SESSION_H
20 struct ohash;
22 struct session_tab {
23 uint32_t flags;
24 char uri[GEMINI_URL_LEN];
25 char title[TITLE_MAX];
26 size_t top_line;
27 size_t current_line;
28 };
30 struct session_tab_hist {
31 char uri[GEMINI_URL_LEN];
32 int future;
33 };
35 struct histitem {
36 time_t ts;
37 char uri[GEMINI_URL_LEN];
38 };
40 struct history_item {
41 time_t ts;
42 char *uri;
43 int dirty;
44 };
46 #define HISTORY_CAP 1000
47 struct history {
48 struct history_item items[HISTORY_CAP];
49 size_t len;
50 size_t dirty;
51 size_t extra;
52 };
53 extern struct history history;
55 void switch_to_tab(struct tab *);
56 unsigned int tab_new_id(void);
57 struct tab *new_tab(const char *, const char *base, struct tab *);
58 void kill_tab(struct tab *, int);
59 struct tab *unkill_tab(void);
60 void free_tab(struct tab *);
61 void stop_tab(struct tab*);
63 void save_session(void);
65 void history_push(struct histitem *);
66 void history_sort(void);
67 void history_add(const char *);
69 void autosave_init(void);
70 void autosave_timer(int, short, void *);
71 void autosave_hook(void);
73 int load_session(struct ohash *);
74 int lock_session(void);
76 #endif