xref: /openbsd-src/usr.sbin/netgroup_mkdb/stringlist.h (revision 893695cea05286a86be12c6215f6501df588dceb)
1*893695ceSjsg /*	$OpenBSD: stringlist.h,v 1.2 2023/01/04 13:00:11 jsg Exp $	*/
2bf89e9b1Sderaadt 
3bf89e9b1Sderaadt /*
4bf89e9b1Sderaadt  * Copyright (c) 1994 Christos Zoulas
5bf89e9b1Sderaadt  * All rights reserved.
6bf89e9b1Sderaadt  *
7bf89e9b1Sderaadt  * Redistribution and use in source and binary forms, with or without
8bf89e9b1Sderaadt  * modification, are permitted provided that the following conditions
9bf89e9b1Sderaadt  * are met:
10bf89e9b1Sderaadt  * 1. Redistributions of source code must retain the above copyright
11bf89e9b1Sderaadt  *    notice, this list of conditions and the following disclaimer.
12bf89e9b1Sderaadt  * 2. Redistributions in binary form must reproduce the above copyright
13bf89e9b1Sderaadt  *    notice, this list of conditions and the following disclaimer in the
14bf89e9b1Sderaadt  *    documentation and/or other materials provided with the distribution.
15bf89e9b1Sderaadt  *
16bf89e9b1Sderaadt  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
17bf89e9b1Sderaadt  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18bf89e9b1Sderaadt  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19bf89e9b1Sderaadt  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
20bf89e9b1Sderaadt  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21bf89e9b1Sderaadt  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22bf89e9b1Sderaadt  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23bf89e9b1Sderaadt  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24bf89e9b1Sderaadt  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25bf89e9b1Sderaadt  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26bf89e9b1Sderaadt  * SUCH DAMAGE.
27bf89e9b1Sderaadt  */
28bf89e9b1Sderaadt 
29bf89e9b1Sderaadt #define _NG_STAR(s)	(((s) == NULL || *(s) == '\0') ? _ngstar : s)
30bf89e9b1Sderaadt #define _NG_EMPTY(s)	((s) == NULL ? "" : s)
31bf89e9b1Sderaadt #define _NG_ISSPACE(p)	(isspace((unsigned char) (p)) || (p) == '\n')
32bf89e9b1Sderaadt 
33bf89e9b1Sderaadt /*
34bf89e9b1Sderaadt  * Simple string list
35bf89e9b1Sderaadt  */
36bf89e9b1Sderaadt struct stringlist {
37bf89e9b1Sderaadt 	char		**sl_str;
38bf89e9b1Sderaadt 	size_t		  sl_max;
39bf89e9b1Sderaadt 	size_t		  sl_cur;
40bf89e9b1Sderaadt };
41bf89e9b1Sderaadt 
42bf89e9b1Sderaadt struct stringlist *_ng_sl_init(void);
43bf89e9b1Sderaadt int	 _ng_sl_add(struct stringlist *, char *);
44bf89e9b1Sderaadt void	  _ng_sl_free(struct stringlist *, int);
45bf89e9b1Sderaadt char	*_ng_sl_find(struct stringlist *, char *);
46bf89e9b1Sderaadt char	*_ng_makekey(const char *, const char *, size_t);
47bf89e9b1Sderaadt int	 _ng_parse(char **, char **, struct netgroup **);
48bf89e9b1Sderaadt void	 _ng_print(char *, size_t, const struct netgroup *);
49