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 * 30 * $FreeBSD: src/usr.sbin/sa/extern.h,v 1.4 1999/08/28 01:19:52 peter Exp $ 31 */ 32 33 #include <sys/types.h> 34 #include <sys/param.h> 35 #include <db.h> 36 37 /* structures */ 38 39 struct cmdinfo { 40 char ci_comm[MAXCOMLEN+2]; /* command name (+ '*') */ 41 u_long ci_uid; /* user id */ 42 u_quad_t ci_calls; /* number of calls */ 43 u_quad_t ci_etime; /* elapsed time */ 44 u_quad_t ci_utime; /* user time */ 45 u_quad_t ci_stime; /* system time */ 46 u_quad_t ci_mem; /* memory use */ 47 u_quad_t ci_io; /* number of disk i/o ops */ 48 u_int ci_flags; /* flags; see below */ 49 }; 50 #define CI_UNPRINTABLE 0x0001 /* unprintable chars in name */ 51 52 struct userinfo { 53 u_long ui_uid; /* user id; for consistency */ 54 u_quad_t ui_calls; /* number of invocations */ 55 u_quad_t ui_utime; /* user time */ 56 u_quad_t ui_stime; /* system time */ 57 u_quad_t ui_mem; /* memory use */ 58 u_quad_t ui_io; /* number of disk i/o ops */ 59 }; 60 61 /* typedefs */ 62 63 typedef int (*cmpf_t) __P((const DBT *, const DBT *)); 64 65 /* external functions in sa.c */ 66 int main __P((int, char **)); 67 68 /* external functions in pdb.c */ 69 int pacct_init __P((void)); 70 void pacct_destroy __P((void)); 71 int pacct_add __P((const struct cmdinfo *)); 72 int pacct_update __P((void)); 73 void pacct_print __P((void)); 74 75 /* external functions in usrdb.c */ 76 int usracct_init __P((void)); 77 void usracct_destroy __P((void)); 78 int usracct_add __P((const struct cmdinfo *)); 79 int usracct_update __P((void)); 80 void usracct_print __P((void)); 81 82 /* variables */ 83 84 extern int aflag, bflag, cflag, dflag, Dflag, fflag, iflag, jflag, kflag; 85 extern int Kflag, lflag, mflag, qflag, rflag, sflag, tflag, uflag, vflag; 86 extern int cutoff; 87 extern cmpf_t sa_cmp; 88 89 /* some #defines to help with db's stupidity */ 90 91 #define DB_CLOSE(db) \ 92 ((*(db)->close)(db)) 93 #define DB_GET(db, key, data, flags) \ 94 ((*(db)->get)((db), (key), (data), (flags))) 95 #define DB_PUT(db, key, data, flags) \ 96 ((*(db)->put)((db), (key), (data), (flags))) 97 #define DB_SYNC(db, flags) \ 98 ((*(db)->sync)((db), (flags))) 99 #define DB_SEQ(db, key, data, flags) \ 100 ((*(db)->seq)((db), (key), (data), (flags))) 101