summaryrefslogtreecommitdiff
path: root/sqmail-4.3.07/src/qsutil.c
diff options
context:
space:
mode:
authorErwin Hoffmann <feh@fehcom.de>2024-01-14 17:55:54 +0100
committerErwin Hoffmann <feh@fehcom.de>2024-01-14 17:55:54 +0100
commita293489ee83c8b05d845a162dc2a4de026f3775d (patch)
treed50ab15afde698ad2d32bfc251753e5e89204f25 /sqmail-4.3.07/src/qsutil.c
s/qmail 4.3.07
Diffstat (limited to 'sqmail-4.3.07/src/qsutil.c')
-rw-r--r--sqmail-4.3.07/src/qsutil.c85
1 files changed, 85 insertions, 0 deletions
diff --git a/sqmail-4.3.07/src/qsutil.c b/sqmail-4.3.07/src/qsutil.c
new file mode 100644
index 0000000..9c438ea
--- /dev/null
+++ b/sqmail-4.3.07/src/qsutil.c
@@ -0,0 +1,85 @@
+#include <unistd.h>
+#include "stralloc.h"
+#include "buffer.h"
+#include "qsutil.h"
+
+static stralloc foo = {0};
+
+static char errbuf[1];
+static struct buffer be = BUFFER_INIT(write,0,errbuf,1);
+
+
+void logsa(stralloc *sa)
+{
+ buffer_putflush(&be,sa->s,sa->len);
+}
+
+void log1s(char *s1)
+{
+ buffer_putsflush(&be,s1);
+}
+
+void log2s(char *s1,char *s2)
+{
+ buffer_putsflush(&be,s1);
+ buffer_putsflush(&be,s2);
+}
+
+void log3s(char *s1,char *s2,char *s3)
+{
+ buffer_putsflush(&be,s1);
+ buffer_putsflush(&be,s2);
+ buffer_putsflush(&be,s3);
+}
+
+void log4s(char *s1,char *s2,char *s3,char *s4)
+{
+ buffer_putsflush(&be,s1);
+ buffer_putsflush(&be,s2);
+ buffer_putsflush(&be,s3);
+ buffer_putsflush(&be,s4);
+}
+
+void log5s(char *s1,char *s2,char *s3,char *s4,char *s5)
+{
+ buffer_putsflush(&be,s1);
+ buffer_putsflush(&be,s2);
+ buffer_putsflush(&be,s3);
+ buffer_putsflush(&be,s4);
+ buffer_putsflush(&be,s5);
+}
+
+void nomem()
+{
+ log1s("alert: out of memory, sleeping...\n");
+ sleep(10);
+}
+
+void pausedir(char *dir)
+{
+ log3s("alert: unable to opendir ",dir,", sleeping...\n");
+ sleep(10);
+}
+
+int issafe(char ch)
+{
+ if (ch == '%') return 0; /* general principle: allman's code is crap */
+ if (ch < 33) return 0;
+ if (ch > 126) return 0;
+ return 1;
+}
+
+void logsafe(char *s)
+{
+ int i;
+
+ while (!stralloc_copys(&foo,s)) nomem();
+ for (i = 0; i < foo.len; ++i)
+ if (foo.s[i] == '\n')
+ foo.s[i] = '/';
+ else
+ if (!issafe(foo.s[i]))
+ foo.s[i] = '_';
+
+ logsa(&foo);
+}