1 /* $NetBSD: misc.c,v 1.10 2012/03/21 10:10:37 matt Exp $ */
4 * Misc routines that are used by tcpd and by tcpdchk.
6 * Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
12 static char sccsic
[] = "@(#) misc.c 1.2 96/02/11 17:01:29";
14 __RCSID("$NetBSD: misc.c,v 1.10 2012/03/21 10:10:37 matt Exp $");
18 #include <sys/types.h>
19 #include <sys/param.h>
20 #include <netinet/in.h>
21 #include <arpa/inet.h>
27 /* xgets - fgets() with backslash-newline stripping */
30 xgets(char *ptr
, int len
, FILE *fp
)
35 while (len
> 1 && fgets(ptr
, len
, fp
)) {
37 if (got
>= 1 && ptr
[got
- 1] == '\n') {
39 if (got
>= 2 && ptr
[got
- 2] == '\\') {
49 return (ptr
> start
? start
: 0);
52 /* split_at - break string at delimiter or return NULL */
55 split_at(char *string
, int delimiter
)
61 for (cp
= string
; cp
&& *cp
; cp
++) {
70 if (bracket
== 0 && *cp
== delimiter
) {
80 /* dot_quad_addr - convert dotted quad to internal form */
83 dot_quad_addr(char *str
, unsigned long *addr
)
87 if (!inet_aton(str
, &a
))