FreeBSD/sys/security/audit/bsm_token.c
token_t *
au_to_exec_args(char **argv)
{
	token_t *t;
	u_char *dptr = NULL;
	const char *nextarg;
	int i, count = 0;
	size_t totlen = 0;

	nextarg = *argv;

	while (nextarg != NULL) {
		int nextlen;

		nextlen = strlen(nextarg);
		totlen += nextlen + 1;
		count++;
		nextarg = *(argv + count);
	}

	GET_TOKEN_AREA(t, dptr, sizeof(u_char) + sizeof(u_int32_t) + totlen);

	ADD_U_CHAR(dptr, AUT_EXEC_ARGS);
	ADD_U_INT32(dptr, count);

	for (i = 0; i < count; i++) {
		nextarg = *(argv + i);
		ADD_MEM(dptr, nextarg, strlen(nextarg) + 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
token ID 1 byte count 4 bytes text count null - terminated strings
token_t *
au_to_exec_args(char **argv)
{
	token_t *t;
	u_char *dptr = NULL;
	const char *nextarg;
	int i, count = 0;
	size_t totlen = 0;
	nextarg = *argv;
	while (nextarg != NULL) {
		int nextlen;
		nextlen = strlen(nextarg);
		totlen += nextlen + 1;
		count++;
		nextarg = *(argv + count);
	}
	GET_TOKEN_AREA(t, dptr, sizeof(u_char) + sizeof(u_int32_t) + totlen);
	ADD_U_CHAR(dptr, AUT_EXEC_ARGS);
	ADD_U_INT32(dptr, count);
	for (i = 0; i < count; i++) {
		nextarg = *(argv + i);
		ADD_MEM(dptr, nextarg, strlen(nextarg) + 1);
	}
	return (t);
}
token_t * au_to_exec_args ( char * * argv ) { token_t * t ; u_char * dptr = NULL ; const char * nextarg ; int i , count = 0 ; size_t totlen = 0 ; nextarg = * argv ; while ( nextarg != NULL ) { int nextlen ; nextlen = strlen ( nextarg ) ; totlen += nextlen + 1 ; count ++ ; nextarg = * ( argv + count ) ; } GET_TOKEN_AREA ( t , dptr , sizeof ( u_char ) + sizeof ( u_int32_t ) + totlen ) ; ADD_U_CHAR ( dptr , AUT_EXEC_ARGS ) ; ADD_U_INT32 ( dptr , count ) ; for ( i = 0 ; i < count ; i ++ ) { nextarg = * ( argv + i ) ; ADD_MEM ( dptr , nextarg , strlen ( nextarg ) + 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