Source
xxxxxxxxxx
from_decimal(timestamp, CUID_BASE_36, ((zbx_uint64_t)current_time.tv_sec * 1000 + current_time.tv_usec / 1000));
/*
** Zabbix
** Copyright (C) 2001-2023 Zabbix SIA
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
static char host_block[HOST_TMP_36_BASE_BUF_LEN];
/******************************************************************************
* *
* Purpose: modify string in-place to the specified length as required by *
* CUID algorithm *
* *
* Parameters: *
* input - [IN/OUT] input string and result *
* input_alloc - [IN] buffer size where the input string is stored. It *
* should be larger than 'pad_size'. *
* pad_size - [IN] target length *
* fill_char - [IN] character used to fill target string if there are *
* not enough existing characters *
* *
******************************************************************************/
static void pad(char *input, size_t input_alloc, size_t pad_size, char fill_char)
{
size_t input_len;
if (pad_size == (input_len = strlen(input)))
return;
if (pad_size > input_len) /* make string longer by prepending fill_char s */
{
if (pad_size + 1 > input_alloc || input_len + 1 > input_alloc)
{
THIS_SHOULD_NEVER_HAPPEN;
return;
}
memmove(input + pad_size - input_len, input, input_len);
memset(input, fill_char, pad_size - input_len);
}
else /* make string shorter by keeping only last characters */
memmove(input, input + input_len - pad_size, pad_size);
input[pad_size] = '\0';
}
static char base36_digit(size_t num)
{
if (num <= 9)
return (char)(num + '0');
return (char)(num - 10 + 'a');
}
static void str_rev(char *str)