next up previous contents index
Next: 9.7 Termination Functions Up: 9 Minimal C Library: Previous: 9.5.18 mem_unlock: Unlock access

9.6 Standard I/O Functions

 

The versions of sprintf, vsprintf, sscanf, and vsscanf provided in the OSKit's minimal C library are completely self-contained; they do not pull in the code for printf, fprintf, or other ``file-oriented'' standard I/O functions. Thus, they can be used in any environment, regardless of whether some kind of console or file I/O is available.

The routines printf, puts, putchar, getchar, etc., are all defined in terms of console_putchar, console_getchar, console_puts, and console_putbytes. This means that you can get working formatted ``console'' output merely by providing an appropriate implementation of the aforementioned console functions. In the base environment, these routines are defined in the kernel library (see Section 10.13).

The standard I/O functions that actually take a FILE* argument, such as fprintf and fwrite, and as such are fundamentally dependent on the notion of files, are implemented in terms of the low-level POSIX file I/O functions such as write. However, unlike in ``real'' C libraries, the high-level file I/O functions provided by the minimal C library only implement the minimum of functionality to provide the basic API: in particular, they do no buffering, so for example an fwrite translates directly to a write. This design reduces code size and minimizes interdependencies between functions, while still providing familiar, useful services such as formatted file I/O.



University of Utah Flux Research Group