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