diff options
| author | LLLL Colonq <llll@colonq> | 2026-09-04 16:29:31 -0400 |
|---|---|---|
| committer | LLLL Colonq <llll@colonq> | 2026-09-04 16:29:31 -0400 |
| commit | 843ea34efc2c5ea10edc4d534304f8287f97fbbc (patch) | |
| tree | 65c2b676b650413a6154ffa7b319d4d0b6f9cff4 /pit/include/lcq | |
| parent | c01f847b68a7fcd48eb0f3d456aa993a6f69ea8d (diff) | |
pit: printf
Diffstat (limited to 'pit/include/lcq')
| -rw-r--r-- | pit/include/lcq/pit/runtime/dump.h | 5 | ||||
| -rw-r--r-- | pit/include/lcq/pit/utils.h | 7 |
2 files changed, 12 insertions, 0 deletions
diff --git a/pit/include/lcq/pit/runtime/dump.h b/pit/include/lcq/pit/runtime/dump.h index 600604e..40b2a70 100644 --- a/pit/include/lcq/pit/runtime/dump.h +++ b/pit/include/lcq/pit/runtime/dump.h @@ -22,4 +22,9 @@ i64 pit_dump(pit_runtime *rt, char *buf, i64 len, pit_value v, bool readable); i64 pit_dump_to_stdout(pit_runtime *rt, char *buf, i64 len, pit_value v, bool readable); void pit_dump_to_file(pit_runtime *rt, void *vf, pit_value v, bool readable); +i64 pit_dump_printf_callback(va_list ap, char *buf, size_t len, void *data); +i64 pit_vsnprintf(pit_runtime *rt, char *buf, i64 len, char *format, va_list ap); +i64 pit_snprintf(pit_runtime *rt, char *buf, i64 len, char *format, ...); +i64 pit_fprintf(pit_runtime *rt, void *vf, char *format, ...); + #endif diff --git a/pit/include/lcq/pit/utils.h b/pit/include/lcq/pit/utils.h index 929472a..d45758f 100644 --- a/pit/include/lcq/pit/utils.h +++ b/pit/include/lcq/pit/utils.h @@ -44,6 +44,13 @@ static inline u8 *pit_libc_string_memcpy(u8 *dest, u8 *src, size_t n) { for (; i < n; ++i) dest[i] = src[i]; return dest; } + +/* printf */ +typedef struct { + char specifier; + i64 (*callback)(va_list ap, char *buf, size_t len, void *data); +} pit_printf_handler; +int pit_vsnprintf_helper(char *buf, size_t len, char *format, va_list ap, pit_printf_handler *handlers, i64 handlers_len, void *data); int pit_libc_string_vsnprintf(char *str, size_t size, char *format, va_list ap); int pit_libc_string_snprintf(char *buf, size_t len, char *format, ...); |
