Changeset 373
- Timestamp:
- 04/17/05 13:10:33 (8 years ago)
- Location:
- trunk/splitpipe
- Files:
-
- 4 modified
-
Makefile (modified) (2 diffs)
-
TODO (modified) (2 diffs)
-
joinpipe.cc (modified) (5 diffs)
-
splitpipe.cc (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/splitpipe/Makefile
r368 r373 2 2 OUTPUTDIR=splitpipe-$(VERSION) 3 3 CXXFLAGS=-Wall -g -O2 -DVERSION=\"$(VERSION)\" 4 PREFIX?=/usr/local/ 5 BINDIR?=$(DESTDIR)/$(PREFIX)/bin/ 6 4 7 5 8 all: splitpipe joinpipe … … 40 43 41 44 install: 42 install -s splitpipe $( DESTDIR)/usr/local/bin43 install -s joinpipe $( DESTDIR)/usr/local/bin45 install -s splitpipe $(BINDIR) 46 install -s joinpipe $(BINDIR) -
trunk/splitpipe/TODO
r370 r373 12 12 - take out getopt_long stuff, it is somewhat ugly 13 13 14 - make buildStretch, which appends stretches to a string14 DONE! - make buildStretch, which appends stretches to a string 15 15 16 16 DONE! - teach writen about EAGAIN … … 23 23 24 24 - add "name" chunk stretch 25 26 - manpages 27 28 - i18n 29 -
trunk/splitpipe/joinpipe.cc
r371 r373 35 35 using namespace std; 36 36 37 struct params 38 { 39 params() 37 namespace { 38 struct params 40 39 { 41 verbose=debug=verify=false; 42 } 43 44 bool verbose; 45 bool debug; 46 bool verify; 47 vector<string> inputDevice; 48 }parameters; 40 params() 41 { 42 verbose = debug = verify = noPrompt = false; 43 } 44 45 bool verbose; 46 bool debug; 47 bool verify; 48 bool noPrompt; 49 vector<string> inputDevice; 50 }parameters; 51 } 49 52 50 53 void usage() … … 54 57 cerr<<" --debug, -d\t\tGive debugging output\n"; 55 58 cerr<<" --help, -h\t\tGive this helpful message\n"; 59 cerr<<" --no-prompt, -h\tRun without user intervention\n"; 56 60 cerr<<" --verbose, -v\t\tGive verbose output\n"; 57 cerr<<" --verify, -t\t\tOnly verify an archive\n";58 61 cerr<<" --version\t\tReport version\n\n"; 59 62 … … 71 74 {"help", 0, 0, 'h'}, 72 75 {"verbose", 0, 0, 'v'}, 73 {" verify", 0, 0, 't'},76 {"no-prompt", 0, 0, 'n'}, 74 77 {"version", 0, 0, 'e'}, 75 78 {0, 0, 0, 0} 76 79 }; 77 80 78 c = getopt_long (argc, argv, "dh v",81 c = getopt_long (argc, argv, "dhnv", 79 82 long_options, &option_index); 80 83 if (c == -1) … … 86 89 break; 87 90 case 'e': 88 cerr<<"joinpipe "VERSION" (C) 2005 Netherlabs Computer Consulting BV "<<endl;91 cerr<<"joinpipe "VERSION" (C) 2005 Netherlabs Computer Consulting BV\nReport bugs to bert hubert <ahu@ds9a.nl>"<<endl; 89 92 exit(EXIT_SUCCESS); 90 93 case 'h': 91 94 usage(); 92 95 break; 93 case 't': 94 parameters.verify=1; 96 97 case 'n': 98 parameters.noPrompt=1; 99 break; 100 95 101 case 'v': 96 102 parameters.verbose=true; 103 break; 104 case '?': 105 usage(); 97 106 break; 98 107 } … … 173 182 cerr<<"joinpipe: end of volume, change media and press enter"<<endl; 174 183 175 waitForUser(); 184 if(!parameters.noPrompt) 185 waitForUser(); 176 186 177 187 if(inputIter + 1 != parameters.inputDevice.end()) -
trunk/splitpipe/splitpipe.cc
r371 r373 32 32 #include "md5.hh" 33 33 34 struct { 35 size_t bufferSize; 36 uint64_t volumeSize; 37 bool verbose; 38 bool debug; 39 string outputCommand; 40 } parameters; 34 namespace { 35 struct paramStruct { 36 paramStruct() 37 { 38 bufferSize = 0; 39 volumeSize = 0; 40 verbose = debug = noPrompt = false; 41 } 42 43 size_t bufferSize; 44 uint64_t volumeSize; 45 bool verbose; 46 bool debug; 47 bool noPrompt; 48 string outputCommand; 49 } parameters; 50 } 41 51 42 52 … … 105 115 cerr<<" --volume-size, -s\tSize of output volumes, in kilobytes. See below"<<endl; 106 116 cerr<<" --help, -h\t\tGive this helpful message"<<endl; 117 cerr<<" --no-prompt, -h\tRun without user intervention\n"; 107 118 cerr<<" --output, -o\t\tThe output script that will be spawned for each volume"<<endl; 108 119 cerr<<" --verbose, -v\t\tGive verbose output\n"; … … 125 136 {"buffer-size", 1, 0, 'b'}, 126 137 {"volume-size", 1, 0, 's'}, 138 {"no-prompt", 0, 0, 'n'}, 127 139 {"output", 1, 0, 'o'}, 128 140 {"debug", 0, 0, 'd'}, … … 133 145 }; 134 146 135 c = getopt_long (argc, argv, "b: s:deho:v",147 c = getopt_long (argc, argv, "b:ns:deho:v", 136 148 long_options, &option_index); 137 149 if (c == -1) … … 149 161 break; 150 162 case 'e': 151 cerr<<"splitpipe "VERSION" (C) 2005 Netherlabs Computer Consulting BV "<<endl;163 cerr<<"splitpipe "VERSION" (C) 2005 Netherlabs Computer Consulting BV\nReport bugs to bert hubert <ahu@ds9a.nl>"<<endl; 152 164 exit(EXIT_SUCCESS); 153 165 case 'h': … … 157 169 parameters.outputCommand=optarg; 158 170 break; 171 case 'n': 172 parameters.noPrompt=1; 173 break; 174 159 175 case 'v': 160 176 parameters.verbose=true; 177 break; 178 179 case '?': 180 usage(); 161 181 break; 162 182 } … … 205 225 } 206 226 227 void appendStretch(int type, const string& content, string& stretches) 228 { 229 struct stretchHeader stretch; 230 stretch.type=type; 231 stretch.size=htons(content.size()); 232 233 char *p=(char*) &stretch; 234 stretches+=string(p, p + sizeof(stretch)); 235 stretches+=content; 236 } 237 207 238 void outputChecksum(int outputfd, const MD5Summer& md5) 208 239 { 209 struct stretchHeader stretch; 210 string md5sum=md5.get(); 211 stretch.size=htons(md5sum.length()); 212 stretch.type=stretchHeader::MD5Checksum; 213 214 int ret=writen(outputfd, &stretch, sizeof(stretch),"write of meta-data to output command"); 240 string stretches; 241 appendStretch(stretchHeader::MD5Checksum, md5.get(), stretches); 242 243 int ret=writen(outputfd, stretches.c_str(), stretches.length(), "write of meta-data to output command"); 215 244 216 245 if(!ret) 217 246 outputGaveEof(outputfd); 218 219 ret=writen(outputfd, md5sum.c_str(), md5sum.length(), "write of meta-data to output command"); 220 247 } 248 249 string g_uuid; 250 251 int outputPerVolumeStretches(int fd, uint16_t volumeNumber) 252 { 253 string stretches; 254 255 appendStretch(stretchHeader::SessionUUID, g_uuid, stretches); 256 257 volumeNumber = htons(volumeNumber); 258 const string volNumString((char*)&volumeNumber, ((char*)&volumeNumber) + 2); 259 260 appendStretch(stretchHeader::VolumeNumber,volNumString, stretches); 261 262 int ret=writen(fd, stretches.c_str(), stretches.length(), "write of per-volume meta-data to output command"); 263 221 264 if(!ret) 222 outputGaveEof(outputfd);223 }224 225 string g_uuid;226 227 int outputPerVolumeStretches(int fd, uint16_t volumeNumber)228 {229 struct stretchHeader stretch;230 stretch.type=stretchHeader::SessionUUID;231 stretch.size=htons(g_uuid.length());232 233 if(!writen(fd, &stretch, sizeof(stretch), "write of Session UUID"))234 265 outputGaveEof(fd); 235 266 236 if(!writen(fd, g_uuid.c_str(), g_uuid.length(), "write of Session UUID")) 237 outputGaveEof(fd); 238 239 stretch.type=stretchHeader::VolumeNumber; 240 stretch.size=htons(2); 241 242 volumeNumber = htons(volumeNumber); 243 if(!writen(fd, &stretch, sizeof(stretch), "write of volume number")) 244 outputGaveEof(fd); 245 246 if(!writen(fd, &volumeNumber, 2, "write of volume number")) 247 outputGaveEof(fd); 248 249 250 return 2 * sizeof(stretch) + g_uuid.length() + 2; 267 return stretches.length(); 251 268 } 252 269 … … 255 272 try 256 273 { 257 parameters.debug=parameters.verbose=false;258 274 parameters.bufferSize=1000000; 259 275 parameters.volumeSize=getSize("DVD-5"); … … 324 340 else { 325 341 cerr<<"splitpipe: reload media, if necessary, and press enter to continue"<<endl; 326 waitForUser(); 342 if(!parameters.noPrompt) 343 waitForUser(); 327 344 } 328 345