1 /* Copyright (c) 1998 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1998.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If not,
17 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. */
27 /* The declarations for the request and response types are in the file
28 "nscd-client.h", which should contain everything needed by client
30 #include "nscd-client.h"
33 /* Handle databases. */
43 /* Structure for one hash table entry. */
46 request_type type
; /* Which type of dataset. */
47 size_t len
; /* Length of key. */
48 void *key
; /* Pointer to key. */
49 struct hashentry
*next
; /* Next entry in this hash bucket list. */
50 time_t timeout
; /* Time when this entry becomes invalid. */
51 ssize_t total
; /* Number of bytes in PACKET. */
52 const void *packet
; /* Records for the result. */
53 void *data
; /* The malloc()ed respond record. */
54 int last
; /* Nonzero if DATA should be free()d. */
55 struct hashentry
*dellist
; /* Next record to be deleted. */
58 /* Structure describing one database. */
61 pthread_rwlock_t lock
;
69 const struct iovec
*disabled_iov
;
71 unsigned long int postimeout
;
72 unsigned long int negtimeout
;
74 unsigned long int poshit
;
75 unsigned long int neghit
;
76 unsigned long int posmiss
;
77 unsigned long int negmiss
;
79 struct hashentry
**array
;
83 /* Global variables. */
84 extern const char *dbnames
[lastdb
];
85 extern const char *serv2str
[LASTREQ
];
87 extern const struct iovec pwd_iov_disabled
;
88 extern const struct iovec grp_iov_disabled
;
89 extern const struct iovec hst_iov_disabled
;
91 /* Number of threads to run. */
95 /* Prototypes for global functions. */
98 extern void termination_handler (int signum
);
99 extern int nscd_open_socket (void);
102 extern void nscd_init (const char *conffile
);
103 extern void close_sockets (void);
104 extern void start_threads (void);
107 extern int nscd_parse_file (const char *fname
, struct database dbs
[lastdb
]);
110 extern void send_stats (int fd
, struct database dbs
[lastdb
]);
111 extern int receive_print_stats (void);
114 extern struct hashentry
*cache_search (int type
, void *key
, size_t len
,
115 struct database
*table
);
116 extern void cache_add (int type
, void *key
, size_t len
,
117 const void *packet
, size_t iovtotal
, void *data
,
118 int last
, time_t t
, struct database
*table
);
119 extern void prune_cache (struct database
*table
, time_t now
);
122 extern void addpwbyname (struct database
*db
, int fd
, request_header
*req
,
124 extern void addpwbyuid (struct database
*db
, int fd
, request_header
*req
,
128 extern void addgrbyname (struct database
*db
, int fd
, request_header
*req
,
130 extern void addgrbygid (struct database
*db
, int fd
, request_header
*req
,
134 extern void addhstbyname (struct database
*db
, int fd
, request_header
*req
,
136 extern void addhstbyaddr (struct database
*db
, int fd
, request_header
*req
,
138 extern void addhstbynamev6 (struct database
*db
, int fd
, request_header
*req
,
140 extern void addhstbyaddrv6 (struct database
*db
, int fd
, request_header
*req
,