summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/alloc.h6
-rw-r--r--include/base64.h6
-rw-r--r--include/byte.h14
-rw-r--r--include/constmap.h8
-rw-r--r--include/env.h6
-rw-r--r--include/fmt.h2
-rw-r--r--include/sig.h66
-rw-r--r--include/socket_if.h2
-rw-r--r--include/str.h13
-rw-r--r--include/uint_t.h4
-rw-r--r--src/alloc.c7
-rw-r--r--src/base64.c2
-rw-r--r--src/buffer.c2
-rw-r--r--src/byte.c23
-rw-r--r--src/dnsstub/dns_transmit.c6
-rw-r--r--src/fmt.c2
-rw-r--r--src/getoptb.c2
-rw-r--r--src/sig.c20
18 files changed, 105 insertions, 86 deletions
diff --git a/include/alloc.h b/include/alloc.h
index 4fec2c2..ecfe02a 100644
--- a/include/alloc.h
+++ b/include/alloc.h
@@ -1,9 +1,9 @@
#ifndef ALLOC_H
#define ALLOC_H
-extern /*@null@*/ /*@out@*/ char *alloc();
-extern void alloc_free();
-extern int alloc_re();
+extern void *alloc(unsigned int);
+extern void alloc_free(void *);
+extern int alloc_re(void *, unsigned int, unsigned int);
/* use these names in the future */
#define qfree alloc_free
diff --git a/include/base64.h b/include/base64.h
index a9164c0..0f318c4 100644
--- a/include/base64.h
+++ b/include/base64.h
@@ -1,7 +1,9 @@
#ifndef BASE64_H
#define BASE64_H
-extern int b64decode();
-extern int b64encode();
+#include "stralloc.h"
+
+extern int b64decode(const unsigned char *in, int l, stralloc *out);
+extern int b64encode(stralloc *in, stralloc *out);
#endif
diff --git a/include/byte.h b/include/byte.h
index 3886127..836e8ca 100644
--- a/include/byte.h
+++ b/include/byte.h
@@ -8,13 +8,13 @@
@comment no declaration of argument types; too many compiler errors
*/
-extern unsigned int byte_chr();
-extern unsigned int byte_rchr();
-extern void byte_copy();
-extern void byte_copyr();
-extern int byte_diff();
-extern void byte_zero();
-extern void byte_fill();
+extern unsigned int byte_chr(char *, unsigned int, int);
+extern unsigned int byte_rchr(char *, unsigned int, int);
+extern void byte_copy(void *, unsigned int, const void *);
+extern void byte_copyr(void *, unsigned int, const void *);
+extern int byte_diff(const void *, unsigned int, const void *);
+extern void byte_zero(void *, unsigned int);
+extern void byte_fill(void *, unsigned int, int);
#define byte_equal(s, n, t) (!byte_diff((s), (n), (t)))
diff --git a/include/constmap.h b/include/constmap.h
index 0a43e98..4d5e2d3 100644
--- a/include/constmap.h
+++ b/include/constmap.h
@@ -13,9 +13,9 @@ struct constmap {
int *inputlen;
};
-int constmap_init(struct constmap *, char *, int, int);
-int constmap_init_char(struct constmap *, char *, int, int, char);
-void constmap_free();
-char *constmap();
+extern int constmap_init(struct constmap *, char *, int, int);
+extern int constmap_init_char(struct constmap *, char *, int, int, char);
+extern void constmap_free(struct constmap *);
+extern char *constmap(struct constmap *cm, char *s, int len);
#endif
diff --git a/include/env.h b/include/env.h
index 26f44b5..bc379ea 100644
--- a/include/env.h
+++ b/include/env.h
@@ -12,15 +12,15 @@
extern char **environ;
extern int env_isinit;
-extern int env_init();
+extern int env_init(void);
extern /*@null@*/ char *env_get(char *);
extern int env_put(char *, char *);
extern int env_puts(char *);
extern int env_set(char *);
extern int env_unset(char *);
-extern char *env_pick();
-extern void env_clear();
+extern char *env_pick(void);
+extern void env_clear(void);
extern char *env_findeq(char *);
diff --git a/include/fmt.h b/include/fmt.h
index eb8b8b8..41acaa1 100644
--- a/include/fmt.h
+++ b/include/fmt.h
@@ -11,7 +11,7 @@
#define FMT_ULONG 40 /* enough space to hold 2^128 - 1 in decimal, plus \0 */
#define FMT_LEN ((char *)0) /* convenient abbreviation */
-extern unsigned int fmt_str(char *, char *);
+extern unsigned int fmt_str(char *, const char *);
extern unsigned int fmt_strn(char *, char *, unsigned int);
extern unsigned int fmt_uint(char *, unsigned int);
extern unsigned int fmt_uint0(char *, unsigned int, unsigned int);
diff --git a/include/sig.h b/include/sig.h
index 4d1743d..bd3efc5 100644
--- a/include/sig.h
+++ b/include/sig.h
@@ -14,10 +14,10 @@ extern int sig_hangup;
extern int sig_pipe;
extern int sig_term;
-extern void (*sig_defaulthandler)();
-extern void (*sig_ignorehandler)();
+extern void (*sig_defaulthandler)(int);
+extern void (*sig_ignorehandler)(int);
-extern void sig_catch(int, void (*)());
+extern void sig_catch(int, void (*)(int));
#define sig_ignore(s) (sig_catch((s), sig_ignorehandler))
#define sig_uncatch(s) (sig_catch((s), sig_defaulthandler))
@@ -29,35 +29,35 @@ extern void sig_pause(void);
extern void sig_dfl(int);
/* declaration of (net)qmail package (untouched) */
-extern void sig_miscignore();
-extern void sig_bugcatch();
-
-extern void sig_pipeignore();
-extern void sig_pipedefault();
-
-extern void sig_contblock();
-extern void sig_contunblock();
-extern void sig_contcatch();
-extern void sig_contdefault();
-
-extern void sig_termblock();
-extern void sig_termunblock();
-extern void sig_termcatch();
-extern void sig_termdefault();
-
-extern void sig_alarmblock();
-extern void sig_alarmunblock();
-extern void sig_alarmcatch();
-extern void sig_alarmdefault();
-
-extern void sig_childblock();
-extern void sig_childunblock();
-extern void sig_childcatch();
-extern void sig_childdefault();
-
-extern void sig_hangupblock();
-extern void sig_hangupunblock();
-extern void sig_hangupcatch();
-extern void sig_hangupdefault();
+extern void sig_miscignore(void);
+extern void sig_bugcatch(void (*)(int));
+
+extern void sig_pipeignore(void);
+extern void sig_pipedefault(void);
+
+extern void sig_contblock(void);
+extern void sig_contunblock(void);
+extern void sig_contcatch(void (*)(int));
+extern void sig_contdefault(void);
+
+extern void sig_termblock(void);
+extern void sig_termunblock(void);
+extern void sig_termcatch(void (*)(int));
+extern void sig_termdefault(void);
+
+extern void sig_alarmblock(void);
+extern void sig_alarmunblock(void);
+extern void sig_alarmcatch(void (*)(int));
+extern void sig_alarmdefault(void);
+
+extern void sig_childblock(void);
+extern void sig_childunblock(void);
+extern void sig_childcatch(void (*)(int));
+extern void sig_childdefault(void);
+
+extern void sig_hangupblock(void);
+extern void sig_hangupunblock(void);
+extern void sig_hangupcatch(void (*)(int));
+extern void sig_hangupdefault(void);
#endif
diff --git a/include/socket_if.h b/include/socket_if.h
index 3681d29..82d091e 100644
--- a/include/socket_if.h
+++ b/include/socket_if.h
@@ -28,7 +28,7 @@ extern int socket_bind4(int, const char[4], uint16);
extern int socket_bind4_reuse(int, const char[4], uint16);
extern int socket_connect4(int, const char[4], uint16);
extern int socket_send4(int, const char *, unsigned int, const char[4], uint16);
-extern int socket_broadcast(int, const char *, unsigned int, uint16);
+extern int socket_broadcast4(int, const char *, unsigned int, uint16);
/* Backward compatibility */
#define socket_local4 socket_local
diff --git a/include/str.h b/include/str.h
index 0d74812..983b3fc 100644
--- a/include/str.h
+++ b/include/str.h
@@ -2,18 +2,17 @@
#define STR_H
/*
- * Revision 20170918, Kai Peter
- * - added 'str_copyb()', thanks Erwin Hoffmann
- * Revision 20170501, Kai Peter
- * - added '*str_append' and 'str_cat'
-*/
+ * Revision 20170918, Kai Peter
+ * - added 'str_copyb()', thanks Erwin Hoffmann
+ * Revision 20170501, Kai Peter
+ * - added '*str_append' and 'str_cat'
+ */
extern unsigned int str_copy(char *, const char *);
extern unsigned int str_copyb(char *, const char *, unsigned int);
extern int str_diff(const char *, const char *);
extern int str_diffn(const char *, const char *, unsigned int);
-//extern unsigned int str_len(char *); // --> this produces lot of warnings !!!
-extern unsigned int str_len();
+extern unsigned int str_len(const char *);
extern unsigned int str_chr(const char *, int);
extern unsigned int str_rchr(const char *, int);
extern int str_start(const char *, const char *);
diff --git a/include/uint_t.h b/include/uint_t.h
index 7bf32c8..529e7b5 100644
--- a/include/uint_t.h
+++ b/include/uint_t.h
@@ -17,6 +17,10 @@ typedef uint8_t uint8;
typedef unsigned char uint8;
#endif
+extern void uint8_pack(char *, uint8);
+extern void uint8_pack_big(char *, uint8);
+extern void uint8_unpack(char *, uint8 *);
+extern void uint8_unpack_big(char *, uint8 *);
#endif
#ifndef UINT16_H
diff --git a/src/alloc.c b/src/alloc.c
index cee09ac..7e4ccb4 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -17,7 +17,7 @@ static aligned realspace[SPACE / ALIGNMENT];
#define space ((char *)realspace)
static unsigned int avail = SPACE; /* multiple of ALIGNMENT; 0<=avail<=SPACE */
-/*@null@*/ /*@out@*/ char *alloc(unsigned int n)
+void *alloc(unsigned int n)
{
char *x;
@@ -38,15 +38,16 @@ static unsigned int avail = SPACE; /* multiple of ALIGNMENT; 0<=avail<=SPACE */
return x;
}
-void alloc_free(char *x)
+void alloc_free(void *x)
{
if (x >= space)
if (x < space + SPACE) return; /* XXX: assuming that pointers are flat */
free(x);
}
-int alloc_re(char **x, unsigned int m, unsigned int n)
+int alloc_re(void *a, unsigned int m, unsigned int n)
{
+ char **x = a;
char *y;
y = alloc(n);
diff --git a/src/base64.c b/src/base64.c
index 33b54e6..17847d9 100644
--- a/src/base64.c
+++ b/src/base64.c
@@ -10,7 +10,7 @@
@brief base64 en+decoding of strings
*/
-static char *b64alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+static const char *b64alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
#define B64PAD '='
/* returns 0 ok, 1 illegal, -1 problem */
diff --git a/src/buffer.c b/src/buffer.c
index 036b298..f094213 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -21,7 +21,7 @@ void buffer_init(buffer *s, ssize_t (*op)(), int fd, char *buf, size_t len)
s->n = len;
}
-ssize_t buffer_0_read(int fd, char *buf, size_t len)
+static ssize_t buffer_0_read(int fd, char *buf, size_t len)
{
if (buffer_flush(buffer_1) == -1) return -1;
return read(fd, buf, len);
diff --git a/src/byte.c b/src/byte.c
index 51f18e1..e027f4d 100644
--- a/src/byte.c
+++ b/src/byte.c
@@ -22,8 +22,11 @@ unsigned int byte_chr(char *s, unsigned int n, int c)
return t - s;
}
-void byte_copy(char *to, unsigned int n, char *from)
+void byte_copy(void *a, unsigned int n, const void *b)
{
+ char *to = a;
+ const char *from = b;
+
for (;;) {
// clang-format off
if (!n) { return; } *to++ = *from++; --n;
@@ -34,10 +37,10 @@ void byte_copy(char *to, unsigned int n, char *from)
}
}
-void byte_copyr(char *to, unsigned int n, char *from)
+void byte_copyr(void *a, unsigned int n, const void *b)
{
- to += n;
- from += n;
+ char *to = a + n;
+ const char *from = b + n;
for (;;) {
// clang-format off
@@ -49,8 +52,11 @@ void byte_copyr(char *to, unsigned int n, char *from)
}
}
-int byte_diff(char *s, unsigned int n, char *t)
+int byte_diff(const void *a, unsigned int n, const void *b)
{
+ const char *s = a;
+ const char *t = b;
+
for (;;) {
// clang-format off
if (!n) { return 0; } if (*s != *t) { break; } ++s; ++t; --n;
@@ -80,8 +86,10 @@ unsigned int byte_rchr(char *s, unsigned int n, int c)
return u - s;
}
-void byte_zero(char *s, unsigned int n)
+void byte_zero(void *v, unsigned int n)
{
+ char *s = v;
+
for (;;) {
// clang-format off
if (!n) { break; } *s++ = 0; --n;
@@ -92,8 +100,9 @@ void byte_zero(char *s, unsigned int n)
}
}
-void byte_fill(char *s, unsigned int n, int c)
+void byte_fill(void *a, unsigned int n, int c)
{
+ char *s = a;
char ch = c;
for (;;) {
diff --git a/src/dnsstub/dns_transmit.c b/src/dnsstub/dns_transmit.c
index 96eb38c..bc37791 100644
--- a/src/dnsstub/dns_transmit.c
+++ b/src/dnsstub/dns_transmit.c
@@ -61,7 +61,7 @@ int serverfailed(const char *buf, unsigned int len)
return 0;
}
-int irrelevant(const struct dns_transmit *d, const char *buf, unsigned int len)
+static int irrelevant(const struct dns_transmit *d, const char *buf, unsigned int len)
{
char out[12];
char *dn;
@@ -142,7 +142,7 @@ int randombind4(struct dns_transmit *d)
return DNS_COM;
}
-int thisudp(struct dns_transmit *d)
+static int thisudp(struct dns_transmit *d)
{
const char *ip;
@@ -210,7 +210,7 @@ int nextudp(struct dns_transmit *d)
return thisudp(d);
}
-int thistcp(struct dns_transmit *d)
+static int thistcp(struct dns_transmit *d)
{
struct taia now;
const char *ip;
diff --git a/src/fmt.c b/src/fmt.c
index 77a3c93..e904bd3 100644
--- a/src/fmt.c
+++ b/src/fmt.c
@@ -7,7 +7,7 @@
@brief formating differnt inputs format for output printing
*/
-unsigned int fmt_str(char *s, char *t)
+unsigned int fmt_str(char *s, const char *t)
{
unsigned int len;
char ch;
diff --git a/src/getoptb.c b/src/getoptb.c
index 64ac8ca..e0f6118 100644
--- a/src/getoptb.c
+++ b/src/getoptb.c
@@ -15,7 +15,7 @@
int opterr = 1;
char *optprogname = 0;
-int getopt(int argc, char **argv, char *opts)
+static int getopt(int argc, char **argv, char *opts)
{
int c;
char *s;
diff --git a/src/sig.c b/src/sig.c
index bf8510e..4c88143 100644
--- a/src/sig.c
+++ b/src/sig.c
@@ -18,7 +18,8 @@ void sig_alarmunblock()
{
sig_unblock(SIGALRM);
}
-void sig_alarmcatch(f) void (*f)();
+
+void sig_alarmcatch(void (*f)(int))
{
sig_catch(SIGALRM, f);
}
@@ -53,7 +54,7 @@ void sig_blocknone()
sigprocmask(SIG_SETMASK, &ss, (sigset_t *)0);
}
-void sig_catch(int sig, void (*f)())
+void sig_catch(int sig, void (*f)(int))
{
struct sigaction sa;
sa.sa_handler = f;
@@ -90,7 +91,8 @@ void sig_childunblock()
{
sig_unblock(SIGCHLD);
}
-void sig_childcatch(f) void (*f)();
+
+void sig_childcatch(void (*f)(int))
{
sig_catch(SIGCHLD, f);
}
@@ -111,7 +113,8 @@ void sig_hangupunblock()
{
sig_unblock(SIGHUP);
}
-void sig_hangupcatch(f) void (*f)();
+
+void sig_hangupcatch(void (*f)(int))
{
sig_catch(SIGHUP, f);
}
@@ -132,7 +135,8 @@ void sig_termunblock()
{
sig_unblock(SIGTERM);
}
-void sig_termcatch(f) void (*f)();
+
+void sig_termcatch(f) void (*f)(int);
{
sig_catch(SIGTERM, f);
}
@@ -144,7 +148,7 @@ void sig_termdefault()
int sig_term = SIGTERM;
-void sig_bugcatch(void (*f)())
+void sig_bugcatch(void (*f)(int))
{
sig_catch(SIGILL, f);
sig_catch(SIGABRT, f);
@@ -159,7 +163,7 @@ void sig_bugcatch(void (*f)())
#endif
}
-void (*sig_defaulthandler)() = SIG_DFL;
+void (*sig_defaulthandler)(int) = SIG_DFL;
void sig_miscignore()
{
@@ -176,6 +180,6 @@ void sig_miscignore()
#endif
}
-void (*sig_ignorehandler)() = SIG_IGN;
+void (*sig_ignorehandler)(int) = SIG_IGN;
int sig_cont = SIGCONT;