\hypertarget{printf_8h}{\section{opal/util/printf.h File Reference}
\label{printf_8h}\index{opal/util/printf.\+h@{opal/util/printf.\+h}}
}


Buffer safe printf functions for portability to archaic platforms.  


{\ttfamily \#include \char`\"{}opal\+\_\+config.\+h\char`\"{}}\\*
{\ttfamily \#include $<$stdarg.\+h$>$}\\*
{\ttfamily \#include $<$stdlib.\+h$>$}\\*
\subsection*{Functions}
\begin{DoxyCompactItemize}
\item 
B\+E\+G\+I\+N\+\_\+\+C\+\_\+\+D\+E\+C\+L\+S O\+P\+A\+L\+\_\+\+D\+E\+C\+L\+S\+P\+E\+C int \hyperlink{printf_8h_a861340b0e0a204bcb1a3914dff571cfe}{opal\+\_\+snprintf} (char $\ast$str, size\+\_\+t size, const char $\ast$fmt,...) \+\_\+\+\_\+opal\+\_\+attribute\+\_\+format\+\_\+\+\_\+(\+\_\+\+\_\+printf\+\_\+\+\_\+
\begin{DoxyCompactList}\small\item\em Writes to a string under the control of a format string that specifies how subsequent arguments are converted for output. \end{DoxyCompactList}\item 
B\+E\+G\+I\+N\+\_\+\+C\+\_\+\+D\+E\+C\+L\+S O\+P\+A\+L\+\_\+\+D\+E\+C\+L\+S\+P\+E\+C \\*
int O\+P\+A\+L\+\_\+\+D\+E\+C\+L\+S\+P\+E\+C int \hyperlink{printf_8h_a586a5853635843d3d1d797068dd4e776}{opal\+\_\+vsnprintf} (char $\ast$str, size\+\_\+t size, const char $\ast$fmt, va\+\_\+list ap) \+\_\+\+\_\+opal\+\_\+attribute\+\_\+format\+\_\+\+\_\+(\+\_\+\+\_\+printf\+\_\+\+\_\+
\begin{DoxyCompactList}\small\item\em 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. \end{DoxyCompactList}\item 
B\+E\+G\+I\+N\+\_\+\+C\+\_\+\+D\+E\+C\+L\+S O\+P\+A\+L\+\_\+\+D\+E\+C\+L\+S\+P\+E\+C \\*
int O\+P\+A\+L\+\_\+\+D\+E\+C\+L\+S\+P\+E\+C int \\*
O\+P\+A\+L\+\_\+\+D\+E\+C\+L\+S\+P\+E\+C int \hyperlink{printf_8h_a4c3daa553d06edb527835fdb4231a2d3}{opal\+\_\+asprintf} (char $\ast$$\ast$ptr, const char $\ast$fmt,...) \+\_\+\+\_\+opal\+\_\+attribute\+\_\+format\+\_\+\+\_\+(\+\_\+\+\_\+printf\+\_\+\+\_\+
\begin{DoxyCompactList}\small\item\em Allocates and writes to a string under the control of a format string that specifies how subsequent arguments are converted for output. \end{DoxyCompactList}\item 
B\+E\+G\+I\+N\+\_\+\+C\+\_\+\+D\+E\+C\+L\+S O\+P\+A\+L\+\_\+\+D\+E\+C\+L\+S\+P\+E\+C \\*
int O\+P\+A\+L\+\_\+\+D\+E\+C\+L\+S\+P\+E\+C int \\*
O\+P\+A\+L\+\_\+\+D\+E\+C\+L\+S\+P\+E\+C int \\*
O\+P\+A\+L\+\_\+\+D\+E\+C\+L\+S\+P\+E\+C int \hyperlink{printf_8h_a018d9d93aa034c23536f944d8483db65}{opal\+\_\+vasprintf} (char $\ast$$\ast$ptr, const char $\ast$fmt, va\+\_\+list ap) \+\_\+\+\_\+opal\+\_\+attribute\+\_\+format\+\_\+\+\_\+(\+\_\+\+\_\+printf\+\_\+\+\_\+
\begin{DoxyCompactList}\small\item\em 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. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Detailed Description}
Buffer safe printf functions for portability to archaic platforms. 



\subsection{Function Documentation}
\hypertarget{printf_8h_a4c3daa553d06edb527835fdb4231a2d3}{\index{printf.\+h@{printf.\+h}!opal\+\_\+asprintf@{opal\+\_\+asprintf}}
\index{opal\+\_\+asprintf@{opal\+\_\+asprintf}!printf.\+h@{printf.\+h}}
\subsubsection[{opal\+\_\+asprintf}]{\setlength{\rightskip}{0pt plus 5cm}B\+E\+G\+I\+N\+\_\+\+C\+\_\+\+D\+E\+C\+L\+S O\+P\+A\+L\+\_\+\+D\+E\+C\+L\+S\+P\+E\+C int O\+P\+A\+L\+\_\+\+D\+E\+C\+L\+S\+P\+E\+C int O\+P\+A\+L\+\_\+\+D\+E\+C\+L\+S\+P\+E\+C int opal\+\_\+asprintf (
\begin{DoxyParamCaption}
\item[{char $\ast$$\ast$}]{ptr, }
\item[{const char $\ast$}]{fmt, }
\item[{}]{...}
\end{DoxyParamCaption}
)}}\label{printf_8h_a4c3daa553d06edb527835fdb4231a2d3}


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


\begin{DoxyParams}{Parameters}
{\em $\ast$ptr} & Pointer to output string buffer \\
\hline
{\em fmt} & Output format \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Length of output string
\end{DoxyReturn}
Sets $\ast$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 N\+U\+L\+L pointer.

Returns the number of characters printed.

T\+H\+I\+S I\+S A P\+O\+R\+T\+A\+B\+I\+L\+I\+T\+Y F\+E\+A\+T\+U\+R\+E\+: U\+S\+E asprintf() in C\+O\+D\+E. \hypertarget{printf_8h_a861340b0e0a204bcb1a3914dff571cfe}{\index{printf.\+h@{printf.\+h}!opal\+\_\+snprintf@{opal\+\_\+snprintf}}
\index{opal\+\_\+snprintf@{opal\+\_\+snprintf}!printf.\+h@{printf.\+h}}
\subsubsection[{opal\+\_\+snprintf}]{\setlength{\rightskip}{0pt plus 5cm}B\+E\+G\+I\+N\+\_\+\+C\+\_\+\+D\+E\+C\+L\+S O\+P\+A\+L\+\_\+\+D\+E\+C\+L\+S\+P\+E\+C int opal\+\_\+snprintf (
\begin{DoxyParamCaption}
\item[{char $\ast$}]{str, }
\item[{size\+\_\+t}]{size, }
\item[{const char $\ast$}]{fmt, }
\item[{}]{...}
\end{DoxyParamCaption}
)}}\label{printf_8h_a861340b0e0a204bcb1a3914dff571cfe}


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


\begin{DoxyParams}{Parameters}
{\em str} & Output string buffer \\
\hline
{\em size} & Size of string buffer \\
\hline
{\em fmt} & Output format \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Length of output string
\end{DoxyReturn}
At most size-\/1 characters are printed into the output string (the size'th character then gets the terminating `\textbackslash{}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 `\textbackslash{}0').

T\+H\+I\+S I\+S A P\+O\+R\+T\+A\+B\+I\+L\+I\+T\+Y F\+E\+A\+T\+U\+R\+E\+: U\+S\+E snprintf() in C\+O\+D\+E. \hypertarget{printf_8h_a018d9d93aa034c23536f944d8483db65}{\index{printf.\+h@{printf.\+h}!opal\+\_\+vasprintf@{opal\+\_\+vasprintf}}
\index{opal\+\_\+vasprintf@{opal\+\_\+vasprintf}!printf.\+h@{printf.\+h}}
\subsubsection[{opal\+\_\+vasprintf}]{\setlength{\rightskip}{0pt plus 5cm}B\+E\+G\+I\+N\+\_\+\+C\+\_\+\+D\+E\+C\+L\+S O\+P\+A\+L\+\_\+\+D\+E\+C\+L\+S\+P\+E\+C int O\+P\+A\+L\+\_\+\+D\+E\+C\+L\+S\+P\+E\+C int O\+P\+A\+L\+\_\+\+D\+E\+C\+L\+S\+P\+E\+C int O\+P\+A\+L\+\_\+\+D\+E\+C\+L\+S\+P\+E\+C int opal\+\_\+vasprintf (
\begin{DoxyParamCaption}
\item[{char $\ast$$\ast$}]{ptr, }
\item[{const char $\ast$}]{fmt, }
\item[{va\+\_\+list}]{ap}
\end{DoxyParamCaption}
)}}\label{printf_8h_a018d9d93aa034c23536f944d8483db65}


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. 


\begin{DoxyParams}{Parameters}
{\em $\ast$ptr} & Pointer to output string buffer \\
\hline
{\em fmt} & Output format \\
\hline
{\em ap} & Variable argument list pointer \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Length of output string
\end{DoxyReturn}
Sets $\ast$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 N\+U\+L\+L pointer.

Returns the number of characters printed.

T\+H\+I\+S I\+S A P\+O\+R\+T\+A\+B\+I\+L\+I\+T\+Y F\+E\+A\+T\+U\+R\+E\+: U\+S\+E vasprintf() in C\+O\+D\+E. \hypertarget{printf_8h_a586a5853635843d3d1d797068dd4e776}{\index{printf.\+h@{printf.\+h}!opal\+\_\+vsnprintf@{opal\+\_\+vsnprintf}}
\index{opal\+\_\+vsnprintf@{opal\+\_\+vsnprintf}!printf.\+h@{printf.\+h}}
\subsubsection[{opal\+\_\+vsnprintf}]{\setlength{\rightskip}{0pt plus 5cm}B\+E\+G\+I\+N\+\_\+\+C\+\_\+\+D\+E\+C\+L\+S O\+P\+A\+L\+\_\+\+D\+E\+C\+L\+S\+P\+E\+C int O\+P\+A\+L\+\_\+\+D\+E\+C\+L\+S\+P\+E\+C int opal\+\_\+vsnprintf (
\begin{DoxyParamCaption}
\item[{char $\ast$}]{str, }
\item[{size\+\_\+t}]{size, }
\item[{const char $\ast$}]{fmt, }
\item[{va\+\_\+list}]{ap}
\end{DoxyParamCaption}
)}}\label{printf_8h_a586a5853635843d3d1d797068dd4e776}


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. 


\begin{DoxyParams}{Parameters}
{\em str} & Output string buffer \\
\hline
{\em size} & Size of string buffer \\
\hline
{\em fmt} & Output format \\
\hline
{\em ap} & Variable argument list pointer \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Length of output string
\end{DoxyReturn}
At most size-\/1 characters are printed into the output string (the size'th character then gets the terminating `\textbackslash{}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 `\textbackslash{}0').

T\+H\+I\+S I\+S A P\+O\+R\+T\+A\+B\+I\+L\+I\+T\+Y F\+E\+A\+T\+U\+R\+E\+: U\+S\+E vsnprintf() in C\+O\+D\+E. 