extern.h revision 169670
155714Skris/*
255714Skris * Copyright (c) 1994 Christopher G. Demetriou
355714Skris * All rights reserved.
455714Skris *
555714Skris * Redistribution and use in source and binary forms, with or without
655714Skris * modification, are permitted provided that the following conditions
755714Skris * are met:
855714Skris * 1. Redistributions of source code must retain the above copyright
955714Skris *    notice, this list of conditions and the following disclaimer.
1055714Skris * 2. Redistributions in binary form must reproduce the above copyright
1155714Skris *    notice, this list of conditions and the following disclaimer in the
1255714Skris *    documentation and/or other materials provided with the distribution.
1355714Skris * 3. All advertising materials mentioning features or use of this software
1455714Skris *    must display the following acknowledgement:
1555714Skris *      This product includes software developed by Christopher G. Demetriou.
1655714Skris * 4. The name of the author may not be used to endorse or promote products
1755714Skris *    derived from this software without specific prior written permission
1855714Skris *
1955714Skris * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
2055714Skris * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
2155714Skris * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
2255714Skris * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
2355714Skris * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
2455714Skris * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2555714Skris * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2655714Skris * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2755714Skris * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
2855714Skris * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2955714Skris *
3055714Skris * $FreeBSD: head/usr.sbin/sa/extern.h 169670 2007-05-18 12:36:10Z dds $
3155714Skris */
3255714Skris
3355714Skris#include <sys/types.h>
3455714Skris#include <sys/param.h>
3555714Skris#include <db.h>
3655714Skris
3755714Skris/* structures */
3855714Skris
3955714Skrisstruct cmdinfo {
4055714Skris	char		ci_comm[MAXCOMLEN+2];	/* command name (+ '*') */
4155714Skris	u_long		ci_uid;			/* user id */
4255714Skris	u_quad_t	ci_calls;		/* number of calls */
4355714Skris	u_quad_t	ci_etime;		/* elapsed time */
4455714Skris	u_quad_t	ci_utime;		/* user time */
4555714Skris	u_quad_t	ci_stime;		/* system time */
4655714Skris	u_quad_t	ci_mem;			/* memory use */
4755714Skris	u_quad_t	ci_io;			/* number of disk i/o ops */
4855714Skris	u_int		ci_flags;		/* flags; see below */
4955714Skris};
5055714Skris#define	CI_UNPRINTABLE	0x0001			/* unprintable chars in name */
5155714Skris
5255714Skrisstruct userinfo {
5355714Skris	u_long		ui_uid;			/* user id; for consistency */
5455714Skris	u_quad_t	ui_calls;		/* number of invocations */
5555714Skris	u_quad_t	ui_utime;		/* user time */
5655714Skris	u_quad_t	ui_stime;		/* system time */
5755714Skris	u_quad_t	ui_mem;			/* memory use */
5855714Skris	u_quad_t	ui_io;			/* number of disk i/o ops */
5955714Skris};
6055714Skris
6155714Skris/* typedefs */
62109998Smarkm
63109998Smarkmtypedef	int (*cmpf_t)(const DBT *, const DBT *);
64238405Sjkim
65109998Smarkm/* external functions in pdb.c */
66109998Smarkmint	pacct_init(void);
6755714Skrisvoid	pacct_destroy(void);
6855714Skrisint	pacct_add(const struct cmdinfo *);
6955714Skrisint	pacct_update(void);
7055714Skrisvoid	pacct_print(void);
7155714Skris
7255714Skris/* external functions in usrdb.c */
73109998Smarkmint	usracct_init(void);
74109998Smarkmvoid	usracct_destroy(void);
7559191Skrisint	usracct_add(const struct cmdinfo *);
7659191Skrisint	usracct_update(void);
7759191Skrisvoid	usracct_print(void);
7859191Skris
7959191Skris/* variables */
8055714Skris
8155714Skrisextern int	aflag, bflag, cflag, dflag, Dflag, fflag, iflag, jflag, kflag;
8255714Skrisextern int	Kflag, lflag, mflag, qflag, rflag, sflag, tflag, uflag, vflag;
8355714Skrisextern u_quad_t	cutoff;
8455714Skrisextern cmpf_t	sa_cmp;
85109998Smarkmextern const char *pdb_file, *usrdb_file;
8655714Skris
8755714Skris/* some #defines to help with db's stupidity */
8855714Skris
8955714Skris#define	DB_CLOSE(db) \
9055714Skris	((*(db)->close)(db))
9155714Skris#define	DB_GET(db, key, data, flags) \
92109998Smarkm	((*(db)->get)((db), (key), (data), (flags)))
9355714Skris#define	DB_PUT(db, key, data, flags) \
9455714Skris	((*(db)->put)((db), (key), (data), (flags)))
9555714Skris#define	DB_SYNC(db, flags) \
96109998Smarkm	((*(db)->sync)((db), (flags)))
97109998Smarkm#define	DB_SEQ(db, key, data, flags) \
98109998Smarkm	((*(db)->seq)((db), (key), (data), (flags)))
99109998Smarkm