- Timestamp:
- 2021-03-10T19:04:01+13:00 (3 years ago)
- 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 147 147 virtual void UpdateDbRecord(MfRecord &m) = 0; 148 148 149 virtual int ReadDbRecord( long mfn, MfRecord &m) = 0;149 virtual int ReadDbRecord(mg_s_long mfn, MfRecord &m) = 0; 150 150 virtual int ReadNextDbRecord(MfRecord &m) = 0; 151 151 152 virtual bool DeleteRecord( long mfn) = 0;152 virtual bool DeleteRecord(mg_s_long mfn) = 0; 153 153 154 154 virtual void PrintDbRecord(MfRecord &m) = 0; 155 155 virtual void PrintDbHdr() = 0; 156 156 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; 159 159 160 160 virtual SMfHeader& GetSMfHeader() = 0; -
main/trunk/greenstone2/build-src/packages/isis-gdl/BlkFile.h
r6127 r34961 55 55 virtual FileError Close(); 56 56 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); 59 59 virtual void ReadBlk(void* d); 60 60 virtual void WriteBlk(void* d); … … 110 110 //////////////////////////////////////// 111 111 112 inline void BlkFile::ReadBlk(void* d, long b)112 inline void BlkFile::ReadBlk(void* d, mg_s_long b) 113 113 // Reads block number b into d, b is in range [1:NBLOCK] 114 114 { … … 121 121 //////////////////////////////////////// 122 122 123 inline void BlkFile::WriteBlk(void* d, long b)123 inline void BlkFile::WriteBlk(void* d, mg_s_long b) 124 124 // Writes blksize bytes from d at block number b 125 125 { … … 138 138 ASSERT(d!=NULL); 139 139 //CFileBase::Fetch(d, blkSize_); 140 long addr = CFileBase::FilePosition();140 mg_s_long addr = CFileBase::FilePosition(); 141 141 cache_.Read(addr, d); 142 142 } … … 149 149 ASSERT(d!=NULL); 150 150 //CFileBase::Store(d, blkSize_); 151 long addr = CFileBase::FilePosition();151 mg_s_long addr = CFileBase::FilePosition(); 152 152 cache_.Write(addr, d); 153 153 } -
main/trunk/greenstone2/build-src/packages/isis-gdl/CRC32.cpp
r6189 r34961 36 36 // remainder 32-bit, which is the checksum. 37 37 // 38 //#include "stdafx.h"38 #include "stdafx.h" 39 39 #include <iomanip> 40 40 #include "CRC32.h" 41 41 #include "CRCTab.h" 42 42 43 unsignedlong CalcCRC32(const char *buf, unsigned len)43 mg_u_long CalcCRC32(const char *buf, unsigned len) 44 44 // Calculate a 32-bit CRC for a raw pattern of bytes. 45 45 // Returns a 32-bit checksum. 46 46 { 47 unsignedlong CRC=0xffffffffL;47 mg_u_long CRC=0xffffffffL; 48 48 unsigned int n = len; 49 49 … … 54 54 } 55 55 56 unsignedlong CalcCRC32(char *buf, unsigned len)56 mg_u_long CalcCRC32(char *buf, unsigned len) 57 57 // Calculate a 32-bit CRC for a raw pattern of bytes. 58 58 // Returns a 32-bit checksum. 59 59 { 60 unsignedlong CRC=0xffffffffL;60 mg_u_long CRC=0xffffffffL; 61 61 unsigned int n = len; 62 62 char *p = (char *)buf; … … 67 67 } 68 68 69 unsigned long CalcCRC32(unsigned char c, unsignedlong CRC)69 mg_u_long CalcCRC32(unsigned char c, mg_u_long CRC) 70 70 // Calculate a 32-bit CRC table value for a single byte. 71 71 // NOTE: The initial CRC value must be set to 0xffffffffL … … 80 80 } 81 81 82 unsignedlong CalcCRC32(std::fstream &infile)82 mg_u_long CalcCRC32(std::fstream &infile) 83 83 // Calculate a 32-bit CRC for a file. Assumes the stream 84 84 // is already open. Returns a 32-bit checksum. 85 85 { 86 unsignedlong CRC=0xffffffffL;86 mg_u_long CRC=0xffffffffL; 87 87 #ifdef _WIN32 88 88 char c; … … 133 133 // and repeats for all eight bits of "q". 134 134 { 135 unsignedlong c; // CRC shift register136 unsignedlong e; // Polynomial exclusive-or pattern135 mg_u_long c; // CRC shift register 136 mg_u_long e; // Polynomial exclusive-or pattern 137 137 int i; // Counter for all possible eight bit values 138 138 int k; // Byte being shifted into crc apparatus -
main/trunk/greenstone2/build-src/packages/isis-gdl/CRC32.h
r6127 r34961 40 40 #include <fstream> 41 41 42 unsigned long CalcCRC32(char *buf, unsigned len); 43 unsigned long CalcCRC32(const char *buf, unsigned len); 44 unsigned long CalcCRC32(unsigned char c, unsignedlong CRC);45 unsignedlong CalcCRC32(std::fstream &infile);42 mg_u_long CalcCRC32(char *buf, unsigned int len); // **** was just 'unsigned len' 43 mg_u_long CalcCRC32(const char *buf, unsigned int len); // **** was just 'unsigned len' 44 mg_u_long CalcCRC32(unsigned char c, mg_u_long CRC); 45 mg_u_long CalcCRC32(std::fstream &infile); 46 46 47 47 #ifdef __USE_CRC32_TABLE_FUNCTIONS__ -
main/trunk/greenstone2/build-src/packages/isis-gdl/CRCTab.h
r6127 r34961 43 43 #define __CRC32_TABLE_HPP__ 44 44 45 const unsignedlong crc32tab[256] = {45 const mg_u_long crc32tab[256] = { 46 46 0x00000000U, 0x77073096U, 0xee0e612cU, 0x990951baU, 0x076dc419U, 47 47 0x706af48fU, 0xe963a535U, 0x9e6495a3U, 0x0edb8832U, 0x79dcb8a4U, -
main/trunk/greenstone2/build-src/packages/isis-gdl/Checking.cpp
r6127 r34961 44 44 void Checking::CheckMfHeader(const _TCHAR *mfname, SMfHeader &mfh) 45 45 { 46 long size = FileSystem::FileSize(mfname);46 mg_s_long size = FileSystem::FileSize(mfname); 47 47 TRACE(_T("\nsize=%ld "), size); 48 long mfSize = mfh.nxtmfb_ * MFBLKSIZE;48 mg_s_long mfSize = mfh.nxtmfb_ * MFBLKSIZE; 49 49 //ASSERT(size == mfSize); 50 50 ASSERT(mfh.nxtmfp_>0 && mfh.nxtmfp_<=MFBLKSIZE); … … 58 58 } 59 59 60 void Checking::CheckMfRecordHeader( long addr)60 void Checking::CheckMfRecordHeader(mg_s_long addr) 61 61 { 62 62 -
main/trunk/greenstone2/build-src/packages/isis-gdl/Checking.h
r6127 r34961 30 30 namespace Checking { 31 31 void CheckMfHeader(const _TCHAR *mfname, SMfHeader &mfh); 32 void CheckMfRecordHeader( long addr);32 void CheckMfRecordHeader(mg_s_long addr); 33 33 34 34 } -
main/trunk/greenstone2/build-src/packages/isis-gdl/Compat.h
r26668 r34961 36 36 #define BOOL bool 37 37 #define WORD unsigned short 38 #define DWORD unsignedlong38 #define DWORD mg_u_long 39 39 #define INT32 int 40 40 #define UINT32 unsigned int 41 #define LONG long int41 #define LONG mg_s_long 42 42 #define TRUE true 43 43 #define FALSE false … … 121 121 } 122 122 123 inline void fix_endianness( long int& x)123 inline void fix_endianness(mg_s_long& x) 124 124 { 125 125 #if !defined(LITTLE_ENDIAN) 126 126 if (x < 0) { 127 unsigned long ux = (unsignedlong) x;127 mg_u_long ux = (mg_u_long) x; 128 128 x = (ux>>24) | 129 129 ((ux<<8) & 0x00FF0000) | -
main/trunk/greenstone2/build-src/packages/isis-gdl/Fdt.cpp
r26668 r34961 368 368 ////////////////////////////// 369 369 370 bool CFdt::Seek( long iRecord)370 bool CFdt::Seek(mg_s_long iRecord) 371 371 { 372 372 -
main/trunk/greenstone2/build-src/packages/isis-gdl/Fdt.h
r26668 r34961 113 113 std::vector<CFieldDef*> m_fieldArray; // Array with fields 114 114 115 long m_iCurrentRecord; // Current read record stored in115 mg_s_long m_iCurrentRecord; // Current read record stored in 116 116 CFdtEntry m_fdtEntry; 117 117 bool m_bReadOnly; … … 162 162 void SetAt(int i, CFdtEntry& e); 163 163 164 bool Seek( long iRecord);164 bool Seek(mg_s_long iRecord); 165 165 void Flush(); 166 166 bool GetValue(int n, std::string& result); -
main/trunk/greenstone2/build-src/packages/isis-gdl/File.h
r6127 r34961 38 38 39 39 // CRC-32 checksum used to detect bit errors 40 typedef unsignedlong Checksum;40 typedef mg_u_long Checksum; 41 41 42 42 -
main/trunk/greenstone2/build-src/packages/isis-gdl/IsisDb.cpp
r6127 r34961 150 150 151 151 //---------------------------------------------------------------------------------- 152 // int IsisDb::ReadDbRecord( long mfn, MfRecord &m)152 // int IsisDb::ReadDbRecord(mg_s_long mfn, MfRecord &m) 153 153 // 154 154 // This function reads Master File record with MFN "mfn" into m … … 157 157 // Active=0, LogicalyDeleted=1, PhysicalyDeleted=2, EndOfFile=-1, NewRecord = 3 158 158 //---------------------------------------------------------------------------------- 159 int IsisDb::ReadDbRecord( long mfn, MfRecord &m)160 { 161 long mfb;159 int IsisDb::ReadDbRecord(mg_s_long mfn, MfRecord &m) 160 { 161 mg_s_long mfb; 162 162 int mfp; 163 163 int status; … … 213 213 } 214 214 //---------------------------------------------------------------------------------- 215 // int IsisDb::DeleteRecord( long mfn)215 // int IsisDb::DeleteRecord(mg_s_long mfn) 216 216 // 217 217 // This function logically deletes a Master File record with MFN "mfn". … … 220 220 // Returns true if successful 221 221 //---------------------------------------------------------------------------------- 222 bool IsisDb::DeleteRecord( long mfn)222 bool IsisDb::DeleteRecord(mg_s_long mfn) 223 223 { 224 224 … … 226 226 } 227 227 228 long IsisDb::GetNextActiveMfn(long mfn /* = -1 */)228 mg_s_long IsisDb::GetNextActiveMfn(mg_s_long mfn /* = -1 */) 229 229 { 230 230 if (mfn == -1) … … 232 232 else 233 233 mfn++; 234 long mfb;234 mg_s_long mfb; 235 235 int mfp; 236 236 int iRet = xf_->GetMfp(mfn, mfb, mfp); -
main/trunk/greenstone2/build-src/packages/isis-gdl/IsisDb.h
r6127 r34961 79 79 void CreateDbRecordWithMfn(MfRecord &m); 80 80 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); 83 83 int ReadNextDbRecord(MfRecord &m); 84 84 void PrintDbRecord(MfRecord &m); 85 85 void PrintDbHdr(); 86 86 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); 90 90 91 91 SMfHeader& GetSMfHeader() { return mf_->GetSMfHeader(); } -
main/trunk/greenstone2/build-src/packages/isis-gdl/IsisDef.h
r26668 r34961 123 123 public: 124 124 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) 126 126 { 127 127 m_iError = iError; -
main/trunk/greenstone2/build-src/packages/isis-gdl/IsisGdl.cpp
r12697 r34961 83 83 // Extract the number of the next master file number to 84 84 // assign 85 const long nextMfn = db.GetNextMfn();85 const mg_s_long nextMfn = db.GetNextMfn(); 86 86 87 87 … … 89 89 // Browse the master file in increasing order of Master 90 90 // 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++) 92 92 { 93 93 -
main/trunk/greenstone2/build-src/packages/isis-gdl/IsisTypes.h
r8752 r34961 47 47 typedef int int32_t; // Word size (4 bytes) 48 48 typedef unsigned int uint32_t; // Unsigned word size (4 bytes) 49 typedef longlong32_t; // Long word (4 bytes)50 typedef unsigned longulong32_t; // Unsigned long word (4 bytes)49 typedef mg_s_long long32_t; // Long word (4 bytes) 50 typedef mg_u_long ulong32_t; // Unsigned long word (4 bytes) 51 51 typedef short int16_t; // short word (2 bytes) 52 52 typedef unsigned short uint16_t; // Unsigned short word (2 bytes) … … 75 75 typedef int int32_t; // Word size (4 bytes) 76 76 typedef unsigned int uint32_t; // Unsigned word size (4 bytes) 77 typedef longlong32_t; // Long word (4 bytes)78 typedef unsigned longulong32_t; // Unsigned long word (4 bytes)77 typedef mg_s_long long32_t; // Long word (4 bytes) 78 typedef mg_u_long ulong32_t; // Unsigned long word (4 bytes) 79 79 typedef short int16_t; // short word (2 bytes) 80 80 typedef unsigned short uint16_t; // Unsigned short word (2 bytes) -
main/trunk/greenstone2/build-src/packages/isis-gdl/MFFile.cpp
r12714 r34961 94 94 95 95 //---------------------------------------------------------------------------------- 96 // void MfFile::ReadMfRecord( long mfb, int mfp, MfRecord &m)96 // void MfFile::ReadMfRecord(mg_s_long mfb, int mfp, MfRecord &m) 97 97 // 98 98 // Reads the master file record beginning at address (mfb,mfp) into m 99 99 //---------------------------------------------------------------------------------- 100 bool MfFile::ReadMfRecord( long mfb, int mfp, MfRecord &m)100 bool MfFile::ReadMfRecord(mg_s_long mfb, int mfp, MfRecord &m) 101 101 { 102 102 return m.Read(*this, mfb, mfp); … … 104 104 105 105 //------------------------------------------------------------------------------- 106 // void WriteMfRecord( long mfb, int mfp, MfRecord &m)106 // void WriteMfRecord(mg_s_long mfb, int mfp, MfRecord &m) 107 107 // 108 108 // Helper protected method, which writes the Master file record m at address 109 109 // (mfb, mfp) mfb (1:MAXMFB), mfp (0: MFBLKSIZE) 110 110 //------------------------------------------------------------------------------- 111 void MfFile::WriteMfRecord( long mfb, int mfp, MfRecord &m)111 void MfFile::WriteMfRecord(mg_s_long mfb, int mfp, MfRecord &m) 112 112 { 113 113 m.Write(*this, mfb, mfp); … … 116 116 117 117 //-------------------------------------------------------------------------------- 118 // void CreateMfRecord(MfRecord &m, long &mfb, int &mfp)118 // void CreateMfRecord(MfRecord &m, mg_s_long &mfb, int &mfp) 119 119 // 120 120 // Create a new record. The MFN to be assigned is obtained from the field nxtmfn_ … … 124 124 // 125 125 //-------------------------------------------------------------------------------- 126 void MfFile::CreateMfRecord(MfRecord &m, long &mfb, int &mfp)126 void MfFile::CreateMfRecord(MfRecord &m, mg_s_long &mfb, int &mfp) 127 127 { 128 128 } … … 133 133 134 134 //-------------------------------------------------------------------------------- 135 // void AddMfRecord(MfRecord &m, long &mfb, int &mfp)135 // void AddMfRecord(MfRecord &m, mg_s_long &mfb, int &mfp) 136 136 // 137 137 // Add the record at the end of the master file, at the position indicated by … … 139 139 // Return the address where the record was stored into mfb & mfp 140 140 //-------------------------------------------------------------------------------- 141 void MfFile::AddMfRecord(MfRecord &m, long &mfb, int &mfp)142 { 143 } 144 145 146 //-------------------------------------------------------------------------------- 147 // void UpdateMfRecord(MfRecord &m, long &mfb, int &mfp)141 void 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) 148 148 // 149 149 // Update a Master file record.If possible, i.e. if the record length was not … … 152 152 // 153 153 //-------------------------------------------------------------------------------- 154 void MfFile::UpdateMfRecord(MfRecord &m, long &mfb, int &mfp)154 void MfFile::UpdateMfRecord(MfRecord &m, mg_s_long &mfb, int &mfp) 155 155 { 156 156 } … … 178 178 179 179 //---------------------------------------------------------------------------------- 180 // void MfFile::ReadMfRecord( long daddr, MfRecord &m)180 // void MfFile::ReadMfRecord(mg_s_long daddr, MfRecord &m) 181 181 // 182 182 // Reads a master file record into the master record object m. 183 183 // Non blocked version 184 184 //---------------------------------------------------------------------------------- 185 void MfFile::ReadMfRecord( long daddr, MfRecord &m)185 void MfFile::ReadMfRecord(mg_s_long daddr, MfRecord &m) 186 186 { 187 187 m.Clear(); … … 210 210 211 211 //--------------------------------------------------------------------------------- 212 // void MfFile::WriteMfRecord( long daddr, MfRecord &m)212 // void MfFile::WriteMfRecord(mg_s_long daddr, MfRecord &m) 213 213 // 214 214 // Stores Master record object m to disk address daddr 215 215 // Non blocked version 216 216 //--------------------------------------------------------------------------------- 217 void MfFile::WriteMfRecord( long daddr, MfRecord &m)217 void MfFile::WriteMfRecord(mg_s_long daddr, MfRecord &m) 218 218 { 219 219 } -
main/trunk/greenstone2/build-src/packages/isis-gdl/MFFile.h
r13518 r34961 47 47 struct SMfLockHeader 48 48 { 49 long lockProtect_; // Serialize access to the file lock members50 long readLock_; // Shared (or read_only) file lock51 long writeLock_; // Exclusive (or write-only) file lock49 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 52 52 53 53 SMfLockHeader() : lockProtect_(0), readLock_(0), writeLock_(0) … … 66 66 { 67 67 private: 68 long m_mfb;68 mg_s_long m_mfb; 69 69 short m_mfp; 70 70 char m_status; 71 71 public: 72 72 MfAddress() { m_status = 0x00; } 73 MfAddress( long mfb, short mfp)73 MfAddress(mg_s_long mfb, short mfp) 74 74 { ASSERT(mfb>0); ASSERT(mfp>=0); m_mfb = mfb; m_mfp = mfp; m_status = 0x03; } 75 75 76 long getMfb() { ASSERT(m_status & 0x01); return m_mfb; }76 mg_s_long getMfb() { ASSERT(m_status & 0x01); return m_mfb; } 77 77 short getMfp() { ASSERT(m_status & 0x02); return m_mfp; } 78 78 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; } 80 80 void setMfp(short mfp) { ASSERT(mfp>=0); m_mfp = mfp; m_status |= 0x02; } 81 81 bool isValid() { return (m_status == 0x03); } … … 126 126 protected: 127 127 SMfHeader mfh_; // Header structure 128 long nextaddr_; // Address of next record128 mg_s_long nextaddr_; // Address of next record 129 129 char buf_[MFBLKSIZE]; // Buffer to hold 1 Master File block 130 130 bool hdr_created_; // True if 1st block exists 131 131 int fileError_; 132 long lastWrittenBlock_;132 mg_s_long lastWrittenBlock_; 133 133 134 134 protected: 135 void WriteMfRecord( long mfb, int mfp, MfRecord &r);135 void WriteMfRecord(mg_s_long mfb, int mfp, MfRecord &r); 136 136 void AppendNewBlock(); 137 137 138 138 public: 139 void setNextMfn( long mfn) // Set MFN to be assigned to next record created139 void setNextMfn(mg_s_long mfn) // Set MFN to be assigned to next record created 140 140 { mfh_.nxtmfn_ = mfn; } 141 141 142 142 protected: 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) 144 144 { mfh_.nxtmfb_ = nxtmfb_; } 145 145 void setNextMfp(int nxtmfp_) // Set offset to next available position in last block … … 147 147 int setm_mftype(int mftype_) // Set type of master file (USERMST or MSGMST) 148 148 { 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); } 151 151 void ReadMfHdr(SMfHeader &h); 152 152 void ReadMfHdr(); 153 153 void WriteMfHdr(SMfHeader &h); 154 154 void WriteMfHdr(); 155 void SetLastWrittenBlock( long b) { lastWrittenBlock_ = b; }155 void SetLastWrittenBlock(mg_s_long b) { lastWrittenBlock_ = b; } 156 156 public: 157 157 MfFile(); … … 163 163 164 164 // Accessors for the Master File Header 165 long GetNextMfn() // Get MFN to be assigned to next record created165 mg_s_long GetNextMfn() // Get MFN to be assigned to next record created 166 166 { 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) 168 168 { return mfh_.nxtmfb_; } 169 169 int GetNextMfp() // Get offset to next available position in last block … … 174 174 175 175 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); 183 183 void RewindMf(); 184 184 bool ReadMfNext(MfRecord &r); 185 185 void WriteMfNext(MfRecord &r); 186 void ReadLeader( long daddr, MfRecord& m)186 void ReadLeader(mg_s_long daddr, MfRecord& m) 187 187 { 188 188 m.ReadLeader(*this, daddr); … … 192 192 void LockMfHdr(); 193 193 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); 196 196 197 197 public: // File lock functions … … 213 213 { 214 214 const MfFile& m_mf; 215 long cur;215 mg_s_long cur; 216 216 public: 217 217 CMfIterator(const MfFile& mf) : m_mf(mf) { } -
main/trunk/greenstone2/build-src/packages/isis-gdl/Master.cpp
r13518 r34961 471 471 } 472 472 473 long MfRecord::GetDirectorySize()473 mg_s_long MfRecord::GetDirectorySize() 474 474 { 475 475 return (GetNvf()*GetDirEntrySize()); 476 476 } 477 477 478 long MfRecord::ComputeMfrl()478 mg_s_long MfRecord::ComputeMfrl() 479 479 { 480 480 return (GetLeaderSize() + GetDirectorySize() + GetFieldSize()); … … 892 892 } 893 893 894 void MfRecord::ReadLeader(MfFile& f, long daddr)894 void MfRecord::ReadLeader(MfFile& f, mg_s_long daddr) 895 895 { 896 896 int leader_size = GetLeaderSize(); … … 902 902 } 903 903 904 bool MfRecord::Read(MfFile& f, long mfb, int mfp)904 bool MfRecord::Read(MfFile& f, mg_s_long mfb, int mfp) 905 905 { 906 906 //TRACE("\nMfFile::ReadMfRecord -- mfb=%ld mfp=%d", mfb, mfp); 907 907 PRECONDITION(mfb>0 && mfb<=MAXMFB); 908 long blk;908 mg_s_long blk; 909 909 int mfrr, offs, l; 910 910 … … 963 963 964 964 965 void MfRecord::Write(MfFile& f, long mfb, int mfp)965 void MfRecord::Write(MfFile& f, mg_s_long mfb, int mfp) 966 966 { 967 967 TRACE(_T("\nMfFile::writeMfRecord - mfb=%ld mfp=%d"), mfb, mfp); … … 970 970 mfp = mfp%MFBLKSIZE; 971 971 972 long hiblk = f.GetNextMfb(); // Highest block number in master file972 mg_s_long hiblk = f.GetNextMfb(); // Highest block number in master file 973 973 974 974 int s = 0; // Index in master file record [0:mfrl-1] 975 975 int d = mfp; // Index in block buffer [0:bsize-1] 976 long b = mfb; // Starting block number976 mg_s_long b = mfb; // Starting block number 977 977 978 978 // Adjust record length -
main/trunk/greenstone2/build-src/packages/isis-gdl/Master.h
r6127 r34961 31 31 #define __MASTER_RECORD_H__ 32 32 33 33 34 #include "BlkFile.h" 34 35 #include <vector> … … 43 44 const int MFALIGN = 2; // Master file record alignment 44 45 const int MFBLKSIZE = 512; // Master file block size 45 46 typedef short int ISIS_INT;47 typedef long int ISIS_LONG;46 47 typedef int16_t ISIS_INT; // used to be defined as 'short int' which worked for 32-bit Unix, but not 64-bit 48 typedef mg_s_long ISIS_LONG; // used to be defined as 'long int' which worked for 32-bit Unix, but not 64-bit 48 49 49 50 #ifdef UNIX_BIREME … … 204 205 protected: // Additional data 205 206 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...] 207 208 int mfp_read_; // Record was read at position in block 208 209 int mflen_read_; // Record length was when record read … … 216 217 int DelDirEntry(int i); 217 218 void SetMfrl(int mfrl); 218 void SetMfbwb( long mfbwb);219 void SetMfbwb(mg_s_long mfbwb); 219 220 void SetMfbwp(int mfbwp); 220 221 void SetBase(int base); … … 223 224 int SetDirEntry(int i, int tag, int pos, int len); 224 225 int SetDirEntry(int i, const DirEntry& d); 225 void SetMfbRead( long b);226 void SetMfbRead(mg_s_long b); 226 227 void SetMfpRead(int pos); 227 228 void SetMflenRead(int len); … … 234 235 void MakeTagVector(); 235 236 236 long ComputeMfrl();237 mg_s_long ComputeMfrl(); 237 238 238 239 void Copy(UMfRecord& rhs); … … 257 258 258 259 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); 262 263 263 264 void MakeISORecord(std::string& s); 264 265 265 long GetMfn() const; // Get MFN266 mg_s_long GetMfn() const; // Get MFN 266 267 int GetMfrl() const; // Get Master File Record Length 267 long GetMfbwb() const; // Get Master File Backward Block number268 mg_s_long GetMfbwb() const; // Get Master File Backward Block number 268 269 int GetMfbwp() const; // Get Master File Backward block position 269 270 int GetBase() const; // Get Variable fields starting byte … … 272 273 DirEntry GetDirEntry(int i) const; // Get a reference to the ieme directory entry 273 274 int GetState() const; // Get record state in memory 274 long GetMfbRead() const;275 mg_s_long GetMfbRead() const; 275 276 int GetMfpRead() const; 276 277 int GetMflenRead() const; … … 294 295 int GetFieldLen(int i); 295 296 296 void SetMfn( long mfn);297 void SetMfn(mg_s_long mfn); 297 298 void SetState(int s); 298 299 299 long GetDirectorySize();300 mg_s_long GetDirectorySize(); 300 301 int GetFieldSize() { return leader_directory_.GetFieldSize(); } 301 302 … … 408 409 ////////////////////////////// 409 410 410 inline long MfRecord::GetMfn() const411 inline mg_s_long MfRecord::GetMfn() const 411 412 // Returns Master file number 412 413 { … … 424 425 ////////////////////////////// 425 426 426 inline long MfRecord::GetMfbwb() const427 inline mg_s_long MfRecord::GetMfbwb() const 427 428 // Returns backward pointer block number 428 429 { … … 483 484 ////////////////////////////// 484 485 485 inline long MfRecord::GetMfbRead() const486 inline mg_s_long MfRecord::GetMfbRead() const 486 487 { 487 488 return mfb_read_; … … 511 512 /////////////////////////////////////////////////////////////////////////////// 512 513 513 inline void MfRecord::SetMfn( long mfn)514 inline void MfRecord::SetMfn(mg_s_long mfn) 514 515 // Set Master file number 515 516 { … … 527 528 ////////////////////////////// 528 529 529 inline void MfRecord::SetMfbwb( long mfbwb)530 inline void MfRecord::SetMfbwb(mg_s_long mfbwb) 530 531 // Sets backward pointer block number to mfbwb 531 532 { … … 578 579 } 579 580 580 inline void MfRecord::SetMfbRead( long b)581 inline void MfRecord::SetMfbRead(mg_s_long b) 581 582 { 582 583 mfb_read_ = b; -
main/trunk/greenstone2/build-src/packages/isis-gdl/Unimarc.cpp
r15554 r34961 361 361 if (directory_[i].field_[j].data_) 362 362 { 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!! 364 383 } 365 384 fc++; -
main/trunk/greenstone2/build-src/packages/isis-gdl/XRFFile.cpp
r13518 r34961 61 61 throw CIsisDbException(isis_error, __FILE__, __LINE__); 62 62 } 63 long file_size = CFileBase::FileSize(file_name);63 mg_s_long file_size = CFileBase::FileSize(file_name); 64 64 65 65 last_block_ = file_size/XRFBLKSIZE; … … 100 100 } 101 101 //----------------------------------------------------------------------------------- 102 // IsisError XrfFile::CreateXrf(const _TCHAR *fname, long nextMfn)102 // IsisError XrfFile::CreateXrf(const _TCHAR *fname, mg_s_long nextMfn) 103 103 // 104 104 // Special xrf_ file creation for building xrf_ blocks of an existing mst 105 105 //----------------------------------------------------------------------------------- 106 IsisError XrfFile::CreateXrf(const _TCHAR *fname, long nextMfn)106 IsisError XrfFile::CreateXrf(const _TCHAR *fname, mg_s_long nextMfn) 107 107 // Creates an xrf_ file 108 108 { 109 109 IsisError isis_error; 110 long nBlocks = (nextMfn-1)/MAXTIV + 1; // Number of blocks to allocate110 mg_s_long nBlocks = (nextMfn-1)/MAXTIV + 1; // Number of blocks to allocate 111 111 try 112 112 { … … 164 164 for (int i=0; i<MAXTIV; i++) 165 165 { 166 long j = xrf_->xrftiv_[i]; // Packed value166 mg_s_long j = xrf_->xrftiv_[i]; // Packed value 167 167 fix_endianness(j); 168 168 bool b = (j < 0); … … 184 184 void XrfFile::Pack(void) 185 185 { 186 long j = xrfa_->xrfpos_;186 mg_s_long j = xrfa_->xrfpos_; 187 187 if (xrfa_->xrfeof_ != 0) 188 188 j = -j; … … 197 197 j = - j; 198 198 //------------------------------------------- 199 // pack block number and offset in a long int199 // pack block number and offset in a mg_s_long 200 200 //------------------------------------------- 201 201 j = j * 2048 + xrfa_->xrftiv_[i].xrfmfp_; … … 206 206 207 207 //------------------------------------------------------------------------------ 208 // int XrfFile::GetMfp( long mfn,long& mfb, int& mfp)208 // int XrfFile::GetMfp(mg_s_long mfn, mg_s_long& mfb, int& mfp) 209 209 // 210 210 // Gets the address of master file data record with MFN "mfn" by accessing the … … 219 219 // wasn't updated, then true mfp is mfp%BLKSIZE 220 220 //------------------------------------------------------------------------------ 221 int XrfFile::GetMfp( long mfn,long& mfb, int& mfp)221 int XrfFile::GetMfp(mg_s_long mfn, mg_s_long& mfb, int& mfp) 222 222 { 223 223 PRECONDITION(mfn>0); 224 224 PRECONDITION(last_block_>0); 225 225 int comp; 226 long comb;226 mg_s_long comb; 227 227 int rc; 228 228 229 long psxrf=(mfn-1)/MAXTIV+1; // Block number229 mg_s_long psxrf=(mfn-1)/MAXTIV+1; // Block number 230 230 if (psxrf > last_block_) 231 231 { … … 274 274 } 275 275 276 void XrfFile::Grow( long from_lastb,long to_lastb)277 { 278 for ( long i=from_lastb+1; i<=to_lastb; i++)276 void 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++) 279 279 { 280 280 //-------------------- … … 296 296 297 297 //------------------------------------------------------------------------------ 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) 299 299 // 300 300 // Puts the address of a master file record (mfb,mfp) as the address for MFN 301 301 // "mfn" in xrf_ file 302 302 //------------------------------------------------------------------------------ 303 void XrfFile::PutMfp( long mfn,long mfb, int mfp, int status)304 { 305 } 303 void 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 50 50 struct MSTA_ENTRY // Unpacked MST address 51 51 { 52 long xrfmfb_; // Master file block52 mg_s_long xrfmfb_; // Master file block 53 53 short int xrfmfp_; // Offset 54 54 } ; … … 56 56 struct XRFA // To strore unpacked addresses 57 57 { 58 long xrfpos_; // Block number on xrf_ file or -1 if empty58 mg_s_long xrfpos_; // Block number on xrf_ file or -1 if empty 59 59 short int xrfeof_; // 1 if last block of xrf_ file 60 60 MSTA_ENTRY xrftiv_[MAXTIV]; // MAXTIV unpacked MST addresses … … 78 78 struct XRF // To store packed addresses 79 79 { // for reading and wrting 80 long xrfpos_; // block number on xrf_ file81 long xrftiv_[MAXTIV]; // MAXTIV packed MST addresses80 mg_s_long xrfpos_; // block number on xrf_ file 81 mg_s_long xrftiv_[MAXTIV]; // MAXTIV packed MST addresses 82 82 } ; 83 83 … … 92 92 XRF* xrf_; // Buffer to store packed addresses 93 93 XRFA* xrfa_; // Buffer to store unpacked addresses 94 long last_block_; // Should always contain the last allocated block94 mg_s_long last_block_; // Should always contain the last allocated block 95 95 96 void ReadXrf( long b);97 void WriteXrf( long b);96 void ReadXrf(mg_s_long b); 97 void WriteXrf(mg_s_long b); 98 98 void UnPack(); 99 99 void Pack(); 100 void Grow( long from_lastb,long to_lastb);100 void Grow(mg_s_long from_lastb, mg_s_long to_lastb); 101 101 public: 102 102 XrfFile(); … … 104 104 FileSystem::AccessMode mode = FileSystem::FILE_READWRITE); 105 105 IsisError CreateXrf(const _TCHAR *fname); 106 IsisError CreateXrf(const _TCHAR *fname, long nextMfn);106 IsisError CreateXrf(const _TCHAR *fname, mg_s_long nextMfn); 107 107 ~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); 110 110 }; 111 111 … … 132 132 ////////////////////////////// 133 133 134 inline void XrfFile::ReadXrf( long b)134 inline void XrfFile::ReadXrf(mg_s_long b) 135 135 // Reads block # b into xrf_ buffer 136 136 { … … 142 142 ////////////////////////////// 143 143 144 inline void XrfFile::WriteXrf( long b)144 inline void XrfFile::WriteXrf(mg_s_long b) 145 145 // Writes the content of xrf_ buffer as block number b 146 146 { -
main/trunk/greenstone2/build-src/packages/isis-gdl/stdafx.h
r6127 r34961 34 34 #include <iostream> 35 35 #include <assert.h> 36 37 #include "mglong.h" 36 38 #include "mytchar.h" 37 39 #include "Compat.h"
Note:
See TracChangeset
for help on using the changeset viewer.