Fix naming convention
This commit is contained in:
parent
bb338affeb
commit
8e52414e44
@ -36,7 +36,7 @@
|
||||
#include <string.h>
|
||||
#include <strformat.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static StrFormatResult
|
||||
static strformat_result
|
||||
write_str(void *user_data, const char *data, unsigned int len)
|
||||
{
|
||||
if(len > 0) {
|
||||
@ -45,7 +45,7 @@ write_str(void *user_data, const char *data, unsigned int len)
|
||||
return STRFORMAT_OK;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static StrFormatContext ctxt =
|
||||
static strformat_context_t ctxt =
|
||||
{
|
||||
write_str,
|
||||
NULL
|
||||
|
@ -35,15 +35,15 @@
|
||||
#include <strformat.h>
|
||||
#include <string.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
struct FmtBuffer {
|
||||
struct fmt_buffer {
|
||||
char *pos;
|
||||
size_t left;
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static StrFormatResult
|
||||
static strformat_result
|
||||
buffer_str(void *user_data, const char *data, unsigned int len)
|
||||
{
|
||||
struct FmtBuffer *buffer = (struct FmtBuffer *)user_data;
|
||||
struct fmt_buffer *buffer = (struct fmt_buffer *)user_data;
|
||||
if(len >= buffer->left) {
|
||||
len = buffer->left;
|
||||
len--;
|
||||
@ -69,8 +69,8 @@ snprintf(char *str, size_t size, const char *format, ...)
|
||||
int
|
||||
vsnprintf(char *str, size_t size, const char *format, va_list ap)
|
||||
{
|
||||
struct FmtBuffer buffer;
|
||||
StrFormatContext ctxt;
|
||||
struct fmt_buffer buffer;
|
||||
strformat_context_t ctxt;
|
||||
int res;
|
||||
ctxt.write_str = buffer_str;
|
||||
ctxt.user_data = &buffer;
|
||||
|
@ -35,7 +35,7 @@
|
||||
#include <strformat.h>
|
||||
#include <string.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static StrFormatResult
|
||||
static strformat_result
|
||||
buffer_str(void *user_data, const char *data, unsigned int len)
|
||||
{
|
||||
memcpy(*(char **)user_data, data, len);
|
||||
@ -46,7 +46,7 @@ buffer_str(void *user_data, const char *data, unsigned int len)
|
||||
int
|
||||
sprintf(char *str, const char *format, ...)
|
||||
{
|
||||
StrFormatContext ctxt;
|
||||
strformat_context_t ctxt;
|
||||
int res;
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
|
@ -239,10 +239,10 @@ output_uint_octal(char **posp, LARGEST_UNSIGNED v)
|
||||
return len;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static StrFormatResult
|
||||
fill_space(const StrFormatContext *ctxt, unsigned int len)
|
||||
static strformat_result
|
||||
fill_space(const strformat_context_t *ctxt, unsigned int len)
|
||||
{
|
||||
StrFormatResult res;
|
||||
strformat_result res;
|
||||
static const char buffer[16] = " ";
|
||||
|
||||
while(len > 16) {
|
||||
@ -260,10 +260,10 @@ fill_space(const StrFormatContext *ctxt, unsigned int len)
|
||||
return ctxt->write_str(ctxt->user_data, buffer, len);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static StrFormatResult
|
||||
fill_zero(const StrFormatContext *ctxt, unsigned int len)
|
||||
static strformat_result
|
||||
fill_zero(const strformat_context_t *ctxt, unsigned int len)
|
||||
{
|
||||
StrFormatResult res;
|
||||
strformat_result res;
|
||||
static const char buffer[16] = "0000000000000000";
|
||||
|
||||
while(len > 16) {
|
||||
@ -281,7 +281,7 @@ fill_zero(const StrFormatContext *ctxt, unsigned int len)
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int
|
||||
format_str(const StrFormatContext *ctxt, const char *format, ...)
|
||||
format_str(const strformat_context_t *ctxt, const char *format, ...)
|
||||
{
|
||||
int ret;
|
||||
va_list ap;
|
||||
@ -292,7 +292,7 @@ format_str(const StrFormatContext *ctxt, const char *format, ...)
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int
|
||||
format_str_v(const StrFormatContext *ctxt, const char *format, va_list ap)
|
||||
format_str_v(const strformat_context_t *ctxt, const char *format, va_list ap)
|
||||
{
|
||||
unsigned int written = 0;
|
||||
const char *pos = format;
|
||||
|
@ -39,21 +39,23 @@
|
||||
#define STRFORMAT_OK 0
|
||||
#define STRFORMAT_FAILED 1
|
||||
/*---------------------------------------------------------------------------*/
|
||||
typedef unsigned int StrFormatResult;
|
||||
typedef unsigned int strformat_result;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* The data argument may only be considered valid during the function call */
|
||||
typedef StrFormatResult (*StrFormatWrite)(void *user_data, const char *data, unsigned int len);
|
||||
typedef strformat_result (*strformat_write)(void *user_data,
|
||||
const char *data,
|
||||
unsigned int len);
|
||||
|
||||
typedef struct _StrFormatContext {
|
||||
StrFormatWrite write_str;
|
||||
typedef struct strformat_context_s {
|
||||
strformat_write write_str;
|
||||
void *user_data;
|
||||
} StrFormatContext;
|
||||
} strformat_context_t;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int format_str(const StrFormatContext *ctxt, const char *format, ...)
|
||||
int format_str(const strformat_context_t *ctxt, const char *format, ...)
|
||||
__attribute__ ((__format__ (__printf__, 2,3)));
|
||||
|
||||
int
|
||||
format_str_v(const StrFormatContext *ctxt, const char *format, va_list ap);
|
||||
format_str_v(const strformat_context_t *ctxt, const char *format, va_list ap);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#endif /* STRFORMAT_H_ */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
Loading…
Reference in New Issue
Block a user