X-Git-Url: http://dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=cmd%2Fdbimport.pl;fp=cmd%2Fdbimport.pl;h=55d5e6322c00c4975e7387f90f2ca02e89781049;hb=9e2fbafcfdab1ee45e581524311f1a97ac41f6ad;hp=0000000000000000000000000000000000000000;hpb=6ab5f0300e614249c24916600817ae221a6bdc8c;p=spider.git diff --git a/cmd/dbimport.pl b/cmd/dbimport.pl new file mode 100644 index 00000000..55d5e632 --- /dev/null +++ b/cmd/dbimport.pl @@ -0,0 +1,50 @@ +#!/usr/bin/perl +# +# Database update routine +# +# Copyright (c) 1999 Dirk Koopman G1TLH +# +my ($self, $line) = @_; +my ($name, $fn) = split /\s+/, $line; +my @out; + +return (1, $self->msg('e5')) if $self->priv < 9; + +my $db = DXDb::getdesc($name); +return (1, $self->msg('db3', $name)) unless $db; +return (1, $self->msg('db1', $db->remote )) if $db->remote; +return (1, $self->msg('e3', 'dbimport', $fn)) unless -e $fn; + +my $state = 0; +my $key; +my $value; +my $count; + +open(IMP, $fn) or return (1, "Cannot open $fn $!"); +while () { + chomp; + s/\r//g; + if ($state == 0) { + if (/^\&\&/) { + $state = 0; + next; + } + $key = uc $_; + $value = undef; + ++$state; + } elsif ($state == 1) { + if (/^\&\&/) { + if ($key =~ /^#/) { + } + $db->putkey($key, $value); + $state = 0; + $count++; + next; + } + $value .= $_ . "\n"; + } +} +close (IMP); + +push @out, $self->msg('db10', $count, $db->name); +return (1, @out);