1 /* ldc2 preliminary main program */
12 #include "tape_block.hh"
13 #include "configuration_manager.hh"
17 int dump_vector(vector
<string
> arguments
){
19 for (vector
<string
>::iterator iter
=arguments
.begin();iter
<arguments
.end();iter
++){
20 printf("%s\n",(*iter
).c_str());
28 int main(int argc
, char ** args
){
30 /* Configuration data */
32 string infile
, outfile
;
33 int infile_set
, outfile_set
, config_file_set
;
42 split_objects_numbered
,
44 ignore_checksum_errors
,
45 pause_on_checksum_error
,
46 ignore_unknown_block_errors
,
47 ignore_object_integrity_errors
;
51 in_fd
=0; /* stdin {O _ \ */
52 out_fd
=1; /* stdout {O ^ / */
54 configuration_manager
ar("ldc2");
56 /* Here come the configuration switches */
57 ar
.add_option_switch("h","help",
58 "Output this help text and exit.",
61 ar
.add_option_switch("a","output_info",
62 "Print tape data information (default)",
65 ar
.add_option_switch("c","output_called",
66 "Print all called symbols from the object(s).",
69 ar
.add_option_switch("e","output_exported",
70 "Print all exported symbols from the object(s).",
73 ar
.add_option_switch("u","output_unsatisfied",
74 "List all unsatisfied symbols.",
77 ar
.add_option_switch("s","split_objects",
78 "Split input data into distinct object files.",
81 ar
.add_option_switch("S","split_objects_numbered",
82 "Split input data into distinct numbered files",
83 &split_objects_numbered
);
85 ar
.add_option_switch("b","ignore_block_errors",
86 "Ignore block integrity errors. This will output broken blocks,too",
87 &ignore_block_errors
);
89 ar
.add_option_switch("k","ignore_checksum_errors",
90 "Ignore block checksum errors. Errors will be converted to warnings.",
91 &ignore_checksum_errors
);
93 ar
.add_option_switch("p","pause_on_checksum_error",
94 "Wait for user input on checksum error.",
95 &pause_on_checksum_error
);
97 ar
.add_option_switch("n","ignore_unknown_block_errors",
98 "Ignore errors caused by unknown block types. Errors will be converted to warnings.",
99 &ignore_unknown_block_errors
);
101 ar
.add_option_switch("g","ignore_object_integrity_errors",
102 "Ignore errors caused by objects without proper end block. \
103 Errors will be converted to warnings.",
104 &ignore_object_integrity_errors
);
106 ar
.add_option_value("i","input_file",
107 "specify input file",
111 ar
.add_option_value("o","output_file",
112 "Specify output file.",
113 &outfile_set
,&outfile
,
117 ar
.add_argument("File from where data is read",
121 ar
.add_argument("File to where output is redirected",
122 &outfile_set
,&outfile
,
125 ar
.add_option_value("F","config_file",
126 "Use the specified configuration file.",
127 &config_file_set
,&config_file
,
130 if((dump_vector(ar
.read_args(argc
,args
))||do_help
)){
131 dump_vector(ar
.get_help());
136 printf("Opening file for input:%s\n",infile
.c_str());
137 in_fd
=open(infile
.c_str(),O_RDONLY
);
139 printf("Error: could not open file:%s\n",infile
.c_str());
147 vector
<tape_block
*> tape
;
150 tape_block
* block
=0;
152 block
=tape_block::gen_from_fd(in_fd
);
153 if (block
->get_state()==tape_block::TBS_OK
){
154 tape
.insert(tape
.end(),block
);
155 dump_vector(block
->get_description());
160 switch(block
->get_state()){
161 case tape_block::TBS_EOF_LEGAL
: printf("File successfully read.\n");
163 case tape_block::TBS_EOF_ILLEGAL
: printf("EOF while in block!\n");
165 case tape_block::TBS_CHECKSUM
:
166 printf("Checksum error!\n");
168 case tape_block::TBS_DEFAULT
:
169 printf("TBS_DEFAULT encountered ->> SEVERY INTERNAL ERROR!\n");
171 case tape_block::TBS_IOERR
:
172 printf("I/O Error... Why?\n");