Recently Written · git

sacc

Mirror of git://bitreich.org/sacc, the sacc gopher client from bitreich.org.

git clone https://github.com/equwal/sacc

Log | Files | Refs


commit 031f781dfa1e657a9c9eb6677d78de4d82c455b1
Quentin Rameau <quinq@fifth.space>
2021-04-10 18:21:58 +0200

Export diag() function

 common.h |  1 +
 sacc.c   | 16 ++++++++--------
 2 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/common.h b/common.h
index 8e71951..7a9e866 100644
--- a/common.h
+++ b/common.h
@@ -44,6 +44,7 @@ struct dir {
 	size_t curline;
 };
 
+extern void (*diag)(char *fmt, ...);
 void die(const char *fmt, ...);
 size_t mbsprint(const char *s, size_t len);
 #ifdef NEED_STRCASESTR
diff --git a/sacc.c b/sacc.c
index 9569eed..fc9a6fb 100644
--- a/sacc.c
+++ b/sacc.c
@@ -28,9 +28,9 @@ static int devnullfd;
 static int parent = 1;
 static int interactive;
 
-static void (*diag)(char *fmt, ...);
+void (*diag)(char *fmt, ...);
 
-void
+static void
 stddiag(char *fmt, ...)
 {
 	va_list arg;
@@ -1013,8 +1013,11 @@ setup(void)
 		die("mkdir: %s: %s", tmpdir, strerror(errno));
 	if(interactive = isatty(1)) {
 		uisetup();
+		diag = uistatus;
 		sa.sa_handler = uisigwinch;
 		sigaction(SIGWINCH, &sa, NULL);
+	} else {
+		diag = stddiag;
 	}
 }
 
@@ -1027,15 +1030,12 @@ main(int argc, char *argv[])
 	setup();
 
 	mainurl = xstrdup(argv[1]);
-
 	mainentry = moldentry(mainurl);
-	if (interactive) {
-		diag = uistatus;
+
+	if (interactive)
 		delve(mainentry);
-	} else {
-		diag = stddiag;
+	else
 		printout(mainentry);
-	}
 
 	exit(0);
 }