xnu-4903.241.1/bsd/security/audit/audit_bsm_token.c
/*
 * token ID               1 byte
 * count                  4 bytes
 * text                   count null-terminated strings
 */
token ID               1 byte
count                  4 bytes
text                   count null-terminated strings
token ID 1 byte count 4 bytes text count null - terminated strings
token_t *
au_to_exec_env(char **envp)
{
	token_t *t;
	u_char *dptr = NULL;
	int i, count = 0;
	size_t totlen = 0;
	const char *nextenv;
	nextenv = *envp;
	while (nextenv != NULL) {
		int nextlen;
		nextlen = strlen(nextenv);
		totlen += nextlen + 1;
		count++;
		nextenv = *(envp + count);
	}
	GET_TOKEN_AREA(t, dptr, sizeof(u_char) + sizeof(u_int32_t) + totlen);
	ADD_U_CHAR(dptr, AUT_EXEC_ENV);
	ADD_U_INT32(dptr, count);
	for (i = 0; i < count; i++) {
		nextenv = *(envp + i);
		ADD_MEM(dptr, nextenv, strlen(nextenv) + 1);
	}
	return (t);
}
token_t * au_to_exec_env ( char * * envp ) { token_t * t ; u_char * dptr = NULL ; int i , count = 0 ; size_t totlen = 0 ; const char * nextenv ; nextenv = * envp ; while ( nextenv != NULL ) { int nextlen ; nextlen = strlen ( nextenv ) ; totlen += nextlen + 1 ; count ++ ; nextenv = * ( envp + count ) ; } GET_TOKEN_AREA ( t , dptr , sizeof ( u_char ) + sizeof ( u_int32_t ) + totlen ) ; ADD_U_CHAR ( dptr , AUT_EXEC_ENV ) ; ADD_U_INT32 ( dptr , count ) ; for ( i = 0 ; i < count ; i ++ ) { nextenv = * ( envp + i ) ; ADD_MEM ( dptr , nextenv , strlen ( nextenv ) + 1 ) ; } return ( t ) ; }
token ID               1 byte
 count                  4 bytes
 text                   count null-terminated strings
token ID 1 byte count 4 bytes text count null - terminated strings