Changeset 18038

Show
Ignore:
Timestamp:
03.12.2008 14:13:06 (11 years ago)
Author:
mdewsnip
Message:

Code modifications to allow the GDBM library to read both little-endian and big-endian GDBM files, thus hopefully removing all the nasty endianness problems Greenstone has had with collections built on different architectures. By Michael Dewsnip at DL Consulting Ltd.

Location:
gsdl/trunk/common-src/packages/gdbm/gdbm-1.8.3
Files:
2 added
3 modified

Legend:

Unmodified
Added
Removed
  • gsdl/trunk/common-src/packages/gdbm/gdbm-1.8.3/Makefile.in

    r18020 r18038  
    6868    gdbmreorg.c gdbmseq.c gdbmsync.c gdbmerrno.c gdbmexists.c gdbmfdesc.c \ 
    6969    gdbmsetopt.c bucket.c falloc.c findkey.c global.c hash.c update.c \ 
    70     version.c 
     70    version.c gsdlmods.c 
    7171 
    7272TEST_CF = testdbm.c testndbm.c testgdbm.c 
     
    8181    gdbmreorg.o gdbmseq.o gdbmsync.o gdbmerrno.o gdbmexists.o gdbmfdesc.o \ 
    8282    gdbmsetopt.o bucket.o falloc.o findkey.o global.o hash.o update.o \ 
    83     version.o 
     83    version.o gsdlmods.o 
    8484 
    8585DBM_LOF = dbminit.lo delete.lo fetch.lo store.lo seq.lo close.lo 
     
    9191    gdbmreorg.lo gdbmseq.lo gdbmsync.lo gdbmerrno.lo gdbmexists.lo \ 
    9292    gdbmfdesc.lo gdbmsetopt.lo bucket.lo falloc.lo findkey.lo global.lo \ 
    93     hash.lo update.lo version.lo 
     93    hash.lo update.lo version.lo gsdlmods.lo 
    9494 
    9595TEX_F = gdbm.aux gdbm.cp gdbm.dvi gdbm.fn gdbm.ky gdbm.log gdbm.pg \ 
  • gsdl/trunk/common-src/packages/gdbm/gdbm-1.8.3/bucket.c

    r18019 r18038  
    3232 
    3333#include "gdbmdefs.h" 
     34 
     35#include "gsdlmods.h" 
    3436 
    3537 
     
    115117      if (num_bytes != dbf->header->bucket_size) 
    116118    _gdbm_fatal (dbf, "read error"); 
     119 
     120      // GREENSTONE CUSTOMISATION: Swap each value in the bucket if the GDBM file is the wrong endianness 
     121      if (wrong_endianness) 
     122      { 
     123    endian_swap_array((int*) dbf->bucket, dbf->header->bucket_size); 
     124      } 
    117125    } 
    118126 
  • gsdl/trunk/common-src/packages/gdbm/gdbm-1.8.3/gdbmopen.c

    r18019 r18038  
    3333#include "gdbmdefs.h" 
    3434#include "gdbmerrno.h" 
     35 
     36#include "gsdlmods.h" 
     37 
    3538 
    3639/* Initialize dbm system.  FILE is a pointer to the file name.  If the file 
     
    330333    } 
    331334 
     335      // GREENSTONE CUSTOMISATION: Check if the magic number is reversed 
     336      // If it is then the GDBM file is the wrong endianness for the current machine 
     337      wrong_endianness = (partial_header.header_magic == 0xCE9A5713); 
     338 
     339      // GREENSTONE CUSTOMISATION: Swap each value in the partial header if the GDBM file is the wrong endianness 
     340      if (wrong_endianness) 
     341      { 
     342    endian_swap_array((int*) &partial_header, sizeof (gdbm_file_header)); 
     343      } 
     344 
    332345      /* Is the magic number good? */ 
    333346      if (partial_header.header_magic != 0x13579ace) 
     
    349362      num_bytes = read (dbf->desc, &dbf->header->avail.av_table[1], 
    350363            dbf->header->block_size-sizeof (gdbm_file_header)); 
     364 
     365      // GREENSTONE CUSTOMISATION: Swap each value in the header if the GDBM file is the wrong endianness 
     366      if (wrong_endianness) 
     367      { 
     368    endian_swap_array((int*) &dbf->header->avail.av_table[1], 
     369              dbf->header->block_size-sizeof(gdbm_file_header)); 
     370      } 
     371 
    351372      if (num_bytes != dbf->header->block_size-sizeof (gdbm_file_header)) 
    352373    { 
     
    382403    } 
    383404 
     405      // GREENSTONE CUSTOMISATION: Swap each value in the directory if the GDBM file is the wrong endianness 
     406      if (wrong_endianness) 
     407      { 
     408    endian_swap_array((int*) dbf->dir, dbf->header->dir_size); 
     409      } 
    384410    } 
    385411