You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.4 KiB
44 lines
1.4 KiB
//
|
|
// Created by MightyPork on 2017/11/09.
|
|
//
|
|
// Small sprintf/snprintf implementation, used instead of the newlib one.
|
|
//
|
|
|
|
#ifndef GEX_SNPRINTF_H
|
|
#define GEX_SNPRINTF_H
|
|
|
|
#include <stdarg.h>
|
|
#include <limits.h>
|
|
|
|
int fixup_vsnprintf(char *str, size_t count, const char *fmt, va_list args);
|
|
int fixup_snprintf(char *str, size_t count,const char *fmt,...);
|
|
int fixup_vasprintf(char **ptr, const char *format, va_list ap);
|
|
int fixup_asprintf(char **ptr, const char *format, ...);
|
|
int fixup_sprintf(char *ptr, const char *format, ...);
|
|
int fixup_printf(const char *format, ...);
|
|
int fixup_vprintf(const char *format, va_list ap);
|
|
|
|
#define VSNPRINTF(...) fixup_vsnprintf(__VA_ARGS__)
|
|
#define SNPRINTF(...) fixup_snprintf(__VA_ARGS__)
|
|
#define VASPRINTF(...) fixup_vasprintf(__VA_ARGS__)
|
|
#define ASPRINTF(...) fixup_asprintf(__VA_ARGS__)
|
|
#define SPRINTF(...) fixup_sprintf(__VA_ARGS__)
|
|
#define PRINTF(...) fixup_printf(__VA_ARGS__)
|
|
#define VPRINTF(...) fixup_vprintf(__VA_ARGS__)
|
|
|
|
// for debug
|
|
//#include <stdio.h>
|
|
//#define PRINTF(...) printf(__VA_ARGS__)
|
|
//#define SPRINTF(...) sprintf(__VA_ARGS__)
|
|
|
|
// extern
|
|
|
|
extern void stdout_puts(const char *s);
|
|
extern void stdout_putchar(char c);
|
|
extern void stdout_write(const char *s, size_t len);
|
|
|
|
#define PUTS(s) stdout_puts((s))
|
|
#define PUTCHAR(c) stdout_putchar((c))
|
|
#define WRITE(s, n) stdout_write((s), (n))
|
|
|
|
#endif //GEX_SNPRINTF_H
|
|
|