|
NetBurner 3.5.8
PDF Version |
Printf-style formatted output to file descriptors. More...
Functions | |
| int | fdprintf (int fd, const char *format,...) |
| Print formatted output to a file descriptor. | |
| int | fdiprintf (int fd, const char *format,...) |
| Print formatted output to a file descriptor (integer-only, no float). | |
| int | vfdprintf (int fd, const char *format, va_list args) |
| Print formatted output to a file descriptor using va_list. | |
| int | vfdiprintf (int fd, const char *format, va_list args) |
| Print formatted output to a file descriptor using va_list (integer-only). | |
Printf-style formatted output to file descriptors.
#include< fdprintf.h>
The fdprintf family of functions extends the familiar printf() functionality to work with any file descriptor in the NetBurner system. This enables formatted output to:
Unlike printf() which outputs to stdout (typically the debug serial port), fdprintf() allows you to direct formatted output to any open file descriptor. This is essential for network protocols, multi-port communications, and custom output devices.
Four variants are provided to suit different needs:
| Function | Float Support | Argument Type | Use Case |
|---|---|---|---|
| fdprintf() | Yes | Variable args | General purpose with float |
| fdiprintf() | No | Variable args | Integer-only (smaller code) |
| vfdprintf() | Yes | va_list | Wrapper functions with float |
| vfdiprintf() | No | va_list | Wrapper functions, integer-only |
fdprintf() supports standard C printf format specifiers:
Width, precision, and flags are supported:
Complete examples are available in the NetBurner SDK:
| int fdiprintf | ( | int | fd, |
| const char * | format, | ||
| ... ) |
#include <fdprintf.h>
Print formatted output to a file descriptor (integer-only, no float).
Similar to fdprintf() but without floating point support. This significantly reduces code size (~10-15KB smaller) and is faster for integer-only formatting. Use this when you only need to format integers, strings, and other non-float types.
| fd | File descriptor to write to. Must be a valid, open file descriptor such as:
|
| format | Format string using standard printf syntax. Supports all specifiers EXCEPT floating point (f, e, g are not supported):
|
| ... | Variable arguments corresponding to format specifiers in the format string |
| >0 | Number of bytes successfully written |
| <0 | Error occurred during write operation |
| int fdprintf | ( | int | fd, |
| const char * | format, | ||
| ... ) |
#include <fdprintf.h>
Print formatted output to a file descriptor.
Outputs formatted text to the specified file descriptor using the same format syntax as standard printf(). Supports all standard format specifiers including floating point.
| fd | File descriptor to write to. Must be a valid, open file descriptor such as:
|
| format | Format string using standard printf syntax. Supports:
|
| ... | Variable arguments corresponding to format specifiers in the format string |
| >0 | Number of bytes successfully written |
| <0 | Error occurred during write operation |
| int vfdiprintf | ( | int | fd, |
| const char * | format, | ||
| va_list | args ) |
#include <fdprintf.h>
Print formatted output to a file descriptor using va_list (integer-only).
Variant of fdiprintf() that accepts a va_list argument instead of variable arguments. This is used for creating wrapper functions that need to forward variable arguments. Does NOT support floating point, resulting in smaller code size.
| fd | File descriptor to write to. Must be a valid, open file descriptor |
| format | Format string using standard printf syntax. Supports all specifiers EXCEPT floating point (f, e, g are not supported):
|
| args | Variable argument list (va_list) containing the arguments specified by the format string. Must be initialized with va_start() and cleaned up with va_end() |
| >0 | Number of bytes successfully written |
| <0 | Error occurred during write operation |
| int vfdprintf | ( | int | fd, |
| const char * | format, | ||
| va_list | args ) |
#include <fdprintf.h>
Print formatted output to a file descriptor using va_list.
Variant of fdprintf() that accepts a va_list argument instead of variable arguments. This is used for creating wrapper functions that need to forward variable arguments. Includes full floating point support.
| fd | File descriptor to write to. Must be a valid, open file descriptor |
| format | Format string using standard printf syntax. Supports all standard format specifiers including floating point |
| args | Variable argument list (va_list) containing the arguments specified by the format string. Must be initialized with va_start() and cleaned up with va_end() |
| >0 | Number of bytes successfully written |
| <0 | Error occurred during write operation |