Deleted Added
full compact
usrdb.c (114601) usrdb.c (141638)
1/*
2 * Copyright (c) 1994 Christopher G. Demetriou
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 15 unchanged lines hidden (view full) ---

24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31#include <sys/cdefs.h>
1/*
2 * Copyright (c) 1994 Christopher G. Demetriou
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 15 unchanged lines hidden (view full) ---

24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31#include <sys/cdefs.h>
32__FBSDID("$FreeBSD: head/usr.sbin/sa/usrdb.c 114601 2003-05-03 21:06:42Z obrien $");
32__FBSDID("$FreeBSD: head/usr.sbin/sa/usrdb.c 141638 2005-02-10 12:43:16Z delphij $");
33
34#include <sys/param.h>
35#include <sys/types.h>
36#include <sys/acct.h>
37#include <err.h>
38#include <errno.h>
39#include <fcntl.h>
40#include <pwd.h>
41#include <stdint.h>
42#include <stdio.h>
43#include <stdlib.h>
44#include <string.h>
45#include "extern.h"
46#include "pathnames.h"
47
33
34#include <sys/param.h>
35#include <sys/types.h>
36#include <sys/acct.h>
37#include <err.h>
38#include <errno.h>
39#include <fcntl.h>
40#include <pwd.h>
41#include <stdint.h>
42#include <stdio.h>
43#include <stdlib.h>
44#include <string.h>
45#include "extern.h"
46#include "pathnames.h"
47
48static int uid_compare __P((const DBT *, const DBT *));
48static int uid_compare(const DBT *, const DBT *);
49
50static DB *usracct_db;
51
52int
53usracct_init()
54{
55 DB *saved_usracct_db;
56 BTREEINFO bti;

--- 58 unchanged lines hidden (view full) ---

115void
116usracct_destroy()
117{
118 if (DB_CLOSE(usracct_db) < 0)
119 warn("destroying user accounting stats");
120}
121
122int
49
50static DB *usracct_db;
51
52int
53usracct_init()
54{
55 DB *saved_usracct_db;
56 BTREEINFO bti;

--- 58 unchanged lines hidden (view full) ---

115void
116usracct_destroy()
117{
118 if (DB_CLOSE(usracct_db) < 0)
119 warn("destroying user accounting stats");
120}
121
122int
123usracct_add(ci)
124 const struct cmdinfo *ci;
123usracct_add(const struct cmdinfo *ci)
125{
126 DBT key, data;
127 struct userinfo newui;
128 u_long uid;
129 int rv;
130
131 uid = ci->ci_uid;
132 key.data = &uid;

--- 131 unchanged lines hidden (view full) ---

264
265 rv = DB_SEQ(usracct_db, &key, &data, R_NEXT);
266 if (rv < 0)
267 warn("retrieving user accounting stats");
268 }
269}
270
271static int
124{
125 DBT key, data;
126 struct userinfo newui;
127 u_long uid;
128 int rv;
129
130 uid = ci->ci_uid;
131 key.data = &uid;

--- 131 unchanged lines hidden (view full) ---

263
264 rv = DB_SEQ(usracct_db, &key, &data, R_NEXT);
265 if (rv < 0)
266 warn("retrieving user accounting stats");
267 }
268}
269
270static int
272uid_compare(k1, k2)
273 const DBT *k1, *k2;
271uid_compare(const DBT *k1, const DBT *k2)
274{
275 u_long d1, d2;
276
277 bcopy(k1->data, &d1, sizeof d1);
278 bcopy(k2->data, &d2, sizeof d2);
279
280 if (d1 < d2)
281 return -1;
282 else if (d1 == d2)
283 return 0;
284 else
285 return 1;
286}
272{
273 u_long d1, d2;
274
275 bcopy(k1->data, &d1, sizeof d1);
276 bcopy(k2->data, &d2, sizeof d2);
277
278 if (d1 < d2)
279 return -1;
280 else if (d1 == d2)
281 return 0;
282 else
283 return 1;
284}