xref: /titanic_44/usr/src/cmd/acct/acctdef.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
27 /*	  All Rights Reserved  	*/
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #include <utmpx.h>
32 
33 static struct utmpx utdummy;	/* dummy - used to get member sizes */
34 
35 #define PACCT		"/var/adm/pacct"
36 #define HOLFILE		"/etc/acct/holidays"
37 #define	NHOLIDAYS	200	/* max number of company holidays per year */
38 #define NSYS		200	/* number of run state changes */
39 #define NFILE		100	/* max number of files that acctmerg handles */
40 
41 #ifdef uts
42 #define CSIZE 		10001
43 #define	MAXUSERS	5003
44 #define A_SSIZE 	60001     /* max num of sessions in 1 acct run */
45 #define A_TSIZE 	10001     /* max num of line names in 1 acct run */
46 #define A_USIZE 	20001     /* max num of distinct login names in 1 acct run */
47 #else
48 #define CSIZE 		5001
49 #define	MAXUSERS	3001
50 #define A_SSIZE 	6001     /* max num of sessions in 1 acct run */
51 #define A_TSIZE 	1001     /* max num of line names in 1 acct run */
52 #define A_USIZE 	2001     /* max num of distinct login names in 1 acct run */
53 #endif
54 #define TSIZE1		100	/* # distinct names, for speed only */
55 #define USIZE1		100
56 
57 #define	MAXIGN		10
58 #define	UNUSED		-1
59 #define	FAIL		-1
60 #define	SUCCEED		0
61 #define	TRUE		1
62 #define	FALSE		0
63 #define PRIME		0
64 #define NONPRIME	1
65 #define MEANSIZE	01
66 #define KCOREMIN	02
67 #define HOGFACTOR	04
68 #define	SEPTIME		010
69 #define	CPUFACTOR	020
70 #define IORW		040
71 #define	ROOT		0
72 #define	ERR		(-1)
73 #define	OK		0
74 #define	NOGOOD		1
75 #define	VALID		0
76 #define	INVALID		1
77 /*
78  * The size of LSZ is based on MAX_SRCH_DEPTH because of the
79  * implementation of devtolin()
80  */
81 #define MAX_SRCH_DEPTH 4
82 #define LSZ		(MAX_SRCH_DEPTH * sizeof (utdummy.ut_line))
83 #define MAX_DEV_PATH	(LSZ + 5)	/* max len of abs line name path */
84 #define NSZ		(sizeof (utdummy.ut_name)) /* sizeof login name */
85 #define	LINESZ		(sizeof (utdummy.ut_line)) /* sizeof device name */
86 /*
87  * These exist for backward compatibility. Until we can change the
88  * output formats, we need to keep the field widths the same as
89  * they always have been.
90  */
91 #define OUTPUT_NSZ	8
92 #define OUTPUT_LSZ	12
93 
94 #define MYKIND(flag)	((flag & ACCTF) == 0)
95 #define SU(flag)	((flag & ASU) == ASU)
96 #define TOTAL(a)	(a[PRIME] + a[NONPRIME])
97 #define	okay(time)	((time/100>=0) && (time/100<=24) \
98 			&& (time%100>=0) && (time%100<60))
99 #define	pf(dble)	fprintf(stdout, " %7.2lf", dble)
100 #define	ps(s)		fprintf(stdout, "%8.8s", s)
101 #define	diag(string)	fprintf(stderr, "\t%s\n", string)
102 #define DATE_FMT	"%a %b %e %H:%M:%S %Y\n"
103 #define DATE_FMT1	" %H:%M:%S"
104 #define CBEMPTY   	(ctab[i].ct_sess == 0)
105 #define UBEMPTY   	(ub[i].ut_pc == 0 && ub[i].ut_cpu[0] == 0 && \
106 ub[i].ut_cpu[1] == 0 && ub[i].ut_kcore[0] ==0 && ub[i].ut_kcore[1] == 0)
107 
108 
109 #define EQN(s1, s2)	(strncmp(s1, s2, sizeof(s1)) == 0)
110 #define CPYN(s1, s2)	(void) strncpy(s1, s2 ? s2 : "", sizeof(s1))
111 
112 #define SECSINDAY	86400L
113 #define SECS(tics)	((double) tics)/HZ
114 #define MINS(secs)	((double) secs)/60
115 #define MINT(tics)	((double) tics)/(60*HZ)
116 
117 #include <unistd.h>
118 #if UTS
119 #define KCORE(clicks)   ((double) BSIZE * (clicks/1024.0))
120 #else
121 #define KCORE(clicks)   ((double) (sysconf(_SC_PAGESIZE) >> 10) *clicks)
122 #endif
123 
124 /*
125  *	total accounting (for acct period), also for day
126  */
127 
128 struct	tacct	{
129 	uid_t		ta_uid;		/* userid */
130 	char		ta_name[NSZ];	/* login name */
131 	float		ta_cpu[2];	/* cum. cpu time, p/np (mins) */
132 	float		ta_kcore[2];	/* cum kcore-minutes, p/np */
133 	float		ta_con[2];	/* cum. connect time, p/np, mins */
134 	float		ta_du;		/* cum. disk usage */
135 	long		ta_pc;		/* count of processes */
136 	unsigned short	ta_sc;		/* count of login sessions */
137 	unsigned short	ta_dc;		/* count of disk samples */
138 	unsigned short	ta_fee;		/* fee for special services */
139 };
140 
141 
142 /*
143  *	connect time record
144  */
145 struct ctmp {
146 	dev_t	ct_tty;			/* major minor */
147 	uid_t	ct_uid;			/* userid */
148 	char	ct_name[NSZ];		/* login name */
149 	long	ct_con[2];		/* connect time (p/np) secs */
150 	time_t	ct_start;		/* session start time */
151 };
152 
153 /*
154  *	per process temporary data
155  */
156 struct ptmp {
157 	uid_t	pt_uid;			/* userid */
158 	char	pt_name[NSZ];		/* login name */
159 	ulong_t	pt_cpu[2];		/* CPU (sys+usr) P/NP time tics */
160 	unsigned pt_mem;		/* avg. memory size (64byte clicks) */
161 };
162