]>
Commit | Line | Data |
---|---|---|
2fc1e207 A |
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 | |
9 | * notice, this list of conditions and the following disclaimer. | |
10 | * 2. Redistributions in binary form must reproduce the above copyright | |
11 | * notice, this list of conditions and the following disclaimer in the | |
12 | * documentation and/or other materials provided with the distribution. | |
13 | * 3. All advertising materials mentioning features or use of this software | |
14 | * must display the following acknowledgement: | |
15 | * This product includes software developed by Christopher G. Demetriou. | |
16 | * 4. The name of the author may not be used to endorse or promote products | |
17 | * derived from this software without specific prior written permission | |
18 | * | |
19 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | |
20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |
21 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |
22 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | |
23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
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 | * | |
ef8ad44b | 30 | * $FreeBSD: src/usr.sbin/sa/extern.h,v 1.7 2007/05/22 06:51:38 dds Exp $ |
2fc1e207 A |
31 | */ |
32 | ||
33 | #include <sys/types.h> | |
34 | #include <sys/param.h> | |
35 | #include <db.h> | |
36 | ||
37 | /* structures */ | |
38 | ||
ef8ad44b A |
39 | /* All times are stored in 1e-6s units. */ |
40 | ||
2fc1e207 A |
41 | struct cmdinfo { |
42 | char ci_comm[MAXCOMLEN+2]; /* command name (+ '*') */ | |
ef8ad44b A |
43 | uid_t ci_uid; /* user id */ |
44 | #ifdef __APPLE__ | |
2fc1e207 A |
45 | u_quad_t ci_calls; /* number of calls */ |
46 | u_quad_t ci_etime; /* elapsed time */ | |
47 | u_quad_t ci_utime; /* user time */ | |
48 | u_quad_t ci_stime; /* system time */ | |
49 | u_quad_t ci_mem; /* memory use */ | |
50 | u_quad_t ci_io; /* number of disk i/o ops */ | |
ef8ad44b A |
51 | #else |
52 | double ci_etime; /* elapsed time */ | |
53 | double ci_utime; /* user time */ | |
54 | double ci_stime; /* system time */ | |
55 | double ci_mem; /* memory use */ | |
56 | double ci_io; /* number of disk i/o ops */ | |
57 | #endif | |
2fc1e207 A |
58 | u_int ci_flags; /* flags; see below */ |
59 | }; | |
60 | #define CI_UNPRINTABLE 0x0001 /* unprintable chars in name */ | |
61 | ||
62 | struct userinfo { | |
ef8ad44b | 63 | uid_t ui_uid; /* user id; for consistency */ |
2fc1e207 | 64 | u_quad_t ui_calls; /* number of invocations */ |
ef8ad44b | 65 | #ifdef __APPLE__ |
2fc1e207 A |
66 | u_quad_t ui_utime; /* user time */ |
67 | u_quad_t ui_stime; /* system time */ | |
68 | u_quad_t ui_mem; /* memory use */ | |
69 | u_quad_t ui_io; /* number of disk i/o ops */ | |
ef8ad44b A |
70 | #else |
71 | double ui_utime; /* user time */ | |
72 | double ui_stime; /* system time */ | |
73 | double ui_mem; /* memory use */ | |
74 | double ui_io; /* number of disk i/o ops */ | |
75 | #endif | |
2fc1e207 A |
76 | }; |
77 | ||
78 | /* typedefs */ | |
79 | ||
80 | typedef int (*cmpf_t)(const DBT *, const DBT *); | |
81 | ||
ef8ad44b A |
82 | /* external functions in db.c */ |
83 | int db_copy_in(DB **mdb, const char *dbname, const char *name, | |
84 | BTREEINFO *bti, int (*v1_to_v2)(DBT *key, DBT *data)); | |
85 | int db_copy_out(DB *mdb, const char *dbname, const char *name, | |
86 | BTREEINFO *bti); | |
87 | void db_destroy(DB *db, const char *uname); | |
88 | ||
2fc1e207 A |
89 | /* external functions in pdb.c */ |
90 | int pacct_init(void); | |
91 | void pacct_destroy(void); | |
92 | int pacct_add(const struct cmdinfo *); | |
93 | int pacct_update(void); | |
94 | void pacct_print(void); | |
95 | ||
ef8ad44b A |
96 | #ifndef __APPLE__ |
97 | /* external functions in readrec.c */ | |
98 | int readrec_forward(FILE *f, struct acctv2 *av2); | |
99 | #endif | |
100 | ||
2fc1e207 A |
101 | /* external functions in usrdb.c */ |
102 | int usracct_init(void); | |
103 | void usracct_destroy(void); | |
104 | int usracct_add(const struct cmdinfo *); | |
105 | int usracct_update(void); | |
106 | void usracct_print(void); | |
107 | ||
108 | /* variables */ | |
109 | ||
110 | extern int aflag, bflag, cflag, dflag, Dflag, fflag, iflag, jflag, kflag; | |
111 | extern int Kflag, lflag, mflag, qflag, rflag, sflag, tflag, uflag, vflag; | |
112 | extern u_quad_t cutoff; | |
113 | extern cmpf_t sa_cmp; | |
ef8ad44b | 114 | extern const char *pdb_file, *usrdb_file; |
2fc1e207 A |
115 | |
116 | /* some #defines to help with db's stupidity */ | |
117 | ||
118 | #define DB_CLOSE(db) \ | |
119 | ((*(db)->close)(db)) | |
120 | #define DB_GET(db, key, data, flags) \ | |
121 | ((*(db)->get)((db), (key), (data), (flags))) | |
122 | #define DB_PUT(db, key, data, flags) \ | |
123 | ((*(db)->put)((db), (key), (data), (flags))) | |
124 | #define DB_SYNC(db, flags) \ | |
125 | ((*(db)->sync)((db), (flags))) | |
126 | #define DB_SEQ(db, key, data, flags) \ | |
127 | ((*(db)->seq)((db), (key), (data), (flags))) |