xref: /netbsd-src/external/ibm-public/postfix/dist/src/util/netstring.h (revision daf6c4152fcddc27c445489775ed1f66ab4ea9a9)
1 /*	$NetBSD: netstring.h,v 1.1.1.1 2009/06/23 10:09:00 tron Exp $	*/
2 
3 #ifndef _NETSTRING_H_INCLUDED_
4 #define _NETSTRING_H_INCLUDED_
5 
6 /*++
7 /* NAME
8 /*	netstring 3h
9 /* SUMMARY
10 /*	netstring stream I/O support
11 /* SYNOPSIS
12 /*	#include <netstring.h>
13 /* DESCRIPTION
14 /* .nf
15 
16  /*
17   * Utility library.
18   */
19 #include <vstring.h>
20 #include <vstream.h>
21 
22  /*
23   * External interface.
24   */
25 #define NETSTRING_ERR_EOF	1	/* unexpected disconnect */
26 #define NETSTRING_ERR_TIME	2	/* time out */
27 #define NETSTRING_ERR_FORMAT	3	/* format error */
28 #define NETSTRING_ERR_SIZE	4	/* netstring too large */
29 
30 extern void netstring_except(VSTREAM *, int);
31 extern void netstring_setup(VSTREAM *, int);
32 extern ssize_t netstring_get_length(VSTREAM *);
33 extern VSTRING *netstring_get_data(VSTREAM *, VSTRING *, ssize_t);
34 extern void netstring_get_terminator(VSTREAM *);
35 extern VSTRING *netstring_get(VSTREAM *, VSTRING *, ssize_t);
36 extern void netstring_put(VSTREAM *, const char *, ssize_t);
37 extern void netstring_put_multi(VSTREAM *,...);
38 extern void netstring_fflush(VSTREAM *);
39 extern VSTRING *netstring_memcpy(VSTRING *, const char *, ssize_t);
40 extern VSTRING *netstring_memcat(VSTRING *, const char *, ssize_t);
41 
42 #define NETSTRING_PUT_BUF(str, buf) \
43 	netstring_put((str), vstring_str(buf), VSTRING_LEN(buf))
44 
45 /* LICENSE
46 /* .ad
47 /* .fi
48 /*	The Secure Mailer license must be distributed with this software.
49 /* AUTHOR(S)
50 /*	Wietse Venema
51 /*	IBM T.J. Watson Research
52 /*	P.O. Box 704
53 /*	Yorktown Heights, NY 10598, USA
54 /*--*/
55 
56 #endif
57