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
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.
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]
23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
26 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
27 /* All Rights Reserved */
29 #pragma ident "%Z%%M% %I% %E% SMI"
33 static struct utmpx utdummy
; /* dummy - used to get member sizes */
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 */
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 */
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 */
54 #define TSIZE1 100 /* # distinct names, for speed only */
78 * The size of LSZ is based on MAX_SRCH_DEPTH because of the
79 * implementation of devtolin()
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 */
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.
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)
109 #define EQN(s1, s2) (strncmp(s1, s2, sizeof(s1)) == 0)
110 #define CPYN(s1, s2) (void) strncpy(s1, s2 ? s2 : "", sizeof(s1))
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)
119 #define KCORE(clicks) ((double) BSIZE * (clicks/1024.0))
121 #define KCORE(clicks) ((double) (sysconf(_SC_PAGESIZE) >> 10) *clicks)
125 * total accounting (for acct period), also for day
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 */
143 * connect time record
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 */
154 * per process temporary data
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) */