2007-07-05 16:01:39 +00:00
|
|
|
#ifndef __STDIO_H
|
|
|
|
#define __STDIO_H
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
2007-07-05 16:01:49 +00:00
|
|
|
#include <console.h>
|
2007-07-05 16:01:39 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* STDIO based functions (can always be used)
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* serial stuff */
|
2011-10-13 22:06:38 +00:00
|
|
|
void serial_printf(const char *fmt, ...) __attribute__ ((format(__printf__, 1, 2)));
|
2007-07-05 16:01:39 +00:00
|
|
|
|
|
|
|
/* stdin */
|
|
|
|
int tstc(void);
|
|
|
|
|
|
|
|
/* stdout */
|
2007-07-05 16:01:49 +00:00
|
|
|
void console_putc(unsigned int ch, const char c);
|
|
|
|
int getc(void);
|
2011-10-14 06:56:22 +00:00
|
|
|
int console_puts(unsigned int ch, const char *s);
|
2009-02-21 00:22:48 +00:00
|
|
|
void console_flush(void);
|
2007-07-05 16:01:49 +00:00
|
|
|
|
2011-10-14 06:56:22 +00:00
|
|
|
static inline int puts(const char *s)
|
2010-12-20 23:02:02 +00:00
|
|
|
{
|
2011-10-14 06:56:22 +00:00
|
|
|
return console_puts(CONSOLE_STDOUT, s);
|
2007-07-05 16:01:49 +00:00
|
|
|
}
|
|
|
|
|
2010-12-20 23:02:02 +00:00
|
|
|
static inline void putchar(char c)
|
|
|
|
{
|
2007-07-05 16:01:49 +00:00
|
|
|
console_putc(CONSOLE_STDOUT, c);
|
|
|
|
}
|
|
|
|
|
2011-10-13 22:06:38 +00:00
|
|
|
int printf(const char *fmt, ...) __attribute__ ((format(__printf__, 1, 2)));
|
2007-09-21 07:09:06 +00:00
|
|
|
int vprintf(const char *fmt, va_list args);
|
2011-10-13 22:06:38 +00:00
|
|
|
int sprintf(char *buf, const char *fmt, ...) __attribute__ ((format(__printf__, 2, 3)));
|
|
|
|
int snprintf(char *buf, size_t size, const char *fmt, ...) __attribute__ ((format(__printf__, 3, 4)));
|
2007-07-05 16:01:43 +00:00
|
|
|
int vsprintf(char *buf, const char *fmt, va_list args);
|
2011-10-13 22:06:38 +00:00
|
|
|
char *asprintf(const char *fmt, ...) __attribute__ ((format(__printf__, 1, 2)));
|
2009-04-06 09:48:41 +00:00
|
|
|
char *vasprintf(const char *fmt, va_list ap);
|
|
|
|
int vsnprintf(char *buf, size_t size, const char *fmt, va_list args);
|
2010-08-04 01:43:54 +00:00
|
|
|
int vscnprintf(char *buf, size_t size, const char *fmt, va_list args);
|
2007-07-05 16:01:39 +00:00
|
|
|
|
|
|
|
/* stderr */
|
2007-07-05 16:01:49 +00:00
|
|
|
#define eputc(c) console_putc(CONSOLE_STDERR, c)
|
|
|
|
#define eputs(s) console_puts(CONSOLE_STDERR, s)
|
2007-07-05 16:01:39 +00:00
|
|
|
#define eprintf(fmt,args...) fprintf(stderr,fmt ,##args)
|
|
|
|
|
|
|
|
/*
|
2007-07-05 16:01:49 +00:00
|
|
|
* FILE based functions
|
2007-07-05 16:01:39 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#define stdin 0
|
|
|
|
#define stdout 1
|
|
|
|
#define stderr 2
|
2010-04-14 08:46:25 +00:00
|
|
|
#define MAX_FILES 128
|
2007-07-05 16:01:39 +00:00
|
|
|
|
2011-11-11 11:25:53 +00:00
|
|
|
int fprintf(int file, const char *fmt, ...) __attribute__ ((format(__printf__, 2, 3)));
|
2007-07-05 16:01:49 +00:00
|
|
|
int fputs(int file, const char *s);
|
|
|
|
int fputc(int file, const char c);
|
2007-07-05 16:01:39 +00:00
|
|
|
int ftstc(int file);
|
|
|
|
int fgetc(int file);
|
|
|
|
|
|
|
|
#endif /* __STDIO_H */
|