Newer
Older
rtlibc / inc / printf.h
/* Copyright (C) Thornwave Labs Inc - All Rights Reserved
 * Unauthorized copying of this file, via any medium is strictly prohibited
 * Proprietary and confidential
 * Written by Razvan Turiac <razvan.turiac@thornwave.com>
 */

#ifndef _RTLIBC_PRINTF_H
#define _RTLIBC_PRINTF_H


#include <stdio.h>


#ifdef __cplusplus
extern "C"
{
#endif

enum
{
	//do not change the order
	FLAG_MINUS	=	(1 << 0),
	FLAG_PLUS	=	(1 << 1),
	FLAG_SPACE	=	(1 << 2),
	FLAG_POUND	=	(1 << 3),
	FLAG_ZERO	=	(1 << 4),
	
	NOT_SPECIFIED		= -1,
	SPECIFIED_AS_ARG	= -2
};


typedef struct
{
	uint8_t flags;
	int32_t width;
	int32_t precision;
	char length;	
	int32_t specifier_index;
}rtformat_specifier_t;


typedef int32_t (*rtprintf_output_handler_t)(void*, const char*, size_t);
typedef int32_t (*rtformat_specifier_handler_t)(rtprintf_output_handler_t, void*, va_list*, rtformat_specifier_t*);



//management functions
void rtprintf_include_float(void);
int32_t rtprintf_add_format(char specifier, rtformat_specifier_handler_t handler);



//full versions
int32_t rtprintf(rtprintf_output_handler_t output_handler, void *user, const char *format, va_list args);


//simplified versions
int32_t rtiprintf(rtprintf_output_handler_t output_handler, void *user, const char *format, va_list args);




#ifdef __cplusplus
}
#endif


#endif