zabbix-agent2/src/libs/zbxcommon/cuid.c
/******************************************************************************
 *                                                                            *
 * Function: zbx_cuid_init                                                    *
 *                                                                            *
 * Purpose: initializes context for the cuid generation                       *
 *                                                                            *
 ******************************************************************************/
zbx_cuid_init

Purpose: initializes context for the cuid generation
zbx_cuid_init Purpose : initializes context for the cuid generation
static void	zbx_cuid_init(void)
{
	char		*hostname;
	size_t		hostname_num, hostname_len, i;
	struct utsname	name;
	srand((unsigned int)time(NULL) + (unsigned int)getpid());
	if (-1 == uname(&name))
		hostname = zbx_strdup(NULL, "dummy");
	else
		hostname = zbx_strdup(NULL, name.nodename);
	hostname_len = strlen(hostname);
	hostname_num = hostname_len + CUID_BASE_36;
	for (i = 0; i < hostname_len; i++)
		hostname_num = hostname_num + (size_t)hostname[i];
	from_decimal(host_block, CUID_BASE_36, hostname_num);
	pad(host_block, sizeof(host_block), CUID_HOSTNAME_BLOCK_SIZE, PAD_FILL_CHAR);
	zbx_free(hostname);
}
static void zbx_cuid_init ( void ) { char * hostname ; size_t hostname_num , hostname_len , i ; struct utsname name ; srand ( ( unsigned int ) time ( NULL ) + ( unsigned int ) getpid ( ) ) ; if ( -1 == uname ( & name ) ) hostname = zbx_strdup ( NULL , " " ) ; else hostname = zbx_strdup ( NULL , name . nodename ) ; hostname_len = strlen ( hostname ) ; hostname_num = hostname_len + CUID_BASE_36 ; for ( i = 0 ; i < hostname_len ; i ++ ) hostname_num = hostname_num + ( size_t ) hostname [ i ] ; from_decimal ( host_block , CUID_BASE_36 , hostname_num ) ; pad ( host_block , sizeof ( host_block ) , CUID_HOSTNAME_BLOCK_SIZE , PAD_FILL_CHAR ) ; zbx_free ( hostname ) ; }
Function: zbx_cuid_init                                                    
                                                                            
 Purpose: initializes context for the cuid generation
Function : zbx_cuid_init Purpose : initializes context for the cuid generation