summaryrefslogtreecommitdiff
path: root/external/bsd/ntp/dist/include/lib_strbuf.h
blob: f02dfec3d7384198213c2772164c545642c0a35c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/*	$NetBSD: lib_strbuf.h,v 1.5 2020/05/25 20:47:19 christos Exp $	*/

/*
 * lib_strbuf.h - definitions for routines which use the common string buffers
 */
#ifndef LIB_STRBUF_H
#define LIB_STRBUF_H

#include <ntp_types.h>
#include <ntp_malloc.h>			/* for ZERO() */

/*
 * Sizes of things
 */
#define LIB_NUMBUF	16
#define	LIB_BUFLENGTH	128

typedef char libbufstr[LIB_BUFLENGTH];
extern libbufstr lib_stringbuf[LIB_NUMBUF];
extern int lib_nextbuf;
extern int lib_inited;


/*
 * Macro to get a pointer to the next buffer
 */
#define	LIB_GETBUF(bufp)					\
	do {							\
		ZERO(lib_stringbuf[lib_nextbuf]);		\
		(bufp) = &lib_stringbuf[lib_nextbuf++][0];	\
		lib_nextbuf %= COUNTOF(lib_stringbuf);		\
	} while (FALSE)

#endif	/* LIB_STRBUF_H */