\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 
\#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
\item 
unsigned \hyperlink{group__iobuf_g2c854014f77658545278463b09758cd5}{iobuf\_\-bufsize}
\end{CompactItemize}
\subsection*{Common}
\begin{CompactItemize}
\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)
\item 
\hypertarget{group__iobuf_g690c6cce9ede03409c28d27a2be73ba9}{
typedef \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)
\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[iobuf\_\-bad]{\setlength{\rightskip}{0pt plus 5cm}\#define iobuf\_\-bad(io)~((io) $\rightarrow$ flags \& IOBUF\_\-BADFLAGS)}}
\label{group__iobuf_g9ff81d3db610c54cf21d19967bea5c3f}


True if the {\tt 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[IOBUF\_\-BADFLAGS]{\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[iobuf\_\-closed]{\setlength{\rightskip}{0pt plus 5cm}\#define iobuf\_\-closed(io)~((io) $\rightarrow$ fd == -1)}}
\label{group__iobuf_g8f5ac893f0d359136bfb72a96863a4a0}


True if the {\tt iobuf} has been closed. \hypertarget{group__iobuf_ga9922524dac6fa4139c68411cb2dec8d}{
\index{iobuf@{iobuf}!IOBUF_EOF@{IOBUF\_\-EOF}}
\index{IOBUF_EOF@{IOBUF\_\-EOF}!iobuf@{iobuf}}
\subsubsection[IOBUF\_\-EOF]{\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[iobuf\_\-error]{\setlength{\rightskip}{0pt plus 5cm}\#define iobuf\_\-error(io)~((io) $\rightarrow$ flags \& IOBUF\_\-ERROR)}}
\label{group__iobuf_g880c0546f9a201b0e2ba7d8f37e018ef}


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


The iobuf has encountered an error. \hypertarget{group__iobuf_g49715bfac7e883555379b6f23f4aa713}{
\index{iobuf@{iobuf}!IOBUF_NEEDSCLOSE@{IOBUF\_\-NEEDSCLOSE}}
\index{IOBUF_NEEDSCLOSE@{IOBUF\_\-NEEDSCLOSE}!iobuf@{iobuf}}
\subsubsection[IOBUF\_\-NEEDSCLOSE]{\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[IOBUF\_\-NEEDSFREE]{\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[IOBUF\_\-NEEDSMUNMAP]{\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[IOBUF\_\-SEEKABLE]{\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[IOBUF\_\-SET\_\-ERROR]{\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[iobuf\_\-timedout]{\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 iobuf} previously timed out. \hypertarget{group__iobuf_g4c4cf7dac5cc7cac920c53c919b54a55}{
\index{iobuf@{iobuf}!IOBUF_TIMEOUT@{IOBUF\_\-TIMEOUT}}
\index{IOBUF_TIMEOUT@{IOBUF\_\-TIMEOUT}!iobuf@{iobuf}}
\subsubsection[IOBUF\_\-TIMEOUT]{\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[ibuf\_\-copytofd]{\setlength{\rightskip}{0pt plus 5cm}int ibuf\_\-copytofd (\hyperlink{structibuf}{ibuf} $\ast$ {\em in}, int {\em out})}}
\label{group__iobuf_g5e1d63bc6e2127fd5cd043caac078867}


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


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


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


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


Initialize an {\tt iobuf} structure. \hypertarget{group__iobuf_g92ccfacce7d0d0c03b3e7ea0d5e49c6b}{
\index{iobuf@{iobuf}!iobuf_timeout@{iobuf\_\-timeout}}
\index{iobuf_timeout@{iobuf\_\-timeout}!iobuf@{iobuf}}
\subsubsection[iobuf\_\-timeout]{\setlength{\rightskip}{0pt plus 5cm}int iobuf\_\-timeout (\hyperlink{structiobuf}{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[obuf\_\-copyfromfd]{\setlength{\rightskip}{0pt plus 5cm}int obuf\_\-copyfromfd (int {\em in}, \hyperlink{structobuf}{obuf} $\ast$ {\em out})}}
\label{group__iobuf_gf21d1424bd0e9de6f80d56070e45f1cc}


Copy all the data from an {\tt ibuf} to an {\tt obuf}. 

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


The default iobuf buffer size, defaults to 8192. 