Source
xxxxxxxxxx
for (pc = p_str, pc_r = *p_b64str; 0 != full_block_num; pc += c_per_block, pc_r += b_per_block, full_block_num--)
/*
** 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.
**/
/******************************************************************************
* *
* Purpose: is the character passed in a base64 character? *
* *
* Parameters: c - character to test *
* *
* Return value: SUCCEED - the character is a base64 character *
* FAIL - otherwise *
* *
******************************************************************************/
static int is_base64(char c)
{
if ((c >= 'A' && c <= 'Z') ||
(c >= 'a' && c <= 'z') ||
(c >= '0' && c <= '9') ||
c == '+' ||
c == '/' ||
c == '=')
{
return SUCCEED;
}
return FAIL;
}
/******************************************************************************
* *
* Purpose: encode 6 bits into a base64 character *
* *
* Parameters: uc - character to encode. Its value must be 0 ... 63. *
* Return value: byte encoded into a base64 character *
* *
******************************************************************************/
static char char_base64_encode(unsigned char uc)
{
static const char base64_set[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
return base64_set[uc];
}
/******************************************************************************
* *
* Purpose: decode a base64 character into a byte *
* *
* Parameters: c - character to decode *
* *
* Return value: base64 character decoded into a byte *
* *
******************************************************************************/
static unsigned char char_base64_decode(char c)
{
if (c >= 'A' && c <= 'Z')
{
return c - 'A';
}
if (c >= 'a' && c <= 'z')
{
return c - 'a' + 26;
}
if (c >= '0' && c <= '9')
{
return c - '0' + 52;
}