OpenMPI 0.1.1

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

Functions
printf.h File Reference

Buffer safe printf functions for portability to archaic platforms. More...

`#include "opal_config.h"`
`#include <stdarg.h>`
`#include <stdlib.h>`

Go to the source code of this file.

## Functions
BEGIN_C_DECLS OPAL_DECLSPEC int | opal_snprintf (char *str, size_t size, const char *fmt,...) __opal_attribute_format__(__printf__
| Writes to a string under the control of a format string that specifies how subsequent arguments are converted for output. More...
BEGIN_C_DECLS OPAL_DECLSPEC int OPAL_DECLSPEC int | opal_vsnprintf (char *str, size_t size, const char *fmt, va_list ap) __opal_attribute_format__(__printf__
| Writes to a string under the control of a format string that specifies how arguments accessed via the variable-length argument facilities of stdarg(3) are converted for output. More...
BEGIN_C_DECLS OPAL_DECLSPEC int OPAL_DECLSPEC int OPAL_DECLSPEC int | opal_asprintf (char **ptr, const char *fmt,...) __opal_attribute_format__(__printf__
| Allocates and writes to a string under the control of a format string that specifies how subsequent arguments are converted for output. More...
BEGIN_C_DECLS OPAL_DECLSPEC int OPAL_DECLSPEC int OPAL_DECLSPEC int OPAL_DECLSPEC int | opal_vasprintf (char **ptr, const char *fmt, va_list ap) __opal_attribute_format__(__printf__
| Allocates and writes to a string under the control of a format string that specifies how arguments accessed via the variable-length argument facilities of stdarg(3) are converted for output. More...

## Detailed Description

Buffer safe printf functions for portability to archaic platforms.

## Function Documentation

BEGIN_C_DECLS OPAL_DECLSPEC int OPAL_DECLSPEC int OPAL_DECLSPEC int opal_asprintf | ( | char ** | ptr,
|  | const char * | fmt,
|  |  | ...
| ) |  |

Allocates and writes to a string under the control of a format string that specifies how subsequent arguments are converted for output.

Parameters

  *ptr | Pointer to output string buffer
  fmt | Output format

Returns
  Length of output string

Sets *ptr to be a pointer to a buffer sufficiently large to hold the formatted string. This pointer should be passed to free(3) to release the allocated storage when it is no longer needed. If sufficient space cannot be allocated, asprintf() and vasprintf() will return -1 and set ret to be a NULL pointer.

Returns the number of characters printed.

THIS IS A PORTABILITY FEATURE: USE asprintf() in CODE.

BEGIN_C_DECLS OPAL_DECLSPEC int opal_snprintf | ( | char * | str,
|  | size_t | size,
|  | const char * | fmt,
|  |  | ...
| ) |  |

Writes to a string under the control of a format string that specifies how subsequent arguments are converted for output.

Parameters

  str | Output string buffer
  size | Size of string buffer
  fmt | Output format

Returns
  Length of output string

At most size-1 characters are printed into the output string (the size'th character then gets the terminating `\0'); if the return value is greater than or equal to the size argument, the string was too short and some of the printed characters were discarded. The output is always null-terminated.

Returns the number of characters that would have been printed if the size were unlimited (again, not including the final `\0').

THIS IS A PORTABILITY FEATURE: USE snprintf() in CODE.

BEGIN_C_DECLS OPAL_DECLSPEC int OPAL_DECLSPEC int OPAL_DECLSPEC int OPAL_DECLSPEC int opal_vasprintf | ( | char ** | ptr,
|  | const char * | fmt,
|  | va_list | ap
| ) |  |

Allocates and writes to a string under the control of a format string that specifies how arguments accessed via the variable-length argument facilities of stdarg(3) are converted for output.

Parameters

  *ptr | Pointer to output string buffer
  fmt | Output format
  ap | Variable argument list pointer

Returns
  Length of output string

Sets *ptr to be a pointer to a buffer sufficiently large to hold the formatted string. This pointer should be passed to free(3) to release the allocated storage when it is no longer needed. If sufficient space cannot be allocated, asprintf() and vasprintf() will return -1 and set ret to be a NULL pointer.

Returns the number of characters printed.

THIS IS A PORTABILITY FEATURE: USE vasprintf() in CODE.

BEGIN_C_DECLS OPAL_DECLSPEC int OPAL_DECLSPEC int opal_vsnprintf | ( | char * | str,
|  | size_t | size,
|  | const char * | fmt,
|  | va_list | ap
| ) |  |

Writes to a string under the control of a format string that specifies how arguments accessed via the variable-length argument facilities of stdarg(3) are converted for output.

Parameters

  str | Output string buffer
  size | Size of string buffer
  fmt | Output format
  ap | Variable argument list pointer

Returns
  Length of output string

At most size-1 characters are printed into the output string (the size'th character then gets the terminating `\0'); if the return value is greater than or equal to the size argument, the string was too short and some of the printed characters were discarded. The output is always null-terminated.

Returns the number of characters that would have been printed if the size were unlimited (again, not including the final `\0').

THIS IS A PORTABILITY FEATURE: USE vsnprintf() in CODE.