\doxysubsection{job.\+h}
\label{job_8h_source}\index{job.h@{job.h}}
\mbox{\hyperlink{job_8h}{Go to the documentation of this file.}}
\begin{DoxyCode}{0}
\DoxyCodeLine{00001 \textcolor{comment}{/*= -\/*-\/ c-\/basic-\/offset: 4; indent-\/tabs-\/mode: nil; -\/*-\/}}
\DoxyCodeLine{00002 \textcolor{comment}{ *}}
\DoxyCodeLine{00003 \textcolor{comment}{ * librsync -\/-\/ the library for network deltas}}
\DoxyCodeLine{00004 \textcolor{comment}{ *}}
\DoxyCodeLine{00005 \textcolor{comment}{ * Copyright (C) 2000, 2001, 2014 by Martin Pool <mbp@sourcefrog.net>}}
\DoxyCodeLine{00006 \textcolor{comment}{ *}}
\DoxyCodeLine{00007 \textcolor{comment}{ * This program is free software; you can redistribute it and/or}}
\DoxyCodeLine{00008 \textcolor{comment}{ * modify it under the terms of the GNU Lesser General Public License}}
\DoxyCodeLine{00009 \textcolor{comment}{ * as published by the Free Software Foundation; either version 2.1 of}}
\DoxyCodeLine{00010 \textcolor{comment}{ * the License, or (at your option) any later version.}}
\DoxyCodeLine{00011 \textcolor{comment}{ *}}
\DoxyCodeLine{00012 \textcolor{comment}{ * This program is distributed in the hope that it will be useful, but}}
\DoxyCodeLine{00013 \textcolor{comment}{ * WITHOUT ANY WARRANTY; without even the implied warranty of}}
\DoxyCodeLine{00014 \textcolor{comment}{ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU}}
\DoxyCodeLine{00015 \textcolor{comment}{ * Lesser General Public License for more details.}}
\DoxyCodeLine{00016 \textcolor{comment}{ *}}
\DoxyCodeLine{00017 \textcolor{comment}{ * You should have received a copy of the GNU Lesser General Public}}
\DoxyCodeLine{00018 \textcolor{comment}{ * License along with this program; if not, write to the Free Software}}
\DoxyCodeLine{00019 \textcolor{comment}{ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.}}
\DoxyCodeLine{00020 \textcolor{comment}{ */}}
\DoxyCodeLine{00021 \textcolor{comment}{}}
\DoxyCodeLine{00022 \textcolor{comment}{/** \(\backslash\)file job.h}}
\DoxyCodeLine{00023 \textcolor{comment}{ * Generic state-\/machine interface.}}
\DoxyCodeLine{00024 \textcolor{comment}{ *}}
\DoxyCodeLine{00025 \textcolor{comment}{ * The point of this is that we need to be able to suspend and resume}}
\DoxyCodeLine{00026 \textcolor{comment}{ * processing at any point at which the buffers may block.}}
\DoxyCodeLine{00027 \textcolor{comment}{ *}}
\DoxyCodeLine{00028 \textcolor{comment}{ * \(\backslash\)sa \(\backslash\)ref api\_streaming \(\backslash\)sa rs\_job\_iter() \(\backslash\)sa ::rs\_job */}}
\DoxyCodeLine{00029 \textcolor{preprocessor}{\#ifndef JOB\_H}}
\DoxyCodeLine{00030 \textcolor{preprocessor}{\#  define JOB\_H}}
\DoxyCodeLine{00031 }
\DoxyCodeLine{00032 \textcolor{preprocessor}{\#  include <assert.h>}}
\DoxyCodeLine{00033 \textcolor{preprocessor}{\#  include <stddef.h>}}
\DoxyCodeLine{00034 \textcolor{preprocessor}{\#  include "{}mdfour.h"{}}}
\DoxyCodeLine{00035 \textcolor{preprocessor}{\#  include "{}checksum.h"{}}}
\DoxyCodeLine{00036 \textcolor{preprocessor}{\#  include "{}librsync.h"{}}}
\DoxyCodeLine{00037 \textcolor{comment}{}}
\DoxyCodeLine{00038 \textcolor{comment}{/** Magic job tag number for checking jobs have been initialized. */}}
\DoxyCodeLine{00039 \textcolor{preprocessor}{\#  define RS\_JOB\_TAG 20010225}}
\DoxyCodeLine{00040 \textcolor{comment}{}}
\DoxyCodeLine{00041 \textcolor{comment}{/** Max length of a singled delta command is including command bytes.}}
\DoxyCodeLine{00042 \textcolor{comment}{ *}}
\DoxyCodeLine{00043 \textcolor{comment}{ * This is used to constrain and set the internal buffer sizes. */}}
\DoxyCodeLine{00044 \textcolor{preprocessor}{\#  define MAX\_DELTA\_CMD (1<<16)}}
\DoxyCodeLine{00045 \textcolor{comment}{}}
\DoxyCodeLine{00046 \textcolor{comment}{/** The contents of this structure are private. */}}
\DoxyCodeLine{00047 \textcolor{keyword}{struct }rs\_job \{}
\DoxyCodeLine{00048     \textcolor{keywordtype}{int} dogtag;}
\DoxyCodeLine{00049 \textcolor{comment}{}}
\DoxyCodeLine{00050 \textcolor{comment}{    /** Human-\/readable job operation name. */}}
\DoxyCodeLine{00051     \textcolor{keyword}{const} \textcolor{keywordtype}{char} *job\_name;}
\DoxyCodeLine{00052 }
\DoxyCodeLine{00053     rs\_buffers\_t *stream;}
\DoxyCodeLine{00054 \textcolor{comment}{}}
\DoxyCodeLine{00055 \textcolor{comment}{    /** Callback for each processing step. */}}
\DoxyCodeLine{00056     rs\_result (*statefn)(rs\_job\_t *);}
\DoxyCodeLine{00057 \textcolor{comment}{}}
\DoxyCodeLine{00058 \textcolor{comment}{    /** Final result of processing job. Used by rs\_job\_s\_failed(). */}}
\DoxyCodeLine{00059     rs\_result final\_result;}
\DoxyCodeLine{00060 }
\DoxyCodeLine{00061     \textcolor{comment}{/* Arguments for initializing the signature used by mksum.c and readsums.c.}}
\DoxyCodeLine{00062 \textcolor{comment}{     */}}
\DoxyCodeLine{00063     \textcolor{keywordtype}{int} sig\_magic;}
\DoxyCodeLine{00064     \textcolor{keywordtype}{int} sig\_block\_len;}
\DoxyCodeLine{00065     \textcolor{keywordtype}{int} sig\_strong\_len;}
\DoxyCodeLine{00066 \textcolor{comment}{}}
\DoxyCodeLine{00067 \textcolor{comment}{    /** The size of the signature file if available. Used by loadsums.c when}}
\DoxyCodeLine{00068 \textcolor{comment}{     * initializing the signature to preallocate memory. */}}
\DoxyCodeLine{00069     rs\_long\_t sig\_fsize;}
\DoxyCodeLine{00070 \textcolor{comment}{}}
\DoxyCodeLine{00071 \textcolor{comment}{    /** Pointer to the signature that's being used by the operation. */}}
\DoxyCodeLine{00072     rs\_signature\_t *signature;}
\DoxyCodeLine{00073 \textcolor{comment}{}}
\DoxyCodeLine{00074 \textcolor{comment}{    /** Flag indicating signature should be destroyed with the job. */}}
\DoxyCodeLine{00075     \textcolor{keywordtype}{int} job\_owns\_sig;}
\DoxyCodeLine{00076 \textcolor{comment}{}}
\DoxyCodeLine{00077 \textcolor{comment}{    /** Command byte currently being processed, if any. */}}
\DoxyCodeLine{00078     \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{char} op;}
\DoxyCodeLine{00079 \textcolor{comment}{}}
\DoxyCodeLine{00080 \textcolor{comment}{    /** The weak signature digest used by readsums.c */}}
\DoxyCodeLine{00081     rs\_weak\_sum\_t weak\_sig;}
\DoxyCodeLine{00082 \textcolor{comment}{}}
\DoxyCodeLine{00083 \textcolor{comment}{    /** The rollsum weak signature accumulator used by delta.c */}}
\DoxyCodeLine{00084     weaksum\_t weak\_sum;}
\DoxyCodeLine{00085 \textcolor{comment}{}}
\DoxyCodeLine{00086 \textcolor{comment}{    /** Lengths of expected parameters. */}}
\DoxyCodeLine{00087     rs\_long\_t param1, param2;}
\DoxyCodeLine{00088 }
\DoxyCodeLine{00089     \textcolor{keyword}{struct }rs\_prototab\_ent const *cmd;}
\DoxyCodeLine{00090     rs\_mdfour\_t output\_md4;}
\DoxyCodeLine{00091 \textcolor{comment}{}}
\DoxyCodeLine{00092 \textcolor{comment}{    /** Encoding statistics. */}}
\DoxyCodeLine{00093     rs\_stats\_t stats;}
\DoxyCodeLine{00094 \textcolor{comment}{}}
\DoxyCodeLine{00095 \textcolor{comment}{    /** Buffer of data in the scoop. Allocation is scoop\_buf[0..scoop\_alloc],}}
\DoxyCodeLine{00096 \textcolor{comment}{     * and scoop\_next[0..scoop\_avail] contains data yet to be processed. */}}
\DoxyCodeLine{00097     rs\_byte\_t *scoop\_buf;       \textcolor{comment}{/**< The buffer allocation pointer. */}}
\DoxyCodeLine{00098     rs\_byte\_t *scoop\_next;      \textcolor{comment}{/**< The next data pointer. */}}
\DoxyCodeLine{00099     \textcolor{keywordtype}{size\_t} scoop\_alloc;         \textcolor{comment}{/**< The buffer allocation size. */}}
\DoxyCodeLine{00100     \textcolor{keywordtype}{size\_t} scoop\_avail;         \textcolor{comment}{/**< The amount of data available. */}}
\DoxyCodeLine{00101 \textcolor{comment}{}}
\DoxyCodeLine{00102 \textcolor{comment}{    /** The delta scan buffer, where scan\_buf[scan\_pos..scan\_len] is the data}}
\DoxyCodeLine{00103 \textcolor{comment}{     * yet to be scanned. */}}
\DoxyCodeLine{00104     rs\_byte\_t *scan\_buf;        \textcolor{comment}{/**< The delta scan buffer pointer. */}}
\DoxyCodeLine{00105     \textcolor{keywordtype}{size\_t} scan\_len;            \textcolor{comment}{/**< The delta scan buffer length. */}}
\DoxyCodeLine{00106     \textcolor{keywordtype}{size\_t} scan\_pos;            \textcolor{comment}{/**< The delta scan position. */}}
\DoxyCodeLine{00107 \textcolor{comment}{}}
\DoxyCodeLine{00108 \textcolor{comment}{    /** If USED is >0, then buf contains that much write data to be sent out. */}}
\DoxyCodeLine{00109     rs\_byte\_t write\_buf[36];}
\DoxyCodeLine{00110     \textcolor{keywordtype}{size\_t} write\_len;}
\DoxyCodeLine{00111 \textcolor{comment}{}}
\DoxyCodeLine{00112 \textcolor{comment}{    /** If \(\backslash\)p copy\_len is >0, then that much data should be copied through}}
\DoxyCodeLine{00113 \textcolor{comment}{     * from the input. */}}
\DoxyCodeLine{00114     \textcolor{keywordtype}{size\_t} copy\_len;}
\DoxyCodeLine{00115 \textcolor{comment}{}}
\DoxyCodeLine{00116 \textcolor{comment}{    /** Copy from the basis position. */}}
\DoxyCodeLine{00117     rs\_long\_t basis\_pos, basis\_len;}
\DoxyCodeLine{00118 \textcolor{comment}{}}
\DoxyCodeLine{00119 \textcolor{comment}{    /** Callback used to copy data from the basis into the output. */}}
\DoxyCodeLine{00120     rs\_copy\_cb *copy\_cb;}
\DoxyCodeLine{00121     \textcolor{keywordtype}{void} *copy\_arg;}
\DoxyCodeLine{00122 \};}
\DoxyCodeLine{00123 }
\DoxyCodeLine{00124 rs\_job\_t *rs\_job\_new(\textcolor{keyword}{const} \textcolor{keywordtype}{char} *, rs\_result (*statefn)(rs\_job\_t *));}
\DoxyCodeLine{00125 \textcolor{comment}{}}
\DoxyCodeLine{00126 \textcolor{comment}{/** Assert that a job is valid.}}
\DoxyCodeLine{00127 \textcolor{comment}{ *}}
\DoxyCodeLine{00128 \textcolor{comment}{ * We don't use a static inline function here so that assert failure output}}
\DoxyCodeLine{00129 \textcolor{comment}{ * points at where rs\_job\_check() was called from. */}}
\DoxyCodeLine{00130 \textcolor{preprocessor}{\#  define rs\_job\_check(job) do \{\(\backslash\)}}
\DoxyCodeLine{00131 \textcolor{preprocessor}{    assert(job-\/>dogtag == RS\_JOB\_TAG);\(\backslash\)}}
\DoxyCodeLine{00132 \textcolor{preprocessor}{\} while (0)}}
\DoxyCodeLine{00133 }
\DoxyCodeLine{00134 \textcolor{preprocessor}{\#endif                          }\textcolor{comment}{/* !JOB\_H */}\textcolor{preprocessor}{}}

\end{DoxyCode}
