\doxysubsection{tube.\+c File Reference}
\label{tube_8c}\index{tube.c@{tube.c}}


A somewhat elastic but fairly small buffer for data passing through a stream.  


Include dependency graph for tube.\+c\+:
\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{tube_8c__incl}
\end{center}
\end{figure}
\doxysubsubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
static void \mbox{\hyperlink{tube_8c_ab55e376728666a0f6138efe348826253}{rs\+\_\+tube\+\_\+catchup\+\_\+write}} (\mbox{\hyperlink{librsync_8h_add6622b38e3fa557301a190876d5ed4a}{rs\+\_\+job\+\_\+t}} $\ast$job)
\item 
static void \mbox{\hyperlink{tube_8c_a3d0f841e07770b6d64e53fce19056a6a}{rs\+\_\+tube\+\_\+catchup\+\_\+copy}} (\mbox{\hyperlink{librsync_8h_add6622b38e3fa557301a190876d5ed4a}{rs\+\_\+job\+\_\+t}} $\ast$job)
\begin{DoxyCompactList}\small\item\em Catch up on an outstanding copy command. \end{DoxyCompactList}\item 
\mbox{\hyperlink{librsync_8h_a7feb858ceba3b8f3cf048d49be108253}{rs\+\_\+result}} \mbox{\hyperlink{tube_8c_a5285265e3d220e43b8fd08867d708d9c}{rs\+\_\+tube\+\_\+catchup}} (\mbox{\hyperlink{librsync_8h_add6622b38e3fa557301a190876d5ed4a}{rs\+\_\+job\+\_\+t}} $\ast$job)
\begin{DoxyCompactList}\small\item\em Put whatever will fit from the tube into the output of the stream. \end{DoxyCompactList}\item 
int \mbox{\hyperlink{tube_8c_afa78a2f17f45a022ec0f93a50c3f142d}{rs\+\_\+tube\+\_\+is\+\_\+idle}} (\mbox{\hyperlink{librsync_8h_add6622b38e3fa557301a190876d5ed4a}{rs\+\_\+job\+\_\+t}} const $\ast$job)
\item 
void \mbox{\hyperlink{tube_8c_aa1170d5552b5581630f90d8a66a71adc}{rs\+\_\+tube\+\_\+copy}} (\mbox{\hyperlink{librsync_8h_add6622b38e3fa557301a190876d5ed4a}{rs\+\_\+job\+\_\+t}} $\ast$job, size\+\_\+t len)
\begin{DoxyCompactList}\small\item\em Queue up a request to copy through {\ttfamily len} bytes from the input to the output of the stream. \end{DoxyCompactList}\item 
void \mbox{\hyperlink{tube_8c_a15809106e8f91386fb19f3934f73b993}{rs\+\_\+tube\+\_\+write}} (\mbox{\hyperlink{librsync_8h_add6622b38e3fa557301a190876d5ed4a}{rs\+\_\+job\+\_\+t}} $\ast$job, const void $\ast$buf, size\+\_\+t len)
\begin{DoxyCompactList}\small\item\em Push some data into the tube for storage. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsubsection{Detailed Description}
A somewhat elastic but fairly small buffer for data passing through a stream. 

In most cases the iter can adjust to send just as much data will fit. In some cases that would be too complicated, because it has to transmit an integer or something similar. So in that case we stick whatever won\textquotesingle{}t fit into a small buffer.

A tube can contain some literal data to go out (typically command bytes), and also an instruction to copy data from the stream\textquotesingle{}s input or from some other location. Both literal data and a copy command can be queued at the same time, but only in that order and at most one of each.

\begin{DoxyRefDesc}{Todo}
\item[\mbox{\hyperlink{todo__todo000018}{Todo}}]As an optimization, write it directly to the stream if possible. But for simplicity don\textquotesingle{}t do that yet.\end{DoxyRefDesc}


\begin{DoxyRefDesc}{Todo}
\item[\mbox{\hyperlink{todo__todo000019}{Todo}}]I think our current copy code will lock up if the application only ever calls us with either input or output buffers, and not both. So I guess in that case we might need to copy into some temporary buffer space, and then back out again later. \end{DoxyRefDesc}


Definition in file \mbox{\hyperlink{tube_8c_source}{tube.\+c}}.



\doxysubsubsection{Function Documentation}
\mbox{\label{tube_8c_ab55e376728666a0f6138efe348826253}} 
\index{tube.c@{tube.c}!rs\_tube\_catchup\_write@{rs\_tube\_catchup\_write}}
\index{rs\_tube\_catchup\_write@{rs\_tube\_catchup\_write}!tube.c@{tube.c}}
\doxyparagraph{\texorpdfstring{rs\_tube\_catchup\_write()}{rs\_tube\_catchup\_write()}}
{\footnotesize\ttfamily static void rs\+\_\+tube\+\_\+catchup\+\_\+write (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{librsync_8h_add6622b38e3fa557301a190876d5ed4a}{rs\+\_\+job\+\_\+t}} $\ast$}]{job }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



Definition at line \mbox{\hyperlink{tube_8c_source_l00063}{63}} of file \mbox{\hyperlink{tube_8c_source}{tube.\+c}}.

\mbox{\label{tube_8c_a3d0f841e07770b6d64e53fce19056a6a}} 
\index{tube.c@{tube.c}!rs\_tube\_catchup\_copy@{rs\_tube\_catchup\_copy}}
\index{rs\_tube\_catchup\_copy@{rs\_tube\_catchup\_copy}!tube.c@{tube.c}}
\doxyparagraph{\texorpdfstring{rs\_tube\_catchup\_copy()}{rs\_tube\_catchup\_copy()}}
{\footnotesize\ttfamily static void rs\+\_\+tube\+\_\+catchup\+\_\+copy (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{librsync_8h_add6622b38e3fa557301a190876d5ed4a}{rs\+\_\+job\+\_\+t}} $\ast$}]{job }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



Catch up on an outstanding copy command. 

Takes data from the scoop and writes as much as will fit to the output, up to the limit of the outstanding copy. 

Definition at line \mbox{\hyperlink{tube_8c_source_l00088}{88}} of file \mbox{\hyperlink{tube_8c_source}{tube.\+c}}.

\mbox{\label{tube_8c_a5285265e3d220e43b8fd08867d708d9c}} 
\index{tube.c@{tube.c}!rs\_tube\_catchup@{rs\_tube\_catchup}}
\index{rs\_tube\_catchup@{rs\_tube\_catchup}!tube.c@{tube.c}}
\doxyparagraph{\texorpdfstring{rs\_tube\_catchup()}{rs\_tube\_catchup()}}
{\footnotesize\ttfamily \mbox{\hyperlink{librsync_8h_a7feb858ceba3b8f3cf048d49be108253}{rs\+\_\+result}} rs\+\_\+tube\+\_\+catchup (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{librsync_8h_add6622b38e3fa557301a190876d5ed4a}{rs\+\_\+job\+\_\+t}} $\ast$}]{job }\end{DoxyParamCaption})}



Put whatever will fit from the tube into the output of the stream. 

\begin{DoxyReturn}{Returns}
RS\+\_\+\+DONE if the tube is now empty and ready to accept another command, RS\+\_\+\+BLOCKED if there is still stuff waiting to go out. 
\end{DoxyReturn}


Definition at line \mbox{\hyperlink{tube_8c_source_l00120}{120}} of file \mbox{\hyperlink{tube_8c_source}{tube.\+c}}.

\mbox{\label{tube_8c_afa78a2f17f45a022ec0f93a50c3f142d}} 
\index{tube.c@{tube.c}!rs\_tube\_is\_idle@{rs\_tube\_is\_idle}}
\index{rs\_tube\_is\_idle@{rs\_tube\_is\_idle}!tube.c@{tube.c}}
\doxyparagraph{\texorpdfstring{rs\_tube\_is\_idle()}{rs\_tube\_is\_idle()}}
{\footnotesize\ttfamily int rs\+\_\+tube\+\_\+is\+\_\+idle (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{librsync_8h_add6622b38e3fa557301a190876d5ed4a}{rs\+\_\+job\+\_\+t}} const $\ast$}]{job }\end{DoxyParamCaption})}



Definition at line \mbox{\hyperlink{tube_8c_source_l00144}{144}} of file \mbox{\hyperlink{tube_8c_source}{tube.\+c}}.

\mbox{\label{tube_8c_aa1170d5552b5581630f90d8a66a71adc}} 
\index{tube.c@{tube.c}!rs\_tube\_copy@{rs\_tube\_copy}}
\index{rs\_tube\_copy@{rs\_tube\_copy}!tube.c@{tube.c}}
\doxyparagraph{\texorpdfstring{rs\_tube\_copy()}{rs\_tube\_copy()}}
{\footnotesize\ttfamily void rs\+\_\+tube\+\_\+copy (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{librsync_8h_add6622b38e3fa557301a190876d5ed4a}{rs\+\_\+job\+\_\+t}} $\ast$}]{job,  }\item[{size\+\_\+t}]{len }\end{DoxyParamCaption})}



Queue up a request to copy through {\ttfamily len} bytes from the input to the output of the stream. 

The data is copied from the scoop (if there is anything there) or from the input, on the next call to \mbox{\hyperlink{tube_8c_a15809106e8f91386fb19f3934f73b993}{rs\+\_\+tube\+\_\+write()}}.

We can only accept this request if there is no copy command already pending.

\begin{DoxyRefDesc}{Todo}
\item[\mbox{\hyperlink{todo__todo000020}{Todo}}]Try to do the copy immediately, and return a result. Then, people can try to continue if possible. Is this really required? Callers can just go out and back in again after flushing the tube. \end{DoxyRefDesc}


Definition at line \mbox{\hyperlink{tube_8c_source_l00160}{160}} of file \mbox{\hyperlink{tube_8c_source}{tube.\+c}}.

\mbox{\label{tube_8c_a15809106e8f91386fb19f3934f73b993}} 
\index{tube.c@{tube.c}!rs\_tube\_write@{rs\_tube\_write}}
\index{rs\_tube\_write@{rs\_tube\_write}!tube.c@{tube.c}}
\doxyparagraph{\texorpdfstring{rs\_tube\_write()}{rs\_tube\_write()}}
{\footnotesize\ttfamily void rs\+\_\+tube\+\_\+write (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{librsync_8h_add6622b38e3fa557301a190876d5ed4a}{rs\+\_\+job\+\_\+t}} $\ast$}]{job,  }\item[{const void $\ast$}]{buf,  }\item[{size\+\_\+t}]{len }\end{DoxyParamCaption})}



Push some data into the tube for storage. 

The tube\textquotesingle{}s never supposed to get very big, so this will just pop loudly if you do that.

We can\textquotesingle{}t accept write data if there\textquotesingle{}s already a copy command in the tube, because the write data comes out first. 

Definition at line \mbox{\hyperlink{tube_8c_source_l00174}{174}} of file \mbox{\hyperlink{tube_8c_source}{tube.\+c}}.

