Export diag() function - sacc - sacc(omys), simple console gopher client
git clone git://bitreich.org/sacc/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/sacc/
Log
Files
Refs
Tags
LICENSE
---
commit 031f781dfa1e657a9c9eb6677d78de4d82c455b1
parent 5a5611b3293eaac0b26832a54b845c6822736b65
Author: Quentin Rameau 
Date:   Sat, 10 Apr 2021 18:21:58 +0200

Export diag() function

Diffstat:
  M common.h                            |       1 +
  M sacc.c                              |      16 ++++++++--------

2 files changed, 9 insertions(+), 8 deletions(-)
---
diff --git 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
@@ -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);
 }