1 /* $NetBSD: update.c,v 1.7 2002/06/06 21:42:43 itojun Exp $ */
4 * Routines for controlled update/initialization of request structures.
6 * request_init() initializes its argument. Pointers and string-valued members
7 * are initialized to zero, to indicate that no lookup has been attempted.
9 * request_set() adds information to an already initialized request structure.
11 * Both functions take a variable-length name-value list.
13 * Diagnostics are reported through syslog(3).
15 * Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
18 #include <sys/cdefs.h>
21 static char sccsid
[] = "@(#) update.c 1.1 94/12/28 17:42:56";
23 __RCSID("$NetBSD: update.c,v 1.7 2002/06/06 21:42:43 itojun Exp $");
27 /* System libraries */
39 static struct request_info
*request_fill
__P((struct request_info
*, va_list));
41 /* request_fill - request update engine */
43 static struct request_info
*request_fill(request
, ap
)
44 struct request_info
*request
;
50 while ((key
= va_arg(ap
, int)) > 0) {
53 tcpd_warn("request_fill: invalid key: %d", key
);
56 request
->fd
= va_arg(ap
, int);
59 request
->client
->sin
= va_arg(ap
, struct sockaddr
*);
62 request
->server
->sin
= va_arg(ap
, struct sockaddr
*);
66 * All other fields are strings with the same maximal length.
70 ptr
= request
->daemon
;
76 ptr
= request
->client
->name
;
79 ptr
= request
->client
->addr
;
82 ptr
= request
->server
->name
;
85 ptr
= request
->server
->addr
;
88 strlcpy(ptr
, va_arg(ap
, char *), STRING_LENGTH
);
93 /* request_init - initialize request structure */
95 struct request_info
*VARARGS(request_init
, struct request_info
*, request
)
97 static struct request_info default_info
;
98 struct request_info
*r
;
102 * Initialize data members. We do not assign default function pointer
103 * members, to avoid pulling in the whole socket module when it is not
106 VASTART(ap
, struct request_info
*, request
);
107 *request
= default_info
;
109 (void)strlcpy(request
->daemon
, unknown
, sizeof(request
->daemon
));
110 (void)snprintf(request
->pid
, sizeof(request
->pid
), "%d", getpid());
111 request
->client
->request
= request
;
112 request
->server
->request
= request
;
113 r
= request_fill(request
, ap
);
118 /* request_set - update request structure */
120 struct request_info
*VARARGS(request_set
, struct request_info
*, request
)
122 struct request_info
*r
;
125 VASTART(ap
, struct request_info
*, request
);
126 r
= request_fill(request
, ap
);