Changeset 373

Show
Ignore:
Timestamp:
04/17/05 13:10:33 (8 years ago)
Author:
ahu
Message:

implement --no-prompt for unattended usage, mostly useful for running
automated tests.

remove --verify from splitpipe

Location:
trunk/splitpipe
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/splitpipe/Makefile

    r368 r373  
    22OUTPUTDIR=splitpipe-$(VERSION) 
    33CXXFLAGS=-Wall -g -O2 -DVERSION=\"$(VERSION)\" 
     4PREFIX?=/usr/local/ 
     5BINDIR?=$(DESTDIR)/$(PREFIX)/bin/ 
     6 
    47 
    58all: splitpipe joinpipe 
     
    4043 
    4144install: 
    42         install -s splitpipe $(DESTDIR)/usr/local/bin 
    43         install -s joinpipe $(DESTDIR)/usr/local/bin 
     45        install -s splitpipe $(BINDIR) 
     46        install -s joinpipe $(BINDIR) 
  • trunk/splitpipe/TODO

    r370 r373  
    1212        - take out getopt_long stuff, it is somewhat ugly 
    1313 
    14         - make buildStretch, which appends stretches to a string 
     14DONE!   - make buildStretch, which appends stretches to a string 
    1515 
    1616DONE!   - teach writen about EAGAIN 
     
    2323 
    2424        - add "name" chunk stretch 
     25 
     26        - manpages 
     27 
     28        - i18n 
     29 
  • trunk/splitpipe/joinpipe.cc

    r371 r373  
    3535using namespace std; 
    3636 
    37 struct params 
    38 { 
    39   params() 
     37namespace { 
     38  struct params 
    4039  { 
    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} 
    4952 
    5053void usage() 
     
    5457  cerr<<" --debug, -d\t\tGive debugging output\n"; 
    5558  cerr<<" --help, -h\t\tGive this helpful message\n"; 
     59  cerr<<" --no-prompt, -h\tRun without user intervention\n"; 
    5660  cerr<<" --verbose, -v\t\tGive verbose output\n"; 
    57   cerr<<" --verify, -t\t\tOnly verify an archive\n"; 
    5861  cerr<<" --version\t\tReport version\n\n"; 
    5962   
     
    7174      {"help", 0, 0, 'h'}, 
    7275      {"verbose", 0, 0, 'v'}, 
    73       {"verify", 0, 0, 't'}, 
     76      {"no-prompt", 0, 0, 'n'}, 
    7477      {"version", 0, 0, 'e'}, 
    7578      {0, 0, 0, 0} 
    7679    }; 
    7780     
    78     c = getopt_long (argc, argv, "dhv", 
     81    c = getopt_long (argc, argv, "dhnv", 
    7982                     long_options, &option_index); 
    8083    if (c == -1) 
     
    8689      break; 
    8790    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; 
    8992      exit(EXIT_SUCCESS); 
    9093    case 'h': 
    9194      usage(); 
    9295      break; 
    93     case 't': 
    94       parameters.verify=1; 
     96 
     97    case 'n': 
     98      parameters.noPrompt=1; 
     99      break; 
     100 
    95101    case 'v': 
    96102      parameters.verbose=true; 
     103      break; 
     104    case '?': 
     105      usage(); 
    97106      break; 
    98107    } 
     
    173182      cerr<<"joinpipe: end of volume, change media and press enter"<<endl; 
    174183 
    175       waitForUser(); 
     184      if(!parameters.noPrompt) 
     185        waitForUser(); 
    176186 
    177187      if(inputIter + 1 != parameters.inputDevice.end()) 
  • trunk/splitpipe/splitpipe.cc

    r371 r373  
    3232#include "md5.hh" 
    3333 
    34 struct { 
    35   size_t bufferSize; 
    36   uint64_t volumeSize; 
    37   bool verbose; 
    38   bool debug; 
    39   string outputCommand; 
    40 } parameters; 
     34namespace { 
     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} 
    4151 
    4252 
     
    105115  cerr<<" --volume-size, -s\tSize of output volumes, in kilobytes. See below"<<endl; 
    106116  cerr<<" --help, -h\t\tGive this helpful message"<<endl; 
     117  cerr<<" --no-prompt, -h\tRun without user intervention\n"; 
    107118  cerr<<" --output, -o\t\tThe output script that will be spawned for each volume"<<endl; 
    108119  cerr<<" --verbose, -v\t\tGive verbose output\n"; 
     
    125136      {"buffer-size", 1, 0, 'b'}, 
    126137      {"volume-size", 1, 0, 's'}, 
     138      {"no-prompt", 0, 0, 'n'}, 
    127139      {"output", 1, 0, 'o'}, 
    128140      {"debug", 0, 0, 'd'}, 
     
    133145    }; 
    134146     
    135     c = getopt_long (argc, argv, "b:s:deho:v", 
     147    c = getopt_long (argc, argv, "b:ns:deho:v", 
    136148                     long_options, &option_index); 
    137149    if (c == -1) 
     
    149161      break; 
    150162    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; 
    152164      exit(EXIT_SUCCESS); 
    153165    case 'h': 
     
    157169      parameters.outputCommand=optarg; 
    158170      break; 
     171    case 'n': 
     172      parameters.noPrompt=1; 
     173      break; 
     174 
    159175    case 'v': 
    160176      parameters.verbose=true; 
     177      break; 
     178 
     179    case '?': 
     180      usage(); 
    161181      break; 
    162182    } 
     
    205225} 
    206226 
     227void 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 
    207238void outputChecksum(int outputfd, const MD5Summer& md5) 
    208239{ 
    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"); 
    215244   
    216245  if(!ret) 
    217246    outputGaveEof(outputfd); 
    218    
    219   ret=writen(outputfd, md5sum.c_str(), md5sum.length(), "write of meta-data to output command"); 
    220    
     247} 
     248 
     249string g_uuid; 
     250 
     251int 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 
    221264  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")) 
    234265    outputGaveEof(fd); 
    235266 
    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(); 
    251268} 
    252269 
     
    255272try 
    256273{ 
    257   parameters.debug=parameters.verbose=false; 
    258274  parameters.bufferSize=1000000; 
    259275  parameters.volumeSize=getSize("DVD-5"); 
     
    324340      else { 
    325341        cerr<<"splitpipe: reload media, if necessary, and press enter to continue"<<endl; 
    326         waitForUser(); 
     342        if(!parameters.noPrompt) 
     343          waitForUser(); 
    327344      } 
    328345