Reference

libproc_output(3)

print data to a string, scale data if necessary fprint_str, fprint_strlist, fprint_hex, fprint_dec, fprint_oct, fprint_bin, fprint_perc, fprint_size, fprint_time_ival, fprint_time_old_ival - print data to a file, scale data if necessary print_str, print_strlist, print_hex, print_dec, print_oct, print_bin, print_perc, print_size, print_time_ival, print_time_old_ival - print data to stdout, scale data if necessary

NAME

sprint_str, sprint_strlist, sprint_hex, sprint_dec, sprint_oct, sprint_bin, sprint_perc, sprint_size, sprint_time_ival, sprint_time_old_ival - print data to a string, scale data if necessary

fprint_str, fprint_strlist, fprint_hex, fprint_dec, fprint_oct, fprint_bin, fprint_perc, fprint_size, fprint_time_ival, fprint_time_old_ival - print data to a file, scale data if necessary

print_str, print_strlist, print_hex, print_dec, print_oct, print_bin, print_perc, print_size, print_time_ival, print_time_old_ival - print data to stdout, scale data if necessary

SYNOPSIS

#include <proc/output.h>

unsigned sprint_str(char *s, char *str",int max );"
unsigned sprint_strlist(char *s, char **strs",int max ,char*"sep");"
unsigned sprint_hex(char *s, unsigned long d, int max);
unsigned sprint_dec(char *s, long d, int max);
unsigned sprint_oct(char *s, unsigned long d, int max);
unsigned sprint_bin(char *s, unsigned long d, int max);
unsigned sprint_perc(char *s,unsigned int d, int max);
unsigned sprint_size(char *s, long d, int max, int mode);
unsigned sprint_time_ival(char *s, time_t t, int max, int centi_sec);
unsigned sprint_time_old_ival(char *s, time_t t, int max);

unsigned fprint_str(FILE *fp, char *str, int max);
unsigned fprint_strlist(FILE *fp, char **strs, int max, char *sep);
unsigned fprint_hex(FILE *fp, unsigned long d, int max);
unsigned fprint_dec(FILE *fp, long d, int max);
unsigned fprint_oct(FILE *fp, unsigned long d, int max);
unsigned fprint_perc(FILE *fp, unsigned int d, int max);
unsigned fprint_size(FILE *fp, long d, int max, int mode);
unsigned fprint_time_ival(FILE *fp, time_t t, int max, int centi_sec);
unsigned sprint_time_old_ival(FILE *fp, time_t t, int max);

unsigned print_str(char *str, int max);
unsigned print_strlist(char **strs, int max, char *sep);
unsigned print_hex(unsigned long d, int max);
unsigned print_dec(long d, int max);
unsigned print_oct(unsigned long d, int max);
unsigned print_perc(unsigned int d, int max);
unsigned print_size(long d, int max, int mode);
unsigned print_time_ival(time_t t, int max, int centi_sec);
unsigned print_time_old_ival(time_t t, int max);

int force_table_size;

DESCRIPTION

Tis family of functions produces output of maximal length max to a provided string, file or stdout. Note that the print_ functions are realized as macros. If the data provided does not fit in the maximal length, the data is scaled to fit. If this doesn't work, the functions not printing an string will return the negative number of characters printed or will print an over- (under-)flow mark is printed, depending whether force_table_size is true or not. This scaling is the same for all functions, regardless of output medium. All functions return the number of characters written to the output device or the negative number, if an overflow occurs and force_table_size isn't set. Only the _str and _strlist functions ever return less than max.

The _str functions print a string, converting non-printables to escape sequences. If the string is longer than max, they truncate the string to the maximal length. No under- or overflow symbols are printed.

The _strlist functions print an array of strings using the corresponding _str function. The strings are separated by inserting sep between them. Again, if the output exceeds max, it is truncated.

The _hex, _oct and _bin functions print an unsigned long integer in hexadecimal, octal or binary format. If the integer does not fit into the maximal field length, the function outputs max > symbols.

The _dec functions print a long integer. If the integer (including sign, if negative) doesn't fit into the maximal field length, the function outputs max > symbols if d is positive, resp. max < symbols if d is negative.

The _perc functions print an integer 0<= d <=999 as percentage value d/10. Sensible field width for this are between 2 and 4.

The _size functions print a size of d kB. Depending on mode, which can take the values OUT_SZ_PM or OUT_SZ_MK, it prints the number of memory pages (which may differ between different ports of Linux) or the amount of memory used in kB. The first case uses the corresponding _dec function. If in the second case an overflow occurs, the value gets transformed to MB (indicated by a trailing M unit), only if even the size in Megabytes doesn't fit anymore, it prints max > symbols.

The _time_ival functions print a time interval. Sensible field widths are 3 or 6. Depending on the length of the interval, the functions print the time in seconds.centiseconds (s) , minutes:seconds (m) , hours:minutes (h) or days (d). In narrow format (i.e. max = 3), it doesn't print a separator and lesser units. If the interval is negative or longer than 99999 days resp. longer than 99 days it will print >>d as overflow mark. Note that a negative time will occur only after 24855 days on 32-bit architectures and only after 106751991167300 days on 64-bit architectures, i.e. after 68 resp. 292471208677 years. If you ever have that problem, please send me a notice.

The _time_old_ival prints a time in the old format (min:sec) without specifying a unit.

AUTHOR

the output functions have been written by Charles Blake ([email protected]) and Helmut Geyer ([email protected]). This manpage was written by Helmut Geyer.

History