#include "xroad_common_types.h"
#include <stdint.h>
#include <stdarg.h>
Go to the source code of this file.
|
int32_t | xroad_format (char *buf, uint32_t len, const char *fmt,...) |
|
int32_t | xroad_vformat (char *buf, uint32_t len, const char *fmt, va_list ap) |
|
◆ xroad_format()
int32_t xroad_format |
( |
char * |
buf, |
|
|
uint32_t |
len, |
|
|
const char * |
fmt, |
|
|
|
... |
|
) |
| |
printf like formatter
- Parameters
-
[in] | buf | - buffer with formatted output |
[in] | len | - maximum buffer length |
[in] | fmt | - format string. Placeholders format %[pad_sym][length][.precision]<type>, where pad_sym - padding symbol for numbers or byte delimiter for byte array length - field length for numbers, chars and floats precision - precision for floats. If not set 8 digits are assumed Available types
- d - argument is int32_t
- D - argument is int64_t
- u - argument is uint32_t
- U - argument is uint64_t
- c - argument is char
- s(zs*) - argument is C-string
- S(zS*) - argument is fixed length string created by xroad_str_decl
- P(zP*) - argument is xroad_str_t
- f - argument is double. Trailing zeroes are truncated
- F - argument is double. Trailing zeroes are not truncated
- X,x - argument is byte array
- i - argument is xroad_time_t
- a - argument is xroad_date_t
- g - argument is xroad_datetime_t
- - nothing will be printed in case of NULL string
|
- Note
- xroad_format doesn't support O, R formatter as xroad_logger does, because I dont want to make common lib dependent from objects library
- Returns
- number of written chars even if there is no enought space in buf to write, if result < 0, error happened
◆ xroad_vformat()
int32_t xroad_vformat |
( |
char * |
buf, |
|
|
uint32_t |
len, |
|
|
const char * |
fmt, |
|
|
va_list |
ap |
|
) |
| |
the same as xroad_format, but accept va_list instead of ...