From 5fadc0cbb8577c61d66bd6f19ceaf0507c11e23b Mon Sep 17 00:00:00 2001 From: Jannis Hoffmann Date: Tue, 9 Jul 2024 14:41:53 +0200 Subject: initial clang-format --- include/alloc.h | 4 +- include/buffer.h | 59 +++++++--------- include/byte.h | 2 +- include/case.h | 18 ++--- include/cdbmake.h | 17 +++-- include/cdbread.h | 28 ++++---- include/constmap.h | 6 +- include/direntry.h | 2 +- include/dnsresolv.h | 184 +++++++++++++++++++++++++------------------------- include/env.h | 4 +- include/error.h | 70 +++++++++---------- include/fd.h | 4 +- include/fifo.h | 2 +- include/fmt.h | 16 ++--- include/genalloc.h | 83 +++++++++++++++-------- include/getln.h | 4 +- include/getoptb.h | 12 ++-- include/iopause.h | 12 ++-- include/ip.h | 76 +++++++++++---------- include/logmsg.h | 24 +++---- include/pathexec.h | 4 +- include/readclose.h | 10 +-- include/scan.h | 14 ++-- include/seek.h | 6 +- include/select.h | 4 +- include/sig.h | 6 +- include/socket_if.h | 50 +++++++------- include/str.h | 20 +++--- include/stralloc.h | 36 +++++----- include/tai.h | 16 ++--- include/taia.h | 20 +++--- include/timeout.h | 4 +- include/timeoutconn.h | 6 +- include/uint_t.h | 61 ++++++++--------- include/wait.h | 8 +-- 35 files changed, 459 insertions(+), 433 deletions(-) (limited to 'include') diff --git a/include/alloc.h b/include/alloc.h index 56a4a52..4fec2c2 100644 --- a/include/alloc.h +++ b/include/alloc.h @@ -1,12 +1,12 @@ #ifndef ALLOC_H #define ALLOC_H -extern /*@null@*//*@out@*/char *alloc(); +extern /*@null@*/ /*@out@*/ char *alloc(); extern void alloc_free(); extern int alloc_re(); /* use these names in the future */ -#define qfree alloc_free +#define qfree alloc_free #define qrealloc alloc_re #endif diff --git a/include/buffer.h b/include/buffer.h index 57cd960..4f513e7 100644 --- a/include/buffer.h +++ b/include/buffer.h @@ -1,6 +1,6 @@ #ifndef BUFFER_H #define BUFFER_H -#include /* need type: ssize_t */ +#include /* need type: ssize_t */ typedef struct buffer { char *x; @@ -10,48 +10,41 @@ typedef struct buffer { ssize_t (*op)(); } buffer; -#define BUFFER_INIT(op,fd,buf,len) { (buf), 0, (len), (fd), (op) } -#define BUFFER_SMALL 256 -#define BUFFER_INSIZE 8192 -#define BUFFER_OUTSIZE 8192 -#define BUFFER_MTUSIZE 1450 +#define BUFFER_INIT(op, fd, buf, len) {(buf), 0, (len), (fd), (op)} +#define BUFFER_SMALL 256 +#define BUFFER_INSIZE 8192 +#define BUFFER_OUTSIZE 8192 +#define BUFFER_MTUSIZE 1450 -extern void buffer_init(buffer *,ssize_t (*op)(),int,char *,size_t); +extern void buffer_init(buffer *, ssize_t (*op)(), int, char *, size_t); extern int buffer_flush(buffer *); -extern int buffer_put(buffer *,const char *,size_t); -extern int buffer_putalign(buffer *,const char *,size_t); -extern int buffer_putflush(buffer *,const char *,size_t); -extern int buffer_puts(buffer *,const char *); -extern int buffer_putsalign(buffer *,const char *); -extern int buffer_putsflush(buffer *,const char *); - -#define buffer_PUTC(s,c) \ - ( ((s)->n != (s)->p) \ - ? ( (s)->x[(s)->p++] = (c), 0 ) \ - : buffer_put((s),&(c),1) \ - ) - -extern int buffer_get(buffer *,char *,size_t); -extern int buffer_bget(buffer *,char *,size_t); +extern int buffer_put(buffer *, const char *, size_t); +extern int buffer_putalign(buffer *, const char *, size_t); +extern int buffer_putflush(buffer *, const char *, size_t); +extern int buffer_puts(buffer *, const char *); +extern int buffer_putsalign(buffer *, const char *); +extern int buffer_putsflush(buffer *, const char *); + +#define buffer_PUTC(s, c) (((s)->n != (s)->p) ? ((s)->x[(s)->p++] = (c), 0) : buffer_put((s), &(c), 1)) + +extern int buffer_get(buffer *, char *, size_t); +extern int buffer_bget(buffer *, char *, size_t); extern int buffer_feed(buffer *); extern char *buffer_peek(buffer *); -extern void buffer_seek(buffer *,size_t); +extern void buffer_seek(buffer *, size_t); -#define buffer_PEEK(s) ( (s)->x + (s)->n ) -#define buffer_SEEK(s,len) ( ( (s)->p -= (len) ) , ( (s)->n += (len) ) ) +#define buffer_PEEK(s) ((s)->x + (s)->n) +#define buffer_SEEK(s, len) (((s)->p -= (len)), ((s)->n += (len))) -#define buffer_GETC(s,c) \ - ( ((s)->p > 0) \ - ? ( *(c) = (s)->x[(s)->n], buffer_SEEK((s),1), 1 ) \ - : buffer_get((s),(c),1) \ - ) +#define buffer_GETC(s, c) \ + (((s)->p > 0) ? (*(c) = (s)->x[(s)->n], buffer_SEEK((s), 1), 1) : buffer_get((s), (c), 1)) -extern int buffer_copy(buffer *,buffer *); +extern int buffer_copy(buffer *, buffer *); -extern ssize_t buffer_unixread(int,char *,size_t); -extern ssize_t buffer_unixwrite(int,char *,size_t); +extern ssize_t buffer_unixread(int, char *, size_t); +extern ssize_t buffer_unixwrite(int, char *, size_t); extern buffer *buffer_0; extern buffer *buffer_1; diff --git a/include/byte.h b/include/byte.h index f437341..04337e8 100644 --- a/include/byte.h +++ b/include/byte.h @@ -16,6 +16,6 @@ extern int byte_diff(); extern void byte_zero(); extern void byte_fill(); -#define byte_equal(s,n,t) (!byte_diff((s),(n),(t))) +#define byte_equal(s, n, t) (!byte_diff((s), (n), (t))) #endif diff --git a/include/case.h b/include/case.h index d4cead2..f63747b 100644 --- a/include/case.h +++ b/include/case.h @@ -2,16 +2,16 @@ #define CASE_H extern void case_lowers(char *); -extern void case_lowerb(char *,unsigned int); +extern void case_lowerb(char *, unsigned int); extern void case_uppers(char *); -extern void case_upperb(char *,unsigned int); -extern int case_diffs(char *,char *); -extern int case_diffrs(char *,char *); -extern int case_diffb(char *,unsigned int,char *); -extern int case_starts(char *,char *); -extern int case_startb(char *,unsigned int,char *); +extern void case_upperb(char *, unsigned int); +extern int case_diffs(char *, char *); +extern int case_diffrs(char *, char *); +extern int case_diffb(char *, unsigned int, char *); +extern int case_starts(char *, char *); +extern int case_startb(char *, unsigned int, char *); -#define case_equals(s,t) (!case_diffs((s),(t))) -#define case_equalrs(s,t) (!case_diffrs((s),(t))) +#define case_equals(s, t) (!case_diffs((s), (t))) +#define case_equalrs(s, t) (!case_diffrs((s), (t))) #endif diff --git a/include/cdbmake.h b/include/cdbmake.h index 9c20d2d..1fa3699 100644 --- a/include/cdbmake.h +++ b/include/cdbmake.h @@ -8,13 +8,16 @@ #define CDB_HPLIST 1000 -struct cdb_hp { uint32 h; uint32 p; } ; +struct cdb_hp { + uint32 h; + uint32 p; +}; struct cdb_hplist { struct cdb_hp hp[CDB_HPLIST]; struct cdb_hplist *next; int num; -} ; +}; struct cdb_make { char bspace[8192]; @@ -28,12 +31,12 @@ struct cdb_make { buffer b; uint32 pos; int fd; -} ; +}; -extern int cdb_make_start(struct cdb_make *,int); -extern int cdb_make_addbegin(struct cdb_make *,unsigned int,unsigned int); -extern int cdb_make_addend(struct cdb_make *,unsigned int,unsigned int,uint32); -extern int cdb_make_add(struct cdb_make *,char *,unsigned int,char *,unsigned int); +extern int cdb_make_start(struct cdb_make *, int); +extern int cdb_make_addbegin(struct cdb_make *, unsigned int, unsigned int); +extern int cdb_make_addend(struct cdb_make *, unsigned int, unsigned int, uint32); +extern int cdb_make_add(struct cdb_make *, char *, unsigned int, char *, unsigned int); extern int cdb_make_finish(struct cdb_make *); #endif diff --git a/include/cdbread.h b/include/cdbread.h index bee4fd4..6f510c3 100644 --- a/include/cdbread.h +++ b/include/cdbread.h @@ -6,31 +6,31 @@ #include "uint_t.h" #define CDB_HASHSTART 5381ULL -extern uint32 cdb_hashadd(uint32,unsigned char); -extern uint32 cdb_hash(char *,unsigned int); +extern uint32 cdb_hashadd(uint32, unsigned char); +extern uint32 cdb_hash(char *, unsigned int); extern uint32 cdb_unpack(unsigned char *); struct cdb { char *map; /* 0 if no map is available */ int fd; - uint32 size; /* initialized if map is nonzero */ - uint32 loop; /* number of hash slots searched under this key */ - uint32 khash; /* initialized if loop is nonzero */ - uint32 kpos; /* initialized if loop is nonzero */ - uint32 hpos; /* initialized if loop is nonzero */ + uint32 size; /* initialized if map is nonzero */ + uint32 loop; /* number of hash slots searched under this key */ + uint32 khash; /* initialized if loop is nonzero */ + uint32 kpos; /* initialized if loop is nonzero */ + uint32 hpos; /* initialized if loop is nonzero */ uint32 hslots; /* initialized if loop is nonzero */ - uint32 dpos; /* initialized if cdb_findnext() returns 1 */ - uint32 dlen; /* initialized if cdb_findnext() returns 1 */ -} ; + uint32 dpos; /* initialized if cdb_findnext() returns 1 */ + uint32 dlen; /* initialized if cdb_findnext() returns 1 */ +}; extern void cdb_free(struct cdb *); -extern void cdb_init(struct cdb *,int fd); +extern void cdb_init(struct cdb *, int fd); -extern int cdb_read(struct cdb *,char *,unsigned int,uint32); +extern int cdb_read(struct cdb *, char *, unsigned int, uint32); extern void cdb_findstart(struct cdb *); -extern int cdb_findnext(struct cdb *,char *,unsigned int); -extern int cdb_find(struct cdb *,char *,unsigned int); +extern int cdb_findnext(struct cdb *, char *, unsigned int); +extern int cdb_find(struct cdb *, char *, unsigned int); #define cdb_datapos(c) ((c)->dpos) #define cdb_datalen(c) ((c)->dlen) diff --git a/include/constmap.h b/include/constmap.h index 750702e..0a43e98 100644 --- a/include/constmap.h +++ b/include/constmap.h @@ -11,10 +11,10 @@ struct constmap { int *next; char **input; int *inputlen; -} ; +}; -int constmap_init(struct constmap *,char *,int,int); -int constmap_init_char(struct constmap *,char *,int,int,char); +int constmap_init(struct constmap *, char *, int, int); +int constmap_init_char(struct constmap *, char *, int, int, char); void constmap_free(); char *constmap(); diff --git a/include/direntry.h b/include/direntry.h index d1628a9..0a7d9d8 100644 --- a/include/direntry.h +++ b/include/direntry.h @@ -3,8 +3,8 @@ /* sysdep: +dirent */ -#include #include +#include #define direntry struct dirent #endif diff --git a/include/dnsresolv.h b/include/dnsresolv.h index 406af50..0d01a87 100644 --- a/include/dnsresolv.h +++ b/include/dnsresolv.h @@ -33,71 +33,71 @@ * - added more DNS RR definitions */ -#include "stralloc.h" #include "iopause.h" +#include "stralloc.h" #include "taia.h" /* Note: The conventions are subject of change in forthcoming versions */ -#define DNS_NXD 0 /* NXDOMAIN, NODATA */ -#define DNS_MEM -1 /* out of memory; fatal */ -#define DNS_ERR -2 /* parsing errors and others */ -#define DNS_COM -3 /* (socket) communication errors: SERVFAIL */ -#define DNS_INT -4 /* internal errors */ -#define DNS_SOFT -5 /* DNS_ERR or DNS_COM */ -#define DNS_HARD -6 /* DNS loop problem */ +#define DNS_NXD 0 /* NXDOMAIN, NODATA */ +#define DNS_MEM -1 /* out of memory; fatal */ +#define DNS_ERR -2 /* parsing errors and others */ +#define DNS_COM -3 /* (socket) communication errors: SERVFAIL */ +#define DNS_INT -4 /* internal errors */ +#define DNS_SOFT -5 /* DNS_ERR or DNS_COM */ +#define DNS_HARD -6 /* DNS loop problem */ -#define MSGSIZE MTUSIZE /* todays default */ +#define MSGSIZE MTUSIZE /* todays default */ // #define MSGSIZE 512 /* RFC 1035 */ -#define MAXMSGSIZE 4096 /* 4069 seen with EDNS0 */ -#define MAXSEGMENT 65535 /* Max TCP buffer size */ +#define MAXMSGSIZE 4096 /* 4069 seen with EDNS0 */ +#define MAXSEGMENT 65535 /* Max TCP buffer size */ -#define QUERY_MAXNS 32 /* 16 IPv4 + 16 IPv6 NS */ -#define QUERY_MAXIPLEN 512 /* QUERY_MAXNS * 16 */ +#define QUERY_MAXNS 32 /* 16 IPv4 + 16 IPv6 NS */ +#define QUERY_MAXIPLEN 512 /* QUERY_MAXNS * 16 */ /* Note: These following definitions are subject of change */ -#define DNS_C_IN "\0\1" +#define DNS_C_IN "\0\1" #define DNS_C_ANY "\0\377" -#define DNS_T_A "\0\1" -#define DNS_T_NS "\0\2" -#define DNS_T_CNAME "\0\5" -#define DNS_T_SOA "\0\6" -#define DNS_T_PTR "\0\14" -#define DNS_T_HINFO "\0\15" -#define DNS_T_MX "\0\17" -#define DNS_T_TXT "\0\20" -#define DNS_T_RP "\0\21" -#define DNS_T_SIG "\0\30" -#define DNS_T_KEY "\0\31" -#define DNS_T_AAAA "\0\34" -#define DNS_T_SRV "\0\41" -#define DNS_T_NAPTR "\0\43" -#define DNS_T_CERT "\0\45" -#define DNS_T_OPT "\0\51" -#define DNS_T_DS "\0\53" -#define DNS_T_SSHFP "\0\54" -#define DNS_T_IPSECKEY "\0\55" -#define DNS_T_RRSIG "\0\56" -#define DNS_T_NSEC "\0\57" -#define DNS_T_DNSKEY "\0\60" -#define DNS_T_NSEC3 "\0\62" +#define DNS_T_A "\0\1" +#define DNS_T_NS "\0\2" +#define DNS_T_CNAME "\0\5" +#define DNS_T_SOA "\0\6" +#define DNS_T_PTR "\0\14" +#define DNS_T_HINFO "\0\15" +#define DNS_T_MX "\0\17" +#define DNS_T_TXT "\0\20" +#define DNS_T_RP "\0\21" +#define DNS_T_SIG "\0\30" +#define DNS_T_KEY "\0\31" +#define DNS_T_AAAA "\0\34" +#define DNS_T_SRV "\0\41" +#define DNS_T_NAPTR "\0\43" +#define DNS_T_CERT "\0\45" +#define DNS_T_OPT "\0\51" +#define DNS_T_DS "\0\53" +#define DNS_T_SSHFP "\0\54" +#define DNS_T_IPSECKEY "\0\55" +#define DNS_T_RRSIG "\0\56" +#define DNS_T_NSEC "\0\57" +#define DNS_T_DNSKEY "\0\60" +#define DNS_T_NSEC3 "\0\62" #define DNS_T_NSEC3PARAM "\0\63" -#define DNS_T_TLSA "\0\64" -#define DNS_T_HIP "\0\67" +#define DNS_T_TLSA "\0\64" +#define DNS_T_HIP "\0\67" #define DNS_T_OPENPGPKEY "\0\75" -#define DNS_T_SPF "\0\143" -#define DNS_T_AXFR "\0\374" -#define DNS_T_ANY "\0\377" -#define DNS_T_CAA "\1\1" +#define DNS_T_SPF "\0\143" +#define DNS_T_AXFR "\0\374" +#define DNS_T_ANY "\0\377" +#define DNS_T_CAA "\1\1" -#define LOCALHOST "localhost" /* no clear distinction IPv4/IPv6 */ +#define LOCALHOST "localhost" /* no clear distinction IPv4/IPv6 */ #define IP4_LOOPBACK "ip4-loopback" #define IP6_LOOPBACK "ip6-loopback" struct dns_transmit { - char *query; /* 0, or dynamically allocated */ + char *query; /* 0, or dynamically allocated */ unsigned int querylen; char *packet; /* 0, or dynamically allocated */ unsigned int packetlen; @@ -111,7 +111,7 @@ struct dns_transmit { uint32 scope_id; char localip[16]; char qtype[2]; -} ; +}; /* General */ @@ -119,71 +119,73 @@ extern void dns_random_init(const char *); extern unsigned int dns_random(unsigned int); extern void dns_domain_free(char **); -extern int dns_domain_copy(char **,const char *); +extern int dns_domain_copy(char **, const char *); extern unsigned int dns_domain_length(const char *); -extern int dns_domain_equal(const char *,const char *); -extern int dns_domain_suffix(const char *,const char *); -extern unsigned int dns_domain_suffixpos(const char *,const char *); -extern int dns_domain_fromdot(char **,const char *,unsigned int); -extern int dns_domain_todot_cat(stralloc *,const char *); -extern int dns_ip_qualify(stralloc *,stralloc *,const stralloc *); -extern int dns_ip_qualify_rules(stralloc *,stralloc *,const stralloc *,const stralloc *); -extern int dns_ip_qualify_localhost(stralloc *,stralloc *,const stralloc *); - -extern unsigned int dns_packet_copy(const char *,unsigned int,unsigned int,char *,unsigned int); -extern unsigned int dns_packet_getname(const char *,unsigned int,unsigned int,char **); -extern unsigned int dns_packet_skipname(const char *,unsigned int,unsigned int); +extern int dns_domain_equal(const char *, const char *); +extern int dns_domain_suffix(const char *, const char *); +extern unsigned int dns_domain_suffixpos(const char *, const char *); +extern int dns_domain_fromdot(char **, const char *, unsigned int); +extern int dns_domain_todot_cat(stralloc *, const char *); +extern int dns_ip_qualify(stralloc *, stralloc *, const stralloc *); +extern int dns_ip_qualify_rules(stralloc *, stralloc *, const stralloc *, const stralloc *); +extern int dns_ip_qualify_localhost(stralloc *, stralloc *, const stralloc *); + +extern unsigned int dns_packet_copy(const char *, unsigned int, unsigned int, char *, unsigned int); +extern unsigned int dns_packet_getname(const char *, unsigned int, unsigned int, char **); +extern unsigned int dns_packet_skipname(const char *, unsigned int, unsigned int); extern struct dns_transmit dns_resolve_tx; -extern int dns_transmit_start(struct dns_transmit *,const char *,int,const char *,const char *,const char *); +extern int dns_transmit_start( + struct dns_transmit *, const char *, int, const char *, const char *, const char *); extern void dns_transmit_free(struct dns_transmit *); -extern void dns_transmit_io(struct dns_transmit *,iopause_fd *,struct taia *); -extern int dns_transmit_get(struct dns_transmit *,const iopause_fd *,const struct taia *); +extern void dns_transmit_io(struct dns_transmit *, iopause_fd *, struct taia *); +extern int dns_transmit_get(struct dns_transmit *, const iopause_fd *, const struct taia *); /* Common IPv4 + IPv6 */ -extern int dns_resolvconfip(char *,uint32 *); +extern int dns_resolvconfip(char *, uint32 *); extern int dns_resolvconfrewrite(stralloc *); -extern int dns_resolve(const char *,const char *); +extern int dns_resolve(const char *, const char *); -extern int dns_name(stralloc *,const char *); -extern int dns_name_packet(stralloc *,const char *,unsigned int); -extern int dns_txt_packet(stralloc *,const char *,unsigned int); -extern int dns_txt(stralloc *,const stralloc *); -extern int dns_mx_packet(stralloc *,const char *,unsigned int); -extern int dns_mx(stralloc *,const stralloc *); +extern int dns_name(stralloc *, const char *); +extern int dns_name_packet(stralloc *, const char *, unsigned int); +extern int dns_txt_packet(stralloc *, const char *, unsigned int); +extern int dns_txt(stralloc *, const stralloc *); +extern int dns_mx_packet(stralloc *, const char *, unsigned int); +extern int dns_mx(stralloc *, const stralloc *); /* IPv4 specific */ -extern int dns_ip4_packet(stralloc *,const char *,unsigned int); -extern int dns_ip4(stralloc *,stralloc *); -extern void dns_sortip4(char *,unsigned int); +extern int dns_ip4_packet(stralloc *, const char *, unsigned int); +extern int dns_ip4(stralloc *, stralloc *); +extern void dns_sortip4(char *, unsigned int); -extern int dns_ip4_qualify_rules(stralloc *,stralloc *,const stralloc *,const stralloc *); -extern int dns_ip4_qualify(stralloc *,stralloc *,const stralloc *); +extern int dns_ip4_qualify_rules(stralloc *, stralloc *, const stralloc *, const stralloc *); +extern int dns_ip4_qualify(stralloc *, stralloc *, const stralloc *); #define DNS_NAME4_DOMAIN 31 -extern int dns_name4_domain(char *,const char *); -extern int dns_name4(stralloc *,const char *); +extern int dns_name4_domain(char *, const char *); +extern int dns_name4(stralloc *, const char *); extern int randombind4(struct dns_transmit *); /* IPv6 specific */ -extern int dns_ip6_packet(stralloc *,const char *,unsigned int); -extern int dns_ip6(stralloc *,stralloc *); -extern void dns_sortip6(char *,unsigned int); +extern int dns_ip6_packet(stralloc *, const char *, unsigned int); +extern int dns_ip6(stralloc *, stralloc *); +extern void dns_sortip6(char *, unsigned int); -extern int dns_ip6_qualify_rules(stralloc *,stralloc *,const stralloc *,const stralloc *); -extern int dns_ip6_qualify(stralloc *,stralloc *,const stralloc *); +extern int dns_ip6_qualify_rules(stralloc *, stralloc *, const stralloc *, const stralloc *); +extern int dns_ip6_qualify(stralloc *, stralloc *, const stralloc *); -#define DNS_NAME6_DOMAIN (4*16+11) -extern int dns_name6_domain(char *,const char *); -extern int dns_name6(stralloc *,const char *); +#define DNS_NAME6_DOMAIN (4 * 16 + 11) +extern int dns_name6_domain(char *, const char *); +extern int dns_name6(stralloc *, const char *); -extern int dns_cname_packet(stralloc *,const char *,unsigned int); -extern int dns_cname(stralloc *,stralloc *); +extern int dns_cname_packet(stralloc *, const char *, unsigned int); +extern int dns_cname(stralloc *, stralloc *); -extern int dns_transmit_start6(struct dns_transmit *,const char *,int,const char *,const char *,const char *,const uint32 *); +extern int dns_transmit_start6( + struct dns_transmit *, const char *, int, const char *, const char *, const char *, const uint32 *); extern int randombind6(struct dns_transmit *); /* General */ @@ -191,9 +193,9 @@ extern int randombind6(struct dns_transmit *); extern void socketfree(struct dns_transmit *); extern void queryfree(struct dns_transmit *); extern void packetfree(struct dns_transmit *); -extern int serverwantstcp(const char *,unsigned int); -extern int serverfailed(const char *,unsigned int); -extern int getscopeid(const struct dns_transmit *,const char *); +extern int serverwantstcp(const char *, unsigned int); +extern int serverfailed(const char *, unsigned int); +extern int getscopeid(const struct dns_transmit *, const char *); extern int firstudp(struct dns_transmit *); extern int nextudp(struct dns_transmit *); extern int firsttcp(struct dns_transmit *); diff --git a/include/env.h b/include/env.h index 8f6ea87..88566cf 100644 --- a/include/env.h +++ b/include/env.h @@ -14,8 +14,8 @@ extern char **environ; extern int env_isinit; extern int env_init(); -extern /*@null@*/char *env_get(char *); -extern int env_put(char *,char *); +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 *); diff --git a/include/error.h b/include/error.h index 7685c9e..63132ff 100644 --- a/include/error.h +++ b/include/error.h @@ -3,8 +3,8 @@ #include -#ifndef EPROTO /* OpenBSD compat */ -#define EPROTO EINTR +#ifndef EPROTO /* OpenBSD compat */ + #define EPROTO EINTR #endif #define error_str(i) errstr(i) @@ -16,42 +16,42 @@ extern char *error_str(int); */ /* djb backwards compatibility - deprecated form of system errors */ - /* Comparison of error codes and constants: +/* Comparison of error codes and constants: intern Linux FreeBSD OmniOS */ -#define error_intr EINTR /* -1 4 4 4 */ -#define error_nomem ENOMEM /* -2 12 12 12 */ -#define error_noent ENOENT /* -3 2 2 2 */ -#define error_txtbsy ETXTBSY /* -4 26 26 26 */ -#define error_io EIO /* -5 5 5 5 */ -#define error_exist EEXIST /* -6 17 17 17 */ -#define error_timeout ETIMEDOUT /* -7 110 60 145 */ -#define error_inprogress EINPROGRESS /* -8 115 36 160 */ -#define error_wouldblock EWOULDBLOCK /* -9 EAGAIN EAGAIN EAGAIN */ -#define error_again EAGAIN /* -10 11 35 11 */ -#define error_pipe EPIPE /* -11 32 32 32 */ -#define error_perm EPERM /* -12 1 1 1 */ -#define error_acces EACCES /* -13 13 13 13 */ -#define error_nodevice ENODEV /* -14 (6) (6) 19 */ -#define error_proto EPROTO /* -15 71 92 71 */ -#define error_isdir EISDIR /* -16 21 21 21 */ -#define error_connrefused ECONNREFUSED /* -17 111 61 146 */ +#define error_intr EINTR /* -1 4 4 4 */ +#define error_nomem ENOMEM /* -2 12 12 12 */ +#define error_noent ENOENT /* -3 2 2 2 */ +#define error_txtbsy ETXTBSY /* -4 26 26 26 */ +#define error_io EIO /* -5 5 5 5 */ +#define error_exist EEXIST /* -6 17 17 17 */ +#define error_timeout ETIMEDOUT /* -7 110 60 145 */ +#define error_inprogress EINPROGRESS /* -8 115 36 160 */ +#define error_wouldblock EWOULDBLOCK /* -9 EAGAIN EAGAIN EAGAIN */ +#define error_again EAGAIN /* -10 11 35 11 */ +#define error_pipe EPIPE /* -11 32 32 32 */ +#define error_perm EPERM /* -12 1 1 1 */ +#define error_acces EACCES /* -13 13 13 13 */ +#define error_nodevice ENODEV /* -14 (6) (6) 19 */ +#define error_proto EPROTO /* -15 71 92 71 */ +#define error_isdir EISDIR /* -16 21 21 21 */ +#define error_connrefused ECONNREFUSED /* -17 111 61 146 */ //extern int error_notdir; /* -18 20 20 20 */ -#define error_rofs EROFS /* -19 30 30 30 */ -#define error_connreset ECONNRESET /* -20 104 54 131 */ +#define error_rofs EROFS /* -19 30 30 30 */ +#define error_connreset ECONNRESET /* -20 104 54 131 */ /* djb uses some internal application error and class definitions -- revised (feh) */ -#define CAT -10 /* raw message w/o terminating \n */ -#define LOG -90 /* generic logging */ -#define INFO -91 /* named logging */ -#define TEMP -97 /* (triggered) temporay alert condition */ -#define ALERT -98 /* (triggered) alert condition */ -#define WARN -99 /* exception condition */ -#define ESOFT -100 /* soft error, reversed negative */ -#define EHARD -111 /* hard error, reversed negative */ -#define USAGE 100 /* usage error on call -- explicit usage() */ -#define SYNTAX 101 /* usage/syntax error on call -- explicit syntaxerror() */ -#define DROP 110 /* connection dropped -- explicit dropped() */ -#define FATAL 111 /* internal error -- all */ -#define ERROR 112 /* application error */ +#define CAT -10 /* raw message w/o terminating \n */ +#define LOG -90 /* generic logging */ +#define INFO -91 /* named logging */ +#define TEMP -97 /* (triggered) temporay alert condition */ +#define ALERT -98 /* (triggered) alert condition */ +#define WARN -99 /* exception condition */ +#define ESOFT -100 /* soft error, reversed negative */ +#define EHARD -111 /* hard error, reversed negative */ +#define USAGE 100 /* usage error on call -- explicit usage() */ +#define SYNTAX 101 /* usage/syntax error on call -- explicit syntaxerror() */ +#define DROP 110 /* connection dropped -- explicit dropped() */ +#define FATAL 111 /* internal error -- all */ +#define ERROR 112 /* application error */ #endif diff --git a/include/fd.h b/include/fd.h index 21047c9..d0c447c 100644 --- a/include/fd.h +++ b/include/fd.h @@ -1,8 +1,8 @@ #ifndef FD_H #define FD_H -extern int fd_copy(int,int); -extern int fd_move(int,int); +extern int fd_copy(int, int); +extern int fd_move(int, int); extern int fd_coe(int fd); #endif diff --git a/include/fifo.h b/include/fifo.h index 3c1bf68..7e7e0f1 100644 --- a/include/fifo.h +++ b/include/fifo.h @@ -7,6 +7,6 @@ @source s/qmail */ -int fifo_make(char *,int); +int fifo_make(char *, int); #endif diff --git a/include/fmt.h b/include/fmt.h index 6e68d60..e6de428 100644 --- a/include/fmt.h +++ b/include/fmt.h @@ -8,15 +8,15 @@ @brief conversion function declarations */ -#define FMT_ULONG 40 /* enough space to hold 2^128 - 1 in decimal, plus \0 */ -#define FMT_LEN ((char *) 0) /* convenient abbreviation */ +#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_strn(char *,char *,unsigned int); -extern unsigned int fmt_uint(char *,unsigned int); -extern unsigned int fmt_uint0(char *,unsigned int,unsigned int); -extern unsigned int fmt_ulong(char *,unsigned long); -extern unsigned int fmt_xlong(char *,unsigned long); +extern unsigned int fmt_str(char *, 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); +extern unsigned int fmt_ulong(char *, unsigned long); +extern unsigned int fmt_xlong(char *, unsigned long); extern int fromhex(unsigned char); extern char tohex(char); diff --git a/include/genalloc.h b/include/genalloc.h index ee489af..d27c6b1 100644 --- a/include/genalloc.h +++ b/include/genalloc.h @@ -36,39 +36,64 @@ Macros: */ /* file: gen_alloc.h */ -#define GEN_ALLOC_typedef(ta,type,field,len,a) \ - typedef struct ta { type *field; unsigned int len; unsigned int a; } ta; +#define GEN_ALLOC_typedef(ta, type, field, len, a) \ + typedef struct ta { \ + type *field; \ + unsigned int len; \ + unsigned int a; \ + } ta; /* file: gen_allocdefs.h (deprecated) */ // used in: ipalloc, prioq, qmail-remote, qmail-inject, token822 -#define GEN_ALLOC_ready(ta,type,field,len,a,i,n,x,base,ta_ready) \ -int ta_ready(x,n) register ta *x; register unsigned int n; \ -{ register unsigned int i; \ - if (x->field) { \ - i = x->a; \ - if (n > i) { \ - x->a = base + n + (n >> 3); \ - if (alloc_re(&x->field,i * sizeof(type),x->a * sizeof(type))) return 1; \ - x->a = i; return 0; } \ - return 1; } \ - x->len = 0; \ - return !!(x->field = (type *) alloc((x->a = n) * sizeof(type))); } +#define GEN_ALLOC_ready(ta, type, field, len, a, i, n, x, base, ta_ready) \ + int ta_ready(x, n) \ + register ta *x; \ + register unsigned int n; \ + { \ + register unsigned int i; \ + if (x->field) { \ + i = x->a; \ + if (n > i) { \ + x->a = base + n + (n >> 3); \ + if (alloc_re(&x->field, i * sizeof(type), x->a * sizeof(type))) return 1; \ + x->a = i; \ + return 0; \ + } \ + return 1; \ + } \ + x->len = 0; \ + return !!(x->field = (type *)alloc((x->a = n) * sizeof(type))); \ + } -#define GEN_ALLOC_readyplus(ta,type,field,len,a,i,n,x,base,ta_rplus) \ -int ta_rplus(x,n) register ta *x; register unsigned int n; \ -{ register unsigned int i; \ - if (x->field) { \ - i = x->a; n += x->len; \ - if (n > i) { \ - x->a = base + n + (n >> 3); \ - if (alloc_re(&x->field,i * sizeof(type),x->a * sizeof(type))) return 1; \ - x->a = i; return 0; } \ - return 1; } \ - x->len = 0; \ - return !!(x->field = (type *) alloc((x->a = n) * sizeof(type))); } +#define GEN_ALLOC_readyplus(ta, type, field, len, a, i, n, x, base, ta_rplus) \ + int ta_rplus(x, n) \ + register ta *x; \ + register unsigned int n; \ + { \ + register unsigned int i; \ + if (x->field) { \ + i = x->a; \ + n += x->len; \ + if (n > i) { \ + x->a = base + n + (n >> 3); \ + if (alloc_re(&x->field, i * sizeof(type), x->a * sizeof(type))) return 1; \ + x->a = i; \ + return 0; \ + } \ + return 1; \ + } \ + x->len = 0; \ + return !!(x->field = (type *)alloc((x->a = n) * sizeof(type))); \ + } -#define GEN_ALLOC_append(ta,type,field,len,a,i,n,x,base,ta_rplus,ta_append) \ -int ta_append(x,i) register ta *x; register type *i; \ -{ if (!ta_rplus(x,1)) return 0; x->field[x->len++] = *i; return 1; } +#define GEN_ALLOC_append(ta, type, field, len, a, i, n, x, base, ta_rplus, ta_append) \ + int ta_append(x, i) \ + register ta *x; \ + register type *i; \ + { \ + if (!ta_rplus(x, 1)) return 0; \ + x->field[x->len++] = *i; \ + return 1; \ + } #endif diff --git a/include/getln.h b/include/getln.h index 23eb58b..60b5dcc 100644 --- a/include/getln.h +++ b/include/getln.h @@ -4,7 +4,7 @@ #include "buffer.h" #include "stralloc.h" -extern int getln(buffer *,stralloc *,int *,int); -extern int sgetln(buffer *,stralloc *,char **,unsigned int *,int); +extern int getln(buffer *, stralloc *, int *, int); +extern int sgetln(buffer *, stralloc *, char **, unsigned int *, int); #endif diff --git a/include/getoptb.h b/include/getoptb.h index 0338a15..61fa7aa 100644 --- a/include/getoptb.h +++ b/include/getoptb.h @@ -6,16 +6,16 @@ * - consolidated 'sgetopt.h' and 'subgetopt.h' into '(b)getopt.h' */ -#define optarg subgetoptarg -#define optind subgetoptind -#define optpos subgetoptpos -#define optproblem subgetoptproblem +#define optarg subgetoptarg +#define optind subgetoptind +#define optpos subgetoptpos +#define optproblem subgetoptproblem #define optprogname subgetoptprogname -#define opteof subgetoptdone +#define opteof subgetoptdone #define SUBGETOPTDONE -1 -extern int subgetopt(int,char **,char *); +extern int subgetopt(int, char **, char *); extern char *subgetoptarg; extern int subgetoptind; extern int subgetoptpos; diff --git a/include/iopause.h b/include/iopause.h index e3cfa01..871c8eb 100644 --- a/include/iopause.h +++ b/include/iopause.h @@ -5,24 +5,24 @@ #include #ifdef HAS_POLL_H -#include + #include typedef struct pollfd iopause_fd; -#define IOPAUSE_READ POLLIN -#define IOPAUSE_WRITE POLLOUT + #define IOPAUSE_READ POLLIN + #define IOPAUSE_WRITE POLLOUT #else typedef struct { int fd; short events; short revents; } iopause_fd; -#define IOPAUSE_READ 1 -#define IOPAUSE_WRITE 4 + #define IOPAUSE_READ 1 + #define IOPAUSE_WRITE 4 #endif #include "taia.h" -extern int iopause(iopause_fd *,unsigned int,struct taia *,struct taia *); +extern int iopause(iopause_fd *, unsigned int, struct taia *, struct taia *); extern unsigned long pollmax; #endif diff --git a/include/ip.h b/include/ip.h index 3f0c299..6088813 100644 --- a/include/ip.h +++ b/include/ip.h @@ -30,35 +30,39 @@ #define V4MAPPREFIX "::ffff:" #define HOSTNAMELEN 1025 -#define IP4MLMTU 512 -#define IP6MLMTU 1280 /* RFC 8200 */ -#define MTUSIZE IP6MLMTU +#define IP4MLMTU 512 +#define IP6MLMTU 1280 /* RFC 8200 */ +#define MTUSIZE IP6MLMTU -#define IP4_FMT 20 /* backwards compatibility */ -#define IP6_FMT 40 /* " */ -#define IPFMT 72 /* used in qmail-remote only (temp?) */ +#define IP4_FMT 20 /* backwards compatibility */ +#define IP6_FMT 40 /* " */ +#define IPFMT 72 /* used in qmail-remote only (temp?) */ /* may be better: */ //#define IP4_FMT IPFMT /* backwards compatibility */ //#define IP6_FMT IPFMT /* " */ /* deprecated: */ -#define FMT_IP4 IP4_FMT /* more backwards compatibility */ -#define FMT_IP6 IP6_FMT /* " */ +#define FMT_IP4 IP4_FMT /* more backwards compatibility */ +#define FMT_IP6 IP6_FMT /* " */ /* these structs are going deprecated (should replaced by socket lib) */ -struct ip4_address { unsigned char d[4]; }; /* 4 decimal pieces */ -struct ip6_address { unsigned char d[16]; }; /* 16 hex pieces */ -#define ip_address ip4_address /* backward compatibility */ +struct ip4_address { + unsigned char d[4]; +}; /* 4 decimal pieces */ +struct ip6_address { + unsigned char d[16]; +}; /* 16 hex pieces */ +#define ip_address ip4_address /* backward compatibility */ -unsigned int ip4_bytestring(stralloc *,char [4],int); -unsigned int ip4_cidr(char *,char [4],unsigned long *); -unsigned int ip4_fmt(char *,char [4]); -unsigned int ip4_scan(const char *,char [4]); -unsigned int ip4_scanbracket(const char *,char [4]); -unsigned int ia4_fmt(char *,char [4]); +unsigned int ip4_bytestring(stralloc *, char[4], int); +unsigned int ip4_cidr(char *, char[4], unsigned long *); +unsigned int ip4_fmt(char *, char[4]); +unsigned int ip4_scan(const char *, char[4]); +unsigned int ip4_scanbracket(const char *, char[4]); +unsigned int ia4_fmt(char *, char[4]); -const static char V4loopback[4] = {127,0,0,1}; -const static char V4localnet[4] = {0,0,0,0}; -const static char V4broadcast[4] = {-1,-1,-1,-1}; // all bits 1 +const static char V4loopback[4] = {127, 0, 0, 1}; +const static char V4localnet[4] = {0, 0, 0, 0}; +const static char V4broadcast[4] = {-1, -1, -1, -1}; // all bits 1 /*** * Compactified IPv6 addresses are really ugly to parse. @@ -82,26 +86,26 @@ const static char V4broadcast[4] = {-1,-1,-1,-1}; // all bits 1 * */ -unsigned int ip6_bytestring(stralloc *,char *,int); -unsigned int ip6_cidr(char *,char [16],unsigned long *); -unsigned int ip6_fmt(char *,char [16]); -unsigned int ip6_fmt_flat(char *,char [16]); -unsigned int ip6_ifscan(char *,char [16],stralloc *); -unsigned int ip6_scan(const char *,char [16]); -unsigned int ip6_scanbracket(const char *,char [16]); -unsigned int ip6_scan_flat(const char *,char [16]); -unsigned int ia6_fmt(char *,char [16]); +unsigned int ip6_bytestring(stralloc *, char *, int); +unsigned int ip6_cidr(char *, char[16], unsigned long *); +unsigned int ip6_fmt(char *, char[16]); +unsigned int ip6_fmt_flat(char *, char[16]); +unsigned int ip6_ifscan(char *, char[16], stralloc *); +unsigned int ip6_scan(const char *, char[16]); +unsigned int ip6_scanbracket(const char *, char[16]); +unsigned int ip6_scan_flat(const char *, char[16]); +unsigned int ia6_fmt(char *, char[16]); -static const unsigned char V4mappedprefix[12] = {0,0,0,0, 0,0,0,0, 0,0,0xff,0xff}; -static const unsigned char V46loopback[16] = {0,0,0,0, 0,0,0,0, 0,0,0xff,0xff, 127,0,0,1}; -static const unsigned char V6loopback[16] = {0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,1}; -static const unsigned char V6localnet[16] = {0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0}; -static const unsigned char V6linklocal[2] = {0xfe,0x80}; +static const unsigned char V4mappedprefix[12] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff}; +static const unsigned char V46loopback[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff, 127, 0, 0, 1}; +static const unsigned char V6loopback[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}; +static const unsigned char V6localnet[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; +static const unsigned char V6linklocal[2] = {0xfe, 0x80}; int fromhex(unsigned char); char tohex(char); -#define V6any V6localnet /* backward compatibility */ -#define ip6_isv4mapped(ip) (byte_equal(ip,12,V4mappedprefix)) +#define V6any V6localnet /* backward compatibility */ +#define ip6_isv4mapped(ip) (byte_equal(ip, 12, V4mappedprefix)) #endif diff --git a/include/logmsg.h b/include/logmsg.h index c480c8b..2f47a94 100644 --- a/include/logmsg.h +++ b/include/logmsg.h @@ -3,29 +3,29 @@ #include #include + #include "error.h" -extern void logmsg(const char *who, int ecode, unsigned int class, - const char *msg); +extern void logmsg(const char *who, int ecode, unsigned int class, const char *msg); /* useful combinations of params */ /* class: FATAL (hard) - system error */ -#define err_sys(w,e) logmsg(w,e,FATAL,"") -#define err_sys_plus(w,e,m) logmsg(w,e,FATAL,m) +#define err_sys(w, e) logmsg(w, e, FATAL, "") +#define err_sys_plus(w, e, m) logmsg(w, e, FATAL, m) /* class: WARN (application) - temporary error */ -#define err_tmp(w,e,m) logmsg(w,e,WARN,m) -#define err_tmp_plus(w,e,m) logmsg(w,e,WARN,m) +#define err_tmp(w, e, m) logmsg(w, e, WARN, m) +#define err_tmp_plus(w, e, m) logmsg(w, e, WARN, m) /* class: facultative ('int'ernal definition */ -#define err_int(w,e,c) logmsg(w,e,c,"") -#define err_int_plus(w,e,c,m) logmsg(w,e,c,m) +#define err_int(w, e, c) logmsg(w, e, c, "") +#define err_int_plus(w, e, c, m) logmsg(w, e, c, m) /* log messages */ /* #define log(w,m) logmsg(w,0,LOG,m) // obsoleted by */ -#define log_who(w,m) logmsg(w,0,LOG,m) -#define log_anon(m) logmsg("",0,LOG,m) -#define log_cat(n) logmsg("",0,CAT,m) +#define log_who(w, m) logmsg(w, 0, LOG, m) +#define log_anon(m) logmsg("", 0, LOG, m) +#define log_cat(n) logmsg("", 0, CAT, m) /* build log message from multiple partial strings */ extern char *build_log_msg(const char *[]); -#define B(...) build_log_msg((const char *[]){__VA_ARGS__,NULL}) // K/R sect. 7.3 +#define B(...) build_log_msg((const char *[]){__VA_ARGS__, NULL}) // K/R sect. 7.3 #endif diff --git a/include/pathexec.h b/include/pathexec.h index 9db6fb4..7ecc0b2 100644 --- a/include/pathexec.h +++ b/include/pathexec.h @@ -2,8 +2,8 @@ #define PATHEXEC_H #include "stralloc.h" -extern void pathexec_run(const char *,char *const *,char *const *); -extern int pathexec_env(const char *,const char *); +extern void pathexec_run(const char *, char *const *, char *const *); +extern int pathexec_env(const char *, const char *); extern int pathexec_multienv(stralloc *); extern void pathexec(char *const *); diff --git a/include/readclose.h b/include/readclose.h index a95f4f5..69264a1 100644 --- a/include/readclose.h +++ b/include/readclose.h @@ -1,14 +1,14 @@ #ifndef READCLOSE_H #define READCLOSE_H -#include "stralloc.h" #include "close.h" +#include "stralloc.h" -extern int readclose_append(int,stralloc *,unsigned int); -extern int readclose(int,stralloc *,unsigned int); +extern int readclose_append(int, stralloc *, unsigned int); +extern int readclose(int, stralloc *, unsigned int); -#define slurpclose readclose /* backwards compatibility */ +#define slurpclose readclose /* backwards compatibility */ -extern int openreadclose(const char *,stralloc *,unsigned int); +extern int openreadclose(const char *, stralloc *, unsigned int); #endif diff --git a/include/scan.h b/include/scan.h index f1d4030..1a55066 100644 --- a/include/scan.h +++ b/include/scan.h @@ -1,12 +1,12 @@ #ifndef SCAN_H #define SCAN_H -extern unsigned int scan_0x(const char *,unsigned int *); -extern unsigned int scan_xint(const char *,unsigned int *); -extern unsigned int scan_8long(const char *,unsigned long *); -extern unsigned int scan_uint(const char *,unsigned int *); -extern unsigned int scan_long(const char *,long *); -extern unsigned int scan_ulong(const char *,unsigned long *); -extern unsigned int scan_xlong(const char *,unsigned long *); +extern unsigned int scan_0x(const char *, unsigned int *); +extern unsigned int scan_xint(const char *, unsigned int *); +extern unsigned int scan_8long(const char *, unsigned long *); +extern unsigned int scan_uint(const char *, unsigned int *); +extern unsigned int scan_long(const char *, long *); +extern unsigned int scan_ulong(const char *, unsigned long *); +extern unsigned int scan_xlong(const char *, unsigned long *); #endif diff --git a/include/seek.h b/include/seek.h index 06aad97..a1d837b 100644 --- a/include/seek.h +++ b/include/seek.h @@ -5,11 +5,11 @@ typedef unsigned long seek_pos; extern seek_pos seek_cur(int); -extern int seek_set(int,seek_pos); +extern int seek_set(int, seek_pos); extern int seek_end(int); -extern int seek_trunc(int,seek_pos); +extern int seek_trunc(int, seek_pos); -#define seek_begin(fd) (seek_set((fd),(seek_pos) 0)) +#define seek_begin(fd) (seek_set((fd), (seek_pos)0)) #endif diff --git a/include/select.h b/include/select.h index 646dd50..7257ddd 100644 --- a/include/select.h +++ b/include/select.h @@ -1,11 +1,11 @@ #ifndef SELECT_H #define SELECT_H -#include #include +#include #ifdef HAS_SELECT_H -#include + #include #endif extern int select(); diff --git a/include/sig.h b/include/sig.h index 3efdd32..4d1743d 100644 --- a/include/sig.h +++ b/include/sig.h @@ -17,9 +17,9 @@ extern int sig_term; extern void (*sig_defaulthandler)(); extern void (*sig_ignorehandler)(); -extern void sig_catch(int,void (*)()); -#define sig_ignore(s) (sig_catch((s),sig_ignorehandler)) -#define sig_uncatch(s) (sig_catch((s),sig_defaulthandler)) +extern void sig_catch(int, void (*)()); +#define sig_ignore(s) (sig_catch((s), sig_ignorehandler)) +#define sig_uncatch(s) (sig_catch((s), sig_defaulthandler)) extern void sig_block(int); extern void sig_unblock(int); diff --git a/include/socket_if.h b/include/socket_if.h index 54cfa5f..3681d29 100644 --- a/include/socket_if.h +++ b/include/socket_if.h @@ -18,52 +18,52 @@ * - enlarged usage for ipv4socket -> dual bind IPv4/IPv6 */ -#define __APPLE_USE_RFC_3542 /* MacOS Anycast support */ +#define __APPLE_USE_RFC_3542 /* MacOS Anycast support */ #include "uint_t.h" /* IPv4 only */ -extern int socket_accept4(int,char [4],uint16 *); -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_accept4(int, char[4], uint16 *); +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); /* Backward compatibility */ -#define socket_local4 socket_local +#define socket_local4 socket_local #define socket_remote4 socket_remote /* IPv6 only */ -extern int socket_bind6(int,const char [16],uint16,uint32); -extern int socket_bind6_reuse(int,const char [16],uint16,uint32); -extern int socket_connect6(int,const char [16],uint16,uint32); -extern int socket_send6(int,const char *,unsigned int,const char [16],uint16,uint32); -extern const char* socket_getifname(uint32); +extern int socket_bind6(int, const char[16], uint16, uint32); +extern int socket_bind6_reuse(int, const char[16], uint16, uint32); +extern int socket_connect6(int, const char[16], uint16, uint32); +extern int socket_send6(int, const char *, unsigned int, const char[16], uint16, uint32); +extern const char *socket_getifname(uint32); extern uint32 socket_getifidx(const char *); extern int socket_ip6optionskill(int); extern int socket_ip6anycast(int); /* Common IPv4 & IPv6 */ -extern int socket_accept(int,char [16],uint16 *,uint32 *); -extern int socket_bind(int,const char [16],uint16,uint32); -extern int socket_bind_reuse(int,const char [16],uint16,uint32); -extern int socket_connect(int,const char [16],uint16,uint32); +extern int socket_accept(int, char[16], uint16 *, uint32 *); +extern int socket_bind(int, const char[16], uint16, uint32); +extern int socket_bind_reuse(int, const char[16], uint16, uint32); +extern int socket_connect(int, const char[16], uint16, uint32); extern int socket_connected(int); -extern int socket_listen(int,int); -extern int socket_local(int,char [16],uint16 *,uint32 *); -extern int socket_recv(int,char *,unsigned int,char [16],uint16 *,uint32 *); -extern int socket_remote(int,char [16],uint16 *,uint32 *); -extern int socket_send(int,const char *,unsigned int,const char [16],uint16,uint32); -extern void socket_tryreservein(int,int); +extern int socket_listen(int, int); +extern int socket_local(int, char[16], uint16 *, uint32 *); +extern int socket_recv(int, char *, unsigned int, char[16], uint16 *, uint32 *); +extern int socket_remote(int, char[16], uint16 *, uint32 *); +extern int socket_send(int, const char *, unsigned int, const char[16], uint16, uint32); +extern void socket_tryreservein(int, int); extern int socket_ipoptionskill(int); extern int socket_dualstack(int); extern int socket_nodualstack(int); /* Backward compatibility */ #define socket_accept6 socket_accept -#define socket_local6 socket_local -#define socket_recv6 socket_recv +#define socket_local6 socket_local +#define socket_recv6 socket_recv #define socket_remote6 socket_remote /* TCP */ diff --git a/include/str.h b/include/str.h index fe36d0b..0d74812 100644 --- a/include/str.h +++ b/include/str.h @@ -8,18 +8,18 @@ * - 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_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_chr(const char *,int); -extern unsigned int str_rchr(const char *,int); -extern int str_start(const char *,const char *); -extern char *str_append(char *out,const char *s); +extern unsigned int str_chr(const char *, int); +extern unsigned int str_rchr(const char *, int); +extern int str_start(const char *, const char *); +extern char *str_append(char *out, const char *s); -#define str_equal(s,t) (!str_diff((s),(t))) -#define str_cat(s,t) str_append(s,t) +#define str_equal(s, t) (!str_diff((s), (t))) +#define str_cat(s, t) str_append(s, t) #endif diff --git a/include/stralloc.h b/include/stralloc.h index 0f4a7d2..b472891 100644 --- a/include/stralloc.h +++ b/include/stralloc.h @@ -15,35 +15,35 @@ */ typedef struct stralloc { - char* s; + char *s; size_t len; size_t a; } stralloc; //extern int stralloc_ready(stralloc *,unsigned int); -extern int stralloc_ready(stralloc *sa,size_t len); +extern int stralloc_ready(stralloc *sa, size_t len); //extern int stralloc_readyplus(stralloc *,unsigned int); -extern int stralloc_readyplus(stralloc *sa,size_t len); -extern int stralloc_copy(stralloc *,stralloc *); -extern int stralloc_cat(stralloc *,stralloc *); -extern int stralloc_copys(stralloc *,const char *); -extern int stralloc_cats(stralloc *,const char *); -extern int stralloc_copyb(stralloc *,const char *,unsigned int); -extern int stralloc_catb(stralloc *,const char *,unsigned int); +extern int stralloc_readyplus(stralloc *sa, size_t len); +extern int stralloc_copy(stralloc *, stralloc *); +extern int stralloc_cat(stralloc *, stralloc *); +extern int stralloc_copys(stralloc *, const char *); +extern int stralloc_cats(stralloc *, const char *); +extern int stralloc_copyb(stralloc *, const char *, unsigned int); +extern int stralloc_catb(stralloc *, const char *, unsigned int); //extern int stralloc_append(stralloc *,char *); /* beware: this takes a pointer to 1 char */ -extern int stralloc_append(stralloc *sa,const char *in); /* beware: this takes a pointer to 1 char */ -extern int stralloc_starts(stralloc *,const char *); +extern int stralloc_append(stralloc *sa, const char *in); /* beware: this takes a pointer to 1 char */ +extern int stralloc_starts(stralloc *, const char *); -#define stralloc_0(sa) stralloc_append(sa,"") +#define stralloc_0(sa) stralloc_append(sa, "") -extern int stralloc_catulong0(stralloc *,unsigned long,unsigned int); -extern int stralloc_catlong0(stralloc *,long,unsigned int); +extern int stralloc_catulong0(stralloc *, unsigned long, unsigned int); +extern int stralloc_catlong0(stralloc *, long, unsigned int); extern void stralloc_free(stralloc *); -#define stralloc_catlong(sa,l) (stralloc_catlong0((sa),(l),0)) -#define stralloc_catuint0(sa,i,n) (stralloc_catulong0((sa),(i),(n))) -#define stralloc_catint0(sa,i,n) (stralloc_catlong0((sa),(i),(n))) -#define stralloc_catint(sa,i) (stralloc_catlong0((sa),(i),0)) +#define stralloc_catlong(sa, l) (stralloc_catlong0((sa), (l), 0)) +#define stralloc_catuint0(sa, i, n) (stralloc_catulong0((sa), (i), (n))) +#define stralloc_catint0(sa, i, n) (stralloc_catlong0((sa), (i), (n))) +#define stralloc_catint(sa, i) (stralloc_catlong0((sa), (i), 0)) #endif diff --git a/include/tai.h b/include/tai.h index 37d24e0..99b1a40 100644 --- a/include/tai.h +++ b/include/tai.h @@ -32,7 +32,7 @@ typedef struct tai { } tai64; -#define tai_unix(t,u) ((void) ((t)->x = 4611686018427387914ULL + (uint64) (u))) +#define tai_unix(t, u) ((void)((t)->x = 4611686018427387914ULL + (uint64)(u))) /* tai_now puts the current time into t. More precisely: tai_now puts * into t its best guess as to the TAI64 label for the 1-second interval @@ -46,26 +46,26 @@ void tai_now(struct tai *); /* tai_approx returns a double-precision approximation to t. The result * of tai_approx is always nonnegative. */ -#define tai_approx(t) ((double) ((t)->x)) +#define tai_approx(t) ((double)((t)->x)) /* tai_add adds a to b modulo 2^64 and puts the result into t. The * inputs and output may overlap. */ -void tai_add(struct tai *,const struct tai *,const struct tai *); +void tai_add(struct tai *, const struct tai *, const struct tai *); /* tai_sub subtracts b from a modulo 2^64 and puts the result into t. * The inputs and output may overlap. */ -void tai_sub(struct tai *,const struct tai *,const struct tai *); +void tai_sub(struct tai *, const struct tai *, const struct tai *); /* tai_less returns 1 if a is less than b, 0 otherwise. */ -#define tai_less(t,u) ((t)->x < (u)->x) +#define tai_less(t, u) ((t)->x < (u)->x) #define TAI_PACK 8 /* tai_pack converts a TAI64 label from internal format in t to external * TAI64 format in buf. */ -void tai_pack(char *,const struct tai *); +void tai_pack(char *, const struct tai *); /* tai_unpack converts a TAI64 label from external TAI64 format in buf * to internal format in t. */ -void tai_unpack(const char *,struct tai *); +void tai_unpack(const char *, struct tai *); -void tai_uint(struct tai *,unsigned int); +void tai_uint(struct tai *, unsigned int); #ifdef __cplusplus } diff --git a/include/taia.h b/include/taia.h index 03f455c..2aaad06 100644 --- a/include/taia.h +++ b/include/taia.h @@ -14,27 +14,27 @@ struct taia { struct tai sec; unsigned long nano; /* 0...999999999 */ unsigned long atto; /* 0...999999999 */ -} ; +}; -extern void taia_tai(struct taia *,struct tai *); +extern void taia_tai(struct taia *, struct tai *); extern int taia_now(struct taia *); extern double taia_approx(struct taia *); extern double taia_frac(struct taia *); -extern void taia_add(struct taia *,struct taia *,struct taia *); -extern void taia_sub(struct taia *,struct taia *,struct taia *); -extern void taia_half(struct taia *,struct taia *); -extern int taia_less(struct taia *,struct taia *); +extern void taia_add(struct taia *, struct taia *, struct taia *); +extern void taia_sub(struct taia *, struct taia *, struct taia *); +extern void taia_half(struct taia *, struct taia *); +extern int taia_less(struct taia *, struct taia *); #define TAIA_PACK 16 -extern void taia_pack(char *,struct taia *); -extern void taia_unpack(char *,struct taia *); +extern void taia_pack(char *, struct taia *); +extern void taia_unpack(char *, struct taia *); #define TAIA_FMTFRAC 19 -extern unsigned int taia_fmtfrac(char *,struct taia *); +extern unsigned int taia_fmtfrac(char *, struct taia *); -extern void taia_uint(struct taia *,unsigned int); +extern void taia_uint(struct taia *, unsigned int); #endif diff --git a/include/timeout.h b/include/timeout.h index 1b45e9f..7b1d6b1 100644 --- a/include/timeout.h +++ b/include/timeout.h @@ -1,7 +1,7 @@ #ifndef TIMEOUT_H #define TIMEOUT_H -extern int timeoutread(int,int,char *,int); -extern int timeoutwrite(int,int,char *,int); +extern int timeoutread(int, int, char *, int); +extern int timeoutwrite(int, int, char *, int); #endif diff --git a/include/timeoutconn.h b/include/timeoutconn.h index 308ec5a..6462488 100644 --- a/include/timeoutconn.h +++ b/include/timeoutconn.h @@ -3,8 +3,8 @@ #include "uint_t.h" -extern int timeoutconn4(int,char *,uint16,unsigned int); -extern int timeoutconn6(int,char *,uint16,unsigned int,uint32); -extern int timeoutconn(int,char *,uint16,unsigned int,uint32); +extern int timeoutconn4(int, char *, uint16, unsigned int); +extern int timeoutconn6(int, char *, uint16, unsigned int, uint32); +extern int timeoutconn(int, char *, uint16, unsigned int, uint32); #endif diff --git a/include/uint_t.h b/include/uint_t.h index 84eb06e..aba0f38 100644 --- a/include/uint_t.h +++ b/include/uint_t.h @@ -9,68 +9,67 @@ */ #ifndef UINT8_H -#define UINT8_H + #define UINT8_H -#ifdef HAS_UINT8_H + #ifdef HAS_UINT8_H typedef uint8_t uint8; -#else + #else typedef unsigned char uint8; -#endif + #endif #endif #ifndef UINT16_H -#define UINT16_H + #define UINT16_H typedef uint16_t uint16; -extern void uint16_pack(char *,uint16); -extern void uint16_pack_big(char *,uint16); -extern void uint16_unpack(char *,uint16 *); -extern void uint16_unpack_big(char *,uint16 *); +extern void uint16_pack(char *, uint16); +extern void uint16_pack_big(char *, uint16); +extern void uint16_unpack(char *, uint16 *); +extern void uint16_unpack_big(char *, uint16 *); #endif #ifndef UINT32_H -#define UINT32_H + #define UINT32_H typedef uint32_t uint32; -extern void uint32_pack(char *,uint32); -extern void uint32_pack_big(char *,uint32); -extern void uint32_unpack(char *,uint32 *); -extern void uint32_unpack_big(char *,uint32 *); +extern void uint32_pack(char *, uint32); +extern void uint32_pack_big(char *, uint32); +extern void uint32_unpack(char *, uint32 *); +extern void uint32_unpack_big(char *, uint32 *); #endif #ifndef UINT64_H -#define UINT64_H + #define UINT64_H -#ifdef HAS_UINT64_H + #ifdef HAS_UINT64_H typedef uint64_t uint64; -#else + #else typedef unsigned long long uint64; -#endif + #endif -extern void uint64_pack(char *,uint64); -extern void uint64_pack_big(char *,uint64); -extern void uint64_unpack(char *,uint64 *); -extern void uint64_unpack_big(char *,uint64 *); +extern void uint64_pack(char *, uint64); +extern void uint64_pack_big(char *, uint64); +extern void uint64_unpack(char *, uint64 *); +extern void uint64_unpack_big(char *, uint64 *); #endif #ifndef UINT128_H -#define UINT128_H + #define UINT128_H /* uint128 used for native IPv6 address presentation */ -struct uint128_t -{ - uint64_t hi; /* routing area */ - uint64_t lo; /* local area */ +struct uint128_t { + uint64_t hi; /* routing area */ + uint64_t lo; /* local area */ }; typedef struct uint128_t uint128; -extern void uint128_pack(char *,uint128); -extern void uint128_pack_big(char *,uint128); -extern void uint128_unpack(char *,uint128 *); -extern void uint128_unpack_big(char *,uint128 *); +extern void uint128_pack(char *, uint128); +extern void uint128_pack_big(char *, uint128); +extern void uint128_unpack(char *, uint128 *); +extern void uint128_unpack_big(char *, uint128 *); #endif diff --git a/include/wait.h b/include/wait.h index f7cfc60..af8a979 100644 --- a/include/wait.h +++ b/include/wait.h @@ -7,14 +7,14 @@ @source s/qmail */ -int wait_pid(int *,int); +int wait_pid(int *, int); int wait_nohang(int *); int wait_stop(); int wait_stopnohang(); -#define wait_crashed(w) ((w) & 127) +#define wait_crashed(w) ((w) & 127) #define wait_exitcode(w) ((w) >> 8) -#define wait_stopsig(w) ((w) >> 8) -#define wait_stopped(w) (((w) & 127) == 127) +#define wait_stopsig(w) ((w) >> 8) +#define wait_stopped(w) (((w) & 127) == 127) #endif -- cgit v1.2.3