Ignore:
Timestamp:
2008-05-26T16:47:17+12:00 (16 years ago)
Author:
mdewsnip
Message:

Merged the one lonely function in unbuildutil into dbutil, as it is GDBM-specific.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gsdl/trunk/perllib/dbutil.pm

    r15699 r15705  
    2929
    3030
     31sub read_infodb_file
     32{
     33    my $infodb_file_path = shift(@_);
     34    my $infodb_map = shift(@_);
     35
     36    &read_infodb_file_gdbm($infodb_file_path, $infodb_map);
     37}
     38
     39
    3140sub write_infodb_entry
    3241{
     
    3645
    3746    &write_infodb_entry_gdbm($infodb_handle, $infodb_key, $infodb_map);
     47}
     48
     49
     50
     51# ----------------------------------------------------------------------------------------
     52#   GDBM FUNCTIONS
     53# ----------------------------------------------------------------------------------------
     54
     55sub read_infodb_file_gdbm
     56{
     57    my $infodb_file_path = shift(@_);
     58    my $infodb_map = shift(@_);
     59
     60    open (PIPEIN, "db2txt \"$infodb_file_path\" |") || die "couldn't open pipe from db2txt\n";
     61    my $infodb_line = "";
     62    my $infodb_key = "";
     63    my $infodb_value = "";
     64    while (defined ($infodb_line = <PIPEIN>))
     65    {
     66    if ($infodb_line =~ /^\[([^\]]+)\]$/)
     67    {
     68        $infodb_key = $1;
     69    }
     70    elsif ($infodb_line =~ /^-{70}$/)
     71    {
     72        $infodb_map->{$infodb_key} = $infodb_value;
     73        $infodb_key = "";
     74        $infodb_value = "";
     75    }
     76    else
     77    {
     78        $infodb_value .= $infodb_line;
     79    }
     80    }
     81
     82    close (PIPEIN);
    3883}
    3984
Note: See TracChangeset for help on using the changeset viewer.