FreeBSD/sys/security/audit/bsm_token.c
/*
 * token ID		1 byte
 * privtstrlen		2 bytes
 * privtstr		N bytes + 1
 * privstrlen		2 bytes
 * privstr		N bytes + 1
 */
token ID             1 byte
privtstrlen          2 bytes
privtstr             N bytes + 1
privstrlen           2 bytes
privstr              N bytes + 1
token ID 1 byte privtstrlen 2 bytes privtstr N bytes + 1 privstrlen 2 bytes privstr N bytes + 1
token_t *
au_to_privset(char *privtypestr, char *privstr)
{
	u_int16_t	 type_len, priv_len;
	u_char		*dptr;
	token_t		*t;
	type_len = strlen(privtypestr) + 1;
	priv_len = strlen(privstr) + 1;
	GET_TOKEN_AREA(t, dptr, sizeof(u_char) + sizeof(u_int16_t) +
	    sizeof(u_int16_t) + type_len + priv_len);
	ADD_U_CHAR(dptr, AUT_PRIV);
	ADD_U_INT16(dptr, type_len);
	ADD_STRING(dptr, privtypestr, type_len);
	ADD_U_INT16(dptr, priv_len);
	ADD_STRING(dptr, privstr, priv_len);
	return (t);
}
token_t * au_to_privset ( char * privtypestr , char * privstr ) { u_int16_t type_len , priv_len ; u_char * dptr ; token_t * t ; type_len = strlen ( privtypestr ) + 1 ; priv_len = strlen ( privstr ) + 1 ; GET_TOKEN_AREA ( t , dptr , sizeof ( u_char ) + sizeof ( u_int16_t ) + sizeof ( u_int16_t ) + type_len + priv_len ) ; ADD_U_CHAR ( dptr , AUT_PRIV ) ; ADD_U_INT16 ( dptr , type_len ) ; ADD_STRING ( dptr , privtypestr , type_len ) ; ADD_U_INT16 ( dptr , priv_len ) ; ADD_STRING ( dptr , privstr , priv_len ) ; return ( t ) ; }
token ID             1 byte
 privtstrlen          2 bytes
 privtstr             N bytes + 1
 privstrlen           2 bytes
 privstr              N bytes + 1
token ID 1 byte privtstrlen 2 bytes privtstr N bytes + 1 privstrlen 2 bytes privstr N bytes + 1