mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
Reformat libmaxsi format.cpp.
This commit is contained in:
parent
63b1c50cd2
commit
6f08593801
1 changed files with 295 additions and 300 deletions
|
@ -1,6 +1,6 @@
|
|||
/******************************************************************************
|
||||
/*******************************************************************************
|
||||
|
||||
COPYRIGHT(C) JONAS 'SORTIE' TERMANSEN 2011.
|
||||
Copyright(C) Jonas 'Sortie' Termansen 2011.
|
||||
|
||||
This file is part of LibMaxsi.
|
||||
|
||||
|
@ -11,8 +11,8 @@
|
|||
|
||||
LibMaxsi 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 Lesser General Public License for
|
||||
more details.
|
||||
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with LibMaxsi. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
@ -20,18 +20,16 @@
|
|||
format.cpp
|
||||
Provides printf formatting functions that uses callbacks.
|
||||
|
||||
******************************************************************************/
|
||||
*******************************************************************************/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
namespace Maxsi
|
||||
namespace String {
|
||||
|
||||
static int ConvertInt32(int32_t num, char* dest)
|
||||
{
|
||||
namespace String
|
||||
{
|
||||
int ConvertInt32(int32_t num, char* dest)
|
||||
{
|
||||
int result = 0;
|
||||
int32_t copy = num;
|
||||
|
||||
|
@ -60,10 +58,10 @@ namespace Maxsi
|
|||
}
|
||||
|
||||
return result + 1;
|
||||
}
|
||||
}
|
||||
|
||||
int ConvertInt64(int64_t num, char* dest)
|
||||
{
|
||||
static int ConvertInt64(int64_t num, char* dest)
|
||||
{
|
||||
int result = 0;
|
||||
int64_t copy = num;
|
||||
|
||||
|
@ -92,10 +90,10 @@ namespace Maxsi
|
|||
}
|
||||
|
||||
return result + 1;
|
||||
}
|
||||
}
|
||||
|
||||
int ConvertUInt32(uint32_t num, char* dest)
|
||||
{
|
||||
static int ConvertUInt32(uint32_t num, char* dest)
|
||||
{
|
||||
int result = 0;
|
||||
uint32_t copy = num;
|
||||
int offset = 0;
|
||||
|
@ -107,10 +105,10 @@ namespace Maxsi
|
|||
}
|
||||
|
||||
return result + 1;
|
||||
}
|
||||
}
|
||||
|
||||
int ConvertUInt64(uint64_t num, char* dest)
|
||||
{
|
||||
static int ConvertUInt64(uint64_t num, char* dest)
|
||||
{
|
||||
int result = 0;
|
||||
uint64_t copy = num;
|
||||
int offset = 0;
|
||||
|
@ -122,10 +120,10 @@ namespace Maxsi
|
|||
}
|
||||
|
||||
return result + 1;
|
||||
}
|
||||
}
|
||||
|
||||
int ConvertUInt32Hex(uint32_t num, char* dest)
|
||||
{
|
||||
static int ConvertUInt32Hex(uint32_t num, char* dest)
|
||||
{
|
||||
char chars[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
||||
'A', 'B', 'C', 'D', 'E', 'F' };
|
||||
int result = 0;
|
||||
|
@ -139,10 +137,10 @@ namespace Maxsi
|
|||
}
|
||||
|
||||
return result + 1;
|
||||
}
|
||||
}
|
||||
|
||||
int ConvertUInt64Hex(uint64_t num, char* dest)
|
||||
{
|
||||
static int ConvertUInt64Hex(uint64_t num, char* dest)
|
||||
{
|
||||
char chars[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
||||
'A', 'B', 'C', 'D', 'E', 'F' };
|
||||
int result = 0;
|
||||
|
@ -156,23 +154,22 @@ namespace Maxsi
|
|||
}
|
||||
|
||||
return result + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace Format
|
||||
{
|
||||
#define READY_SIZE 128
|
||||
} // namespace String
|
||||
|
||||
#define READY_FLUSH() \
|
||||
#define READY_SIZE 128
|
||||
|
||||
#define READY_FLUSH() \
|
||||
ready[readylen] = '\0'; \
|
||||
if ( 0 < readylen && callback && callback(user, ready, readylen) != readylen ) { return SIZE_MAX; } \
|
||||
written += readylen; readylen = 0;
|
||||
|
||||
extern "C" size_t vprintf_callback(size_t (*callback)(void*, const char*, size_t),
|
||||
extern "C" size_t vprintf_callback(size_t (*callback)(void*, const char*, size_t),
|
||||
void* user,
|
||||
const char* restrict format,
|
||||
va_list parameters)
|
||||
{
|
||||
{
|
||||
size_t written = 0;
|
||||
size_t readylen = 0;
|
||||
char ready[READY_SIZE + 1];
|
||||
|
@ -327,6 +324,4 @@ namespace Maxsi
|
|||
READY_FLUSH();
|
||||
|
||||
return written;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue