X-Git-Url: http://gitweb.hachti.de/?a=blobdiff_plain;f=pc-tools%2Fldc2%2Fsrc%2Fmain.cpp;h=3e1244b19e98690c7456d1682e49238ebf4321bb;hb=b90c2253e383a435bb80072559b6f5bc3c5929ac;hp=f8274103d6d8db868da086181623cc8d94043dd3;hpb=798b0c1d967a7d8ac3c7a867d41bfa7b8e824048;p=h316.git diff --git a/pc-tools/ldc2/src/main.cpp b/pc-tools/ldc2/src/main.cpp index f827410..3e1244b 100644 --- a/pc-tools/ldc2/src/main.cpp +++ b/pc-tools/ldc2/src/main.cpp @@ -5,61 +5,93 @@ #include #include +#include +#include +#include #include "tape_block.hh" -#include "data_block.hh" - -#include "argread.hh" +#include "argument_reader.hh" using namespace std; -void tape_start(void* m){ - printf("tape_start\n"); -} - -void tape_stop(void* m){ - printf("tape_stop\n"); +int dump_vector(vector arguments){ + int res=0; + for (vector::iterator iter=arguments.begin();iter","File from where data is read",&infile_set,&infile); + ar.add_argument("","File to where output is redirected",&outfile_set,&outfile); + + + if((dump_vector(ar.read_args(argc,args))||help_wanted)){ + dump_vector(ar.get_help()); + exit(1); + } + if(greet_want)printf("Hallo!\n"); + + if (infile_set==1){ + printf("Opening file for input:%s\n",infile.c_str()); + in_fd=open(infile.c_str(),O_RDONLY); + if (in_fd<0){ + printf("Error: could not open file:%s\n",infile.c_str()); + exit (3); + } + } + + vector tape; + + + tape_block * block=0; + while(1){ + block=tape_block::gen_from_fd(in_fd); + if (block->get_state()==tape_block::TBS_OK){ + tape.insert(tape.end(),block); + dump_vector(block->get_description()); + } + else break; + } -void dump_vector(vector arguments){ - for (vector::iterator iter=arguments.begin();iterget_state()){ + case tape_block::TBS_EOF_LEGAL: printf("File successfully read.\n"); + break; + case tape_block::TBS_EOF_ILLEGAL: printf("EOF while in block!\n"); + break; + case tape_block::TBS_CHECKSUM: + printf("Checksum error!\n"); + break; + case tape_block::TBS_DEFAULT: + printf("TBS_DEFAULT encountered ->> SEVERY INTERNAL ERROR!\n"); + exit(88); + case tape_block::TBS_IOERR: + printf("I/O Error... Why?\n"); + exit (43); } -} -int main(int argc, char ** args){ - int help_needed; - int name_set; - int file_set; - string name="Philipp"; - string filename; - - argreader ar("ldc2"); - ar.add_param("n","name=","Enter other name",&name_set,&name,""); - ar.add_param("h","help","Give help",&help_needed); - ar.add_free_param("","File to read data from",&file_set,&filename); - - - - dump_vector(ar.read_args(argc,args)); - - if (help_needed==1) dump_vector(ar.get_help()); - - printf("Hallo %s!\n",name.c_str()); - exit(0); - tape_block * myblock=0; - do{ - if (myblock) delete myblock; - myblock=tape_block::gen_from_fd(0); - - vector desc=myblock->get_description(); - for (vector::iterator iter=desc.begin(); - iter!=desc.end();iter++) - printf("%s\n",(*iter).c_str()); - } while (myblock->get_state()==tape_block::TBS_OK); - return 0; -} + return 0; +} // main()