PRINT(3)

NAME
print, fprint, sprint, doprnt -- very simple formatted-output routines

SYNOPSIS
#include <system.h>
#include <print.h>

void print(char *format [, arg] ... )

void fprint(File *filep, char *format [, arg] ... )

char *sprint(char *s, char *format [, arg] ... )

void doprnt(File *filep, char *format, va_list args)

int _format(char *buf, char *format, va_lsit args)

DESCRIPTION
print writes output on standard output. fprint and doprnt place output on the open file known by filep. filep could for instance be STDOUT or STDERR. sprint places `output' in the string s, followed by the character `\0'.

Each of these functions converts, formats and prints its arguments, following the format argument, under control of format. Format is a character string which contains two types of objects: plain characters, which are simply copied to the output destination, and conversion specifications, each of which causes conversion and printing of the next successive argument.

A conversion specification is introduced by the character %. Following the %, there may be

•   an optional row of decimal digits specifying the field width; if the converted integral value has fewer characters than the field width, it will be blank-padded on the left; if the field width begins with a zero, zero-padding will be done;

•   the character l specifying that a following b, d, o, u or x corresponds to a long-integer argument;

•   a character which indicates the type of conversion to be applied.

The conversion characters and their meanings are

bdox
    The next argument is an integer and is converted to binary, decimal, octal or hexadecimal notation respectively.

c   Next argument is a character and is put directly into the resulting string. the field width is one character.

s   Next argument is taken to be a character pointer and characters from the string are taken until a null character is reached; a specified field width is not taken into account.

u   The unsigned integer argument is converted to decimal.

Integral arguments are not truncated, even if their size exceeds the specified field width. Padding takes place only if the specified field width exceeds the actual width.

The printing routines build the string to be printed internally and use sys_write to print it.

The _format routine builds the string, but does not null-terminate it. It returns the length of the string.

doprnt takes args as the address of the arguments of the format string.

FILES
~em/modules/lib/libprint.a

MODULES
system(3), string(3)

DIAGNOSTICS

Each illegal conversion specification is replaced by the string "<bad format>".

BUGS
The maximum length of the string to be printed is 1024 characters.

SEE ALSO
printf(3)