1 /* $NetBSD: update.c,v 1.9 2012/03/21 10:10:37 matt 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.9 2012/03/21 10:10:37 matt Exp $");
27 /* System libraries */
39 static struct request_info
*request_fill(struct request_info
*, va_list);
41 /* request_fill - request update engine */
43 static struct request_info
*
44 request_fill(struct request_info
*request
, va_list ap
)
49 while ((key
= va_arg(ap
, int)) > 0) {
52 tcpd_warn("request_fill: invalid key: %d", key
);
55 request
->fd
= va_arg(ap
, int);
58 request
->client
->sin
= va_arg(ap
, struct sockaddr
*);
61 request
->server
->sin
= va_arg(ap
, struct sockaddr
*);
65 * All other fields are strings with the same maximal length.
69 ptr
= request
->daemon
;
75 ptr
= request
->client
->name
;
78 ptr
= request
->client
->addr
;
81 ptr
= request
->server
->name
;
84 ptr
= request
->server
->addr
;
87 strlcpy(ptr
, va_arg(ap
, char *), STRING_LENGTH
);
92 /* request_init - initialize request structure */
94 struct request_info
*VARARGS(request_init
, struct request_info
*, request
)
96 static struct request_info default_info
;
97 struct request_info
*r
;
101 * Initialize data members. We do not assign default function pointer
102 * members, to avoid pulling in the whole socket module when it is not
105 VASTART(ap
, struct request_info
*, request
);
106 *request
= default_info
;
108 (void)strlcpy(request
->daemon
, unknown
, sizeof(request
->daemon
));
109 (void)snprintf(request
->pid
, sizeof(request
->pid
), "%d", getpid());
110 request
->client
->request
= request
;
111 request
->server
->request
= request
;
112 r
= request_fill(request
, ap
);
117 /* request_set - update request structure */
119 struct request_info
*VARARGS(request_set
, struct request_info
*, request
)
121 struct request_info
*r
;
124 VASTART(ap
, struct request_info
*, request
);
125 r
= request_fill(request
, ap
);