mirror of
https://github.com/tailix/libkernaux.git
synced 2024-10-30 11:54:01 -04:00
Reorder code
This commit is contained in:
parent
8eae115cbd
commit
1a0c46b03d
2 changed files with 19 additions and 19 deletions
|
@ -50,15 +50,6 @@ extern "C" {
|
|||
int kernaux_printf(void (*out)(char character, void* arg), void* arg, const char* format, ...);
|
||||
int kernaux_vprintf(void (*out)(char character, void* arg), void* arg, const char* format, va_list va);
|
||||
|
||||
/**
|
||||
* Tiny sprintf implementation
|
||||
* Due to security reasons (buffer overflow) YOU SHOULD CONSIDER USING (V)SNPRINTF INSTEAD!
|
||||
* \param buffer A pointer to the buffer where to store the formatted string. MUST be big enough to store the output!
|
||||
* \param format A string that specifies the format of the output
|
||||
* \return The number of characters that are WRITTEN into the buffer, not counting the terminating null character
|
||||
*/
|
||||
int kernaux_sprintf(char* buffer, const char* format, ...);
|
||||
|
||||
/**
|
||||
* Tiny snprintf/vsnprintf implementation
|
||||
* \param buffer A pointer to the buffer where to store the formatted string
|
||||
|
@ -72,6 +63,15 @@ int kernaux_sprintf(char* buffer, const char* format, ...);
|
|||
int kernaux_snprintf(char* buffer, size_t count, const char* format, ...);
|
||||
int kernaux_vsnprintf(char* buffer, size_t count, const char* format, va_list va);
|
||||
|
||||
/**
|
||||
* Tiny sprintf implementation
|
||||
* Due to security reasons (buffer overflow) YOU SHOULD CONSIDER USING (V)SNPRINTF INSTEAD!
|
||||
* \param buffer A pointer to the buffer where to store the formatted string. MUST be big enough to store the output!
|
||||
* \param format A string that specifies the format of the output
|
||||
* \return The number of characters that are WRITTEN into the buffer, not counting the terminating null character
|
||||
*/
|
||||
int kernaux_sprintf(char* buffer, const char* format, ...);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
20
src/printf.c
20
src/printf.c
|
@ -852,16 +852,6 @@ int kernaux_vprintf(void (*out)(char character, void* arg), void* arg, const cha
|
|||
}
|
||||
|
||||
|
||||
int kernaux_sprintf(char* buffer, const char* format, ...)
|
||||
{
|
||||
va_list va;
|
||||
va_start(va, format);
|
||||
const int ret = _vsnprintf(_out_buffer, buffer, (size_t)-1, format, va);
|
||||
va_end(va);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int kernaux_snprintf(char* buffer, size_t count, const char* format, ...)
|
||||
{
|
||||
va_list va;
|
||||
|
@ -876,3 +866,13 @@ int kernaux_vsnprintf(char* buffer, size_t count, const char* format, va_list va
|
|||
{
|
||||
return _vsnprintf(_out_buffer, buffer, count, format, va);
|
||||
}
|
||||
|
||||
|
||||
int kernaux_sprintf(char* buffer, const char* format, ...)
|
||||
{
|
||||
va_list va;
|
||||
va_start(va, format);
|
||||
const int ret = _vsnprintf(_out_buffer, buffer, (size_t)-1, format, va);
|
||||
va_end(va);
|
||||
return ret;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue