xref: /netbsd-src/external/bsd/ntp/dist/include/lib_strbuf.h (revision eabc0478de71e4e011a5b4e0392741e01d491794)
1*eabc0478Schristos /*	$NetBSD: lib_strbuf.h,v 1.6 2024/08/18 20:46:50 christos Exp $	*/
2abb0f93cSkardel 
3abb0f93cSkardel /*
4abb0f93cSkardel  * lib_strbuf.h - definitions for routines which use the common string buffers
5abb0f93cSkardel  */
68585484eSchristos #ifndef LIB_STRBUF_H
78585484eSchristos #define LIB_STRBUF_H
8abb0f93cSkardel 
9abb0f93cSkardel #include <ntp_types.h>
10*eabc0478Schristos #include <ntp_malloc.h>			/* for zero_mem() */
11abb0f93cSkardel 
128585484eSchristos #define	LIB_BUFLENGTH	128
138585484eSchristos 
148585484eSchristos extern int	lib_inited;
15*eabc0478Schristos extern int	ipv4_works;
16*eabc0478Schristos extern int	ipv6_works;
178585484eSchristos 
18*eabc0478Schristos extern	void	init_lib(void);
19abb0f93cSkardel 
20abb0f93cSkardel /*
21*eabc0478Schristos  * Get a pointer to the next string buffer of LIB_BUFLENGTH octets.
22*eabc0478Schristos  * New and modified code should use buf = lib_getbuf() directly to
23*eabc0478Schristos  * provide clarity for folks familiar with common C style, but there's
24*eabc0478Schristos  * no need to churn the history with a mechanical switch away from
25*eabc0478Schristos  * LIB_GETBUF(buf).
26abb0f93cSkardel  */
27*eabc0478Schristos extern	char* lib_getbuf(void);
28*eabc0478Schristos 
298585484eSchristos #define	LIB_GETBUF(bufp)		\
30abb0f93cSkardel 	do {				\
31*eabc0478Schristos 		(bufp) = lib_getbuf();	\
328585484eSchristos 	} while (FALSE)
33abb0f93cSkardel 
348585484eSchristos #endif	/* LIB_STRBUF_H */
35