00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00016 #ifndef JIGDO_IO_HH
00017 #define JIGDO_IO_HH
00018
00019 #include <config.h>
00020 #include <vector>
00021 #include <string>
00022
00023 #include <datasource.hh>
00024 #include <gunzip.hh>
00025 #include <jigdo-io.fh>
00026 #include <makeimagedl.hh>
00027 #include <md5sum.fh>
00028 #include <nocopy.hh>
00029 #include <status.hh>
00030
00031
00032 namespace Job {
00033 class JigdoIO;
00034 struct JigdoIOTest;
00035 }
00036
00038 class Job::JigdoIO : NoCopy, public Job::DataSource::IO, Gunzip::IO {
00039 public:
00040
00046 JigdoIO(MakeImageDl::Child* c, const string& url
00047 );
00048 ~JigdoIO();
00049
00050 inline MakeImageDl* master() const;
00051 inline DataSource* source() const;
00052
00053 private:
00054 friend struct Job::JigdoIOTest;
00055
00056
00057 JigdoIO(MakeImageDl::Child* c, const string& url,
00058 JigdoIO* parentJigdo,
00059 int inclLine);
00060
00062 inline JigdoIO* root();
00063 inline const JigdoIO* root() const;
00065 inline bool isRoot() const;
00071 inline JigdoIO* imgSectCandidate() const;
00073 inline void setImgSectCandidate(JigdoIO* c);
00074
00075 inline void imgSect_newChild(JigdoIO* child);
00076 inline void imgSect_parsed();
00077
00078
00079 inline XStatus imgSect_eof();
00080
00081
00082 void generateError(const string& msg);
00083 void generateError(const char* msg);
00084
00085 void generateError_plain(const string& err);
00086
00087 inline bool failed() const;
00088
00089 void jigdoLine(string* l);
00090 void include(string* url);
00091 void entry(string* label, string* data, unsigned valueOff);
00092
00093
00094 Status sectionEnd();
00095
00096
00097 virtual void job_deleted();
00098 virtual void job_succeeded();
00099 virtual void job_failed(const string& message);
00100 virtual void job_message(const string& message);
00101 virtual void dataSource_dataSize(uint64 n);
00102 virtual void dataSource_data(const byte* data, unsigned size,
00103 uint64 currentSize);
00104
00105
00106 virtual void gunzip_deleted();
00107 virtual void gunzip_data(Gunzip*, byte* decompressed, unsigned size);
00108 virtual void gunzip_needOut(Gunzip*);
00109 virtual void gunzip_failed(string* message);
00110
00111 MakeImageDl::Child* childDl;
00112 string urlVal;
00113
00114
00115
00116
00117
00118 JigdoIO* parent;
00119 int includeLine;
00120 JigdoIO* firstChild;
00121 JigdoIO* next;
00122
00123
00124 JigdoIO* rootAndImageSectionCandidate;
00125
00126 int line;
00127 bool finished() { return line < 0; }
00128 void setFinished() { line = -1; }
00129 string section;
00130
00131
00132 int imageSectionLine;
00133 string imageName;
00134 string imageInfo, imageShortInfo;
00135 SmartPtr<PartUrlMapping> templateUrls;
00136 MD5* templateMd5;
00137
00138
00139
00140 static const unsigned GUNZIP_BUF_SIZE = 16384;
00141 Gunzip gunzip;
00142 byte gunzipBuf[GUNZIP_BUF_SIZE];
00143 };
00144
00145
00146 Job::JigdoIO* Job::JigdoIO::root() {
00147 if (isRoot()) return this; else return rootAndImageSectionCandidate;
00148 }
00149 const Job::JigdoIO* Job::JigdoIO::root() const {
00150 if (isRoot()) return this; else return rootAndImageSectionCandidate;
00151 }
00152 bool Job::JigdoIO::isRoot() const {
00153 return parent == 0;
00154 }
00155
00156 Job::JigdoIO* Job::JigdoIO::imgSectCandidate() const {
00157 if (isRoot())
00158 return rootAndImageSectionCandidate;
00159 else
00160 return rootAndImageSectionCandidate->rootAndImageSectionCandidate;
00161 }
00162 void Job::JigdoIO::setImgSectCandidate(JigdoIO* c) {
00163 if (isRoot())
00164 rootAndImageSectionCandidate = c;
00165 else
00166 rootAndImageSectionCandidate->rootAndImageSectionCandidate = c;
00167 }
00168
00169 Job::MakeImageDl* Job::JigdoIO::master() const { return childDl->master(); }
00170 Job::DataSource* Job::JigdoIO::source() const { return childDl->source(); }
00171
00172 bool Job::JigdoIO::failed() const {
00173 return (imageName.length() == 1 && imageName[0] == '\0');
00174
00175 }
00176
00177 #endif