---
name: "libproc_output"
section: "3"
platform: "linux"
package: "libproc-dev"
version: "1.12.2"
release: "Debian 1.3 (Bo)"
platforms: ["linux"]
url: "https://new.carta.tech/libproc_output"
---

# 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 (cblake@bbn.com)  and Helmut Geyer (Helmut.Geyer@iwr.uni-heidelberg.de). This manpage was written by Helmut Geyer.
