FreeBSD/sys/security/audit/bsm_token.c
/*
 * token ID                1 byte
 * how to print            1 byte
 * basic unit              1 byte
 * unit count              1 byte
 * data items              (depends on basic unit)
 */
token ID                1 byte
how to print            1 byte
basic unit              1 byte
unit count              1 byte
data items              (depends on basic unit)
token ID 1 byte how to print 1 byte basic unit 1 byte unit count 1 byte data items ( depends on basic unit )
token_t *
au_to_data(char unit_print, char unit_type, char unit_count, const char *p)
{
	token_t *t;
	u_char *dptr = NULL;
	size_t datasize, totdata;
	switch (unit_type) {
	case AUR_BYTE:
		datasize = AUR_BYTE_SIZE;
		break;
	case AUR_SHORT:
		datasize = AUR_SHORT_SIZE;
		break;
	case AUR_INT32:
		datasize = AUR_INT32_SIZE;
		break;
	case AUR_INT64:
		datasize = AUR_INT64_SIZE;
		break;
	default:
		return (NULL);
	}
	totdata = datasize * unit_count;
	GET_TOKEN_AREA(t, dptr, 4 * sizeof(u_char) + totdata);
	ADD_U_CHAR(dptr, AUT_DATA);
	ADD_U_CHAR(dptr, unit_print);
	ADD_U_CHAR(dptr, unit_type);
	ADD_U_CHAR(dptr, unit_count);
	ADD_MEM(dptr, p, totdata);
	return (t);
}
token_t * au_to_data ( char unit_print , char unit_type , char unit_count , const char * p ) { token_t * t ; u_char * dptr = NULL ; size_t datasize , totdata ; switch ( unit_type ) { case AUR_BYTE : datasize = AUR_BYTE_SIZE ; break ; case AUR_SHORT : datasize = AUR_SHORT_SIZE ; break ; case AUR_INT32 : datasize = AUR_INT32_SIZE ; break ; case AUR_INT64 : datasize = AUR_INT64_SIZE ; break ; default : return ( NULL ) ; } totdata = datasize * unit_count ; GET_TOKEN_AREA ( t , dptr , 4 * sizeof ( u_char ) + totdata ) ; ADD_U_CHAR ( dptr , AUT_DATA ) ; ADD_U_CHAR ( dptr , unit_print ) ; ADD_U_CHAR ( dptr , unit_type ) ; ADD_U_CHAR ( dptr , unit_count ) ; ADD_MEM ( dptr , p , totdata ) ; return ( t ) ; }
token ID                1 byte
 how to print            1 byte
 basic unit              1 byte
 unit count              1 byte
 data items              (depends on basic unit)
token ID 1 byte how to print 1 byte basic unit 1 byte unit count 1 byte data items ( depends on basic unit )
/* Determine the size of the basic unit. */ /* case AUR_CHAR: */ /* case AUR_INT: */ /*
	 * XXXRW: We should be byte-swapping each data item for multi-byte
	 * types.
	 */