2022-07-28 17:18:17 +08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "arch.h"
|
|
|
|
#include "iobuf.h"
|
|
|
|
|
2023-02-10 23:29:25 +08:00
|
|
|
typedef void (*mg_pfn_t)(char, void *); // Output function
|
2022-07-28 17:18:17 +08:00
|
|
|
typedef size_t (*mg_pm_t)(mg_pfn_t, void *, va_list *); // %M printer
|
|
|
|
|
2023-02-10 23:29:25 +08:00
|
|
|
// The lowest level
|
2022-08-14 03:34:20 +08:00
|
|
|
size_t mg_vxprintf(void (*)(char, void *), void *, const char *fmt, va_list *);
|
|
|
|
size_t mg_xprintf(void (*fn)(char, void *), void *, const char *fmt, ...);
|
2023-02-10 23:29:25 +08:00
|
|
|
|
|
|
|
// Convenience wrappers around mg_xprintf
|
2022-07-28 17:18:17 +08:00
|
|
|
size_t mg_vsnprintf(char *buf, size_t len, const char *fmt, va_list *ap);
|
|
|
|
size_t mg_snprintf(char *, size_t, const char *fmt, ...);
|
2022-08-13 22:37:55 +08:00
|
|
|
char *mg_vmprintf(const char *fmt, va_list *ap);
|
2022-07-28 17:18:17 +08:00
|
|
|
char *mg_mprintf(const char *fmt, ...);
|
2023-02-10 23:29:25 +08:00
|
|
|
|
|
|
|
// %M print helper functions
|
|
|
|
size_t mg_print_ip(void (*out)(char, void *), void *arg, va_list *ap);
|
|
|
|
size_t mg_print_ip_port(void (*out)(char, void *), void *arg, va_list *ap);
|
|
|
|
size_t mg_print_ip4(void (*out)(char, void *), void *arg, va_list *ap);
|
|
|
|
size_t mg_print_ip6(void (*out)(char, void *), void *arg, va_list *ap);
|
|
|
|
size_t mg_print_mac(void (*out)(char, void *), void *arg, va_list *ap);
|
|
|
|
|
|
|
|
// Various output functions
|
|
|
|
void mg_pfn_iobuf(char ch, void *param); // param: struct mg_iobuf *
|
|
|
|
void mg_pfn_stdout(char c, void *param); // param: ignored
|