1 /* $NetBSD: misc.c,v 1.8 2002/05/24 05:38:20 itojun 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.8 2002/05/24 05:38:20 itojun 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 */
29 char *xgets(ptr
, len
, fp
)
37 while (len
> 1 && fgets(ptr
, len
, fp
)) {
39 if (got
>= 1 && ptr
[got
- 1] == '\n') {
41 if (got
>= 2 && ptr
[got
- 2] == '\\') {
51 return (ptr
> start
? start
: 0);
54 /* split_at - break string at delimiter or return NULL */
56 char *split_at(string
, delimiter
)
64 for (cp
= string
; cp
&& *cp
; cp
++) {
73 if (bracket
== 0 && *cp
== delimiter
) {
83 /* dot_quad_addr - convert dotted quad to internal form */
85 int dot_quad_addr(str
, addr
)
91 if (!inet_aton(str
, &a
))