FreeBSD/usr.bin/lastcomm/readrec.c
/*
 * Read a v1 accounting record stored at the current
 * position of stream f.
 * Convert the data to the current record format.
 * Return EOF on error or end-of-file.
 */
Read a v1 accounting record stored at the current
position of stream f.
Convert the data to the current record format.
Return EOF on error or end-of-file.
Read a v1 accounting record stored at the current position of stream f . Convert the data to the current record format . Return EOF on error or end - of - file .
static int
readrec_v1(FILE *f, struct acctv2 *av2)
{
	struct acctv1 av1;
	int rv;
	if ((rv = fread_record(&av1, sizeof(av1), f)) == EOF)
		return (EOF);
	av2->ac_zero = 0;
	av2->ac_version = 2;
	av2->ac_len = av2->ac_len2 = sizeof(*av2);
	memcpy(av2->ac_comm, av1.ac_comm, AC_COMM_LEN);
	av2->ac_utime = decode_comp(av1.ac_utime) * 1000000;
	av2->ac_stime = decode_comp(av1.ac_stime) * 1000000;
	av2->ac_etime = decode_comp(av1.ac_etime) * 1000000;
	av2->ac_btime = av1.ac_btime;
	av2->ac_uid = av1.ac_uid;
	av2->ac_gid = av1.ac_gid;
	av2->ac_mem = av1.ac_mem;
	av2->ac_io = decode_comp(av1.ac_io);
	av2->ac_tty = av1.ac_tty;
	av2->ac_flagx = av1.ac_flag | ANVER;
	return (0);
}
static int readrec_v1 ( FILE * f , struct acctv2 * av2 ) { struct acctv1 av1 ; int rv ; if ( ( rv = fread_record ( & av1 , sizeof ( av1 ) , f ) ) == EOF ) return ( EOF ) ; av2 -> ac_zero = 0 ; av2 -> ac_version = 2 ; av2 -> ac_len = av2 -> ac_len2 = sizeof ( * av2 ) ; memcpy ( av2 -> ac_comm , av1 . ac_comm , AC_COMM_LEN ) ; av2 -> ac_utime = decode_comp ( av1 . ac_utime ) * 1000000 ; av2 -> ac_stime = decode_comp ( av1 . ac_stime ) * 1000000 ; av2 -> ac_etime = decode_comp ( av1 . ac_etime ) * 1000000 ; av2 -> ac_btime = av1 . ac_btime ; av2 -> ac_uid = av1 . ac_uid ; av2 -> ac_gid = av1 . ac_gid ; av2 -> ac_mem = av1 . ac_mem ; av2 -> ac_io = decode_comp ( av1 . ac_io ) ; av2 -> ac_tty = av1 . ac_tty ; av2 -> ac_flagx = av1 . ac_flag | ANVER ; return ( 0 ) ; }
Read a v1 accounting record stored at the current
 position of stream f.
 Convert the data to the current record format.
Read a v1 accounting record stored at the current position of stream f . Convert the data to the current record format .