/[webpac]/trunk/all2xml.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/all2xml.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 98 by dpavlin, Sun Jul 13 22:29:14 2003 UTC revision 144 by dpavlin, Sun Nov 16 11:55:18 2003 UTC
# Line 160  sub data2xml { Line 160  sub data2xml {
160                                          }                                          }
161                                          if ($filter) {                                          if ($filter) {
162                                                  no strict 'refs';                                                  no strict 'refs';
163                                                  $display_data .= join($delimiter,&$filter($display));                                                  if ($display_data) {
164                                                            $display_data .= $delimiter.join($delimiter,&$filter($display));
165                                                    } else {
166                                                            $display_data = join($delimiter,&$filter($display));
167                                                    }
168                                          } else {                                          } else {
169                                                  if ($display_data) {                                                  if ($display_data) {
170                                                          $display_data .= $delimiter.$display;                                                          $display_data .= $delimiter.$display;
171                                                  } else {                                                  } else {
172                                                          $display_data .= $display;                                                          $display_data = $display;
173                                                  }                                                  }
174                                          }                                          }
175                                  }                                  }
# Line 181  sub data2xml { Line 185  sub data2xml {
185                          if (@index_data) {                          if (@index_data) {
186                                  if ($index_filter) {                                  if ($index_filter) {
187                                          no strict 'refs';                                          no strict 'refs';
188                                          foreach my $d (&$index_filter(@index_data)) {                                          foreach my $d (@index_data) {
189                                                  $index->insert($field, $d, $path);                                                  $index->insert($field, &$index_filter($d), $path);
190                                          }                                          }
191                                  } else {                                  } else {
192                                          foreach my $d (@index_data) {                                          foreach my $d (@index_data) {
# Line 294  print STDERR "reading ./import_xml/$type Line 298  print STDERR "reading ./import_xml/$type
298          # output current progress indicator          # output current progress indicator
299          my $last_p = 0;          my $last_p = 0;
300          sub progress {          sub progress {
301                  # XXX return if ($show_progress ne "");                  return if (! $show_progress);
302                  my $current = shift;                  my $current = shift;
303                  my $total = shift || 1;                  my $total = shift || 1;
304                  my $p = int($current * 100 / $total);                  my $p = int($current * 100 / $total);
# Line 306  print STDERR "reading ./import_xml/$type Line 310  print STDERR "reading ./import_xml/$type
310    
311          my $fake_dir = 1;          my $fake_dir = 1;
312          sub fakeprogress {          sub fakeprogress {
313                    return if (! $show_progress);
314                  my $current = shift @_;                  my $current = shift @_;
315    
316                  my @ind = ('-','\\','|','/','-','\\','|','/', '-');                  my @ind = ('-','\\','|','/','-','\\','|','/', '-');
# Line 327  print STDERR "using: $type...\n"; Line 332  print STDERR "using: $type...\n";
332                  $import2cp = Text::Iconv->new($config->{isis_codepage},$codepage);                  $import2cp = Text::Iconv->new($config->{isis_codepage},$codepage);
333                  my $db = OpenIsis::open( $isis_db );                  my $db = OpenIsis::open( $isis_db );
334    
335                    # check if .txt database for OpenIsis is zero length,
336                    # if so, erase it and re-open database
337                    sub check_txt_db {
338                            my $isis_db = shift || die "need isis database name";
339                            my $reopen = 0;
340    
341                            if (-e $isis_db.".TXT") {
342                                    print STDERR "WARNING: removing $isis_db.TXT OpenIsis database...\n";
343                                    unlink $isis_db.".TXT" || warn "FATAL: unlink error on '$isis_db.TXT': $!";
344                                    $reopen++;
345                            }
346                            if (-e $isis_db.".PTR") {
347                                    print STDERR "WARNING: removing $isis_db.PTR OpenIsis database...\n";
348                                    unlink $isis_db.".PTR" || warn "FATAL: unlink error on '$isis_db.PTR': $!";
349                                    $reopen++;
350                            }
351                            return OpenIsis::open( $isis_db ) if ($reopen);
352                    }
353    
354                    # EOF error
355                    if ($db == -1) {
356                            $db = check_txt_db($isis_db);
357                            if ($db == -1) {
358                                    print STDERR "FATAL: OpenIsis can't open zero size file $isis_db\n";
359                                    next;
360                            }
361                    }
362    
363                    # OpenIsis::ERR_BADF
364                    if ($db == -4) {
365                            print STDERR "FATAL: OpenIsis can't find file $isis_db\n";
366                            next;
367                    # OpenIsis::ERR_IO
368                    } elsif ($db == -5) {
369                            print STDERR "FATAL: OpenIsis can't access file $isis_db\n";
370                            next;
371                    } elsif ($db < 0) {
372                            print STDERR "FATAL: OpenIsis unknown error $db with file $isis_db\n";
373                            next;
374                    }
375    
376                  my $max_rowid = OpenIsis::maxRowid( $db );                  my $max_rowid = OpenIsis::maxRowid( $db );
377    
378                    # if 0 records, try to rease isis .txt database
379                    if ($max_rowid == 0) {
380                            # force removal of database
381                            $db = check_txt_db($isis_db);
382                            $max_rowid = OpenIsis::maxRowid( $db );
383                    }
384    
385                  print STDERR "Reading database: $isis_db [$max_rowid rows]\n";                  print STDERR "Reading database: $isis_db [$max_rowid rows]\n";
386    
387                  my $path = $database;                  my $path = $database;
# Line 350  print STDERR "using: $type...\n"; Line 403  print STDERR "using: $type...\n";
403                                  }                                  }
404                          }                          }
405                  }                  }
406                    # for this to work with current version of OpenIsis (0.9.0)
407                    # you might need my patch from
408                    # http://www.rot13.org/~dpavlin/projects/openisis-0.9.0-perl_close.diff
409                    OpenIsis::close($db);
410                  print STDERR "\n";                  print STDERR "\n";
411    
412          } elsif ($type_base eq "excel") {          } elsif ($type_base eq "excel") {

Legend:
Removed from v.98  
changed lines
  Added in v.144

  ViewVC Help
Powered by ViewVC 1.1.26