2025-07-17 11:36:45 +00:00
|
|
|
/**
|
|
|
|
|
* @file io.h
|
|
|
|
|
* @brief In/Out
|
|
|
|
|
* @details Common library for handling user i/o. Aims to be mechanic agnostic, and instead
|
|
|
|
|
* focus on implementing generic functions to format and manipulate data.
|
|
|
|
|
*/
|
2025-06-29 05:13:43 +00:00
|
|
|
#ifndef IO_H
|
|
|
|
|
#define IO_H
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
2025-07-17 11:36:45 +00:00
|
|
|
/**
|
|
|
|
|
* @brief
|
|
|
|
|
*/
|
2025-07-03 05:36:47 +00:00
|
|
|
typedef struct char_writer_s char_writer_t;
|
2025-07-17 11:36:45 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief
|
|
|
|
|
*/
|
2025-07-03 05:36:47 +00:00
|
|
|
struct char_writer_s {
|
2025-07-17 11:36:45 +00:00
|
|
|
int (*putChar)(void* ctx, char out); /**< @brief */
|
|
|
|
|
void* ctx; /**< @brief */
|
2025-07-03 05:36:47 +00:00
|
|
|
};
|
|
|
|
|
|
2025-07-17 11:36:45 +00:00
|
|
|
/**
|
|
|
|
|
* @brief
|
|
|
|
|
*/
|
2025-07-04 06:20:31 +00:00
|
|
|
extern char_writer_t* default_output;
|
|
|
|
|
|
2025-07-17 11:36:45 +00:00
|
|
|
/**
|
|
|
|
|
* @brief
|
|
|
|
|
* @param
|
|
|
|
|
* @param
|
|
|
|
|
* @return int
|
|
|
|
|
*/
|
2025-07-03 05:36:47 +00:00
|
|
|
int putc(char_writer_t*, char);
|
2025-07-17 11:36:45 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief
|
|
|
|
|
* @param
|
|
|
|
|
* @param
|
|
|
|
|
* @return int
|
|
|
|
|
*/
|
2025-07-03 05:36:47 +00:00
|
|
|
int print(char_writer_t*, const char*);
|
2025-07-17 11:36:45 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief
|
|
|
|
|
* @param
|
|
|
|
|
* @param
|
|
|
|
|
* @return int
|
|
|
|
|
*/
|
2025-07-03 05:36:47 +00:00
|
|
|
int println(char_writer_t*, const char*);
|
2025-07-17 11:36:45 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief
|
|
|
|
|
* @param
|
|
|
|
|
* @param
|
|
|
|
|
* @return int
|
|
|
|
|
*/
|
2025-07-05 08:36:39 +00:00
|
|
|
int printhex(char_writer_t*, uint64_t);
|
2025-07-17 11:36:45 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief
|
|
|
|
|
* @param
|
|
|
|
|
* @param out
|
|
|
|
|
* @return int
|
|
|
|
|
*/
|
2025-07-05 08:36:39 +00:00
|
|
|
int prindec(char_writer_t*, uint64_t out);
|
2025-07-17 11:36:45 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief
|
|
|
|
|
* @param
|
|
|
|
|
* @param fmt
|
|
|
|
|
* @param ...
|
|
|
|
|
* @return int
|
|
|
|
|
*/
|
2025-07-03 05:36:47 +00:00
|
|
|
int printf(char_writer_t*, const char* fmt, ...);
|
2025-06-29 05:13:43 +00:00
|
|
|
|
|
|
|
|
#endif
|