2022-11-19 12:30:36 +01:00
|
|
|
#pragma once
|
2022-12-04 12:42:43 +01:00
|
|
|
#include <luna/Attributes.h>
|
|
|
|
#include <luna/Result.h>
|
2022-11-19 12:30:36 +01:00
|
|
|
#include <stdarg.h>
|
|
|
|
|
2022-11-19 16:13:25 +01:00
|
|
|
typedef Result<void> (*callback_t)(char, void*);
|
2022-11-19 15:53:58 +01:00
|
|
|
|
2023-03-02 13:40:42 +01:00
|
|
|
// Format output according to a format string and a list of variadic arguments. callback is called with arg for every
|
|
|
|
// character in the resulting string.
|
2022-11-30 12:36:21 +01:00
|
|
|
Result<usize> cstyle_format(const char* format, callback_t callback, void* arg, va_list ap);
|
2022-12-17 12:43:29 +01:00
|
|
|
|
|
|
|
// Convenience function which outputs into a fixed-size buffer (not unlike vsnprintf)
|
2022-12-16 18:32:29 +01:00
|
|
|
usize vstring_format(char* buf, usize max, const char* format, va_list ap);
|
2022-12-17 12:43:29 +01:00
|
|
|
|
|
|
|
// Convenience function which outputs into a fixed-size buffer (not unlike snprintf)
|
2023-01-02 13:07:29 +01:00
|
|
|
usize string_format(char* buf, usize max, const char* format, ...) _format(3, 4);
|