Blame


1 d163c210 2024-02-06 op /*
2 d163c210 2024-02-06 op * Copyright (c) 2021, 2022, 2024 Omar Polo <op@omarpolo.com>
3 d163c210 2024-02-06 op *
4 d163c210 2024-02-06 op * Permission to use, copy, modify, and distribute this software for any
5 d163c210 2024-02-06 op * purpose with or without fee is hereby granted, provided that the above
6 d163c210 2024-02-06 op * copyright notice and this permission notice appear in all copies.
7 d163c210 2024-02-06 op *
8 d163c210 2024-02-06 op * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 d163c210 2024-02-06 op * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 d163c210 2024-02-06 op * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 d163c210 2024-02-06 op * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 d163c210 2024-02-06 op * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 d163c210 2024-02-06 op * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 d163c210 2024-02-06 op * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 d163c210 2024-02-06 op */
16 d163c210 2024-02-06 op
17 d163c210 2024-02-06 op #define TOFU_URL_MAX_LEN (1024 + 1)
18 d163c210 2024-02-06 op
19 d163c210 2024-02-06 op struct tofu_entry {
20 d163c210 2024-02-06 op char domain[TOFU_URL_MAX_LEN];
21 d163c210 2024-02-06 op
22 d163c210 2024-02-06 op /*
23 d163c210 2024-02-06 op * enough space for ``PROTO:HASH''. probably isn't a good
24 d163c210 2024-02-06 op * idea tho.
25 d163c210 2024-02-06 op */
26 d163c210 2024-02-06 op char hash[128+1];
27 d163c210 2024-02-06 op int verified;
28 d163c210 2024-02-06 op };
29 d163c210 2024-02-06 op
30 d163c210 2024-02-06 op void tofu_init(struct ohash *, unsigned int, ptrdiff_t);
31 d163c210 2024-02-06 op struct tofu_entry *tofu_lookup(struct ohash *, const char *,
32 d163c210 2024-02-06 op const char *);
33 d163c210 2024-02-06 op void tofu_add(struct ohash *, struct tofu_entry *);
34 d163c210 2024-02-06 op int tofu_save(struct ohash *, struct tofu_entry *);
35 d163c210 2024-02-06 op void tofu_update(struct ohash *, struct tofu_entry *);
36 d163c210 2024-02-06 op int tofu_update_persist(struct ohash *,
37 d163c210 2024-02-06 op struct tofu_entry *);
38 d163c210 2024-02-06 op void tofu_temp_trust(struct ohash *, const char *,
39 d163c210 2024-02-06 op const char *, const char *);