\hypertarget{group__iobuf}{
\section{iobuf: I/O Buffer Management}
\label{group__iobuf}\index{iobuf: I/O Buffer Management@{iobuf: I/O Buffer Management}}
}
\subsection*{Data Structures}
\begin{CompactItemize}
\item 
struct \hyperlink{structiobuf}{iobuf}
\end{CompactItemize}
\subsection*{Status Flags}
\begin{CompactItemize}
\item 
unsigned \hyperlink{group__iobuf_g2c854014f77658545278463b09758cd5}{iobuf\_\-bufsize}
\item 
\#define \hyperlink{group__iobuf_ga9922524dac6fa4139c68411cb2dec8d}{IOBUF\_\-EOF}~1
\item 
\#define \hyperlink{group__iobuf_g7a539e207e174c527cf0a8dab7331bdb}{IOBUF\_\-ERROR}~2
\item 
\#define \hyperlink{group__iobuf_g4c4cf7dac5cc7cac920c53c919b54a55}{IOBUF\_\-TIMEOUT}~4
\item 
\#define \hyperlink{group__iobuf_gd7612c4c1636fb11daf6bd74ef302d52}{IOBUF\_\-BADFLAGS}~0xf
\item 
\#define \hyperlink{group__iobuf_g724f6d12b6627f3813a762cd84c7bd28}{IOBUF\_\-SEEKABLE}~0x10
\item 
\#define \hyperlink{group__iobuf_g49715bfac7e883555379b6f23f4aa713}{IOBUF\_\-NEEDSCLOSE}~0x20
\item 
\#define \hyperlink{group__iobuf_gace66a8b07b3bb95258588d79854d489}{IOBUF\_\-NEEDSFREE}~0x40
\item 
\#define \hyperlink{group__iobuf_g189c4467a682c5d0d97e750f99a8a424}{IOBUF\_\-NEEDSMUNMAP}~0x80
\end{CompactItemize}
\subsection*{Common}
\begin{CompactItemize}
\item 
\hypertarget{group__iobuf_g690c6cce9ede03409c28d27a2be73ba9}{
typedef struct \hyperlink{structiobuf}{iobuf} \textbf{iobuf}}
\label{group__iobuf_g690c6cce9ede03409c28d27a2be73ba9}

\item 
int \hyperlink{group__iobuf_g1f577ec79ef10d4ffa30b23981536ac8}{iobuf\_\-init} (\hyperlink{structiobuf}{iobuf} $\ast$io, int fd, unsigned bufsize, char $\ast$buffer, unsigned flags)
\item 
int \hyperlink{group__iobuf_g02d1cff3c2911677d2ba3257f0c73259}{iobuf\_\-close} (\hyperlink{structiobuf}{iobuf} $\ast$io)
\item 
int \hyperlink{group__iobuf_g92ccfacce7d0d0c03b3e7ea0d5e49c6b}{iobuf\_\-timeout} (\hyperlink{structiobuf}{iobuf} $\ast$io, int poll\_\-out)
\item 
\#define \hyperlink{group__iobuf_gd8df365380fe10ef962692eb2123f061}{IOBUF\_\-SET\_\-ERROR}(io)
\item 
\#define \hyperlink{group__iobuf_g8f5ac893f0d359136bfb72a96863a4a0}{iobuf\_\-closed}(io)~((io) $\rightarrow$ fd == -1)
\item 
\#define \hyperlink{group__iobuf_g880c0546f9a201b0e2ba7d8f37e018ef}{iobuf\_\-error}(io)~((io) $\rightarrow$ flags \& IOBUF\_\-ERROR)
\item 
\#define \hyperlink{group__iobuf_gd3c3c0e8bb56ad8405669ae0ee1fff01}{iobuf\_\-timedout}(io)~((io) $\rightarrow$ flags \& IOBUF\_\-TIMEOUT)
\item 
\#define \hyperlink{group__iobuf_g9ff81d3db610c54cf21d19967bea5c3f}{iobuf\_\-bad}(io)~((io) $\rightarrow$ flags \& IOBUF\_\-BADFLAGS)
\end{CompactItemize}
\subsection*{Mass copying functions.}
\begin{CompactItemize}
\item 
int \hyperlink{group__iobuf_g2d8a3151c65892ca5146330f46dd9b3a}{iobuf\_\-copy} (\hyperlink{structibuf}{ibuf} $\ast$in, \hyperlink{structobuf}{obuf} $\ast$out)
\item 
int \hyperlink{group__iobuf_g6434153f5f1fa56f26fcfa305a47d264}{iobuf\_\-copyflush} (\hyperlink{structibuf}{ibuf} $\ast$in, \hyperlink{structobuf}{obuf} $\ast$out)
\item 
int \hyperlink{group__iobuf_g5e1d63bc6e2127fd5cd043caac078867}{ibuf\_\-copytofd} (\hyperlink{structibuf}{ibuf} $\ast$in, int out)
\item 
int \hyperlink{group__iobuf_gf21d1424bd0e9de6f80d56070e45f1cc}{obuf\_\-copyfromfd} (int in, \hyperlink{structobuf}{obuf} $\ast$out)
\end{CompactItemize}


\subsection{Detailed Description}
\begin{Desc}
\item[Calling Convention]\end{Desc}
Unless otherwise specified, the return value is non-zero (true) if the entire requested operation completed, and {\tt 0} (false) otherwise. 

\subsection{Define Documentation}
\hypertarget{group__iobuf_g9ff81d3db610c54cf21d19967bea5c3f}{
\index{iobuf@{iobuf}!iobuf\_\-bad@{iobuf\_\-bad}}
\index{iobuf\_\-bad@{iobuf\_\-bad}!iobuf@{iobuf}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}\#define iobuf\_\-bad(io)~((io) $\rightarrow$ flags \& IOBUF\_\-BADFLAGS)}}
\label{group__iobuf_g9ff81d3db610c54cf21d19967bea5c3f}


True if the {\tt \hyperlink{structiobuf}{iobuf}} is in a \char`\"{}bad\char`\"{} state. \hypertarget{group__iobuf_gd7612c4c1636fb11daf6bd74ef302d52}{
\index{iobuf@{iobuf}!IOBUF\_\-BADFLAGS@{IOBUF\_\-BADFLAGS}}
\index{IOBUF\_\-BADFLAGS@{IOBUF\_\-BADFLAGS}!iobuf@{iobuf}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}\#define IOBUF\_\-BADFLAGS~0xf}}
\label{group__iobuf_gd7612c4c1636fb11daf6bd74ef302d52}


Mask of all the error type flags. \hypertarget{group__iobuf_g8f5ac893f0d359136bfb72a96863a4a0}{
\index{iobuf@{iobuf}!iobuf\_\-closed@{iobuf\_\-closed}}
\index{iobuf\_\-closed@{iobuf\_\-closed}!iobuf@{iobuf}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}\#define iobuf\_\-closed(io)~((io) $\rightarrow$ fd == -1)}}
\label{group__iobuf_g8f5ac893f0d359136bfb72a96863a4a0}


True if the {\tt \hyperlink{structiobuf}{iobuf}} has been closed. \hypertarget{group__iobuf_ga9922524dac6fa4139c68411cb2dec8d}{
\index{iobuf@{iobuf}!IOBUF\_\-EOF@{IOBUF\_\-EOF}}
\index{IOBUF\_\-EOF@{IOBUF\_\-EOF}!iobuf@{iobuf}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}\#define IOBUF\_\-EOF~1}}
\label{group__iobuf_ga9922524dac6fa4139c68411cb2dec8d}


Reading reached end of file. \hypertarget{group__iobuf_g880c0546f9a201b0e2ba7d8f37e018ef}{
\index{iobuf@{iobuf}!iobuf\_\-error@{iobuf\_\-error}}
\index{iobuf\_\-error@{iobuf\_\-error}!iobuf@{iobuf}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}\#define iobuf\_\-error(io)~((io) $\rightarrow$ flags \& IOBUF\_\-ERROR)}}
\label{group__iobuf_g880c0546f9a201b0e2ba7d8f37e018ef}


True if the {\tt \hyperlink{structiobuf}{iobuf}} has an error flag. \hypertarget{group__iobuf_g7a539e207e174c527cf0a8dab7331bdb}{
\index{iobuf@{iobuf}!IOBUF\_\-ERROR@{IOBUF\_\-ERROR}}
\index{IOBUF\_\-ERROR@{IOBUF\_\-ERROR}!iobuf@{iobuf}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}\#define IOBUF\_\-ERROR~2}}
\label{group__iobuf_g7a539e207e174c527cf0a8dab7331bdb}


The \hyperlink{structiobuf}{iobuf} has encountered an error. \hypertarget{group__iobuf_g49715bfac7e883555379b6f23f4aa713}{
\index{iobuf@{iobuf}!IOBUF\_\-NEEDSCLOSE@{IOBUF\_\-NEEDSCLOSE}}
\index{IOBUF\_\-NEEDSCLOSE@{IOBUF\_\-NEEDSCLOSE}!iobuf@{iobuf}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}\#define IOBUF\_\-NEEDSCLOSE~0x20}}
\label{group__iobuf_g49715bfac7e883555379b6f23f4aa713}


The file descriptor needs to be closed. \hypertarget{group__iobuf_gace66a8b07b3bb95258588d79854d489}{
\index{iobuf@{iobuf}!IOBUF\_\-NEEDSFREE@{IOBUF\_\-NEEDSFREE}}
\index{IOBUF\_\-NEEDSFREE@{IOBUF\_\-NEEDSFREE}!iobuf@{iobuf}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}\#define IOBUF\_\-NEEDSFREE~0x40}}
\label{group__iobuf_gace66a8b07b3bb95258588d79854d489}


The buffer needs to be deallocated with {\tt free} \hypertarget{group__iobuf_g189c4467a682c5d0d97e750f99a8a424}{
\index{iobuf@{iobuf}!IOBUF\_\-NEEDSMUNMAP@{IOBUF\_\-NEEDSMUNMAP}}
\index{IOBUF\_\-NEEDSMUNMAP@{IOBUF\_\-NEEDSMUNMAP}!iobuf@{iobuf}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}\#define IOBUF\_\-NEEDSMUNMAP~0x80}}
\label{group__iobuf_g189c4467a682c5d0d97e750f99a8a424}


The buffer needs to be deallocated with {\tt munmap} \hypertarget{group__iobuf_g724f6d12b6627f3813a762cd84c7bd28}{
\index{iobuf@{iobuf}!IOBUF\_\-SEEKABLE@{IOBUF\_\-SEEKABLE}}
\index{IOBUF\_\-SEEKABLE@{IOBUF\_\-SEEKABLE}!iobuf@{iobuf}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}\#define IOBUF\_\-SEEKABLE~0x10}}
\label{group__iobuf_g724f6d12b6627f3813a762cd84c7bd28}


{\tt lseek} is possible on the file descriptor. \hypertarget{group__iobuf_gd8df365380fe10ef962692eb2123f061}{
\index{iobuf@{iobuf}!IOBUF\_\-SET\_\-ERROR@{IOBUF\_\-SET\_\-ERROR}}
\index{IOBUF\_\-SET\_\-ERROR@{IOBUF\_\-SET\_\-ERROR}!iobuf@{iobuf}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}\#define IOBUF\_\-SET\_\-ERROR(io)}}
\label{group__iobuf_gd8df365380fe10ef962692eb2123f061}


\textbf{Value:}

\begin{Code}\begin{verbatim}do{ \
  io->flags |= IOBUF_ERROR; \
  io->errnum = errno; \
  return 0; \
}while(0)
\end{verbatim}
\end{Code}
Set the error flag, save {\tt errno}, and return false. \hypertarget{group__iobuf_gd3c3c0e8bb56ad8405669ae0ee1fff01}{
\index{iobuf@{iobuf}!iobuf\_\-timedout@{iobuf\_\-timedout}}
\index{iobuf\_\-timedout@{iobuf\_\-timedout}!iobuf@{iobuf}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}\#define iobuf\_\-timedout(io)~((io) $\rightarrow$ flags \& IOBUF\_\-TIMEOUT)}}
\label{group__iobuf_gd3c3c0e8bb56ad8405669ae0ee1fff01}


True if the input or output to the {\tt \hyperlink{structiobuf}{iobuf}} previously timed out. \hypertarget{group__iobuf_g4c4cf7dac5cc7cac920c53c919b54a55}{
\index{iobuf@{iobuf}!IOBUF\_\-TIMEOUT@{IOBUF\_\-TIMEOUT}}
\index{IOBUF\_\-TIMEOUT@{IOBUF\_\-TIMEOUT}!iobuf@{iobuf}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}\#define IOBUF\_\-TIMEOUT~4}}
\label{group__iobuf_g4c4cf7dac5cc7cac920c53c919b54a55}


The timeout expired before the read or write could be completed. 

\subsection{Function Documentation}
\hypertarget{group__iobuf_g5e1d63bc6e2127fd5cd043caac078867}{
\index{iobuf@{iobuf}!ibuf\_\-copytofd@{ibuf\_\-copytofd}}
\index{ibuf\_\-copytofd@{ibuf\_\-copytofd}!iobuf@{iobuf}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int ibuf\_\-copytofd ({\bf ibuf} $\ast$ {\em in}, int {\em out})}}
\label{group__iobuf_g5e1d63bc6e2127fd5cd043caac078867}


Copy all the data from an {\tt \hyperlink{structibuf}{ibuf}} to an output file descriptor. \hypertarget{group__iobuf_g02d1cff3c2911677d2ba3257f0c73259}{
\index{iobuf@{iobuf}!iobuf\_\-close@{iobuf\_\-close}}
\index{iobuf\_\-close@{iobuf\_\-close}!iobuf@{iobuf}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int iobuf\_\-close ({\bf iobuf} $\ast$ {\em io})}}
\label{group__iobuf_g02d1cff3c2911677d2ba3257f0c73259}


Close an {\tt \hyperlink{structiobuf}{iobuf}} and deallocate the buffer. \hypertarget{group__iobuf_g2d8a3151c65892ca5146330f46dd9b3a}{
\index{iobuf@{iobuf}!iobuf\_\-copy@{iobuf\_\-copy}}
\index{iobuf\_\-copy@{iobuf\_\-copy}!iobuf@{iobuf}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int iobuf\_\-copy ({\bf ibuf} $\ast$ {\em in}, {\bf obuf} $\ast$ {\em out})}}
\label{group__iobuf_g2d8a3151c65892ca5146330f46dd9b3a}


Copy all the data from an {\tt \hyperlink{structibuf}{ibuf}} to an {\tt \hyperlink{structobuf}{obuf}}. \hypertarget{group__iobuf_g6434153f5f1fa56f26fcfa305a47d264}{
\index{iobuf@{iobuf}!iobuf\_\-copyflush@{iobuf\_\-copyflush}}
\index{iobuf\_\-copyflush@{iobuf\_\-copyflush}!iobuf@{iobuf}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int iobuf\_\-copyflush ({\bf ibuf} $\ast$ {\em in}, {\bf obuf} $\ast$ {\em out})}}
\label{group__iobuf_g6434153f5f1fa56f26fcfa305a47d264}


Copy all the data from an {\tt \hyperlink{structibuf}{ibuf}} to an {\tt \hyperlink{structobuf}{obuf}}, and flush the {\tt \hyperlink{structobuf}{obuf}} after writing is completed. \hypertarget{group__iobuf_g1f577ec79ef10d4ffa30b23981536ac8}{
\index{iobuf@{iobuf}!iobuf\_\-init@{iobuf\_\-init}}
\index{iobuf\_\-init@{iobuf\_\-init}!iobuf@{iobuf}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int iobuf\_\-init ({\bf iobuf} $\ast$ {\em io}, int {\em fd}, unsigned {\em bufsize}, char $\ast$ {\em buffer}, unsigned {\em flags})}}
\label{group__iobuf_g1f577ec79ef10d4ffa30b23981536ac8}


Initialize an {\tt \hyperlink{structiobuf}{iobuf}} structure. \hypertarget{group__iobuf_g92ccfacce7d0d0c03b3e7ea0d5e49c6b}{
\index{iobuf@{iobuf}!iobuf\_\-timeout@{iobuf\_\-timeout}}
\index{iobuf\_\-timeout@{iobuf\_\-timeout}!iobuf@{iobuf}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int iobuf\_\-timeout ({\bf iobuf} $\ast$ {\em io}, int {\em poll\_\-out})}}
\label{group__iobuf_g92ccfacce7d0d0c03b3e7ea0d5e49c6b}


Wait for a file descriptor to be ready for reading or writing. \hypertarget{group__iobuf_gf21d1424bd0e9de6f80d56070e45f1cc}{
\index{iobuf@{iobuf}!obuf\_\-copyfromfd@{obuf\_\-copyfromfd}}
\index{obuf\_\-copyfromfd@{obuf\_\-copyfromfd}!iobuf@{iobuf}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int obuf\_\-copyfromfd (int {\em in}, {\bf obuf} $\ast$ {\em out})}}
\label{group__iobuf_gf21d1424bd0e9de6f80d56070e45f1cc}


Copy all the data from an input file descriptor to an {\tt \hyperlink{structobuf}{obuf}}. 

\subsection{Variable Documentation}
\hypertarget{group__iobuf_g2c854014f77658545278463b09758cd5}{
\index{iobuf@{iobuf}!iobuf\_\-bufsize@{iobuf\_\-bufsize}}
\index{iobuf\_\-bufsize@{iobuf\_\-bufsize}!iobuf@{iobuf}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}unsigned {\bf iobuf\_\-bufsize}}}
\label{group__iobuf_g2c854014f77658545278463b09758cd5}


The default \hyperlink{structiobuf}{iobuf} buffer size, defaults to 8192. 