Changeset 34961 for main


Ignore:
Timestamp:
2021-03-10T19:04:01+13:00 (3 years ago)
Author:
anupama
Message:

Merging Dr Bainbridge's mg-long related updates for IsisGdl that got IsisGdl working on 64 bit linux, and on new Macs that were no longer backwards compatible with 32 bit. Tested only to compile and run (CDS-ISIS tutorial) on 64 bit linux. Merged version of code untested on Mac, though it was used to generate the static 64 bit Mac IsisGdl before. Also untested on 32 bit linux, but Dr Bainbridge had earlier indicated it was backwards. At present the release kit code is still grabbing the statically built IsisGdl (for 32 and nowadayas also 64 bit Mac/Linux) as before and including in binaries. This can be changed later. These code changes are for locally compiling up GS from SVN with an IsisGdl built on the local machine meant to work on that local machine.

Location:
main/trunk/greenstone2/build-src/packages/isis-gdl
Files:
1 added
24 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/build-src/packages/isis-gdl/AbstractIsisDb.h

    r6127 r34961  
    147147   virtual void  UpdateDbRecord(MfRecord &m) = 0;
    148148   
    149    virtual int   ReadDbRecord(long mfn, MfRecord &m) = 0;
     149   virtual int   ReadDbRecord(mg_s_long mfn, MfRecord &m) = 0;
    150150   virtual int   ReadNextDbRecord(MfRecord &m)       = 0;
    151151   
    152    virtual bool  DeleteRecord(long mfn)              = 0;
     152   virtual bool  DeleteRecord(mg_s_long mfn)              = 0;
    153153
    154154   virtual void  PrintDbRecord(MfRecord &m)          = 0;
    155155   virtual void  PrintDbHdr()                        = 0;
    156156
    157    virtual long GetNextMfn() = 0;
    158    virtual long GetNextActiveMfn(long mfn=-1) = 0;
     157   virtual mg_s_long GetNextMfn() = 0;
     158   virtual mg_s_long GetNextActiveMfn(mg_s_long mfn=-1) = 0;
    159159
    160160   virtual SMfHeader& GetSMfHeader() = 0;
  • main/trunk/greenstone2/build-src/packages/isis-gdl/BlkFile.h

    r6127 r34961  
    5555   virtual FileError Close();
    5656   virtual ~BlkFile();
    57    virtual void ReadBlk(void* d, long b);
    58    virtual void WriteBlk(void* d, long b);
     57   virtual void ReadBlk(void* d, mg_s_long b);
     58   virtual void WriteBlk(void* d, mg_s_long b);
    5959   virtual void ReadBlk(void* d);
    6060   virtual void WriteBlk(void* d);
     
    110110////////////////////////////////////////
    111111 
    112 inline void BlkFile::ReadBlk(void* d, long b)
     112inline void BlkFile::ReadBlk(void* d, mg_s_long b)
    113113// Reads block number b into d, b is in range [1:NBLOCK]
    114114{
     
    121121////////////////////////////////////////
    122122 
    123 inline void BlkFile::WriteBlk(void* d, long b)
     123inline void BlkFile::WriteBlk(void* d, mg_s_long b)
    124124// Writes blksize bytes from d at block number b
    125125{
     
    138138    ASSERT(d!=NULL);
    139139    //CFileBase::Fetch(d, blkSize_);
    140     long addr = CFileBase::FilePosition();
     140    mg_s_long addr = CFileBase::FilePosition();
    141141    cache_.Read(addr, d);
    142142}
     
    149149    ASSERT(d!=NULL);
    150150    //CFileBase::Store(d, blkSize_);
    151     long addr = CFileBase::FilePosition();
     151    mg_s_long addr = CFileBase::FilePosition();
    152152    cache_.Write(addr, d);
    153153}
  • main/trunk/greenstone2/build-src/packages/isis-gdl/CRC32.cpp

    r6189 r34961  
    3636// remainder 32-bit, which is the checksum.
    3737//
    38 // #include "stdafx.h"
     38#include "stdafx.h"
    3939#include <iomanip>
    4040#include "CRC32.h"
    4141#include "CRCTab.h"
    4242
    43 unsigned long CalcCRC32(const char *buf, unsigned len)
     43mg_u_long CalcCRC32(const char *buf, unsigned len)
    4444// Calculate a 32-bit CRC for a raw pattern of bytes.
    4545// Returns a 32-bit checksum.
    4646{
    47  unsigned long CRC=0xffffffffL;
     47 mg_u_long CRC=0xffffffffL;
    4848 unsigned int n = len;
    4949
     
    5454}
    5555
    56 unsigned long CalcCRC32(char *buf, unsigned len)
     56mg_u_long CalcCRC32(char *buf, unsigned len)
    5757// Calculate a 32-bit CRC for a raw pattern of bytes.
    5858// Returns a 32-bit checksum.
    5959{
    60  unsigned long CRC=0xffffffffL;
     60 mg_u_long CRC=0xffffffffL;
    6161 unsigned int n = len;
    6262 char *p = (char *)buf;
     
    6767}
    6868
    69 unsigned long CalcCRC32(unsigned char c, unsigned long CRC)
     69mg_u_long CalcCRC32(unsigned char c, mg_u_long CRC)
    7070// Calculate a 32-bit CRC table value for a single byte.
    7171// NOTE: The initial CRC value must be set to 0xffffffffL
     
    8080}
    8181
    82 unsigned long CalcCRC32(std::fstream &infile)
     82mg_u_long CalcCRC32(std::fstream &infile)
    8383// Calculate a 32-bit CRC for a file. Assumes the stream
    8484// is already open. Returns a 32-bit checksum.
    8585{
    86  unsigned long CRC=0xffffffffL;
     86 mg_u_long CRC=0xffffffffL;
    8787#ifdef _WIN32
    8888 char c;
     
    133133// and repeats for all eight bits of "q".
    134134{
    135   unsigned long c; // CRC shift register
    136   unsigned long e; // Polynomial exclusive-or pattern
     135  mg_u_long c; // CRC shift register
     136  mg_u_long e; // Polynomial exclusive-or pattern
    137137  int i;           // Counter for all possible eight bit values
    138138  int k;           // Byte being shifted into crc apparatus
  • main/trunk/greenstone2/build-src/packages/isis-gdl/CRC32.h

    r6127 r34961  
    4040#include <fstream>
    4141
    42 unsigned long CalcCRC32(char *buf, unsigned len);
    43 unsigned long CalcCRC32(const char *buf, unsigned len);
    44 unsigned long CalcCRC32(unsigned char c, unsigned long CRC);
    45 unsigned long CalcCRC32(std::fstream &infile);
     42mg_u_long CalcCRC32(char *buf, unsigned int len); // **** was just 'unsigned len'
     43mg_u_long CalcCRC32(const char *buf, unsigned int len); // ****  was just 'unsigned len'
     44mg_u_long CalcCRC32(unsigned char c, mg_u_long CRC);
     45mg_u_long CalcCRC32(std::fstream &infile);
    4646
    4747#ifdef __USE_CRC32_TABLE_FUNCTIONS__
  • main/trunk/greenstone2/build-src/packages/isis-gdl/CRCTab.h

    r6127 r34961  
    4343#define __CRC32_TABLE_HPP__
    4444
    45 const unsigned long crc32tab[256] = {
     45const mg_u_long crc32tab[256] = {
    4646  0x00000000U, 0x77073096U, 0xee0e612cU, 0x990951baU, 0x076dc419U,
    4747  0x706af48fU, 0xe963a535U, 0x9e6495a3U, 0x0edb8832U, 0x79dcb8a4U,
  • main/trunk/greenstone2/build-src/packages/isis-gdl/Checking.cpp

    r6127 r34961  
    4444void Checking::CheckMfHeader(const _TCHAR *mfname, SMfHeader &mfh)
    4545{
    46     long size = FileSystem::FileSize(mfname);
     46    mg_s_long size = FileSystem::FileSize(mfname);
    4747    TRACE(_T("\nsize=%ld "), size);
    48     long mfSize = mfh.nxtmfb_ * MFBLKSIZE;
     48    mg_s_long mfSize = mfh.nxtmfb_ * MFBLKSIZE;
    4949    //ASSERT(size == mfSize);
    5050    ASSERT(mfh.nxtmfp_>0 && mfh.nxtmfp_<=MFBLKSIZE);
     
    5858}
    5959
    60 void Checking::CheckMfRecordHeader(long addr)
     60void Checking::CheckMfRecordHeader(mg_s_long addr)
    6161{
    6262
  • main/trunk/greenstone2/build-src/packages/isis-gdl/Checking.h

    r6127 r34961  
    3030namespace Checking {
    3131   void CheckMfHeader(const _TCHAR *mfname, SMfHeader &mfh);
    32    void CheckMfRecordHeader(long addr);
     32   void CheckMfRecordHeader(mg_s_long addr);
    3333
    3434}
  • main/trunk/greenstone2/build-src/packages/isis-gdl/Compat.h

    r26668 r34961  
    3636#define BOOL   bool
    3737#define WORD   unsigned short
    38 #define DWORD  unsigned long
     38#define DWORD  mg_u_long
    3939#define INT32  int
    4040#define UINT32 unsigned int
    41 #define LONG   long int
     41#define LONG   mg_s_long
    4242#define TRUE   true
    4343#define FALSE  false
     
    121121}
    122122
    123 inline void fix_endianness(long int& x)
     123inline void fix_endianness(mg_s_long& x)
    124124{
    125125#if !defined(LITTLE_ENDIAN)
    126126  if (x < 0) {
    127     unsigned long ux = (unsigned long) x;
     127    mg_u_long ux = (mg_u_long) x;
    128128    x = (ux>>24) |
    129129      ((ux<<8) & 0x00FF0000) |
  • main/trunk/greenstone2/build-src/packages/isis-gdl/Fdt.cpp

    r26668 r34961  
    368368//////////////////////////////
    369369
    370 bool CFdt::Seek(long iRecord)
     370bool CFdt::Seek(mg_s_long iRecord)
    371371{
    372372
  • main/trunk/greenstone2/build-src/packages/isis-gdl/Fdt.h

    r26668 r34961  
    113113    std::vector<CFieldDef*> m_fieldArray;        // Array with fields
    114114
    115     long        m_iCurrentRecord;    // Current read record stored in
     115    mg_s_long        m_iCurrentRecord;    // Current read record stored in
    116116    CFdtEntry   m_fdtEntry;
    117117    bool        m_bReadOnly;
     
    162162    void SetAt(int i, CFdtEntry& e);
    163163
    164     bool Seek(long iRecord);
     164    bool Seek(mg_s_long iRecord);
    165165    void Flush();
    166166    bool GetValue(int n, std::string& result);
  • main/trunk/greenstone2/build-src/packages/isis-gdl/File.h

    r6127 r34961  
    3838
    3939// CRC-32 checksum used to detect bit errors
    40 typedef unsigned long Checksum;
     40typedef mg_u_long Checksum;
    4141
    4242
  • main/trunk/greenstone2/build-src/packages/isis-gdl/IsisDb.cpp

    r6127 r34961  
    150150 
    151151//----------------------------------------------------------------------------------
    152 // int  IsisDb::ReadDbRecord(long mfn, MfRecord &m)
     152// int  IsisDb::ReadDbRecord(mg_s_long mfn, MfRecord &m)
    153153//
    154154// This function reads Master File record with MFN "mfn" into m
     
    157157// Active=0, LogicalyDeleted=1, PhysicalyDeleted=2, EndOfFile=-1, NewRecord = 3
    158158//----------------------------------------------------------------------------------
    159 int  IsisDb::ReadDbRecord(long mfn, MfRecord &m)
    160 {
    161    long mfb;
     159int  IsisDb::ReadDbRecord(mg_s_long mfn, MfRecord &m)
     160{
     161   mg_s_long mfb;
    162162   int mfp;
    163163   int status;
     
    213213}
    214214//----------------------------------------------------------------------------------
    215 // int  IsisDb::DeleteRecord(long mfn)
     215// int  IsisDb::DeleteRecord(mg_s_long mfn)
    216216//
    217217// This function logically deletes a Master File record with MFN "mfn".
     
    220220// Returns true if successful
    221221//----------------------------------------------------------------------------------
    222 bool  IsisDb::DeleteRecord(long mfn)
     222bool  IsisDb::DeleteRecord(mg_s_long mfn)
    223223{
    224224
     
    226226}
    227227
    228 long  IsisDb::GetNextActiveMfn(long mfn /* = -1 */)
     228mg_s_long  IsisDb::GetNextActiveMfn(mg_s_long mfn /* = -1 */)
    229229{
    230230    if (mfn == -1)
     
    232232    else
    233233        mfn++;
    234     long  mfb;
     234    mg_s_long  mfb;
    235235    int  mfp;
    236236    int iRet = xf_->GetMfp(mfn, mfb, mfp);
  • main/trunk/greenstone2/build-src/packages/isis-gdl/IsisDb.h

    r6127 r34961  
    7979   void  CreateDbRecordWithMfn(MfRecord &m);
    8080   void  UpdateDbRecord(MfRecord &m);
    81    bool  DeleteRecord(long mfn);
    82    int   ReadDbRecord(long mfn, MfRecord &m);
     81   bool  DeleteRecord(mg_s_long mfn);
     82   int   ReadDbRecord(mg_s_long mfn, MfRecord &m);
    8383   int   ReadNextDbRecord(MfRecord &m);
    8484   void  PrintDbRecord(MfRecord &m);
    8585   void  PrintDbHdr();
    8686
    87    void SetNextMfn(long mfn) { mf_->setNextMfn(mfn); }
    88    long GetNextMfn()        { return mf_->GetNextMfn(); }
    89    long GetNextActiveMfn(long mfn=-1);
     87   void SetNextMfn(mg_s_long mfn) { mf_->setNextMfn(mfn); }
     88   mg_s_long GetNextMfn()        { return mf_->GetNextMfn(); }
     89   mg_s_long GetNextActiveMfn(mg_s_long mfn=-1);
    9090
    9191   SMfHeader& GetSMfHeader() { return mf_->GetSMfHeader(); }
  • main/trunk/greenstone2/build-src/packages/isis-gdl/IsisDef.h

    r26668 r34961  
    123123public:
    124124    int m_iError;
    125     CIsisDbException(const int iError, const char* file_name, const long line_number)
     125    CIsisDbException(const int iError, const char* file_name, const mg_s_long line_number)
    126126    {
    127127        m_iError = iError;
  • main/trunk/greenstone2/build-src/packages/isis-gdl/IsisGdl.cpp

    r12697 r34961  
    8383    // Extract the number of the next master file number to
    8484    // assign
    85     const long nextMfn = db.GetNextMfn();
     85    const mg_s_long nextMfn = db.GetNextMfn();
    8686
    8787
     
    8989    // Browse the master file in increasing order of Master
    9090    // file numbers (MFN is the record ID)
    91     for (long i=1; i<nextMfn; i++)
     91    for (mg_s_long i=1; i<nextMfn; i++)
    9292    {
    9393
  • main/trunk/greenstone2/build-src/packages/isis-gdl/IsisTypes.h

    r8752 r34961  
    4747typedef int             int32_t;   // Word size (4 bytes)
    4848typedef unsigned int    uint32_t;  // Unsigned word size (4 bytes)
    49 typedef long            long32_t;  // Long word (4 bytes)
    50 typedef unsigned long   ulong32_t; // Unsigned long word (4 bytes)
     49typedef mg_s_long       long32_t;  // Long word (4 bytes)
     50typedef mg_u_long       ulong32_t; // Unsigned long word (4 bytes)
    5151typedef short           int16_t;   // short word (2 bytes)
    5252typedef unsigned short  uint16_t;  // Unsigned short word (2 bytes)
     
    7575typedef int             int32_t;   // Word size (4 bytes)
    7676typedef unsigned int    uint32_t;  // Unsigned word size (4 bytes)
    77 typedef long            long32_t;  // Long word (4 bytes)
    78 typedef unsigned long   ulong32_t; // Unsigned long word (4 bytes)
     77typedef mg_s_long       long32_t;  // Long word (4 bytes)
     78typedef mg_u_long       ulong32_t; // Unsigned long word (4 bytes)
    7979typedef short           int16_t;   // short word (2 bytes)
    8080typedef unsigned short  uint16_t;  // Unsigned short word (2 bytes)
  • main/trunk/greenstone2/build-src/packages/isis-gdl/MFFile.cpp

    r12714 r34961  
    9494 
    9595//----------------------------------------------------------------------------------
    96 // void  MfFile::ReadMfRecord(long mfb, int mfp, MfRecord &m)
     96// void  MfFile::ReadMfRecord(mg_s_long mfb, int mfp, MfRecord &m)
    9797//
    9898// Reads the master file record beginning at address (mfb,mfp) into m
    9999//----------------------------------------------------------------------------------
    100 bool  MfFile::ReadMfRecord(long mfb, int mfp, MfRecord &m)
     100bool  MfFile::ReadMfRecord(mg_s_long mfb, int mfp, MfRecord &m)
    101101{
    102102    return m.Read(*this, mfb, mfp);
     
    104104
    105105//-------------------------------------------------------------------------------
    106 //  void WriteMfRecord(long mfb, int mfp, MfRecord &m)
     106//  void WriteMfRecord(mg_s_long mfb, int mfp, MfRecord &m)
    107107//
    108108//  Helper protected method, which writes the Master file record m at address
    109109//  (mfb, mfp)   mfb (1:MAXMFB),   mfp (0: MFBLKSIZE)
    110110//-------------------------------------------------------------------------------
    111 void  MfFile::WriteMfRecord(long mfb, int mfp, MfRecord &m)
     111void  MfFile::WriteMfRecord(mg_s_long mfb, int mfp, MfRecord &m)
    112112{
    113113    m.Write(*this, mfb, mfp);
     
    116116
    117117//--------------------------------------------------------------------------------
    118 // void CreateMfRecord(MfRecord &m, long &mfb, int &mfp)
     118// void CreateMfRecord(MfRecord &m, mg_s_long &mfb, int &mfp)
    119119//
    120120//  Create a new record. The MFN to be assigned is obtained from the field nxtmfn_
     
    124124//
    125125//--------------------------------------------------------------------------------
    126 void  MfFile::CreateMfRecord(MfRecord &m, long &mfb, int &mfp)
     126void  MfFile::CreateMfRecord(MfRecord &m, mg_s_long &mfb, int &mfp)
    127127{
    128128}
     
    133133
    134134//--------------------------------------------------------------------------------
    135 // void AddMfRecord(MfRecord &m, long &mfb, int &mfp)
     135// void AddMfRecord(MfRecord &m, mg_s_long &mfb, int &mfp)
    136136//
    137137// Add the record at the end of the master file, at the position indicated by
     
    139139// Return the address where the record was stored into mfb & mfp
    140140//--------------------------------------------------------------------------------
    141 void  MfFile::AddMfRecord(MfRecord &m, long &mfb, int &mfp)
    142 {
    143 }
    144  
    145  
    146 //--------------------------------------------------------------------------------
    147 // void UpdateMfRecord(MfRecord &m, long &mfb, int &mfp)
     141void  MfFile::AddMfRecord(MfRecord &m, mg_s_long &mfb, int &mfp)
     142{
     143}
     144 
     145 
     146//--------------------------------------------------------------------------------
     147// void UpdateMfRecord(MfRecord &m, mg_s_long &mfb, int &mfp)
    148148//
    149149// Update a Master file record.If possible, i.e. if the record length was not
     
    152152//
    153153//--------------------------------------------------------------------------------
    154 void  MfFile::UpdateMfRecord(MfRecord &m, long &mfb, int &mfp)
     154void  MfFile::UpdateMfRecord(MfRecord &m, mg_s_long &mfb, int &mfp)
    155155{
    156156}
     
    178178 
    179179//----------------------------------------------------------------------------------
    180 // void MfFile::ReadMfRecord(long daddr, MfRecord &m)
     180// void MfFile::ReadMfRecord(mg_s_long daddr, MfRecord &m)
    181181//
    182182// Reads a master file record into the master record object m.
    183183// Non blocked version
    184184//----------------------------------------------------------------------------------
    185 void MfFile::ReadMfRecord(long daddr, MfRecord &m)
     185void MfFile::ReadMfRecord(mg_s_long daddr, MfRecord &m)
    186186{
    187187    m.Clear();
     
    210210
    211211//---------------------------------------------------------------------------------
    212 // void  MfFile::WriteMfRecord(long daddr, MfRecord &m)
     212// void  MfFile::WriteMfRecord(mg_s_long daddr, MfRecord &m)
    213213//
    214214// Stores Master record object m to disk address daddr
    215215// Non blocked version
    216216//---------------------------------------------------------------------------------
    217 void  MfFile::WriteMfRecord(long daddr, MfRecord &m)
     217void  MfFile::WriteMfRecord(mg_s_long daddr, MfRecord &m)
    218218{
    219219}
  • main/trunk/greenstone2/build-src/packages/isis-gdl/MFFile.h

    r13518 r34961  
    4747struct SMfLockHeader
    4848{
    49     long lockProtect_; // Serialize access to the file lock members
    50     long readLock_;    // Shared (or read_only) file lock
    51     long writeLock_;   // Exclusive (or write-only) file lock
     49    mg_s_long lockProtect_; // Serialize access to the file lock members
     50    mg_s_long readLock_;    // Shared (or read_only) file lock
     51    mg_s_long writeLock_;   // Exclusive (or write-only) file lock
    5252
    5353    SMfLockHeader() : lockProtect_(0), readLock_(0), writeLock_(0)
     
    6666{
    6767private:
    68     long  m_mfb;
     68    mg_s_long  m_mfb;
    6969    short m_mfp;
    7070    char  m_status;
    7171public:
    7272    MfAddress() { m_status = 0x00; }
    73     MfAddress(long mfb, short mfp)
     73    MfAddress(mg_s_long mfb, short mfp)
    7474    { ASSERT(mfb>0); ASSERT(mfp>=0); m_mfb = mfb; m_mfp = mfp; m_status = 0x03; }
    7575
    76     long getMfb()          { ASSERT(m_status & 0x01); return m_mfb; }
     76    mg_s_long getMfb()          { ASSERT(m_status & 0x01); return m_mfb; }
    7777    short getMfp()         { ASSERT(m_status & 0x02); return m_mfp; }
    7878
    79     void setMfb(long mfb)  { ASSERT(mfb>0);  m_mfb = mfb; m_status |= 0x01; }
     79    void setMfb(mg_s_long mfb)  { ASSERT(mfb>0);  m_mfb = mfb; m_status |= 0x01; }
    8080    void setMfp(short mfp) { ASSERT(mfp>=0); m_mfp = mfp; m_status |= 0x02; }
    8181    bool isValid()         { return (m_status == 0x03); }
     
    126126protected:
    127127   SMfHeader mfh_;            // Header structure
    128    long nextaddr_;            // Address of next record
     128   mg_s_long nextaddr_;            // Address of next record
    129129   char buf_[MFBLKSIZE];      // Buffer to hold 1 Master File block
    130130   bool hdr_created_;         // True if 1st block exists
    131131   int  fileError_;
    132    long lastWrittenBlock_;
     132   mg_s_long lastWrittenBlock_;
    133133
    134134protected: 
    135    void WriteMfRecord(long mfb, int mfp, MfRecord &r);
     135   void WriteMfRecord(mg_s_long mfb, int mfp, MfRecord &r);
    136136   void AppendNewBlock();
    137137
    138138public:
    139    void setNextMfn(long mfn)       // Set MFN to be assigned to next record created
     139   void setNextMfn(mg_s_long mfn)       // Set MFN to be assigned to next record created
    140140   { mfh_.nxtmfn_ = mfn; }
    141141
    142142protected:
    143    void setNextMfb(long nxtmfb_)  // Set last block number allocated (1st is 1)
     143   void setNextMfb(mg_s_long nxtmfb_)  // Set last block number allocated (1st is 1)
    144144   { mfh_.nxtmfb_ = nxtmfb_; }
    145145   void setNextMfp(int nxtmfp_)   // Set offset to next available position in last block
     
    147147   int setm_mftype(int mftype_)     // Set type of master file (USERMST or MSGMST)
    148148   { mfh_.mftype_ = mftype_; }     
    149    virtual void ReadBlk(void* d, long b)  { BlkFile::ReadBlk(d, b);  }
    150    virtual void WriteBlk(void* d, long b) { BlkFile::WriteBlk(d, b); }
     149   virtual void ReadBlk(void* d, mg_s_long b)  { BlkFile::ReadBlk(d, b);  }
     150   virtual void WriteBlk(void* d, mg_s_long b) { BlkFile::WriteBlk(d, b); }
    151151   void ReadMfHdr(SMfHeader &h);
    152152   void ReadMfHdr();
    153153   void WriteMfHdr(SMfHeader &h);
    154154   void WriteMfHdr();
    155    void SetLastWrittenBlock(long b) { lastWrittenBlock_ = b; }
     155   void SetLastWrittenBlock(mg_s_long b) { lastWrittenBlock_ = b; }
    156156public:
    157157   MfFile();
     
    163163
    164164   // Accessors for the Master File Header
    165    long GetNextMfn()        // Get MFN to be assigned to next record created
     165   mg_s_long GetNextMfn()        // Get MFN to be assigned to next record created
    166166   { return mfh_.nxtmfn_; }
    167    long GetNextMfb()        // Get last block number allocated (1st is 1)
     167   mg_s_long GetNextMfb()        // Get last block number allocated (1st is 1)
    168168   { return mfh_.nxtmfb_; }
    169169   int GetNextMfp()         // Get offset to next available position in last block
     
    174174
    175175
    176    void CreateMfRecord(MfRecord &m, long &mfb, int &mfp);
    177    void AddMfRecord(MfRecord &m, long &mfb, int &mfp);
    178    void UpdateMfRecord(MfRecord &m, long &mfb, int &mfp);
    179    bool ReadMfRecord(long mfb, int mfp, MfRecord &r);
    180 
    181    void ReadMfRecord(long addr, MfRecord &r);
    182    void WriteMfRecord(long addr, MfRecord &r);
     176   void CreateMfRecord(MfRecord &m, mg_s_long &mfb, int &mfp);
     177   void AddMfRecord(MfRecord &m, mg_s_long &mfb, int &mfp);
     178   void UpdateMfRecord(MfRecord &m, mg_s_long &mfb, int &mfp);
     179   bool ReadMfRecord(mg_s_long mfb, int mfp, MfRecord &r);
     180
     181   void ReadMfRecord(mg_s_long addr, MfRecord &r);
     182   void WriteMfRecord(mg_s_long addr, MfRecord &r);
    183183   void RewindMf();
    184184   bool ReadMfNext(MfRecord &r);
    185185   void WriteMfNext(MfRecord &r);
    186    void ReadLeader(long daddr, MfRecord& m)
     186   void ReadLeader(mg_s_long daddr, MfRecord& m)
    187187   {
    188188       m.ReadLeader(*this, daddr);
     
    192192   void LockMfHdr();
    193193   void UnlockMfHdr();
    194    void LockMfr(long mfn);
    195    void UnlockMfr(long mfn);
     194   void LockMfr(mg_s_long mfn);
     195   void UnlockMfr(mg_s_long mfn);
    196196
    197197public: // File lock functions
     
    213213{
    214214    const MfFile& m_mf;
    215     long cur;
     215    mg_s_long cur;
    216216public:
    217217    CMfIterator(const MfFile& mf) : m_mf(mf) { }
  • main/trunk/greenstone2/build-src/packages/isis-gdl/Master.cpp

    r13518 r34961  
    471471}
    472472
    473 long MfRecord::GetDirectorySize()
     473mg_s_long MfRecord::GetDirectorySize()
    474474{
    475475    return (GetNvf()*GetDirEntrySize());
    476476}
    477477
    478 long MfRecord::ComputeMfrl()
     478mg_s_long MfRecord::ComputeMfrl()
    479479{
    480480    return (GetLeaderSize() + GetDirectorySize() + GetFieldSize());
     
    892892}
    893893
    894 void MfRecord::ReadLeader(MfFile& f, long daddr)
     894void MfRecord::ReadLeader(MfFile& f, mg_s_long daddr)
    895895{
    896896    int leader_size = GetLeaderSize();
     
    902902}
    903903
    904 bool  MfRecord::Read(MfFile& f, long mfb, int mfp)
     904bool  MfRecord::Read(MfFile& f, mg_s_long mfb, int mfp)
    905905{
    906906    //TRACE("\nMfFile::ReadMfRecord -- mfb=%ld mfp=%d", mfb, mfp);
    907907    PRECONDITION(mfb>0 && mfb<=MAXMFB);
    908     long  blk;
     908    mg_s_long  blk;
    909909    int   mfrr, offs, l;
    910910
     
    963963
    964964
    965 void  MfRecord::Write(MfFile& f, long mfb, int mfp)
     965void  MfRecord::Write(MfFile& f, mg_s_long mfb, int mfp)
    966966{
    967967    TRACE(_T("\nMfFile::writeMfRecord - mfb=%ld mfp=%d"), mfb, mfp);
     
    970970    mfp = mfp%MFBLKSIZE;
    971971   
    972     long hiblk = f.GetNextMfb(); // Highest block number in master file
     972    mg_s_long hiblk = f.GetNextMfb(); // Highest block number in master file
    973973   
    974974    int s  = 0;              // Index in master file record [0:mfrl-1]
    975975    int d  = mfp;            // Index in block buffer [0:bsize-1]
    976     long b = mfb;            // Starting block number
     976    mg_s_long b = mfb;            // Starting block number
    977977   
    978978    // Adjust record length
  • main/trunk/greenstone2/build-src/packages/isis-gdl/Master.h

    r6127 r34961  
    3131#define __MASTER_RECORD_H__
    3232
     33
    3334#include "BlkFile.h"
    3435#include <vector>
     
    4344const int MFALIGN   =    2;   // Master file record alignment
    4445const int MFBLKSIZE =  512;   // Master file block size
    45  
    46 typedef short int ISIS_INT;
    47 typedef long  int ISIS_LONG;
     46
     47typedef int16_t   ISIS_INT;  // used to be defined as 'short int' which worked for 32-bit Unix, but not 64-bit
     48typedef mg_s_long ISIS_LONG; // used to be defined as 'long int' which worked for 32-bit Unix, but not 64-bit
    4849
    4950#ifdef UNIX_BIREME
     
    204205protected: // Additional data
    205206    short int state_;         // Record state in memory
    206     long      mfb_read_;      // Record was read at Block number [1...]
     207    mg_s_long      mfb_read_;      // Record was read at Block number [1...]
    207208    int       mfp_read_;      // Record was read at position in block
    208209    int       mflen_read_;    // Record length was when record read
     
    216217   int          DelDirEntry(int i);
    217218   void         SetMfrl(int mfrl);
    218    void         SetMfbwb(long mfbwb);
     219   void         SetMfbwb(mg_s_long mfbwb);
    219220   void         SetMfbwp(int mfbwp);
    220221   void         SetBase(int base);
     
    223224   int          SetDirEntry(int i, int tag, int pos, int len);
    224225   int          SetDirEntry(int i, const DirEntry& d);
    225    void         SetMfbRead(long b);
     226   void         SetMfbRead(mg_s_long b);
    226227   void         SetMfpRead(int pos);
    227228   void         SetMflenRead(int len);
     
    234235   void         MakeTagVector();
    235236
    236    long         ComputeMfrl();
     237   mg_s_long         ComputeMfrl();
    237238
    238239   void         Copy(UMfRecord& rhs);           
     
    257258
    258259
    259    void ReadLeader(MfFile& f, long daddr);
    260    bool Read (MfFile& f, long mfb, int mfp);
    261    void Write(MfFile& f, long mfb, int mfp);
     260   void ReadLeader(MfFile& f, mg_s_long daddr);
     261   bool Read (MfFile& f, mg_s_long mfb, int mfp);
     262   void Write(MfFile& f, mg_s_long mfb, int mfp);
    262263
    263264   void MakeISORecord(std::string& s);
    264265 
    265    long         GetMfn()           const; // Get MFN
     266   mg_s_long         GetMfn()           const; // Get MFN
    266267   int          GetMfrl()          const; // Get Master File Record Length
    267    long         GetMfbwb()         const; // Get Master File Backward Block number
     268   mg_s_long         GetMfbwb()         const; // Get Master File Backward Block number
    268269   int          GetMfbwp()         const; // Get Master File Backward block position
    269270   int          GetBase()          const; // Get Variable fields starting byte
     
    272273   DirEntry     GetDirEntry(int i) const; // Get a reference to the ieme directory entry
    273274   int          GetState()         const; // Get record state in memory
    274    long         GetMfbRead()       const;
     275   mg_s_long         GetMfbRead()       const;
    275276   int          GetMfpRead()       const;
    276277   int          GetMflenRead()     const;
     
    294295   int          GetFieldLen(int i);
    295296 
    296    void         SetMfn(long mfn);
     297   void         SetMfn(mg_s_long mfn);
    297298   void         SetState(int s);
    298299
    299    long         GetDirectorySize();
     300   mg_s_long         GetDirectorySize();
    300301   int          GetFieldSize()     { return leader_directory_.GetFieldSize(); }
    301302
     
    408409//////////////////////////////
    409410 
    410 inline long MfRecord::GetMfn() const
     411inline mg_s_long MfRecord::GetMfn() const
    411412// Returns Master file number
    412413{
     
    424425//////////////////////////////
    425426 
    426 inline long MfRecord::GetMfbwb() const
     427inline mg_s_long MfRecord::GetMfbwb() const
    427428// Returns backward pointer block number
    428429{
     
    483484//////////////////////////////
    484485 
    485 inline long MfRecord::GetMfbRead() const
     486inline mg_s_long MfRecord::GetMfbRead() const
    486487{
    487488   return mfb_read_;
     
    511512///////////////////////////////////////////////////////////////////////////////
    512513 
    513 inline void MfRecord::SetMfn(long mfn)
     514inline void MfRecord::SetMfn(mg_s_long mfn)
    514515// Set Master file number
    515516{
     
    527528//////////////////////////////
    528529 
    529 inline void MfRecord::SetMfbwb(long mfbwb)
     530inline void MfRecord::SetMfbwb(mg_s_long mfbwb)
    530531// Sets backward pointer block number to mfbwb
    531532{
     
    578579}
    579580
    580 inline void MfRecord::SetMfbRead(long b)
     581inline void MfRecord::SetMfbRead(mg_s_long b)
    581582{
    582583    mfb_read_ = b;
  • main/trunk/greenstone2/build-src/packages/isis-gdl/Unimarc.cpp

    r15554 r34961  
    361361            if (directory_[i].field_[j].data_)
    362362            {
    363                 putchar((unsigned long)directory_[i].field_[j].data_);
     363              // The following is a call to the C-library, and so editing the
     364              // code from "unsigned long" to mg_u_long (as has been done elsewhere
     365              // in the code as a systematic change to allow 64-bit Unix system
     366              // to cope with the Unesco code that was written on the assumption
     367              // that 'long' is always 4 bytes in size -- it is *not* an appropriate
     368              // to change the reference to "unsigned long" here.
     369              //
     370              // putchar() takes a 'int' as its argument for much deeper legacy
     371              // reasons concerning C compilers (pre C90) as discussed here:
     372              //   https://stackoverflow.com/questions/40712493/why-argument-type-of-putchar-fputc-and-putc-is-not-char
     373              // This does make the use of "unsigned long" in the original Unesco code a bit
     374              // suspect, since "int" would make more sense, however given the way
     375              // putchar() works -- passing the argument as a larger integer type
     376              // than is needed, but then 'cutting' out the unsigned char val that
     377              // is sitting there in the LSB and writing it out -- this means sticking
     378              // to the Unesco coded "unsigned long" is an acceptable (if slightly confusing)
     379              // thing to do.
     380             
     381             
     382              putchar((unsigned long)directory_[i].field_[j].data_); // **** could be more needs to be done here!!
    364383            }
    365384            fc++;
  • main/trunk/greenstone2/build-src/packages/isis-gdl/XRFFile.cpp

    r13518 r34961  
    6161        throw CIsisDbException(isis_error, __FILE__, __LINE__);
    6262    }
    63     long file_size   = CFileBase::FileSize(file_name);
     63    mg_s_long file_size   = CFileBase::FileSize(file_name);
    6464   
    6565    last_block_  = file_size/XRFBLKSIZE;
     
    100100}
    101101//-----------------------------------------------------------------------------------
    102 // IsisError  XrfFile::CreateXrf(const _TCHAR *fname, long nextMfn)
     102// IsisError  XrfFile::CreateXrf(const _TCHAR *fname, mg_s_long nextMfn)
    103103//
    104104// Special xrf_ file creation for building xrf_ blocks of an existing mst
    105105//-----------------------------------------------------------------------------------
    106 IsisError  XrfFile::CreateXrf(const _TCHAR *fname, long nextMfn)
     106IsisError  XrfFile::CreateXrf(const _TCHAR *fname, mg_s_long nextMfn)
    107107// Creates an xrf_ file
    108108{
    109109    IsisError isis_error;
    110     long nBlocks = (nextMfn-1)/MAXTIV + 1;       // Number of blocks to allocate
     110    mg_s_long nBlocks = (nextMfn-1)/MAXTIV + 1;       // Number of blocks to allocate
    111111    try
    112112    {
     
    164164   for (int i=0; i<MAXTIV; i++)
    165165   {
    166       long j = xrf_->xrftiv_[i];             // Packed value
     166      mg_s_long j = xrf_->xrftiv_[i];             // Packed value
    167167      fix_endianness(j);
    168168      bool b = (j < 0);
     
    184184void XrfFile::Pack(void)
    185185{
    186    long j = xrfa_->xrfpos_;
     186   mg_s_long j = xrfa_->xrfpos_;
    187187   if (xrfa_->xrfeof_ != 0)
    188188      j = -j;
     
    197197         j = - j;
    198198      //-------------------------------------------
    199       // pack block number and offset in a long int
     199      // pack block number and offset in a mg_s_long
    200200      //-------------------------------------------
    201201      j = j * 2048 + xrfa_->xrftiv_[i].xrfmfp_;
     
    206206 
    207207//------------------------------------------------------------------------------
    208 // int XrfFile::GetMfp(long mfn, long& mfb, int& mfp)
     208// int XrfFile::GetMfp(mg_s_long mfn, mg_s_long& mfb, int& mfp)
    209209//
    210210// Gets the address of master file data record with MFN "mfn" by accessing the
     
    219219//  wasn't updated, then true mfp is mfp%BLKSIZE
    220220//------------------------------------------------------------------------------
    221 int XrfFile::GetMfp(long mfn, long& mfb, int& mfp)
     221int XrfFile::GetMfp(mg_s_long mfn, mg_s_long& mfb, int& mfp)
    222222{
    223223    PRECONDITION(mfn>0);
    224224    PRECONDITION(last_block_>0);
    225225    int  comp;
    226     long comb;
     226    mg_s_long comb;
    227227    int  rc;
    228228   
    229     long psxrf=(mfn-1)/MAXTIV+1;       // Block number
     229    mg_s_long psxrf=(mfn-1)/MAXTIV+1;       // Block number
    230230    if (psxrf > last_block_)
    231231    {
     
    274274}
    275275 
    276 void XrfFile::Grow(long from_lastb, long to_lastb)
    277 {
    278     for (long i=from_lastb+1; i<=to_lastb; i++)
     276void XrfFile::Grow(mg_s_long from_lastb, mg_s_long to_lastb)
     277{
     278    for (mg_s_long i=from_lastb+1; i<=to_lastb; i++)
    279279    {
    280280        //--------------------
     
    296296 
    297297//------------------------------------------------------------------------------
    298 // void XrfFile::PutMfp(long mfn, long mfb, int mfp, int status)
     298// void XrfFile::PutMfp(mg_s_long mfn, mg_s_long mfb, int mfp, int status)
    299299//
    300300// Puts the address of a master file record (mfb,mfp) as the address for MFN
    301301// "mfn" in xrf_ file
    302302//------------------------------------------------------------------------------
    303 void XrfFile::PutMfp(long mfn, long mfb, int mfp, int status)
    304 {
    305 }
     303void XrfFile::PutMfp(mg_s_long mfn, mg_s_long mfb, int mfp, int status)
     304{
     305}
  • main/trunk/greenstone2/build-src/packages/isis-gdl/XRFFile.h

    r6127 r34961  
    5050struct MSTA_ENTRY                 // Unpacked MST address
    5151{             
    52    long       xrfmfb_;             // Master file block
     52   mg_s_long       xrfmfb_;             // Master file block
    5353   short int  xrfmfp_;             // Offset
    5454} ;
     
    5656struct XRFA                       // To strore unpacked addresses
    5757{               
    58    long          xrfpos_;          // Block number on xrf_ file or -1 if empty
     58   mg_s_long          xrfpos_;          // Block number on xrf_ file or -1 if empty
    5959   short int     xrfeof_;          // 1 if last block of xrf_ file
    6060   MSTA_ENTRY xrftiv_[MAXTIV];     // MAXTIV unpacked MST addresses
     
    7878struct XRF                       // To store packed addresses
    7979{                                // for reading and wrting
    80    long xrfpos_;                  // block number on xrf_ file
    81    long xrftiv_[MAXTIV];          // MAXTIV packed MST addresses
     80   mg_s_long xrfpos_;                  // block number on xrf_ file
     81   mg_s_long xrftiv_[MAXTIV];          // MAXTIV packed MST addresses
    8282} ;
    8383 
     
    9292   XRF*  xrf_;             // Buffer to store packed addresses
    9393   XRFA* xrfa_;            // Buffer to store unpacked addresses
    94    long  last_block_;      // Should always contain the last allocated block
     94   mg_s_long  last_block_;      // Should always contain the last allocated block
    9595   
    96    void ReadXrf(long b);
    97    void WriteXrf(long b);
     96   void ReadXrf(mg_s_long b);
     97   void WriteXrf(mg_s_long b);
    9898   void UnPack();
    9999   void Pack();
    100    void Grow(long from_lastb, long to_lastb);
     100   void Grow(mg_s_long from_lastb, mg_s_long to_lastb);
    101101public:
    102102   XrfFile();
     
    104104                     FileSystem::AccessMode mode = FileSystem::FILE_READWRITE);
    105105   IsisError CreateXrf(const _TCHAR *fname);
    106    IsisError CreateXrf(const _TCHAR *fname, long nextMfn);
     106   IsisError CreateXrf(const _TCHAR *fname, mg_s_long nextMfn);
    107107  ~XrfFile();
    108    int  GetMfp(long mfn, long& mfb, int& mfp);
    109    void PutMfp(long mfn, long mfb, int mfp, int status);
     108   int  GetMfp(mg_s_long mfn, mg_s_long& mfb, int& mfp);
     109   void PutMfp(mg_s_long mfn, mg_s_long mfb, int mfp, int status);
    110110};
    111111 
     
    132132//////////////////////////////
    133133 
    134 inline void XrfFile::ReadXrf(long b)
     134inline void XrfFile::ReadXrf(mg_s_long b)
    135135// Reads block # b into xrf_ buffer
    136136{
     
    142142//////////////////////////////
    143143 
    144 inline void XrfFile::WriteXrf(long b)
     144inline void XrfFile::WriteXrf(mg_s_long b)
    145145// Writes the content of xrf_ buffer as block number b
    146146{
  • main/trunk/greenstone2/build-src/packages/isis-gdl/stdafx.h

    r6127 r34961  
    3434#include <iostream>
    3535#include <assert.h>
     36
     37#include "mglong.h"
    3638#include "mytchar.h"
    3739#include "Compat.h"
Note: See TracChangeset for help on using the changeset viewer.