/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* acctcon1 [-p] [-t] [-l file] [-o file] <wtmpx-file >ctmp-file
* -p print input only, no processing
* -t test mode: use latest time found in input, rather than
* current time when computing times of lines still on
* (only way to get repeatable data from old files)
* -l file causes output of line usage summary
* A_TSIZE is max # distinct ttys
*/
#include "acctdef.h"
#include <stdio.h>
#include <ctype.h>
#include <time.h>
#include <utmpx.h>
#include <locale.h>
#include <stdlib.h>
struct tbuf {
} * tbuf;
int nsys;
struct sys {
int exitcode;
int printonly;
int tflag;
static int valid(void);
static void loop(void);
static void bootshut(void);
static int iline(void);
static void upall(void);
static void printrep(void);
static void printlin(void);
int
{
switch(*++*argv) {
case 'l':
if (--argc > 0)
continue;
case 'o':
if (--argc > 0)
continue;
case 'p':
printonly++;
continue;
case 't':
tflag++;
continue;
default:
exit(1);
}
exit(3);
}
if (printonly) {
while (wread()) {
if (valid()) {
printf("%.*s\t%.*s\t%lu",
} else
}
}
while (wread()) {
if (firstime == 0)
if (valid())
loop();
else
}
if (tflag)
else
loop();
printrep();
printlin();
}
static size_t
wread()
{
}
/*
* valid: check input wtmp record, return 1 if looks OK
*/
static int
valid()
{
int i, c;
/* XPG say that user names should not start with a "-". */
return(0);
for (i = 0; i < NSZ; i++) {
continue;
else if (c == '\0')
break;
else
return(0);
}
return(1);
return(0);
}
/*
* fixup assumes that V6 wtmp (16 bytes long) is mixed in with
* V7 records (20 bytes each)
*
* Starting with Release 5.0 of UNIX, this routine will no
* longer reset the read pointer. This has a snowball effect
* On the following records until the offset corrects itself.
* If a message is printed from here, it should be regarded as
* a bad record and not as a V6 record.
*/
static void
{
#ifdef V6
#endif
exitcode = 1;
}
static void
loop()
{
int timediff;
return; /* no connect accounting data here */
case OLD_TIME:
return;
case NEW_TIME:
if(datetime == 0)
return;
datetime = 0;
ndates++;
return;
case BOOT_TIME:
upall();
case ACCOUNTING:
case RUN_LVL:
bootshut();
return;
case USER_PROCESS:
case LOGIN_PROCESS:
case INIT_PROCESS:
case DEAD_PROCESS:
return;
case EMPTY:
return;
default:
time_buf);
}
}
/*
* bootshut: record reboot (or shutdown)
* bump count, looking up wb.ut_line in sy table
*/
static void
bootshut()
{
int i;
;
if (i >= nsys) {
"acctcon1: recompile with larger NSYS\n");
return;
}
}
}
/*
* (used to avoid system dependencies on naming)
*/
static int
iline()
{
int i;
for (i = 0; i <= tsize; i++)
return(i);
exit(2);
}
}
return(tsize);
}
static void
upall()
{
}
/*
* update tbuf with new time, write ctmp record for end of session
*/
static void
{
/* Difference is connect time */
exitcode = 1;
return;
}
case USER_PROCESS:
/* logging off. Put out record. */
exit(1);
}
}
else /* Someone just logged in */
break;
case INIT_PROCESS:
case LOGIN_PROCESS:
case DEAD_PROCESS:
/* Set up and print ctmp record */
exit(1);
}
}
}
}
static void
printrep()
{
int i;
if (ndates)
for (i = 0; i < nsys; i++)
}
/*
* print summary of line usage
* accuracy only guaranteed for wtmpx file started fresh
*/
static void
printlin()
{
double ttime;
ttime = 0.0;
printf("LINE MINUTES PERCENT # SESS # ON # OFF\n");
printf("%-*.*s %-7.0f %-7.0f %-6d %-4d %-5d\n",
}
printf("TOTALS %-7.0f -- %-6d %-4d %-5d\n",
}
static void
{
printf("%u\t%ld\t%.*s\t%lu\t%lu\t%lu",
t->ct_tty,
t->ct_uid,
t->ct_name,
t->ct_con[0],
t->ct_con[1],
t->ct_start);
}