Commit Diff


commit - f7db6d139bba0fb56f0560533b77af219958ecc0
commit + d163c2104eb8f8603c4dfc4c9ad566511eac143b
blob - 50f3c6a232db5209e86526c2a045844bfae08fc0
blob + bc278afeb2580ae9e5bb6a01b29dcbdd99e5c878
--- Makefile.am
+++ Makefile.am
@@ -49,6 +49,7 @@ telescope_SOURCES =	certs.c			\
 			telescope.c		\
 			telescope.h		\
 			tofu.c			\
+			tofu.h			\
 			ui.c			\
 			ui.h			\
 			utf8.c			\
blob - 55ec2474b63d18f22c3f76662ac98092bef60623
blob + 00ec289712d0468169ede9e25727384fb46c6299
--- session.c
+++ session.c
@@ -30,6 +30,7 @@
 #include "hist.h"
 #include "minibuffer.h"
 #include "session.h"
+#include "tofu.h"
 #include "ui.h"
 
 struct history	history;
blob - 8af4c2ddcddd5dc206f2b4b1960d87bc5d3465b7
blob + 555f69ecb0f9371d00a0c1cc99c4a50c56780bcc
--- telescope.c
+++ telescope.c
@@ -43,6 +43,7 @@
 #include "parser.h"
 #include "session.h"
 #include "telescope.h"
+#include "tofu.h"
 #include "ui.h"
 #include "utils.h"
 
blob - 5606b819462af0eb3ae524f2e0ec2083c7f8d44e
blob + 69895df6b55abbe22eee103fa8d64bb8d882ea42
--- telescope.h
+++ telescope.h
@@ -154,17 +154,6 @@ enum trust_state {
 	TS_TEMP_TRUSTED,
 	TS_TRUSTED,
 	TS_VERIFIED,
-};
-
-struct tofu_entry {
-	char	domain[GEMINI_URL_LEN];
-
-	/*
-	 * enough space for ``PROTO:HASH''.  probably isn't a good
-	 * idea tho.
-	 */
-	char	hash[128+1];
-	int	verified;
 };
 
 struct buffer {
@@ -293,15 +282,6 @@ void		 humanify_url(const char *, const char *, char *
 int		 bookmark_page(const char *);
 int		 ui_send_net(int, uint32_t, int, const void *, uint16_t);
 
-/* tofu.c */
-void			 tofu_init(struct ohash*, unsigned int, ptrdiff_t);
-struct tofu_entry	*tofu_lookup(struct ohash*, const char*, const char*);
-void			 tofu_add(struct ohash*, struct tofu_entry*);
-int			 tofu_save(struct ohash *, struct tofu_entry *);
-void			 tofu_update(struct ohash*, struct tofu_entry*);
-int			 tofu_update_persist(struct ohash *, struct tofu_entry *);
-void			 tofu_temp_trust(struct ohash *, const char *, const char *, const char *);
-
 /* wrap.c */
 void		 erase_buffer(struct buffer *);
 void		 empty_linelist(struct buffer*);
blob - 46f253b1358289bad78d5f37a60448b6014f50e0
blob + ad8310d2c5dcc0005a0e4a875299a7f07bc15d1a
--- tofu.c
+++ tofu.c
@@ -17,12 +17,13 @@
 #include "compat.h"
 
 #include <limits.h>
+#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
 
 #include "fs.h"
-#include "telescope.h"
+#include "tofu.h"
 #include "utils.h"
 
 void
@@ -41,7 +42,7 @@ tofu_init(struct ohash *h, unsigned int sz, ptrdiff_t 
 struct tofu_entry *
 tofu_lookup(struct ohash *h, const char *domain, const char *port)
 {
-	char		buf[GEMINI_URL_LEN];
+	char		buf[TOFU_URL_MAX_LEN];
 	unsigned int	slot;
 
 	strlcpy(buf, domain, sizeof(buf));
blob - /dev/null
blob + aacb21c2cfec98a67c9b7a4fa06aee5e3c09cb8e (mode 644)
--- /dev/null
+++ tofu.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2021, 2022, 2024 Omar Polo <op@omarpolo.com>
+ *
+ * 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.
+ */
+
+#define TOFU_URL_MAX_LEN	(1024 + 1)
+
+struct tofu_entry {
+	char	domain[TOFU_URL_MAX_LEN];
+
+	/*
+	 * enough space for ``PROTO:HASH''.  probably isn't a good
+	 * idea tho.
+	 */
+	char	hash[128+1];
+	int	verified;
+};
+
+void			 tofu_init(struct ohash *, unsigned int, ptrdiff_t);
+struct tofu_entry	*tofu_lookup(struct ohash *, const char *,
+			    const char *);
+void			 tofu_add(struct ohash *, struct tofu_entry *);
+int			 tofu_save(struct ohash *, struct tofu_entry *);
+void			 tofu_update(struct ohash *, struct tofu_entry *);
+int			 tofu_update_persist(struct ohash *,
+			    struct tofu_entry *);
+void			 tofu_temp_trust(struct ohash *, const char *,
+			    const char *, const char *);