1 /* $NetBSD: extern.h,v 1.9 2010/06/10 06:17:21 dholland Exp $ */ 2 3 /* 4 * Copyright (c) 1994 Christopher G. Demetriou 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 3. All advertising materials mentioning features or use of this software 16 * must display the following acknowledgement: 17 * This product includes software developed for the 18 * NetBSD Project. See http://www.NetBSD.org/ for 19 * information about NetBSD. 20 * 4. The name of the author may not be used to endorse or promote products 21 * derived from this software without specific prior written permission. 22 * 23 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 24 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 25 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 26 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 27 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 28 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 32 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 * 34 * <<Id: LICENSE,v 1.2 2000/06/14 15:57:33 cgd Exp>> 35 */ 36 37 #include <sys/types.h> 38 #include <sys/param.h> 39 #include <db.h> 40 41 /* structures */ 42 43 struct cmdinfo { 44 char ci_comm[MAXCOMLEN+2]; /* command name (+ '*') */ 45 uid_t ci_uid; /* user id */ 46 u_quad_t ci_calls; /* number of calls */ 47 u_quad_t ci_etime; /* elapsed time */ 48 u_quad_t ci_utime; /* user time */ 49 u_quad_t ci_stime; /* system time */ 50 u_quad_t ci_mem; /* memory use */ 51 u_quad_t ci_io; /* number of disk i/o ops */ 52 u_int32_t ci_flags; /* flags; see below */ 53 }; 54 #define CI_UNPRINTABLE 0x0001 /* unprintable chars in name */ 55 56 struct userinfo { 57 uid_t ui_uid; /* user id; for consistency */ 58 u_quad_t ui_calls; /* number of invocations */ 59 u_quad_t ui_utime; /* user time */ 60 u_quad_t ui_stime; /* system time */ 61 u_quad_t ui_mem; /* memory use */ 62 u_quad_t ui_io; /* number of disk i/o ops */ 63 }; 64 65 /* typedefs */ 66 67 typedef int (*cmpf_t)(const DBT *, const DBT *); 68 69 /* external functions in sa.c */ 70 const char *fmt(const DBT *); 71 72 /* external functions in pdb.c */ 73 int pacct_init(void); 74 void pacct_destroy(void); 75 int pacct_add(const struct cmdinfo *); 76 int pacct_update(void); 77 void pacct_print(void); 78 79 /* external functions in usrdb.c */ 80 int usracct_init(void); 81 void usracct_destroy(void); 82 int usracct_add(const struct cmdinfo *); 83 int usracct_update(void); 84 void usracct_print(void); 85 86 /* variables */ 87 88 extern int aflag, bflag, cflag, dflag, Dflag, fflag, iflag, jflag, kflag; 89 extern int Kflag, lflag, mflag, qflag, rflag, sflag, tflag, uflag, vflag; 90 extern int cutoff; 91 extern cmpf_t sa_cmp; 92 93 /* some #defines to help with db's stupidity */ 94 95 #define DB_CLOSE(db) \ 96 ((*(db)->close)(db)) 97 #define DB_GET(db, key, data, flags) \ 98 ((*(db)->get)((db), (key), (data), (flags))) 99 #define DB_PUT(db, key, data, flags) \ 100 ((*(db)->put)((db), (key), (data), (flags))) 101 #define DB_SYNC(db, flags) \ 102 ((*(db)->sync)((db), (flags))) 103 #define DB_SEQ(db, key, data, flags) \ 104 ((*(db)->seq)((db), (key), (data), (flags))) 105