Ignore:
Timestamp:
2008-12-03T14:13:06+13:00 (15 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.