diff options
author | Jannis Hoffmann <jannis@fehcom.de> | 2024-09-28 21:20:40 +0200 |
---|---|---|
committer | Jannis Hoffmann <jannis@fehcom.de> | 2024-09-28 21:20:40 +0200 |
commit | e36f3367bbc8973889994abea648db8651ad8580 (patch) | |
tree | 04b64ec822f648121c85e4315abd0e386192c008 | |
parent | ccb28724025e886ad7e952f6da28f4a3f3611ea0 (diff) |
update to version 25cjannis
93 files changed, 619 insertions, 532 deletions
@@ -67,3 +67,15 @@ fehQlibs-22a fehQlibs-23 More documentation for dns resolver routines. Added function stralloc_free() which was alreday in the header. +fehQlibs-24 Removed 'register' in functions. Added 'const' for input strings. +fehQlibs-25 Compatibility with current gcc and clang compilers: + (Internal) Unrolling for() loops removed. Internal functions are static now. + (Internal) buffer_init uses now 'buffer_unixread' and 'buffer_unixwrite' with matching signatures. + (External) Added getopb() as external and thus removing getop() compatibility. + (Installation) Moved C source files to ./src. Added INSTALL.md to describe changes. + (Compilation) Added -fwrapv flag to the compiler (correctly handling two's complement). + Open issues: + 'constmap' is struct and function name! + (Internal) alloc_re()'s first argument is now a void pointer to a list [gcc 14.2]. +fehQlibs-25(b) + (Make) conf-build was not called due to move to ./src. Missing dot in ./configure. diff --git a/CONTENT b/CONTENT deleted file mode 100755 index 25fa27d..0000000 --- a/CONTENT +++ /dev/null @@ -1,63 +0,0 @@ -Content of fehQlibs -------------------- - -This list contains the generated archive and supplementary -object files together with their main header files (to be -found under ./include) and man pages (located at ./man). -The list is incomplete. - -Archive/Object | Headers | Description ------------------------------------------------ -alloc.a alloc.h alloc.3 -buffer.a buffer.h buffer.3 - byte.h byte.3 -case.a case.h case.3 -cdb.a cdbmake.h cdbmake.3 - cdbread.h cdbread.3 -constmap.a constmap.h constmap.3 -dnsresolv.a dnsresolv.h dns.3, dnsstub.3 -env.a env.h env.3 -fd.a fd.h fd.3 -fs.a fmt.h fmt.3 - scan.h scan.3 -getln.a getln.h getln.3 -getopt.a getoptb.h getoptb.3 -ip.a ip.h ip4.3, ip6.3 -lock.a lock.h -logmsg.a logmsg.h logmsg.3 - error.h error.3 -ndelay.a ndelay.h -open.a open.h -seek.a seek.h -sig.a sig.h -socket.a socket_if.h socket_bind.3, socket_connect.3 - ip.h socket_if.3, socket_info.3 - socket_recv.3, socket_send.3 - socket_setup.3, socket_tcp.3 - socket_udp.3 -str.a str.h -stralloc.a stralloc.h stralloc.3 -time.a tai.h, taia.3 - timeout.h timeout.3 - timeoutconn.h timeoutconn.3 - iopause.h iopause.3 - select.h -wait.a wait.h wait.3 - -pathexec.o pathexec.h pathexec.3 -prot.o prot.h -byte.o byte.h byte.3 - base64.h -readclose.o readclose.h -uint8p.o uint_t.h -uint16p.o uint_t.h -uint32p.o uint_t.h -uint64p.o uint_t.h -uint128p.o uint_t.h - - -Two main archives are generated: - -- (lib)qlibs.a -- including all above, except for -- (lib)dnsresolv.a -- routines located at ./dnsstub. - diff --git a/CONTENT.md b/CONTENT.md new file mode 100755 index 0000000..ef42b84 --- /dev/null +++ b/CONTENT.md @@ -0,0 +1,63 @@ +Content of fehQlibs +=================== + +This list contains the generated archive and supplementary +object files together with their main header files (to be +found under ./include) and man pages (located at ./man). +The list is incomplete. + + Archive/Object | Headers | Description + ----------------------------------------------- + alloc.a alloc.h alloc.3 + buffer.a buffer.h buffer.3 + byte.h byte.3 + case.a case.h case.3 + cdb.a cdbmake.h cdbmake.3 + cdbread.h cdbread.3 + constmap.a constmap.h constmap.3 + dnsresolv.a dnsresolv.h dns.3, dnsstub.3 + env.a env.h env.3 + fd.a fd.h fd.3 + fs.a fmt.h fmt.3 + scan.h scan.3 + getln.a getln.h getln.3 + getopt.a getoptb.h getoptb.3 + ip.a ip.h ip4.3, ip6.3 + lock.a lock.h + logmsg.a logmsg.h logmsg.3 + error.h error.3 + ndelay.a ndelay.h + open.a open.h + seek.a seek.h + sig.a sig.h + socket.a socket_if.h socket_bind.3, socket_connect.3 + ip.h socket_if.3, socket_info.3 + socket_recv.3, socket_send.3 + socket_setup.3, socket_tcp.3 + socket_udp.3 + str.a str.h + stralloc.a stralloc.h stralloc.3 + time.a tai.h, taia.3 + timeout.h timeout.3 + timeoutconn.h timeoutconn.3 + iopause.h iopause.3 + select.h + wait.a wait.h wait.3 + + pathexec.o pathexec.h pathexec.3 + prot.o prot.h + byte.o byte.h byte.3 + base64.h + readclose.o readclose.h + uint8p.o uint_t.h + uint16p.o uint_t.h + uint32p.o uint_t.h + uint64p.o uint_t.h + uint128p.o uint_t.h + + +Two main archives are generated: + +- (lib)qlibs.a -- including all above, except for +- (lib)dnsresolv.a -- routines located at ./dnsstub. + diff --git a/INSTALL.md b/INSTALL.md new file mode 100644 index 0000000..a372829 --- /dev/null +++ b/INSTALL.md @@ -0,0 +1,116 @@ +fehQlibs installation +===================== + +Configuration +------------- + +Some build options can be configured through 'conf-build'. +Read the comments in this file for more information. + + +Building +-------- + +a) Static libs: + +Execute + + $ make -C src + +which does the steps of './configure && make'. +Don't forget to make sure that libs and headers will be found by the compiler/linker. + +In fehQlibs main directory you will find now + +- libdnsresolv.a +- libqlibs.a + +ready for use. + +b) Shared objects libs: + +You can also build dynamic libaries for qlibs and dnsresolv. After + + $ make -C src + +call + + $ make -C src shared + +Additionally, the files + +- libdnsresolv.so +- libqlibs.so + +are created. + + +Deployment +---------- + +In case 'conf-build' has been customized to include the location of + +- HDRDIR +- LIBDIR + +issue + + $ make -C src install + +to deploy the include files and libs at the given location. +By default, for the libs the parent directory is used. + + +Cleaning +-------- + +Calling + + $ make -C src clean + +will remove the object files in the src directories, but will +leave the generated libraries as they are in the main directory. +They will be overwritten on the next call of make. + + +Verification +------------ + +Check the ELFCLASS of the generated binaries in the src directory while calling + + $ file open.o + +They need to comply with your OS. See 'conf-build' for options. + +* Resulting libraries: + +The following libraries are generated: + +- qlibs.a - static basic [w/o DNS] lib (linked to libqlibs.a) +- dnsresolv.a - static DNS resolver lib (linked to libdnsresolv.a) + +and perhaps + +- libqlibs.so - dynamic, position independent (PIC) 'shared object' lib +- libdnsresolv.so - dynamic, position independent (PIC) 'shared object' lib + +These libs are of type ELF64 or ELF32 depending on the system. + +Use 'ar -t' to get the included members of the static libs. +Use 'nm' to view the members and symbols of the libs. + +The shared object libs are known NOT not work on MacOS. +You might need additional parameters in 'conf-build'. + + +Man pages +--------- + +In the ./man directory the current man pages for the basic qlibs routines are included. +Determine the current $mandir and (as root) install the man pages: + + $ cp *.3 $mandir/man3/ + +----- + +Updated: 20240920, Erwin Hoffmann @@ -1,5 +1,4 @@ /*! \mainpage - qlibs - C library and headers based on "djb's libs" and libowfat ================================================================ @@ -30,82 +29,7 @@ See the README in the ./dnsstub directory for details. Installation ------------ -Some build options can be configured through 'conf-build'. -Read the comments in this file for more information. - -* Building: - -a) Static libs: - -Execute - - $ make - -which does the steps of './configure && make'. -Don't forget to make sure that libs and headers will be found by the compiler/linker. -For convenience, link the current version of fehQlibs to qlibs - - $ ln -s fehQlibs-XY qlibs - -b) Shared objects libs: - -You can also build dynamic libaries for qlibs and dnsresolv. After - - $ make - -call - - $ make shared - -* Deployment: - -In case conf-build has been customized to include the location of - -- HDRDIR -- LIBDIR - -issue - - $ make install - -to deploy the include files and libs at the given location. -By default, for the libs the parent directory is used. - -* Verification: - -Check the ELFCLASS of the generated binaries in the source directory while calling - - $ file open.o - -They need to comply with your OS. See 'conf-build' for options. - -* Resulting libraries: - -The following libraries are generated: - -- qlibs.a - static basic [w/o DNS] lib (linked to libqlibs.a) -- dnsresolv.a - static DNS resolver lib (linked to libdnsresolv.a) - -and perhaps - -- libqlibs.so - dynamic, position independent (PIC) 'shared object' lib -- libdnsresolv.so - dynamic, position independent (PIC) 'shared object' lib - -These libs are of type ELF64 or ELF32 depending on the system. - -Use 'ar -t' to get the included members of the static libs. -Use 'nm' to view the members and symbols of the libs. - -The shared object libs are known NOT not work on MacOS. - - -Man pages ---------- - -In the ./man directory the current man pages for the basic qlibs routines are included. -Determine the current $mandir and (as root) install the man pages: - - $ cp *.3 $mandir/man3/ +Check the INSTALL.md document. Packaging @@ -114,8 +38,8 @@ Packaging The fehQlibs are incompatible with Gentoo's parallel compilation flag '-jN' for N > 1. -Compilation ------------ +Compatibility +------------- Starting with version fehQlibs-15b, GCC 10 and Clang compatibility is provided, which means ISO C conformance. @@ -124,9 +48,15 @@ by the global (external) 'ipv4socket' variable are avoided. stralloc.h is decoupled from genalloc.h (to be included separately). This respects the GCC 10 compilation unit behavior. +fehQlibs-25 provide compatibility with GCC 14 and Clang 18. Under the hood, +the prototypes include now the correct types of arguments (signatures) required +for function pointers. Some warning still exits; some are silly, others need to +be tackled in forthcoming releases. This depends however on the development +of the 'C' standard and the respective 'C' compilers. + ----- Updated: 20170329, Kai Peter -Updated: 20220706, Erwin Hoffmann +Updated: 20240804, Erwin Hoffmann @@ -1 +1 @@ -fehQlibs-23 +fehQlibs-25 @@ -3,7 +3,7 @@ # #******************************************************************************** # default compiler flags - usually this shouldn't be changed -CFLAGS='-O2 -Iinclude -fPIC -Wall' +CFLAGS='-O2 -Iinclude -fPIC -fwrapv -Wall' # under OmniOS the binaries are build as 32 bit version; except enabling this: #CFLAGS='-O2 -Iinclude -Wall -fPIC -m64' @@ -23,7 +23,7 @@ CFLAGS='-O2 -Iinclude -fPIC -Wall' # HDRDIR=$LIBDIR/include - copy all header files into /usr/local/lib/include # LIBDIR=.. -HDRDIR=../include/ +HDRDIR= #******************************************************************************** # Additional libs (object files, delimited by space, enclosed in "'") diff --git a/src/configure b/configure index 47b0f08..47b0f08 100755 --- a/src/configure +++ b/configure diff --git a/include/byte.h b/include/byte.h index 836e8ca..96bbefc 100644 --- a/include/byte.h +++ b/include/byte.h @@ -3,9 +3,8 @@ /** @file byte.h - @author djb, feh - @source s/qmail - @comment no declaration of argument types; too many compiler errors + @authors djb, feh, jmh + @ref s/qmail */ extern unsigned int byte_chr(char *, unsigned int, int); diff --git a/include/constmap.h b/include/constmap.h index 4d5e2d3..723cb6f 100644 --- a/include/constmap.h +++ b/include/constmap.h @@ -13,9 +13,9 @@ struct constmap { int *inputlen; }; -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); +int constmap_init(struct constmap *, char *, int, int); +int constmap_init_char(struct constmap *, char *, int, int, char); +void constmap_free(struct constmap *); +char *constmap(struct constmap *, char *, int); #endif diff --git a/include/exit.h b/include/exit.h index 8e54239..2e1c482 100644 --- a/include/exit.h +++ b/include/exit.h @@ -3,8 +3,8 @@ /** @file exit.h - @author djb, feh - @source qmail + @author djb + @ref qmail @brief convenience header */ diff --git a/include/fifo.h b/include/fifo.h index ad3d15e..c29fc39 100644 --- a/include/fifo.h +++ b/include/fifo.h @@ -3,8 +3,8 @@ /** @file fifo.h - @author djb, feh - @source s/qmail + @author djb + @ref s/qmail */ int fifo_make(char *, int); diff --git a/include/fmt.h b/include/fmt.h index 41acaa1..790a56a 100644 --- a/include/fmt.h +++ b/include/fmt.h @@ -3,8 +3,8 @@ /** @file fmt.h - @author djb, kp, feh - @source qmail + @authors djb, kp, feh + @ref qmail @brief conversion function declarations */ @@ -12,7 +12,7 @@ #define FMT_LEN ((char *)0) /* convenient abbreviation */ extern unsigned int fmt_str(char *, const char *); -extern unsigned int fmt_strn(char *, char *, unsigned int); +extern unsigned int fmt_strn(char *, const 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); diff --git a/include/getoptb.h b/include/getoptb.h index 426567d..ad27f17 100644 --- a/include/getoptb.h +++ b/include/getoptb.h @@ -2,6 +2,8 @@ #define BGETOPT_H /* + * Revision 20240731, Erwin Hoffmann + * - added getoptb() prototype * Revision 20160714, Kai Peter * - consolidated 'sgetopt.h' and 'subgetopt.h' into '(b)getopt.h' */ @@ -15,6 +17,8 @@ #define SUBGETOPTDONE -1 +extern int getoptb(int, char **, char *); + extern int subgetopt(int, char **, char *); extern char *subgetoptarg; extern int subgetoptind; diff --git a/include/lock.h b/include/lock.h index 6abecb7..14f5ff8 100644 --- a/include/lock.h +++ b/include/lock.h @@ -3,8 +3,8 @@ /** @file lock.h - @author djb, feh - @source s/qmail + @author djb + @ref s/qmail */ int lock_ex(int); diff --git a/include/ndelay.h b/include/ndelay.h index 6791c5b..85388a3 100644 --- a/include/ndelay.h +++ b/include/ndelay.h @@ -2,9 +2,9 @@ #define NDELAY_H /** - @brief ndelay.h - @author djb, feh - @source s/qmail + @file ndelay.h + @author djb + @ref s/qmail */ int ndelay_on(int); diff --git a/include/open.h b/include/open.h index c2f272b..5b471a2 100644 --- a/include/open.h +++ b/include/open.h @@ -3,8 +3,8 @@ /** @file open.h - @author djb, feh - @source s/qmail + @authors djb, feh + @ref s/qmail */ int open_read(const char *); diff --git a/include/select.h b/include/select.h index 7257ddd..4f63684 100644 --- a/include/select.h +++ b/include/select.h @@ -8,6 +8,6 @@ #include <sys/select.h> #endif -extern int select(); +extern int select(int, fd_set *, fd_set *, fd_set *, struct timeval *); #endif diff --git a/include/sig.h b/include/sig.h index bd3efc5..276e5b0 100644 --- a/include/sig.h +++ b/include/sig.h @@ -2,6 +2,7 @@ #define SIG_H /* + * Revision 20240720, Erwin Hoffmann, jmh * Revision 20160714, Kai Peter * - updated some declarations no new(er) one's from ucspi-tcp-0.88 */ diff --git a/include/socket_if.h b/include/socket_if.h index 82d091e..3681d29 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_broadcast4(int, const char *, unsigned int, uint16); +extern int socket_broadcast(int, const char *, unsigned int, uint16); /* Backward compatibility */ #define socket_local4 socket_local diff --git a/include/uint_t.h b/include/uint_t.h index 529e7b5..5471813 100644 --- a/include/uint_t.h +++ b/include/uint_t.h @@ -2,8 +2,8 @@ /** @file uint_t.h - @author djb, kp, feh - @source qmail, djbdns6 + @authors djb, kp, feh + @ref qmail, djbdns6 @brief additional types and pack routines @brief define basic integer types and size through <stdint.h> */ @@ -28,10 +28,10 @@ extern void uint8_unpack_big(char *, uint8 *); 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[16], uint16); +extern void uint16_pack_big(char[16], uint16); +extern void uint16_unpack(char[16], uint16 *); +extern void uint16_unpack_big(char[16], uint16 *); #endif #ifndef UINT32_H diff --git a/include/wait.h b/include/wait.h index dd059d9..7de9276 100644 --- a/include/wait.h +++ b/include/wait.h @@ -4,7 +4,7 @@ /** @file wait.h @author djb - @source s/qmail + @ref s/qmail */ int wait_pid(int *, int); @@ -1,9 +1,11 @@ #!/bin/sh -. ./conf-build +# We are in ./src: -install_libs() { cp src/*.a $OFILES "$LIBDIR" ; } -install_hdrs() { cp include/*.h "$HDRDIR" ; } +. ../conf-build + +install_libs() { cp *.a $OFILES "$LIBDIR" ; } +install_hdrs() { cp ../include/*.h "$HDRDIR" ; } echo -n "Installing qlibs ..." mkdir -p "$LIBDIR" "$HDRDIR" 2>/dev/null diff --git a/man/buffer.3 b/man/buffer.3 index 2d4d0d2..331c32e 100644 --- a/man/buffer.3 +++ b/man/buffer.3 @@ -31,9 +31,9 @@ int \fBbuffer_flush\fP(buffer *\fIb\fR); .br int \fBbuffer_copy\fP(buffer *\fIbo\fR,buffer *\fIbi\fR); -int \fBbuffer_unixread\fP(int \fIfd\fR,char *\fIbuf\fR,size_t \fIlen\fR); +ssize_t \fBbuffer_unixread\fP(int \fIfd\fR,char *\fIbuf\fR,size_t \fIlen\fR); .br -int \fBbuffer_unixwrite\fP(int \fIfd\fR,char *\fIbuf\fR,size_t \fIlen\fR); +ssize_t \fBbuffer_unixwrite\fP(int \fIfd\fR,char *\fIbuf\fR,size_t \fIlen\fR); .SH DESCRIPTION .B buffer.h describes a generic buffer interface that can be used for @@ -111,13 +111,17 @@ fills all available space with data before calling copies one buffer to other one. The output buffer needs to have at least the preallocated size of the input buffer. + .B buffer_unixread and .B buffer_unixwrite perform the same operation like standard Unix .B read or -.BR write. +.B write +however provide the function return signature +.IR ssize_t +required to be used with the buffer interface. .SH MACROS Apart from this basic usage, some helpful macro definitions are provided: diff --git a/man/getln.3 b/man/getln.3 index bb4ae7c..01f8b89 100644 --- a/man/getln.3 +++ b/man/getln.3 @@ -4,11 +4,11 @@ getln \ - read one line of data .SH SYNTAX .B #include \(dqgetln.h\(dq -int \fBgetln\fP(&buffer_0,&sa,&match,sep); +int \fBgetln\fP(&buf,&sa,&match,sep); .br -int \fBgetln2\fP(&buffer_0,&sa,&cont,&clen,sep); +int \fBgetln2\fP(&buf,&sa,&cont,&clen,sep); -buffer \fIbuffer_0\fR; +buffer \fIbuf\fR; .br stralloc \fIsa\fR; .br @@ -22,7 +22,7 @@ unsigned int \fIclen\fR; .SH DESCRIPTION .B getln reads a line of characters, terminated by a sep character, from -.IR buffer_0 . +.IR buf . It returns the line in .I sa and sets match to @@ -39,18 +39,18 @@ and sets match to .B getln2 reads a line of characters, terminated by a .I sep -character, from -.IR buffer_0 . +character from +.IR buf . The line is returned in two pieces. The first piece is stored in .IR sa . The second piece is .IR cont , a pointer to .I clen -characters inside the -.I buffer_0 -buffer. The second piece must be copied somewhere else before -.I ss +characters inside +.IR buf . +The second piece must be copied somewhere else before +.I sa is used again. If .B getln2 @@ -64,12 +64,19 @@ and does not set .IR cont . It puts the partial line into .IR sa. +.SH "BUFFER" +.I buf +can be a pre-allocated buffer like +.I buffer_0 +reading from +.I STDIN +or any other explicitly generated buffer on a given file descriptor. .SH "RETURN CODES" .B getln normally returns .IR 0 . If it runs out of memory, or encounters an error from -.IR ss , +.IR sa , it returns .IR -1 , setting @@ -80,17 +87,12 @@ appropriately. normally returns .IR 0 . If it runs out of memory, or encounters an error from -.IR ss , +.IR sa , it returns .IR -1 , setting .I errno appropriately. -.SH NOTE -The input buffer -.I buffer_0 -is already pre-allocated. -It can be used without initialization as synonym for STDIN. .SH CREDITS The .B getln @@ -99,4 +101,4 @@ and man page were taken from Bruce Guenther and originally published by Dan Bernstein for qmail-1.03. .SH SEE ALSO -stralloc(3) +stralloc(3), buffer(3). diff --git a/man/getoptb.3 b/man/getoptb.3 index f3e329b..1c5522a 100644 --- a/man/getoptb.3 +++ b/man/getoptb.3 @@ -5,7 +5,7 @@ getoptb \- get option character from command line .B #include \(dqgetoptb.h\(dq .SH DESCRIPTION Qlib's -.B getopt +.B getoptb is a replacement for the standard Unix .B getopt library, based on diff --git a/src/Makefile b/src/Makefile index 4685a0a..1ac0c88 100644 --- a/src/Makefile +++ b/src/Makefile @@ -4,15 +4,15 @@ COMPILE = ./compile MAKELIB = ./makelib SHAREDLIB = ./sharedlib -CCFLAGS = -Iinclude +CCFLAGS = -I../include default: clean check libs check: - @[ -f $(COMPILE) ] && [ -f $(MAKELIB) ] || ./configure + @[ -f $(COMPILE) ] && [ -f $(MAKELIB) ] || ../configure clean: - @echo -n Cleaning up libs ... + @echo "Cleaning up libs ..." @rm -f `cat TARGETS` @$(MAKE) -C dnsstub -s clean @echo " done!" @@ -31,22 +31,26 @@ obj: install: setup setup: - @./install + @../install shared: $(COMPILE) $(SHAREDLIB) $(OBJS) ./dnsstub/$(OBJS) - @echo Building shared qlibs ... + @echo "Building shared qlibs ..." $(SHAREDLIB) $(LDFLAGS) $(OBJS) -o libqlibs.so $(SHAREDLIB) $(LDFLAGS) ./dnsstub/$(OBJS) -o libdnsresolv.so + @ln -f libqlibs.so ../libqlibs.so + @ln -f libdnsresolv.so ../libdnsresolv.so + qlibs.a: obj socket.a $(MAKELIB) $(LDFLAGS) qlibs.a *.o - ln -sf qlibs.a libqlibs.a + @echo "Creating libqlibs ... " + @ln -f qlibs.a ../libqlibs.a -dnsresolv.a: +dnsresolv.a: @echo "Building @dnsresolv lib ..." - @$(MAKE) -C dnsstub + @cd dnsstub ; make @cp dnsstub/dnsresolv.a dnsresolv.a - ln -sf dnsresolv.a libdnsresolv.a + @ln -f dnsresolv.a ../libdnsresolv.a socket.a: ip.a @echo "Building socket lib ..." diff --git a/src/TARGETS b/src/TARGETS index df6d6ee..4341e72 100644 --- a/src/TARGETS +++ b/src/TARGETS @@ -46,6 +46,7 @@ readclose.o scan.o seek.a seek.o +sharedlib sig.a sig.o socket.a diff --git a/src/alloc.c b/src/alloc.c index 7e4ccb4..ea19e8e 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -8,13 +8,21 @@ #define ALIGNMENT 16 /* XXX: assuming that this alignment is enough */ #define SPACE 4096 /* must be multiple of ALIGNMENT */ +#define space ((char *)realspace) + +/** + @file alloc.c + @authors djb, feh, jmh + @ref qmail + @brief Generic allocation of heap memory +*/ typedef union { char irrelevant[ALIGNMENT]; double d; } aligned; + static aligned realspace[SPACE / ALIGNMENT]; -#define space ((char *)realspace) static unsigned int avail = SPACE; /* multiple of ALIGNMENT; 0<=avail<=SPACE */ void *alloc(unsigned int n) diff --git a/src/base64.c b/src/base64.c index 17847d9..3bb76d4 100644 --- a/src/base64.c +++ b/src/base64.c @@ -6,7 +6,6 @@ /** @file base64.c @author unkown - @source unknown @brief base64 en+decoding of strings */ diff --git a/src/buffer.c b/src/buffer.c index f094213..68327b8 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -27,16 +27,26 @@ static ssize_t buffer_0_read(int fd, char *buf, size_t len) return read(fd, buf, len); } +ssize_t buffer_unixread(int fd, char *buf, size_t len) +{ + return (ssize_t)read(fd, buf, len); +} + +ssize_t buffer_unixwrite(int fd, char *buf, size_t len) +{ + return (ssize_t)write(fd, buf, len); +} + char buffer_0_space[BUFFER_INSIZE]; static buffer it0 = BUFFER_INIT(buffer_0_read, 0, buffer_0_space, sizeof(buffer_0_space)); buffer *buffer_0 = &it0; char buffer_1_space[BUFFER_OUTSIZE]; -static buffer it1 = BUFFER_INIT(write, 1, buffer_1_space, sizeof(buffer_1_space)); +static buffer it1 = BUFFER_INIT(buffer_unixwrite, 1, buffer_1_space, sizeof(buffer_1_space)); buffer *buffer_1 = &it1; char buffer_2_space[BUFFER_OUTSIZE]; -static buffer it2 = BUFFER_INIT(write, 2, buffer_2_space, sizeof(buffer_2_space)); +static buffer it2 = BUFFER_INIT(buffer_unixwrite, 2, buffer_2_space, sizeof(buffer_2_space)); buffer *buffer_2 = &it2; char buffer_0_small[BUFFER_SMALL]; @@ -44,23 +54,13 @@ static buffer is0 = BUFFER_INIT(buffer_0_read, 0, buffer_0_small, sizeof(buffer_ buffer *buffer_0small = &is0; char buffer_1_small[BUFFER_SMALL]; -static buffer is1 = BUFFER_INIT(write, 1, buffer_1_small, sizeof(buffer_1_small)); +static buffer is1 = BUFFER_INIT(buffer_unixwrite, 1, buffer_1_small, sizeof(buffer_1_small)); buffer *buffer_1small = &is1; char buffer_2_small[BUFFER_SMALL]; -static buffer is2 = BUFFER_INIT(write, 2, buffer_2_small, sizeof(buffer_2_small)); +static buffer is2 = BUFFER_INIT(buffer_unixwrite, 2, buffer_2_small, sizeof(buffer_2_small)); buffer *buffer_2small = &is2; -ssize_t buffer_unixread(int fd, char *buf, size_t len) -{ - return read(fd, buf, len); -} - -ssize_t buffer_unixwrite(int fd, char *buf, size_t len) -{ - return write(fd, buf, len); -} - int buffer_copy(buffer *bout, buffer *bin) { int n; @@ -12,60 +12,63 @@ unsigned int byte_chr(char *s, unsigned int n, int c) char *t = s; for (;;) { - // clang-format off - if (!n) { break; } if (*t == ch) { break; } ++t; --n; - if (!n) { break; } if (*t == ch) { break; } ++t; --n; - if (!n) { break; } if (*t == ch) { break; } ++t; --n; - if (!n) { break; } if (*t == ch) { break; } ++t; --n; - // clang-format on + if (!n) { + break; + } + if (*t == ch) { + break; + } + ++t; + --n; } return t - s; } -void byte_copy(void *a, unsigned int n, const void *b) +void byte_copy(void *to, unsigned int n, const void *from) { - char *to = a; - const char *from = b; + char *out = to; // share same address + const char *in = from; // one byte for (;;) { - // clang-format off - if (!n) { return; } *to++ = *from++; --n; - if (!n) { return; } *to++ = *from++; --n; - if (!n) { return; } *to++ = *from++; --n; - if (!n) { return; } *to++ = *from++; --n; - // clang-format on + if (!n) { + return; + } + *out++ = *in++; + --n; } } -void byte_copyr(void *a, unsigned int n, const void *b) +void byte_copyr(void *to, unsigned int n, const void *from) { - char *to = a + n; - const char *from = b + n; + char *out = to + n; + const char *in = from + n; for (;;) { - // clang-format off - if (!n) { return; } *--to = *--from; --n; - if (!n) { return; } *--to = *--from; --n; - if (!n) { return; } *--to = *--from; --n; - if (!n) { return; } *--to = *--from; --n; - // clang-format on + if (!n) { + return; + } + *--out = *--in; + --n; } } -int byte_diff(const void *a, unsigned int n, const void *b) +int byte_diff(const void *s, unsigned int n, const void *t) { - const char *s = a; - const char *t = b; + const char *a = s; + const char *b = t; for (;;) { - // clang-format off - if (!n) { return 0; } if (*s != *t) { break; } ++s; ++t; --n; - if (!n) { return 0; } if (*s != *t) { break; } ++s; ++t; --n; - if (!n) { return 0; } if (*s != *t) { break; } ++s; ++t; --n; - if (!n) { return 0; } if (*s != *t) { break; } ++s; ++t; --n; - // clang-format on + if (!n) { + return 0; + } + if (*a != *b) { + break; + } + ++a; + ++b; + --n; } - return ((int)(unsigned int)(unsigned char)*s) - ((int)(unsigned int)(unsigned char)*t); + return ((int)(unsigned int)(unsigned char)*a) - ((int)(unsigned int)(unsigned char)*b); } unsigned int byte_rchr(char *s, unsigned int n, int c) @@ -75,42 +78,44 @@ unsigned int byte_rchr(char *s, unsigned int n, int c) char *u = 0; for (;;) { - // clang-format off - if (!n) { break; } if (*t == ch) { u = t; } ++t; --n; - if (!n) { break; } if (*t == ch) { u = t; } ++t; --n; - if (!n) { break; } if (*t == ch) { u = t; } ++t; --n; - if (!n) { break; } if (*t == ch) { u = t; } ++t; --n; - // clang-format on + if (!n) { + break; + } + if (*t == ch) { + u = t; + } + ++t; + --n; + } + if (!u) { + u = t; } - if (!u) u = t; return u - s; } -void byte_zero(void *v, unsigned int n) +void byte_zero(void *s, unsigned int n) { - char *s = v; + char *out = s; for (;;) { - // clang-format off - if (!n) { break; } *s++ = 0; --n; - if (!n) { break; } *s++ = 0; --n; - if (!n) { break; } *s++ = 0; --n; - if (!n) { break; } *s++ = 0; --n; - // clang-format on + if (!n) { + break; + } + *out++ = 0; + --n; } } -void byte_fill(void *a, unsigned int n, int c) +void byte_fill(void *to, unsigned int n, int c) { - char *s = a; + char *s = to; char ch = c; for (;;) { - // clang-format off - if (!n) { break; } *s++ = ch; --n; - if (!n) { break; } *s++ = ch; --n; - if (!n) { break; } *s++ = ch; --n; - if (!n) { break; } *s++ = ch; --n; - // clang-format on + if (!n) { + break; + } + *s++ = ch; + --n; } } diff --git a/src/cdbmake.c b/src/cdbmake.c index d1464d1..d4d9270 100644 --- a/src/cdbmake.c +++ b/src/cdbmake.c @@ -10,7 +10,7 @@ /** @file cdbmake.c @author djb - @source ucspi-tcp + @ref ucspi-tcp @brief constant data base (cdb) generation */ diff --git a/src/cdbread.c b/src/cdbread.c index 8ba920c..6f985f8 100644 --- a/src/cdbread.c +++ b/src/cdbread.c @@ -12,7 +12,7 @@ /** @file cdbread.c @author djb - @source ucspi-tcp, fastforward + @ref ucspi-tcp, fastforward @brief read entries from a cdb */ diff --git a/src/constmap.c b/src/constmap.c index 360d6f5..13df324 100644 --- a/src/constmap.c +++ b/src/constmap.c @@ -3,6 +3,15 @@ #include "alloc.h" #include "case.h" +/** + @file constmap.c + @author djb + @ref qmail + @brief constant hash table + @brief Attention! constmap is both function and struct +*/ + + static constmap_hash hash(char *s, int len) { unsigned char ch; diff --git a/src/dnsstub/Makefile b/src/dnsstub/Makefile index 6963fe0..47634b5 100644 --- a/src/dnsstub/Makefile +++ b/src/dnsstub/Makefile @@ -5,7 +5,7 @@ CCFLAGS=-I../../include default: clean check dnsresolv.a check: - @[ -f $(COMPILE) ] && [ -f $(MAKELIB) ] || (cd .. && ./configure) + @[ -f $(COMPILE) ] && [ -f $(MAKELIB) ] || (cd ../../ && ./configure) clean: rm -f `cat TARGETS` diff --git a/src/dnsstub/dns_dfd.c b/src/dnsstub/dns_dfd.c index 832bd6e..772dbc3 100644 --- a/src/dnsstub/dns_dfd.c +++ b/src/dnsstub/dns_dfd.c @@ -4,10 +4,10 @@ #include "error.h" /** - @file dns_dfd.c - @author djb - @source ucspi-tcp - @brief domain name qualification (domain from dot) + @file dns_dfd.c + @author djb + @ref ucspi-tcp + @brief domain name qualification (domain from dot) */ int dns_domain_fromdot(char **out, const char *buf, unsigned int n) diff --git a/src/dnsstub/dns_domain.c b/src/dnsstub/dns_domain.c index dcdf2f2..6c6228d 100644 --- a/src/dnsstub/dns_domain.c +++ b/src/dnsstub/dns_domain.c @@ -4,10 +4,10 @@ #include "dnsresolv.h" /** - @file dns_domain.c - @author djb - @source ucspi-tcp - @brief domain qualification + @file dns_domain.c + @author djb + @ref ucspi-tcp + @brief domain qualification */ unsigned int dns_domain_length(const char *dn) diff --git a/src/dnsstub/dns_dtda.c b/src/dnsstub/dns_dtda.c index f1b7d58..5da6186 100644 --- a/src/dnsstub/dns_dtda.c +++ b/src/dnsstub/dns_dtda.c @@ -2,10 +2,10 @@ #include "stralloc.h" /** - @file dns_dtda.c - @author djb - @source ucspi-tcp - @brief domain to dot append + @file dns_dtda.c + @author djb + @ref ucspi-tcp + @brief domain to dot append */ int dns_domain_todot_cat(stralloc *out, const char *d) diff --git a/src/dnsstub/dns_ip.c b/src/dnsstub/dns_ip.c index 913c310..88f12b3 100644 --- a/src/dnsstub/dns_ip.c +++ b/src/dnsstub/dns_ip.c @@ -5,10 +5,10 @@ #include "uint_t.h" /** - @file dns_ip.c - @author djb, fefe, feh - @source ucspi-tcp6 - @brief DNS IP query + @file dns_ip.c + @authors djb, fefe, feh + @ref ucspi-tcp6 + @brief DNS IP query */ static char *q = 0; diff --git a/src/dnsstub/dns_ipq.c b/src/dnsstub/dns_ipq.c index 49049b5..2bfd97e 100644 --- a/src/dnsstub/dns_ipq.c +++ b/src/dnsstub/dns_ipq.c @@ -7,9 +7,9 @@ #include "stralloc.h" /** - @file dns_ipq.c - @author djb, feh - @source ucspi-tcp + @file dns_ipq.c + @authors djb, feh + @ref ucspi-tcp @brief DNS hostname qualification for ipv4 and ipv6 */ diff --git a/src/dnsstub/dns_mx.c b/src/dnsstub/dns_mx.c index 967999e..5cf7a62 100644 --- a/src/dnsstub/dns_mx.c +++ b/src/dnsstub/dns_mx.c @@ -6,7 +6,7 @@ /** @file dns_mx.c @author djb - @source qmail + @ref qmail @brief dns MX query @param (on output) stralloc out */ diff --git a/src/dnsstub/dns_name.c b/src/dnsstub/dns_name.c index 1802143..f77cbe1 100644 --- a/src/dnsstub/dns_name.c +++ b/src/dnsstub/dns_name.c @@ -5,10 +5,10 @@ #include "uint_t.h" /** - @file dns_name.c - @author djb, fefe, feh - @source ucspi-tcp - @brief DNS name query (ptr) + @file dns_name.c + @authors djb, fefe, feh + @ref ucspi-tcp + @brief DNS name query (ptr) */ static char *q = 0; diff --git a/src/dnsstub/dns_nd.c b/src/dnsstub/dns_nd.c index b8e153a..a5f9cc7 100644 --- a/src/dnsstub/dns_nd.c +++ b/src/dnsstub/dns_nd.c @@ -5,8 +5,8 @@ /** @file dns_nd.c - @autor djb, fefe - @source ucspi-tcp + @authors djb, fefe + @ref ucspi-tcp @brief DNS domain name for ip (wire format) */ diff --git a/src/dnsstub/dns_packet.c b/src/dnsstub/dns_packet.c index 66d6196..d654a84 100644 --- a/src/dnsstub/dns_packet.c +++ b/src/dnsstub/dns_packet.c @@ -2,11 +2,11 @@ #include "error.h" /** - @file dns_packet.c - @author djb - @source ucspi-tcp - @brief DNS low level packet routine - @brief DNS should have used LZ77 instead of its own sophomoric compression algorithm. + @file dns_packet.c + @author djb + @ref ucspi-tcp + @brief DNS low level packet routine + @brief DNS should have used LZ77 instead of its own sophomoric compression algorithm. */ unsigned int dns_packet_copy( diff --git a/src/dnsstub/dns_random.c b/src/dnsstub/dns_random.c index d345c78..fede312 100644 --- a/src/dnsstub/dns_random.c +++ b/src/dnsstub/dns_random.c @@ -5,10 +5,10 @@ #include "uint_t.h" /** - @file dns_random.c - @author djb - @source ucspi-tcp - @brief random use of DNS resolvers given their IP + @file dns_random.c + @author djb + @ref ucspi-tcp + @brief random use of DNS resolvers given their IP */ static uint32 seed[32]; diff --git a/src/dnsstub/dns_rcip.c b/src/dnsstub/dns_rcip.c index 2d6ad08..ca09ad2 100644 --- a/src/dnsstub/dns_rcip.c +++ b/src/dnsstub/dns_rcip.c @@ -9,7 +9,7 @@ /** @file dns_rcip.c @author djb, fefe, feh - @source ucspi-tcp + @ref ucspi-tcp @brief DNS receive for query */ diff --git a/src/dnsstub/dns_rcrw.c b/src/dnsstub/dns_rcrw.c index 95239a2..ba8daa0 100644 --- a/src/dnsstub/dns_rcrw.c +++ b/src/dnsstub/dns_rcrw.c @@ -10,7 +10,7 @@ /** @file dns_rcrw.c @author djb - @source ucspi-tcp + @ref ucspi-tcp @brief DNS receive rewrite */ diff --git a/src/dnsstub/dns_resolve.c b/src/dnsstub/dns_resolve.c index 6257b08..bb688a2 100644 --- a/src/dnsstub/dns_resolve.c +++ b/src/dnsstub/dns_resolve.c @@ -6,8 +6,8 @@ /** @file dns_resolve.c - @author djb, fefe, feh - @source ucspi-tcp + @authors djb, fefe, feh + @ref ucspi-tcp @brief high-level DNS resolve function */ diff --git a/src/dnsstub/dns_sortip.c b/src/dnsstub/dns_sortip.c index f319f53..dd3eb17 100644 --- a/src/dnsstub/dns_sortip.c +++ b/src/dnsstub/dns_sortip.c @@ -5,7 +5,7 @@ /** @file dns_sortip.c @authors djb, fefe, feh - @source ucspi-tcp6 + @ref ucspi-tcp6 @brief random sort of DNS servers per IP */ diff --git a/src/dnsstub/dns_transmit.c b/src/dnsstub/dns_transmit.c index bc37791..49cc18e 100644 --- a/src/dnsstub/dns_transmit.c +++ b/src/dnsstub/dns_transmit.c @@ -13,7 +13,7 @@ /** @file dns_transmit.c @authors djb, fefe, feh - @source qlibs + @ref qlibs @brief DNS query function @brief scope_ids[32] -> 32 LLU root servers supported */ diff --git a/src/dnsstub/dns_txt.c b/src/dnsstub/dns_txt.c index 8368a05..cead0d8 100644 --- a/src/dnsstub/dns_txt.c +++ b/src/dnsstub/dns_txt.c @@ -3,6 +3,13 @@ #include "stralloc.h" #include "uint_t.h" +/** + @file dns_txt.c + @authors djb, fefe, feh + @ref ucspi-tcp + @brief DNS text query (txt) +*/ + int dns_txt_packet(stralloc *out, const char *buf, unsigned int len) { unsigned int pos; @@ -6,7 +6,7 @@ /** @file env.c @author djb - @source ucspi-tcp + @ref ucspi-tcp @brief setting up environment after fork */ @@ -111,7 +111,7 @@ int env_put(char *name, char *value) return 1; } -int env_init(void) +int env_init() { char **newenviron; int i; diff --git a/src/errstr.c b/src/errstr.c index e2807ef..7de2cd7 100644 --- a/src/errstr.c +++ b/src/errstr.c @@ -3,7 +3,7 @@ /** @file errstr.c @author kp - @source qlibs + @ref qlibs @brief error output to log for different conditions and OS */ @@ -5,7 +5,7 @@ /** @file fd.c @autor djb - @source qmail + @ref qmail @brief file descriptor manipulation */ @@ -2,8 +2,8 @@ /** @file fmt.c - @author djb - @source qmail + @authors djb, feh + @ref qmail @brief formating differnt inputs format for output printing */ @@ -20,7 +20,7 @@ unsigned int fmt_str(char *s, const char *t) return len; } -unsigned int fmt_strn(char *s, char *t, unsigned int n) +unsigned int fmt_strn(char *s, const char *t, unsigned int n) { unsigned int len; char ch; diff --git a/src/getln.c b/src/getln.c index 476e197..f1e059c 100644 --- a/src/getln.c +++ b/src/getln.c @@ -5,8 +5,8 @@ /** @file getln.c @author djb - @source qmail - @brief evaluting tokenized input arguments + @ref qmail + @brief evaluating tokenized input arguments */ int getln(buffer *b, stralloc *sa, int *match, int sep) diff --git a/src/getoptb.c b/src/getoptb.c index e0f6118..f64d0ef 100644 --- a/src/getoptb.c +++ b/src/getoptb.c @@ -5,7 +5,7 @@ /** @file getoptb.c @author djb - @source ucspi-tcp + @ref ucspi-tcp @brief 'getopt' version w/o stdlib */ @@ -15,7 +15,7 @@ int opterr = 1; char *optprogname = 0; -static int getopt(int argc, char **argv, char *opts) +int getoptb(int argc, char **argv, char *opts) { int c; char *s; diff --git a/src/iopause.c b/src/iopause.c index 9c160ac..b8614b2 100644 --- a/src/iopause.c +++ b/src/iopause.c @@ -8,7 +8,7 @@ /** @file iopause.c @author djb - @source qmail + @ref qmail @brief stateful reading from net @return > 0 if successful */ @@ -5,19 +5,18 @@ /** @file ip4.c - @author djb, fefe, feh, kp - @source ucspi-tcp, ucspi-tcp6 + @authors djb, fefe, feh, kp + @ref ucspi-tcp, ucspi-tcp6 @brief handling of IPv4 addresses */ /** - @brief ip4_fmt - converts IPv4 address to dotted decimal string format - @param input: IPv4 char array - output: IPv4 address string - @return int length of address (ok > 0) - */ - + * @brief ip4_fmt + * converts IPv4 address to dotted decimal string format + * @param input: IPv4 char array + * output: IPv4 address string + * @return int length of address (ok > 0) + */ unsigned int ip4_fmt(char *s, char ip[4]) { unsigned int len; @@ -25,25 +24,24 @@ unsigned int ip4_fmt(char *s, char ip[4]) len = 0; // clang-format off - i = fmt_ulong(s,(unsigned long) (unsigned char) ip[0]); len += i; if (s) s += i; + i = fmt_ulong(s, (unsigned long)(unsigned char)ip[0]); len += i; if (s) s += i; if (s) { *s++ = '.'; } ++len; - i = fmt_ulong(s,(unsigned long) (unsigned char) ip[1]); len += i; if (s) s += i; + i = fmt_ulong(s, (unsigned long)(unsigned char)ip[1]); len += i; if (s) s += i; if (s) { *s++ = '.'; } ++len; - i = fmt_ulong(s,(unsigned long) (unsigned char) ip[2]); len += i; if (s) s += i; + i = fmt_ulong(s, (unsigned long)(unsigned char)ip[2]); len += i; if (s) s += i; if (s) { *s++ = '.'; } ++len; - i = fmt_ulong(s,(unsigned long) (unsigned char) ip[3]); len += i; if (s) s += i; + i = fmt_ulong(s, (unsigned long)(unsigned char)ip[3]); len += i; if (s) s += i; // clang-format on return len; } /** - @brief ia4_fmt - converts IPv4 address into DNS inverse nibble format - @param input: IPv4 char array - output: IPv4 address string - @return int length of address (ok > 0) - */ - + * @brief ia4_fmt + * converts IPv4 address into DNS inverse nibble format + * @param input: IPv4 char array + * output: IPv4 address string + * @return int length of address (ok > 0) + */ unsigned int ia4_fmt(char *s, char ip[4]) { unsigned int i; @@ -51,26 +49,25 @@ unsigned int ia4_fmt(char *s, char ip[4]) len = 0; // clang-format off - i = fmt_ulong(s,(unsigned long) ip[3]); len += i; if (s) s += i; - i = fmt_str(s,"."); len += i; if (s) s += i; - i = fmt_ulong(s,(unsigned long) ip[2]); len += i; if (s) s += i; - i = fmt_str(s,"."); len += i; if (s) s += i; - i = fmt_ulong(s,(unsigned long) ip[1]); len += i; if (s) s += i; - i = fmt_str(s,"."); len += i; if (s) s += i; - i = fmt_ulong(s,(unsigned long) ip[0]); len += i; if (s) s += i; - i = fmt_str(s,".in-addr.arpa."); len += i; if (s) s += i; + i = fmt_ulong(s, (unsigned long)ip[3]); len += i; if (s) s += i; + i = fmt_str(s, "."); len += i; if (s) s += i; + i = fmt_ulong(s, (unsigned long)ip[2]); len += i; if (s) s += i; + i = fmt_str(s, "."); len += i; if (s) s += i; + i = fmt_ulong(s, (unsigned long)ip[1]); len += i; if (s) s += i; + i = fmt_str(s, "."); len += i; if (s) s += i; + i = fmt_ulong(s, (unsigned long)ip[0]); len += i; if (s) s += i; + i = fmt_str(s, ".in-addr.arpa."); len += i; if (s) s += i; // clang-format on return len; } /** - @brief ip4_scan - parse IPv4 address string and convert to IP address array - @param input: IPv4 address string - output: IPv4 char array - @return int length of ip_address (ok > 0) - */ - + * @brief ip4_scan + * parse IPv4 address string and convert to IP address array + * @param input: IPv4 address string + * output: IPv4 char array + * @return int length of ip_address (ok > 0) + */ unsigned int ip4_scan(const char *s, char ip[4]) { unsigned int i; @@ -80,25 +77,24 @@ unsigned int ip4_scan(const char *s, char ip[4]) byte_zero(ip, 4); len = 0; // clang-format off - i = scan_ulong((char *)s,&u); if (!i) { return 0; } ip[0] = u; s += i; len += i; + i = scan_ulong((char *)s, &u); if (!i) { return 0; } ip[0] = u; s += i; len += i; if (*s != '.') { return 0; } ++s; ++len; - i = scan_ulong((char *)s,&u); if (!i) { return 0; } ip[1] = u; s += i; len += i; + i = scan_ulong((char *)s, &u); if (!i) { return 0; } ip[1] = u; s += i; len += i; if (*s != '.') { return 0; } ++s; ++len; - i = scan_ulong((char *)s,&u); if (!i) { return 0; } ip[2] = u; s += i; len += i; + i = scan_ulong((char *)s, &u); if (!i) { return 0; } ip[2] = u; s += i; len += i; if (*s != '.') { return 0; } ++s; ++len; - i = scan_ulong((char *)s,&u); if (!i) { return 0; } ip[3] = u; s += i; len += i; + i = scan_ulong((char *)s, &u); if (!i) { return 0; } ip[3] = u; s += i; len += i; // clang-format on return len; } /** - @brief ip4_scanbracket - parse IPv4 address string enclosed in brackets and convert to IP address array - @param input: IPv4 char array - output: IPv4 char array - @return int length of ip_address (ok > 0) - */ - + * @brief ip4_scanbracket + * parse IPv4 address string enclosed in brackets and convert to IP address array + * @param input: IPv4 char array + * output: IPv4 char array + * @return int length of ip_address (ok > 0) + */ unsigned int ip4_scanbracket(const char *s, char ip[4]) { unsigned int len; @@ -111,14 +107,13 @@ unsigned int ip4_scanbracket(const char *s, char ip[4]) } /** - @brief ip4_cidr - parse IPv4 address string - concatinated with the prefix length: 192.168.1/24 - @param input: IPv6 char array - output: IPv6 char array, long plen - @return int length of ip6_address/ip - */ - + * @brief ip4_cidr + * parse IPv4 address string + * concatinated with the prefix length: 192.168.1/24 + * @param input: IPv6 char array + * output: IPv6 char array, long plen + * @return int length of ip6_address/ip + */ unsigned int ip4_cidr(char *s, char ip[4], unsigned long *plen) { unsigned int j = 0; @@ -133,13 +128,12 @@ unsigned int ip4_cidr(char *s, char ip[4], unsigned long *plen) } /** - @brief ip4_bytestring - parse IPv4 address and represent as char string with length prefix - @param input: IPv4 char array, prefix length - output: pointer to stralloc bytestring - @return n: number of bytes, if ok; -1: memory shortage; -2: input error - */ - + * @brief ip4_bytestring + * parse IPv4 address and represent as char string with length prefix + * @param input: IPv4 char array, prefix length + * output: pointer to stralloc bytestring + * @return n: number of bytes, if ok; -1: memory shortage; -2: input error + */ unsigned int ip4_bytestring(stralloc *ipstring, char ip[4], int prefix) { int i, j, n = 0; @@ -6,19 +6,18 @@ /** @file ip6.c - @author djb, fefe, feh - @source ucspi-tcp, ucspi-tcp6 + @authors djb, fefe, feh + @ref ucspi-tcp, ucspi-tcp6 @brief handling of IPv6 addresses */ -/*** - @brief ip6_fmt - convert IPv6 address to compactified IPv6 address string - @param input: IPv6 char array - output: pointer to IPv6 address string - @return int length of address (ok > 0) - */ - +/** + @brief ip6_fmt + convert IPv6 address to compactified IPv6 address string + @param input: IPv6 char array + output: pointer to IPv6 address string + @return int length of address (ok > 0) +*/ unsigned int ip6_fmt(char *s, char ip[16]) { unsigned int len; @@ -76,14 +75,13 @@ unsigned int ip6_fmt(char *s, char ip[16]) return len; } -/*** - @brief ip6_fmt_flat - convert IPv6 address to IPv6 address string - @param input: IPv6 char array - output: pointer to IPv6 address string - @return int length of address (ok > 0) - */ - +/** + * @brief ip6_fmt_flat + * convert IPv6 address to IPv6 address string + * @param input: IPv6 char array + * output: pointer to IPv6 address string + * @return int length of address (ok > 0) + */ unsigned int ip6_fmt_flat(char *s, char ip[16]) { int i; @@ -95,13 +93,13 @@ unsigned int ip6_fmt_flat(char *s, char ip[16]) } /** - @brief ia6_fmt - convert IPv6 address to inverse DNS nibble format - 1.2.3.4.5.6.7.8.9.a.b.c.d.e.f.1.2.3.4.5.6.7.8.9.a.b.c.d.e.f.ip6.arpa - @param input: IPv6 char array - output: pointer to IPv6 address string - @return int length of address -*/ + * @brief ia6_fmt + * convert IPv6 address to inverse DNS nibble format + * 1.2.3.4.5.6.7.8.9.a.b.c.d.e.f.1.2.3.4.5.6.7.8.9.a.b.c.d.e.f.ip6.arpa + * @param input: IPv6 char array + * output: pointer to IPv6 address string + * @return int length of address + */ unsigned int ia6_fmt(char *s, char ip[16]) { unsigned int i; @@ -132,15 +130,13 @@ unsigned int ia6_fmt(char *s, char ip[16]) return len; } - -/*** - @brief ip6_scan_flat - convert IPv6 address string to IPv6 address array - @param input: pointer to IPv6 address string - output: IPv6 char array - @return int length of address (ok > 0) - */ - +/** + * @brief ip6_scan_flat + * convert IPv6 address string to IPv6 address array + * @param input: pointer to IPv6 address string + * output: IPv6 char array + * @return int length of address (ok > 0) + */ unsigned int ip6_scan_flat(const char *s, char ip[16]) { int i, tmp; @@ -156,14 +152,13 @@ unsigned int ip6_scan_flat(const char *s, char ip[16]) return 32; } -/*** - @brief ip6_scan - parse compactified IPv6 address string and convert to IPv6 address array - @param input: pointer to IPv6 address string - output: IPv6 char array - @return int length of ip6_address/ip - */ - +/** + * @brief ip6_scan + * parse compactified IPv6 address string and convert to IPv6 address array + * @param input: pointer to IPv6 address string + * output: IPv6 char array + * @return int length of ip6_address/ip + */ unsigned int ip6_scan(const char *s, char ip[16]) { unsigned int i, j; @@ -251,14 +246,13 @@ unsigned int ip6_scan(const char *s, char ip[16]) return len; } -/*** - @brief ip6_scanbracket - parse IPv6 string address enclosed in brackets - @param input: pointer to IPv6 address string - output: IPv6 char array - @return int length of ip_address (ok > 0) - */ - +/** + * @brief ip6_scanbracket + * parse IPv6 string address enclosed in brackets + * @param input: pointer to IPv6 address string + * output: IPv6 char array + * @return int length of ip_address (ok > 0) + */ unsigned int ip6_scanbracket(const char *s, char ip[16]) { unsigned int len; @@ -271,14 +265,13 @@ unsigned int ip6_scanbracket(const char *s, char ip[16]) } /** - @brief ip6_ifscan - parse compactified IPv6 address string - concatinated with the interface name: fe80::1%eth0 - @param input: pointer to IPv6 address string - output: IPv6 char array, stralloc interface_name - @return int length of ip6_address/ip - */ - + * @brief ip6_ifscan + * parse compactified IPv6 address string + * concatinated with the interface name: fe80::1%eth0 + * @param input: pointer to IPv6 address string + * output: IPv6 char array, stralloc interface_name + * @return int length of ip6_address/ip + */ unsigned int ip6_ifscan(char *s, char ip[16], stralloc *ifname) { int i; @@ -303,14 +296,13 @@ unsigned int ip6_ifscan(char *s, char ip[16], stralloc *ifname) } /** - @brief ip6_cidr - parse compactified IPv6 address string - concatinated with the prefix length: fe80::1/64 - @param input: pointer to IPv6 address string - output: IPv6 char array, long plen - @return int length of ip6_address/ip - */ - + * @brief ip6_cidr + * parse compactified IPv6 address string + * concatinated with the prefix length: fe80::1/64 + * @param input: pointer to IPv6 address string + * output: IPv6 char array, long plen + * @return int length of ip6_address/ip + */ unsigned int ip6_cidr(char *s, char ip[16], unsigned long *plen) { unsigned int j = 0; @@ -325,13 +317,12 @@ unsigned int ip6_cidr(char *s, char ip[16], unsigned long *plen) } /** - @brief ip6_bytestring - parse IPv6 address and represent as char string with length prefix - @param input: IPv6 char array, prefix length - output: pointer to stralloc bit string; - @return n: number of bytes, if ok; -1: memory shortage - */ - + * @brief ip6_bytestring + * parse IPv6 address and represent as char string with length prefix + * @param input: IPv6 char array, prefix length + * output: pointer to stralloc bit string; + * @return n: number of bytes, if ok; -1: memory shortage + */ unsigned int ip6_bytestring(stralloc *ipstring, char ip[16], int prefix) { int i, j, n = 0; @@ -8,7 +8,7 @@ /** @file lock.c @author djb - @source qmail + @ref qmail @brief locking of resources */ diff --git a/src/logmsg.c b/src/logmsg.c index f254fd9..f18bda9 100644 --- a/src/logmsg.c +++ b/src/logmsg.c @@ -13,7 +13,7 @@ /** @file logmsg.c @author kp, feh - @source qlibs + @ref qlibs @brief unified system and error message handling */ diff --git a/src/ndelay.c b/src/ndelay.c index 44a34d7..3701650 100644 --- a/src/ndelay.c +++ b/src/ndelay.c @@ -6,7 +6,7 @@ /** @file ndelay.c @author djb - @soure qmail + @ref qmail @brief delaying of IO operations */ @@ -6,7 +6,7 @@ /** @file open.c @author djb - @source qmail + @ref qmail @brief open a file */ diff --git a/src/pathexec.c b/src/pathexec.c index e588c65..d0e8e84 100644 --- a/src/pathexec.c +++ b/src/pathexec.c @@ -12,7 +12,7 @@ /** @file pathexec.c @author djb - @source ucspi-tcp, ucspi-ssl + @ref ucspi-tcp, ucspi-ssl @brief populate environment after fork */ @@ -9,7 +9,7 @@ /** @file prot.c @author djb - @source qmail + @ref qmail @brief setting up uid an gid for OS (short group was for ancient solaris) */ diff --git a/src/readclose.c b/src/readclose.c index 307f830..e489967 100644 --- a/src/readclose.c +++ b/src/readclose.c @@ -8,10 +8,10 @@ /** @file readclose.c @author kp - @source qlibs - @brief This is the successor of the older 'slurpclose.c' file. The function - 'slurpclose' is now called 'readclose_append'. The other function - 'readclose' was introduced here initial. + @ref qlibs + @brief This is the successor of the older 'slurpclose.c' file. + @brief The function * 'slurpclose' is now called 'readclose_append'. + @brief The other function 'readclose' was introduced here initial. */ int readclose_append(int fd, stralloc *sa, unsigned int bufsize) @@ -1,10 +1,10 @@ #include "scan.h" /** - @file scan.c + @file scan.c @author djb - @source qmail, ucspi-tcp - @brief scanning/conversion of strings to different variable types + @ref qmail, ucspi-tcp + @brief scanning/conversion of strings to different variable types */ static long int fromhex(unsigned char c) @@ -5,7 +5,7 @@ /** @file seek.c @author djb - @source qmail + @ref qmail @brief seek in an open file descritor */ diff --git a/src/sharedlib b/src/sharedlib deleted file mode 100755 index 3bf4f26..0000000 --- a/src/sharedlib +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -exec cc -shared ${1+"$@"} @@ -4,8 +4,8 @@ /** @file sig.c - @author djb - @source qmail + @authors djb, jmh + @ref qmail @brief signal handling functions */ @@ -136,7 +136,7 @@ void sig_termunblock() sig_unblock(SIGTERM); } -void sig_termcatch(f) void (*f)(int); +void sig_termcatch(void (*f)(int)) { sig_catch(SIGTERM, f); } diff --git a/src/socket_bind.c b/src/socket_bind.c index 314ffa0..ecac6bb 100644 --- a/src/socket_bind.c +++ b/src/socket_bind.c @@ -10,7 +10,7 @@ /** @file socket_bind.c @author djb, fefe, feh - @source qmail, djbdns, ucspi-tcp6 + @ref qmail, djbdns, ucspi-tcp6 @brief binding a socket to a local resource */ diff --git a/src/socket_connect.c b/src/socket_connect.c index 240d5da..cd44c8e 100644 --- a/src/socket_connect.c +++ b/src/socket_connect.c @@ -11,8 +11,8 @@ /** @file socket_connect.c - @author djb, fefe, feh, kp - @source qmail, ucscpi-tcp6 + @authors djb, fefe, feh, kp + @ref qmail, ucscpi-tcp6 @brief connection to remote IP host */ diff --git a/src/socket_if.c b/src/socket_if.c index 682f8bd..fbbd6d0 100644 --- a/src/socket_if.c +++ b/src/socket_if.c @@ -8,8 +8,8 @@ /** @file socket_if.c - @author fefe, feh - @source ucspi-tcp6 + @authors fefe, feh + @ref ucspi-tcp6 @brief interface handling for LLU */ diff --git a/src/socket_info.c b/src/socket_info.c index 14ec6b0..89a9c5d 100644 --- a/src/socket_info.c +++ b/src/socket_info.c @@ -9,8 +9,8 @@ /** @file socket_info.c - @author djb, fefe, feh - @source ucspi-tcp6 + @authors djb, fefe, feh + @ref ucspi-tcp6 @brief querying local and remote info for socket */ diff --git a/src/socket_recv.c b/src/socket_recv.c index 2fb1e64..83f648b 100644 --- a/src/socket_recv.c +++ b/src/socket_recv.c @@ -9,8 +9,8 @@ /** @file socket_recv.c - @author djb, fefe - @source ucspi-tcp6 + @authors djb, fefe + @ref ucspi-tcp6 @brief setup receiving socket */ diff --git a/src/socket_send.c b/src/socket_send.c index 1d0ce56..5aa0535 100644 --- a/src/socket_send.c +++ b/src/socket_send.c @@ -9,8 +9,8 @@ /** @file socket_send.c - @author djb, fefe, feh - @source ucspi-tcp6 + @authors djb, fefe, feh + @ref ucspi-tcp6 @brief setup sending socket */ diff --git a/src/socket_setup.c b/src/socket_setup.c index 39fc3dd..1c18727 100644 --- a/src/socket_setup.c +++ b/src/socket_setup.c @@ -9,8 +9,8 @@ /** @file socket_setup.c - @author djb, feh - @source ucspi-tcp6 + @authors djb, feh + @ref ucspi-tcp6 @brief setup listening socket */ diff --git a/src/socket_tcp.c b/src/socket_tcp.c index f350330..866ac19 100644 --- a/src/socket_tcp.c +++ b/src/socket_tcp.c @@ -16,8 +16,8 @@ /** @file socket_tcp.c - @author djb, fefe, feh - @source ucspi-tcp6 + @authors djb, fefe, feh + @ref ucspi-tcp6 @brief setup TCP stream socket */ diff --git a/src/socket_udp.c b/src/socket_udp.c index 59af450..7da1def 100644 --- a/src/socket_udp.c +++ b/src/socket_udp.c @@ -16,8 +16,8 @@ /** @file socket_udp.c - @author djb, fefe, feh - @source ucspi-tcp6 + @authors djb, fefe, feh + @ref ucspi-tcp6 @brief setup a UDP message socket */ @@ -4,8 +4,8 @@ /** @file str.c - @author djb - @source qmail + @authors djb, feh + @ref qmail @brief string handling functions */ diff --git a/src/stralloc.c b/src/stralloc.c index 8351473..8373bfe 100644 --- a/src/stralloc.c +++ b/src/stralloc.c @@ -9,7 +9,7 @@ /** @file stralloc.c @author djb - @source qmail, ucspi-tcp + @ref qmail, ucspi-tcp @brief genious dynamic string handling */ @@ -5,7 +5,7 @@ /** @file tai.c @author djb - @source qmail + @ref qmail @brief 'temps atomic' time handling */ @@ -52,13 +52,13 @@ void tai_unpack(const char *s, struct tai *t) x = (unsigned char)s[0]; // clang-format off - x <<= 8; x += (unsigned char) s[1]; - x <<= 8; x += (unsigned char) s[2]; - x <<= 8; x += (unsigned char) s[3]; - x <<= 8; x += (unsigned char) s[4]; - x <<= 8; x += (unsigned char) s[5]; - x <<= 8; x += (unsigned char) s[6]; - x <<= 8; x += (unsigned char) s[7]; + x <<= 8; x += (unsigned char)s[1]; + x <<= 8; x += (unsigned char)s[2]; + x <<= 8; x += (unsigned char)s[3]; + x <<= 8; x += (unsigned char)s[4]; + x <<= 8; x += (unsigned char)s[5]; + x <<= 8; x += (unsigned char)s[6]; + x <<= 8; x += (unsigned char)s[7]; // clang-format on t->x = x; } @@ -6,7 +6,7 @@ /** @file taia.c @author djb - @source qmail + @ref qmail @brief 'tai' attosecond time handling */ diff --git a/src/timeout.c b/src/timeout.c index 9d34e69..c0a904f 100644 --- a/src/timeout.c +++ b/src/timeout.c @@ -8,8 +8,9 @@ /** @file timeout.c @author djb - @source qmail + @ref qmail @brief read/write timeout handling + @return same as read(2) or write(2); -1 on error */ int timeoutread(int t, int fd, char *buf, int len) diff --git a/src/timeoutconn.c b/src/timeoutconn.c index 205db0a..402e9d3 100644 --- a/src/timeoutconn.c +++ b/src/timeoutconn.c @@ -8,8 +8,8 @@ /** @file timeoutconn.c - @author djb, fefe, feh - @source qmail + @authors djb, fefe, feh + @ref qmail @brief socket read/write timeout handling; return code of iopause considered */ diff --git a/src/uint128p.c b/src/uint128p.c index e92b5a7..4606076 100644 --- a/src/uint128p.c +++ b/src/uint128p.c @@ -2,8 +2,8 @@ /** @file uint128p.c - @author feh, jannis - @source djbdns6 + @authors feh, jmh + @ref djbdns6 @brief packing/unpacking 128 bit integer to/from char string */ diff --git a/src/uint16p.c b/src/uint16p.c index 06556e4..f2e19e0 100644 --- a/src/uint16p.c +++ b/src/uint16p.c @@ -3,7 +3,7 @@ /** @file uint16p.c @author djb - @source qmail + @ref qmail @brief packing/unpacking 16 bit integer to/from char string */ diff --git a/src/uint32p.c b/src/uint32p.c index de96958..0c266a9 100644 --- a/src/uint32p.c +++ b/src/uint32p.c @@ -3,7 +3,7 @@ /** @file uint32p.c @author djb - @source qmail + @ref qmail @brief packing/unpacking 32 bit integer to/from char string */ diff --git a/src/uint64p.c b/src/uint64p.c index 4631bce..9f2e0e1 100644 --- a/src/uint64p.c +++ b/src/uint64p.c @@ -2,8 +2,8 @@ /** @file uint64p.c - @author feh, jannis - @source djbdns6 + @authors feh, jmh + @ref djbdns6 @brief packing/unpacking 64 bit integer to/from char string */ diff --git a/src/uint8p.c b/src/uint8p.c index d3921d9..466c792 100644 --- a/src/uint8p.c +++ b/src/uint8p.c @@ -1,7 +1,7 @@ #include "uint_t.h" /** - @file uint8x.c + @file uint8p.c @author feh @brief packing/unpacking 8 bit int to/from char string */ @@ -8,7 +8,7 @@ /** @file wait.c @author djb - @source qmail + @ref qmail @brief wait for forked processes */ |