FreeBSD/usr.bin/lastcomm/readrec.c
/*
 * Read a new-style (post-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 new-style (post-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 new - style ( post - 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_vx(FILE *f, struct acctv2 *av2)
{
	uint8_t magic, version;
	if (fread_record(&magic, sizeof(magic), f) == EOF ||
	    fread_record(&version, sizeof(version), f) == EOF ||
	    ungetc(version, f) == EOF ||
	    ungetc(magic, f) == EOF)
		return (EOF);
	switch (version) {
	case 2:
		return (readrec_v2(f, av2));
	default:
		errno = EFTYPE;
		return (EOF);
	}
}
static int readrec_vx ( FILE * f , struct acctv2 * av2 ) { uint8_t magic , version ; if ( fread_record ( & magic , sizeof ( magic ) , f ) == EOF || fread_record ( & version , sizeof ( version ) , f ) == EOF || ungetc ( version , f ) == EOF || ungetc ( magic , f ) == EOF ) return ( EOF ) ; switch ( version ) { case 2 : return ( readrec_v2 ( f , av2 ) ) ; default : errno = EFTYPE ; return ( EOF ) ; } }
Read a new-style (post-v1) accounting record stored at
 the current position of stream f.
 Convert the data to the current record format.
Read a new - style ( post - v1 ) accounting record stored at the current position of stream f . Convert the data to the current record format .
/* Add handling for more versions here. */