1 require "newgetopt.pl";
4 print DEBUG "FHOUT 6: ARGV[0]=" . $ARGV[0] . "\n" if ($debug == 1);
5 print DEBUG "FHOUT 6: ARGV[1]=" . $ARGV[1] . "\n" if ($debug == 1);
6 print DEBUG "FHOUT 6: ARGV[2]=" . $ARGV[2] . "\n" if ($debug == 1);
7 print DEBUG "FHOUT 6: ARGV[3]=" . $ARGV[3] . "\n" if ($debug == 1);
8 print DEBUG "FHOUT 6: ARGV[4]=" . $ARGV[4] . "\n" if ($debug == 1);
9 print DEBUG "FHOUT 6: ARGV[5]=" . $ARGV[5] . "\n" if ($debug == 1);
10 print DEBUG "FHOUT 6: ARGV[6]=" . $ARGV[6] . "\n" if ($debug == 1);
11 print DEBUG "FHOUT 6: ARGV[7]=" . $ARGV[7] . "\n" if ($debug == 1);
12 print DEBUG "FHOUT 6: ARGV[8]=" . $ARGV[8] . "\n" if ($debug == 1);
13 print DEBUG "FHOUT 6: ARGV[9]=" . $ARGV[9] . "\n" if ($debug == 1);
15 $result = &NGetOpt ("config=s", "host=s", "disk=s", "device=s", "level=s", "index=s", "message=s", "collection", "record");
18 print DEBUG "FHOUT 6: config =" . $opt_config . "\n" if ($debug == 1);
19 print DEBUG "FHOUT 6: disk =" . $opt_disk . "\n" if ($debug == 1);
20 print DEBUG "FHOUT 6: host =" . $opt_host . "\n" if ($debug == 1);
21 print DEBUG "FHOUT 6: device =" . $opt_device . "\n" if ($debug == 1);
22 print DEBUG "FHOUT 6: level =" . $opt_level . "\n" if ($debug == 1);
23 print DEBUG "FHOUT 6: index =" . $opt_index . "\n" if ($debug == 1);
24 print DEBUG "FHOUT 6: message =" . $opt_message. "\n" if ($debug == 1);
25 print DEBUG "FHOUT 6: collection=" . $opt_collection. "\n" if ($debug == 1);
26 print DEBUG "FHOUT 6: record =" . $opt_record . "\n" if ($debug == 1);
28 print DEBUG "FHOUT 6: A-ARGV[0]=" . $ARGV[0] . "\n" if ($debug == 1);
29 print DEBUG "FHOUT 6: A-ARGV[1]=" . $ARGV[1] . "\n" if ($debug == 1);
30 print DEBUG "FHOUT 6: A-ARGV[2]=" . $ARGV[2] . "\n" if ($debug == 1);
31 print DEBUG "FHOUT 6: A-ARGV[3]=" . $ARGV[3] . "\n" if ($debug == 1);
32 print DEBUG "FHOUT 6: A-ARGV[4]=" . $ARGV[4] . "\n" if ($debug == 1);
33 print DEBUG "FHOUT 6: A-ARGV[5]=" . $ARGV[5] . "\n" if ($debug == 1);
34 print DEBUG "FHOUT 6: A-ARGV[6]=" . $ARGV[6] . "\n" if ($debug == 1);
36 if (defined $opt_config) {
37 $opt_config =~ /^([\_\.A-Za-z0-9]*)$/;
41 if (defined $opt_host) {
42 $opt_host =~ /^([\_\.A-Za-z0-9]*)$/;
46 if (defined $opt_disk) {
47 $opt_disk =~ /^([\/\_\:\.A-Za-z0-9]*)$/;
51 if (defined $opt_device) {
52 $opt_device =~ /^([\/\_\:\.A-Za-z0-9]*)$/;
56 if (defined $opt_level) {
57 $opt_level =~ /^(\d)$/;
66 while($property_line = <STDIN>) {
68 ($prop_name, $prop_value) = shellwords($property_line);
69 push @{$property{$prop_name}}, $prop_value;
70 print DEBUG "$prop_name = $prop_value\n" if ($debug == 1);
74 foreach $prop_name (keys(%property)) {
75 print DEBUG "PROPERTY: $prop_name\n";
76 print DEBUG " VALUE: ", join(',',@{$property{$prop_name}}) , "\n";
80 sub wrapper_support();
81 sub wrapper_selfcheck();
82 sub wrapper_estimate();
84 sub wrapper_restore();
86 if ($command eq "support") {
89 elsif ($command eq "selfcheck") {
92 elsif ($command eq "estimate") {
95 elsif ($command eq "backup") {
98 elsif ($command eq "restore") {
102 printf STDERR "Unknown command `$command'.\n";
107 sub wrapper_support() {
108 if(defined(&command_support)) {
109 command_support($opt_config, $opt_host, $opt_disk, $opt_device, $opt_level);
112 print "LEVEL 0-", $max_level , "\n" if defined($max_level);
113 print "INDEX-LINE YES\n" if defined($index_line) && $index_line == 1;
114 print "INDEX-XML NO\n" if defined($index_xml) && $index_xml == 1;
115 print "MESSAGE-LINE YES\n" if defined($message_line) && $message_line == 1;
116 print "MESSAGE-XML NO\n" if defined($message_xml) && $message_xml == 1;
117 print "RECORD YES\n" if defined($record) && $record == 1;
118 print "INCLUDE-FILE NO\n" if defined($include_file) && $include_file == 1;
119 print "INCLUDE-LIST NO\n" if defined($include_list) && $include_list == 1;
120 print "EXCLUDE-FILE NO\n" if defined($exclude_file) && $exclude_file == 1;
121 print "EXCLUDE-LIST NO\n" if defined($exclude_list) && $exclude_list == 1;
122 print "COLLECTION NO\n" if defined($collection) && $collection == 1;
126 sub wrapper_selfcheck() {
127 if(defined(&command_selfcheck)) {
128 command_selfcheck($opt_config, $opt_host, $opt_disk, $opt_device, $opt_level);
135 sub wrapper_estimate() {
136 if(defined(&command_estimate)) {
137 command_estimate($opt_config, $opt_host, $opt_disk, $opt_device, $opt_level);
143 sub wrapper_estimate_parse() {
144 if(defined(&command_estimate_parse)) {
145 command_estimate_parse($opt_config, $opt_host, $opt_disk, $opt_device, $opt_level);
148 printf STDERR "`estimate-parse' is not supported.\n";
153 sub wrapper_backup() {
154 if(defined(&command_backup)) {
155 command_backup($opt_config, $opt_host, $opt_disk, $opt_device, $opt_level);
157 print DEBUG "wrapper_backup: !defined(command_backup)\n" if ($debug == 1);
162 sub wrapper_backup_parse() {
163 if(defined(&command_backup_parse)) {
164 command_backup_parse($opt_config, $opt_host, $opt_disk, $opt_device, $opt_level);
167 printf STDERR "`backup-parse' is not supported.\n";
172 sub wrapper_index_from_output() {
173 if(defined(&command_index_from_output)) {
174 command_index_from_output($opt_config, $opt_host, $opt_disk, $opt_device, $opt_level);
177 printf STDERR "`index-from-output' is not supported.\n";
182 sub wrapper_index_from_image() {
183 if(defined(&command_index_from_image)) {
184 command_index_from_image($opt_config, $opt_host, $opt_disk, $opt_device, $opt_level);
187 printf STDERR "command `index-from-image' is not supported.\n";
192 sub wrapper_restore() {
193 if(defined(&command_restore)) {
194 command_restore($opt_config, $opt_host, $opt_disk, $opt_device, $opt_level);
197 printf STDERR "`restore' is not supported.\n";
202 sub parse_options() {
204 my($options, @options, $option, $name, $option_name, $value);
206 while($no_option <= $#ARGV) {
207 $options = $ARGV[${no_option}];
208 @options = split (/;/,$options);
209 foreach $option (@options) {
210 if( $option =~ /=/ ) {
211 ($name,$value) = split(/=/,$option);
217 $option_name = "option_$name";
218 $option_name =~ s/\-/\_/g;
219 $$option_name = $value;
226 my($filename, $mode) = @_;
232 print "OK $filename exists\n";
235 print "ERROR [can not find $filename]\n";
238 elsif($mode eq "x") {
240 print "OK $filename executable\n";
243 print "ERROR [can not execute $filename]\n";
246 elsif($mode eq "r") {
248 print "OK $filename readable\n";
251 print "ERROR [can not read $filename]\n";
254 elsif($mode eq "w") {
256 print "OK $filename writable\n";
259 print "ERROR [can not write $filename]\n";
263 print "ERROR [check_file: unknow mode $mode]\n";