1
0
Fork 0
mirror of https://github.com/tailix/libkernaux.git synced 2025-04-14 17:32:55 -04:00

Main: include/kernaux/file.h: Added

This commit is contained in:
Alex Kotov 2022-06-07 20:46:52 +03:00
parent aa6077b88c
commit b5eb326392
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08
8 changed files with 34 additions and 3 deletions

1
.gitignore vendored
View file

@ -95,6 +95,7 @@
/include/kernaux.h
/include/kernaux/console.h
/include/kernaux/printf.h
/examples/assert_guards
/examples/assert_simple

View file

@ -2,6 +2,7 @@
* include/kernaux/libc.h: Has been split into separate headers
* include/kernaux/print.h: Functions "[v]printf" renamed to "[v]fprintf"
* include/kernaux/file.h: Added
2022-06-06 Alex Kotov <kotovalexarian@gmail.com>

View file

@ -44,6 +44,7 @@ zero). Work-in-progress APIs can change at any time.
* [Panic: simple](/examples/panic_simple.c)
* [Panic: guards](/examples/panic_guards.c)
* Stack trace *(planned)*
* [File simulator](/include/kernaux/file.h) (*work in progress*)
* Device drivers (for debugging only)
* [Serial console](/include/kernaux/console.h) (*work in progress*)
* [Framebuffer](/include/kernaux/framebuffer.h) (*planned*)
@ -67,7 +68,7 @@ zero). Work-in-progress APIs can change at any time.
* Usual functions
* [itoa/ftoa replacement](/include/kernaux/ntoa.h) (*stable since* **0.1.0**, *non-breaking since* **?.?.?**)
* [Example](/examples/ntoa.c)
* [printf replacement](/include/kernaux/printf.h) (*stable since* **0.1.0**)
* [printf replacement](/include/kernaux/printf.h.in) (*stable since* **0.1.0**, *non-breaking since* **?.?.?**)
* Code from [https://github.com/mpaland/printf](https://github.com/mpaland/printf). Thank you!
* [fprintf](/examples/fprintf.c)
* [vfprintf](/examples/fprintf_va.c)
@ -117,6 +118,7 @@ All packages are included by default. To exclude all packages except those
explicitly included, use `--without-all`.
* `--with[out]-cmdline` - command line parser
* `--with[out]-file` - file simulator
* `--with[out]-ntoa` - itoa/ftoa
* `--with[out]-printf` - printf

View file

@ -32,6 +32,7 @@ AC_ARG_WITH( [all], AS_HELP_STRING([--without-all], [without a
AC_ARG_WITH( [cmdline], AS_HELP_STRING([--without-cmdline], [without command line parser]))
AC_ARG_WITH( [console], AS_HELP_STRING([--without-console], [without serial console]))
AC_ARG_WITH( [elf], AS_HELP_STRING([--without-elf], [without ELF utils]))
AC_ARG_WITH( [file], AS_HELP_STRING([--without-file], [without file simulator]))
AC_ARG_WITH( [framebuffer], AS_HELP_STRING([--without-framebuffer], [without framebuffer]))
AC_ARG_WITH( [mbr], AS_HELP_STRING([--without-mbr], [without Master Boot Record]))
AC_ARG_WITH( [multiboot2], AS_HELP_STRING([--without-multiboot2], [without Multiboot 2 information parser]))
@ -62,6 +63,7 @@ AC_DEFUN([do_without_all],
if test -z "$with_cmdline"; then with_cmdline=no; fi
if test -z "$with_console"; then with_console=no; fi
if test -z "$with_elf"; then with_elf=no; fi
if test -z "$with_file"; then with_file=no; fi
if test -z "$with_framebuffer"; then with_framebuffer=no; fi
if test -z "$with_mbr"; then with_mbr=no; fi
if test -z "$with_multiboot2"; then with_multiboot2=no; fi
@ -94,6 +96,7 @@ AS_IF([test "$with_all" = no ], [with_all=no], [with_all=
AS_IF([test "$with_cmdline" = no ], [with_cmdline=no], [with_cmdline=yes])
AS_IF([test "$with_console" = no ], [with_console=no], [with_console=yes])
AS_IF([test "$with_elf" = no ], [with_elf=no], [with_elf=yes])
AS_IF([test "$with_file" = no ], [with_file=no], [with_file=yes])
AS_IF([test "$with_framebuffer" = no ], [with_framebuffer=no], [with_framebuffer=yes])
AS_IF([test "$with_mbr" = no ], [with_mbr=no], [with_mbr=yes])
AS_IF([test "$with_multiboot2" = no ], [with_multiboot2=no], [with_multiboot2=yes])
@ -147,6 +150,7 @@ dnl Packages (enabled by default)
AM_CONDITIONAL([WITH_CMDLINE], [test "$with_cmdline" = yes])
AM_CONDITIONAL([WITH_CONSOLE], [test "$with_console" = yes])
AM_CONDITIONAL([WITH_ELF], [test "$with_elf" = yes])
AM_CONDITIONAL([WITH_FILE], [test "$with_file" = yes])
AM_CONDITIONAL([WITH_FRAMEBUFFER], [test "$with_framebuffer" = yes])
AM_CONDITIONAL([WITH_MBR], [test "$with_mbr" = yes])
AM_CONDITIONAL([WITH_MULTIBOOT2], [test "$with_multiboot2" = yes])
@ -183,6 +187,7 @@ dnl Packages (enabled by default)
AS_IF([test "$with_cmdline" = yes], [AC_DEFINE([WITH_CMDLINE], [1], [with command line parser])])
AS_IF([test "$with_console" = yes], [AC_DEFINE([WITH_CONSOLE], [1], [with serial console])])
AS_IF([test "$with_elf" = yes], [AC_DEFINE([WITH_ELF], [1], [with ELF utils])])
AS_IF([test "$with_file" = yes], [AC_DEFINE([WITH_FILE], [1], [with file simulator])])
AS_IF([test "$with_framebuffer" = yes], [AC_DEFINE([WITH_FRAMEBUFFER], [1], [with framebuffer])])
AS_IF([test "$with_mbr" = yes], [AC_DEFINE([WITH_MBR], [1], [with Master Boot Record])])
AS_IF([test "$with_multiboot2" = yes], [AC_DEFINE([WITH_MULTIBOOT2], [1], [with Multiboot 2 information parser])])
@ -205,6 +210,7 @@ dnl Packages (enabled by default)
AS_IF([test "$with_cmdline" = no], [AC_SUBST([comment_line_cmdline], [//])])
AS_IF([test "$with_console" = no], [AC_SUBST([comment_line_console], [//])])
AS_IF([test "$with_elf" = no], [AC_SUBST([comment_line_elf], [//])])
AS_IF([test "$with_file" = no], [AC_SUBST([comment_line_file], [//])])
AS_IF([test "$with_framebuffer" = no], [AC_SUBST([comment_line_framebuffer], [//])])
AS_IF([test "$with_mbr" = no], [AC_SUBST([comment_line_mbr], [//])])
AS_IF([test "$with_multiboot2" = no], [AC_SUBST([comment_line_multiboot2], [//])])
@ -230,6 +236,7 @@ AC_CONFIG_FILES([
libc/Makefile
include/kernaux.h
include/kernaux/console.h
include/kernaux/printf.h
])
AC_LANG([C])

View file

@ -24,6 +24,9 @@ endif
if WITH_ELF
nobase_include_HEADERS += kernaux/elf.h
endif
if WITH_FILE
nobase_include_HEADERS += kernaux/file.h
endif
if WITH_FRAMEBUFFER
nobase_include_HEADERS += kernaux/framebuffer.h
endif

View file

@ -8,6 +8,7 @@
@comment_line_cmdline@#include <kernaux/cmdline.h>
@comment_line_console@#include <kernaux/console.h>
@comment_line_elf@#include <kernaux/elf.h>
@comment_line_file@#include <kernaux/file.h>
@comment_line_framebuffer@#include <kernaux/framebuffer.h>
@comment_line_mbr@#include <kernaux/mbr.h>
@comment_line_multiboot2@#include <kernaux/multiboot2.h>

14
include/kernaux/file.h Normal file
View file

@ -0,0 +1,14 @@
#ifndef KERNAUX_INCLUDED_FILE
#define KERNAUX_INCLUDED_FILE
#ifdef __cplusplus
extern "C" {
#endif
typedef void (*KernAux_File_Out)(char c, void *arg);
#ifdef __cplusplus
}
#endif
#endif

View file

@ -8,6 +8,8 @@ extern "C" {
#include <stdarg.h>
#include <stddef.h>
@comment_line_file@#include <kernaux/file.h>
/**
* Tiny [v]fprintf implementation
* \param out An output function which takes one character and an argument pointer
@ -16,8 +18,8 @@ extern "C" {
* \param va A value identifying a variable arguments list
* \return The number of characters that are sent to the output function, not counting the terminating null character
*/
int kernaux_fprintf(void (*out)(char character, void* arg), void* arg, const char* format, ...);
int kernaux_vfprintf(void (*out)(char character, void* arg), void* arg, const char* format, va_list va);
@comment_line_file@int kernaux_fprintf(KernAux_File_Out out, void* arg, const char* format, ...);
@comment_line_file@int kernaux_vfprintf(KernAux_File_Out out, void* arg, const char* format, va_list va);
/**
* Tiny [v]snprintf implementation