1 /* Copyright (c) 1998, 1999, 2000 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Thorsten Kukuk <kukuk@suse.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 uid_t owner
; /* If secure table, this is the owner. */
50 struct hashentry
*next
; /* Next entry in this hash bucket list. */
51 time_t timeout
; /* Time when this entry becomes invalid. */
52 ssize_t total
; /* Number of bytes in PACKET. */
53 const void *packet
; /* Records for the result. */
54 void *data
; /* The malloc()ed respond record. */
55 int last
; /* Nonzero if DATA should be free()d. */
56 struct hashentry
*dellist
; /* Next record to be deleted. */
59 /* Structure describing one database. */
62 pthread_rwlock_t lock
;
70 const struct iovec
*disabled_iov
;
72 unsigned long int postimeout
;
73 unsigned long int negtimeout
;
75 unsigned long int poshit
;
76 unsigned long int neghit
;
77 unsigned long int posmiss
;
78 unsigned long int negmiss
;
80 struct hashentry
**array
;
84 /* Global variables. */
85 extern const char *dbnames
[lastdb
];
86 extern const char *serv2str
[LASTREQ
];
88 extern const struct iovec pwd_iov_disabled
;
89 extern const struct iovec grp_iov_disabled
;
90 extern const struct iovec hst_iov_disabled
;
92 /* Number of threads to run. */
95 /* Tables for which we cache data with uid */
96 extern int secure
[lastdb
];
97 extern int secure_in_use
; /* Is one of the above 1 ? */
99 /* User name to run server processes as */
100 extern const char *server_user
;
102 /* Prototypes for global functions. */
105 extern void termination_handler (int signum
) __attribute__ ((__noreturn__
));
106 extern int nscd_open_socket (void);
109 extern void nscd_init (const char *conffile
);
110 extern void close_sockets (void);
111 extern void start_threads (void);
114 extern int nscd_parse_file (const char *fname
, struct database dbs
[lastdb
]);
117 extern void send_stats (int fd
, struct database dbs
[lastdb
]);
118 extern int receive_print_stats (void) __attribute__ ((__noreturn__
));
121 extern struct hashentry
*cache_search (int type
, void *key
, size_t len
,
122 struct database
*table
, uid_t owner
);
123 extern void cache_add (int type
, void *key
, size_t len
,
124 const void *packet
, size_t iovtotal
, void *data
,
125 int last
, time_t t
, struct database
*table
,
127 extern void prune_cache (struct database
*table
, time_t now
);
130 extern void addpwbyname (struct database
*db
, int fd
, request_header
*req
,
131 void *key
, uid_t uid
);
132 extern void addpwbyuid (struct database
*db
, int fd
, request_header
*req
,
133 void *key
, uid_t uid
);
136 extern void addgrbyname (struct database
*db
, int fd
, request_header
*req
,
137 void *key
, uid_t uid
);
138 extern void addgrbygid (struct database
*db
, int fd
, request_header
*req
,
139 void *key
, uid_t uid
);
142 extern void addhstbyname (struct database
*db
, int fd
, request_header
*req
,
143 void *key
, uid_t uid
);
144 extern void addhstbyaddr (struct database
*db
, int fd
, request_header
*req
,
145 void *key
, uid_t uid
);
146 extern void addhstbynamev6 (struct database
*db
, int fd
, request_header
*req
,
147 void *key
, uid_t uid
);
148 extern void addhstbyaddrv6 (struct database
*db
, int fd
, request_header
*req
,
149 void *key
, uid_t uid
);