Deleted Added
full compact
usrdb.c (169857) usrdb.c (201227)
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 169857 2007-05-22 06:51:38Z dds $");
32__FBSDID("$FreeBSD: head/usr.sbin/sa/usrdb.c 201227 2009-12-29 22:53:27Z ed $");
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>

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

92 data->size = sizeof(uiv2);
93 data->data = &uiv2;
94
95 return (0);
96}
97
98/* Copy usrdb_file to in-memory usracct_db. */
99int
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>

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

92 data->size = sizeof(uiv2);
93 data->data = &uiv2;
94
95 return (0);
96}
97
98/* Copy usrdb_file to in-memory usracct_db. */
99int
100usracct_init()
100usracct_init(void)
101{
102 BTREEINFO bti;
103
104 bzero(&bti, sizeof bti);
105 bti.compare = uid_compare;
106
107 return (db_copy_in(&usracct_db, usrdb_file, "user accounting",
108 &bti, v1_to_v2));
109}
110
111void
101{
102 BTREEINFO bti;
103
104 bzero(&bti, sizeof bti);
105 bti.compare = uid_compare;
106
107 return (db_copy_in(&usracct_db, usrdb_file, "user accounting",
108 &bti, v1_to_v2));
109}
110
111void
112usracct_destroy()
112usracct_destroy(void)
113{
114 db_destroy(usracct_db, "user accounting");
115}
116
117int
118usracct_add(const struct cmdinfo *ci)
119{
120 DBT key, data;

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

161 return (-1);
162 }
163
164 return (0);
165}
166
167/* Copy in-memory usracct_db to usrdb_file. */
168int
113{
114 db_destroy(usracct_db, "user accounting");
115}
116
117int
118usracct_add(const struct cmdinfo *ci)
119{
120 DBT key, data;

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

161 return (-1);
162 }
163
164 return (0);
165}
166
167/* Copy in-memory usracct_db to usrdb_file. */
168int
169usracct_update()
169usracct_update(void)
170{
171 BTREEINFO bti;
172
173 bzero(&bti, sizeof bti);
174 bti.compare = uid_compare;
175
176 return (db_copy_out(usracct_db, usrdb_file, "user accounting",
177 &bti));
178}
179
180void
170{
171 BTREEINFO bti;
172
173 bzero(&bti, sizeof bti);
174 bti.compare = uid_compare;
175
176 return (db_copy_out(usracct_db, usrdb_file, "user accounting",
177 &bti));
178}
179
180void
181usracct_print()
181usracct_print(void)
182{
183 DBT key, data;
184 struct userinfo uistore, *ui = &uistore;
185 double t;
186 int rv;
187
188 rv = DB_SEQ(usracct_db, &key, &data, R_FIRST);
189 if (rv < 0)

--- 50 unchanged lines hidden ---
182{
183 DBT key, data;
184 struct userinfo uistore, *ui = &uistore;
185 double t;
186 int rv;
187
188 rv = DB_SEQ(usracct_db, &key, &data, R_FIRST);
189 if (rv < 0)

--- 50 unchanged lines hidden ---