diff options
author | Daniel Brahneborg <basic@chello.se> | 2002-03-04 14:31:16 +0000 |
---|---|---|
committer | Daniel Brahneborg <basic@chello.se> | 2002-03-04 14:31:16 +0000 |
commit | dbfc3ee2b91ed26eb00e85a32c715995f4fce41b (patch) | |
tree | 82605dba9b7a1d14c3e952af32bef2852d60703b /lib | |
parent | b68ab4b0002aa0c59fdbbfee3076e35aeac44d68 (diff) | |
download | plptools-dbfc3ee2b91ed26eb00e85a32c715995f4fce41b.tar.gz plptools-dbfc3ee2b91ed26eb00e85a32c715995f4fce41b.tar.bz2 plptools-dbfc3ee2b91ed26eb00e85a32c715995f4fce41b.zip |
Use plp standard types.
Fix copyright include.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/siscomponentrecord.cpp | 14 | ||||
-rw-r--r-- | lib/siscomponentrecord.h | 14 | ||||
-rw-r--r-- | lib/sisfile.cpp | 4 | ||||
-rw-r--r-- | lib/sisfile.h | 8 | ||||
-rw-r--r-- | lib/sisfileheader.cpp | 8 | ||||
-rw-r--r-- | lib/sisfileheader.h | 52 | ||||
-rw-r--r-- | lib/sisfilerecord.cpp | 12 | ||||
-rw-r--r-- | lib/sisfilerecord.h | 24 | ||||
-rw-r--r-- | lib/sislangrecord.cpp | 2 | ||||
-rw-r--r-- | lib/sislangrecord.h | 8 | ||||
-rw-r--r-- | lib/sisreqrecord.cpp | 8 | ||||
-rw-r--r-- | lib/sisreqrecord.h | 20 | ||||
-rw-r--r-- | lib/sistypes.cpp | 14 | ||||
-rw-r--r-- | lib/sistypes.h | 16 |
14 files changed, 95 insertions, 109 deletions
diff --git a/lib/siscomponentrecord.cpp b/lib/siscomponentrecord.cpp index 8078886..fb1c05e 100644 --- a/lib/siscomponentrecord.cpp +++ b/lib/siscomponentrecord.cpp @@ -32,18 +32,18 @@ SISComponentNameRecord::~SISComponentNameRecord() } SisRC -SISComponentNameRecord::fillFrom(uchar* buf, int base, off_t len, +SISComponentNameRecord::fillFrom(uint8_t* buf, int base, off_t len, SISFile* sisFile) { int n = sisFile->m_header.m_nlangs; if (base + 8 + n * 4 * 2) return SIS_TRUNCATED; - uchar* p = buf + base; + uint8_t* p = buf + base; int size = 0; - m_nameLengths = new uint32[n]; - m_namePtrs = new uint32[n]; + m_nameLengths = new uint32_t[n]; + m_namePtrs = new uint32_t[n]; // First read lengths. // @@ -60,7 +60,7 @@ SISComponentNameRecord::fillFrom(uchar* buf, int base, off_t len, // Then read ptrs. // - m_names = new uchar*[n]; + m_names = new uint8_t*[n]; for (int i = 0; i < n; ++i) { m_namePtrs[i] = read32(p + size); @@ -77,7 +77,7 @@ SISComponentNameRecord::fillFrom(uchar* buf, int base, off_t len, m_nameLengths[i], buf + m_namePtrs[i]); int len = m_nameLengths[i]; - m_names[i] = new uchar[len + 1]; + m_names[i] = new uint8_t[len + 1]; memcpy(m_names[i], buf + m_namePtrs[i], len); m_names[i][len] = 0; } @@ -86,7 +86,7 @@ SISComponentNameRecord::fillFrom(uchar* buf, int base, off_t len, return SIS_OK; } -uchar* +uint8_t* SISComponentNameRecord::getName(int no) { return m_names[no]; diff --git a/lib/siscomponentrecord.h b/lib/siscomponentrecord.h index f2a85da..d15e754 100644 --- a/lib/siscomponentrecord.h +++ b/lib/siscomponentrecord.h @@ -1,4 +1,4 @@ -/** -*-c++-*- +/* -*-c++-*- * $Id$ * * This file is part of plptools. @@ -25,8 +25,6 @@ #include "sistypes.h" -#include <sys/types.h> - class SISFile; /** @@ -42,24 +40,24 @@ public: /** * Populate the fields. */ - SisRC fillFrom(uchar* buf, int base, off_t len, SISFile* sisFile); + SisRC fillFrom(uint8_t* buf, int base, off_t len, SISFile* sisFile); /** * Return the name for the given language. * The number is the sequence number in the list of language records * in the sis file. */ - uchar* getName(int no); + uint8_t* getName(int no); private: - uint32* m_nameLengths; - uint32* m_namePtrs; + uint32_t* m_nameLengths; + uint32_t* m_namePtrs; /** * The extracted names. */ - uchar** m_names; + uint8_t** m_names; }; diff --git a/lib/sisfile.cpp b/lib/sisfile.cpp index f9a19fb..ec8adb8 100644 --- a/lib/sisfile.cpp +++ b/lib/sisfile.cpp @@ -28,7 +28,7 @@ #include <stdio.h> SisRC -SISFile::fillFrom(uchar* buf, off_t len) +SISFile::fillFrom(uint8_t* buf, off_t len) { int ix = 0; SisRC rc = m_header.fillFrom(buf, &ix, len); @@ -117,7 +117,7 @@ SISFile::getLanguage(int i) return &langTable[m_langRecords[i].m_lang]; } -uchar* +uint8_t* SISFile::getName() { return m_componentRecord.getName(m_header.m_installationLanguage); diff --git a/lib/sisfile.h b/lib/sisfile.h index 45490da..02e400b 100644 --- a/lib/sisfile.h +++ b/lib/sisfile.h @@ -1,4 +1,4 @@ -/** -*-c++-*- +/* -*-c++-*- * $Id$ * * This file is part of plptools. @@ -27,8 +27,6 @@ #include "sisfileheader.h" #include "siscomponentrecord.h" -#include <sys/types.h> - class SISLangRecord; class SISFileRecord; class SISReqRecord; @@ -43,7 +41,7 @@ public: /** * Populate the fields. */ - SisRC fillFrom(uchar* buf, off_t len); + SisRC fillFrom(uint8_t* buf, off_t len); /** * Return the currently selected installation language. @@ -59,7 +57,7 @@ public: /** * Get the name of this component, in the selected language. */ - uchar* getName(); + uint8_t* getName(); /** * Set the installed drive. diff --git a/lib/sisfileheader.cpp b/lib/sisfileheader.cpp index 3279c38..19724c3 100644 --- a/lib/sisfileheader.cpp +++ b/lib/sisfileheader.cpp @@ -29,11 +29,11 @@ const int OFF_NUMBER_OF_FILES = 26; const int OFF_INSTALLATION_DRIVE = 28; SisRC -SISFileHeader::fillFrom(uchar* buf, int* base, off_t len) +SISFileHeader::fillFrom(uint8_t* buf, int* base, off_t len) { if (*base + 68 > len) return SIS_TRUNCATED; - uchar* start = buf + *base; + uint8_t* start = buf + *base; m_buf = buf; m_uid1 = read32(start); if (logLevel >= 1) @@ -56,10 +56,10 @@ SISFileHeader::fillFrom(uchar* buf, int* base, off_t len) printf("Got uid3 = %08x\n", m_uid3); m_uid4 = read32(start + 12); // printf("Got uid4 = %08x\n", m_uid4); - uint16 crc1 = 0; + uint16_t crc1 = 0; for (int i = 0; i < 12; i += 2) crc1 = updateCrc(crc1, buf[*base + i]); - uint16 crc2 = 0; + uint16_t crc2 = 0; for (int i = 0; i < 12; i += 2) crc2 = updateCrc(crc2, buf[*base + i + 1]); if (logLevel >= 2) diff --git a/lib/sisfileheader.h b/lib/sisfileheader.h index 8c90511..eba4c97 100644 --- a/lib/sisfileheader.h +++ b/lib/sisfileheader.h @@ -1,4 +1,4 @@ -/** -*-c++-*- +/* -*-c++-*- * $Id$ * * This file is part of plptools. @@ -23,8 +23,6 @@ #ifndef _SISFILEHEADER_H #define _SISFILEHEADER_H -#include <sys/types.h> - #include "sistypes.h" /** @@ -37,7 +35,7 @@ public: /** * Populate the fields. */ - SisRC fillFrom(uchar* buf, int* base, off_t len); + SisRC fillFrom(uint8_t* buf, int* base, off_t len); /** * Update the drive letter, and patch the parsed buffer. @@ -69,32 +67,32 @@ public: #endif }; - uint32 m_uid1; - uint32 m_uid2; - uint32 m_uid3; - uint32 m_uid4; - uint16 m_crc; - uint16 m_nlangs; - uint16 m_nfiles; - uint16 m_nreqs; - uint16 m_installationLanguage; - uint16 m_installationFiles; - uint32 m_installationDrive; - uint32 m_installerVersion; - uint16 m_options; - uint16 m_type; - uint16 m_major; - uint16 m_minor; - uint32 m_variant; - uint32 m_languagePtr; - uint32 m_filesPtr; - uint32 m_reqPtr; - uint32 m_unknown; - uint32 m_componentPtr; + uint32_t m_uid1; + uint32_t m_uid2; + uint32_t m_uid3; + uint32_t m_uid4; + uint16_t m_crc; + uint16_t m_nlangs; + uint16_t m_nfiles; + uint16_t m_nreqs; + uint16_t m_installationLanguage; + uint16_t m_installationFiles; + uint32_t m_installationDrive; + uint32_t m_installerVersion; + uint16_t m_options; + uint16_t m_type; + uint16_t m_major; + uint16_t m_minor; + uint32_t m_variant; + uint32_t m_languagePtr; + uint32_t m_filesPtr; + uint32_t m_reqPtr; + uint32_t m_unknown; + uint32_t m_componentPtr; private: - uchar* m_buf; + uint8_t* m_buf; }; diff --git a/lib/sisfilerecord.cpp b/lib/sisfilerecord.cpp index baa5776..e7dd007 100644 --- a/lib/sisfilerecord.cpp +++ b/lib/sisfilerecord.cpp @@ -26,12 +26,12 @@ #include <stdio.h> SisRC -SISFileRecord::fillFrom(uchar* buf, int* base, off_t len, SISFile* sisFile) +SISFileRecord::fillFrom(uint8_t* buf, int* base, off_t len, SISFile* sisFile) { if (*base + 28 + 4 * 2 > len) return SIS_TRUNCATED; - uchar* p = buf + *base; + uint8_t* p = buf + *base; int size = 0; m_flags = read32(p); if (logLevel >= 2) @@ -59,8 +59,8 @@ SISFileRecord::fillFrom(uchar* buf, int* base, off_t len, SISFile* sisFile) switch (m_flags) { case 0: // Only one file. - m_fileLengths = new uint32[1]; - m_filePtrs = new uint32[1]; + m_fileLengths = new uint32_t[1]; + m_filePtrs = new uint32_t[1]; m_fileLengths[0] = read32(p + size); m_filePtrs[0] = read32(p + size + 4); size += 8; @@ -80,8 +80,8 @@ SISFileRecord::fillFrom(uchar* buf, int* base, off_t len, SISFile* sisFile) case 1: // One file per language. { int n = sisFile->m_header.m_nlangs; - m_fileLengths = new uint32[n]; - m_filePtrs = new uint32[n]; + m_fileLengths = new uint32_t[n]; + m_filePtrs = new uint32_t[n]; if (*base + size + n * 8 > len) return SIS_TRUNCATED; for (int i = 0; i < n; ++i) diff --git a/lib/sisfilerecord.h b/lib/sisfilerecord.h index ae99836..0f6526b 100644 --- a/lib/sisfilerecord.h +++ b/lib/sisfilerecord.h @@ -1,4 +1,4 @@ -/** -*-c++-*- +/* -*-c++-*- * $Id$ * * This file is part of plptools. @@ -25,8 +25,6 @@ #include "sistypes.h" -#include <sys/types.h> - class SISFile; /** @@ -42,12 +40,12 @@ public: /** * Populate the fields. */ - SisRC fillFrom(uchar* buf, int* base, off_t len, SISFile* sisFile); + SisRC fillFrom(uint8_t* buf, int* base, off_t len, SISFile* sisFile); /** * 1 if multiple language versions, otherwise 0. */ - uint32 m_flags; + uint32_t m_flags; /** * Type of file. @@ -59,7 +57,7 @@ public: * - 4. Does not exist yet, but will be created when app is run, so * it should not be removed during an upgrade. */ - uint32 m_fileType; + uint32_t m_fileType; /** * If file type is 1: @@ -74,14 +72,14 @@ public: * - 1. Run during removal. * - 2. Run during both installation and removal. */ - uint32 m_fileDetails; + uint32_t m_fileDetails; - uint32 m_sourceLength; - uint32 m_sourcePtr; - uint32 m_destLength; - uint32 m_destPtr; - uint32* m_fileLengths; - uint32* m_filePtrs; + uint32_t m_sourceLength; + uint32_t m_sourcePtr; + uint32_t m_destLength; + uint32_t m_destPtr; + uint32_t* m_fileLengths; + uint32_t* m_filePtrs; }; #endif diff --git a/lib/sislangrecord.cpp b/lib/sislangrecord.cpp index 2b6afc4..1a55784 100644 --- a/lib/sislangrecord.cpp +++ b/lib/sislangrecord.cpp @@ -25,7 +25,7 @@ #include <stdio.h> SisRC -SISLangRecord::fillFrom(uchar* buf, int* base, off_t len) +SISLangRecord::fillFrom(uint8_t* buf, int* base, off_t len) { if (*base + 2 > len) return SIS_TRUNCATED; diff --git a/lib/sislangrecord.h b/lib/sislangrecord.h index 9a2b5e9..5aecd4a 100644 --- a/lib/sislangrecord.h +++ b/lib/sislangrecord.h @@ -1,4 +1,4 @@ -/** -*-c++-*- +/* -*-c++-*- * $Id$ * * This file is part of plptools. @@ -23,8 +23,6 @@ #ifndef _SISLANGRECORD_H #define _SISLANGRECORD_H -#include <sys/types.h> - #include "sistypes.h" /** @@ -38,9 +36,9 @@ public: /** * Populate the fields. */ - SisRC fillFrom(uchar* buf, int* base, off_t len); + SisRC fillFrom(uint8_t* buf, int* base, off_t len); - uint16 m_lang; + uint16_t m_lang; }; #endif diff --git a/lib/sisreqrecord.cpp b/lib/sisreqrecord.cpp index c13308e..f734e51 100644 --- a/lib/sisreqrecord.cpp +++ b/lib/sisreqrecord.cpp @@ -26,21 +26,21 @@ #include <stdio.h> SisRC -SISReqRecord::fillFrom(uchar* buf, int* base, off_t len, SISFile* sisFile) +SISReqRecord::fillFrom(uint8_t* buf, int* base, off_t len, SISFile* sisFile) { int n = sisFile->m_header.m_nreqs; if (*base + 12 + n * 4 * 2) return SIS_TRUNCATED; - uchar* p = buf + *base; + uint8_t* p = buf + *base; int size = 0; m_uid = read32(p); m_major = read16(p + 4); m_minor = read16(p + 6); m_variant = read32(p + 8); - m_nameLengths = new uint32[n]; - m_namePtrs = new uint32[n]; + m_nameLengths = new uint32_t[n]; + m_namePtrs = new uint32_t[n]; // First read lengths. // diff --git a/lib/sisreqrecord.h b/lib/sisreqrecord.h index 44206a1..7219fe4 100644 --- a/lib/sisreqrecord.h +++ b/lib/sisreqrecord.h @@ -1,4 +1,4 @@ -/** -*-c++-*- +/* -*-c++-*- * $Id$ * * This file is part of plptools. @@ -25,8 +25,6 @@ #include "sistypes.h" -#include <sys/types.h> - class SISFile; /** @@ -40,14 +38,14 @@ public: /** * Populate the fields. */ - SisRC fillFrom(uchar* buf, int* base, off_t len, SISFile* file); - - uint32 m_uid; - uint16 m_major; - uint16 m_minor; - uint32 m_variant; - uint32* m_nameLengths; - uint32* m_namePtrs; + SisRC fillFrom(uint8_t* buf, int* base, off_t len, SISFile* file); + + uint32_t m_uid; + uint16_t m_major; + uint16_t m_minor; + uint32_t m_variant; + uint32_t* m_nameLengths; + uint32_t* m_namePtrs; }; #endif diff --git a/lib/sistypes.cpp b/lib/sistypes.cpp index 2dd8b61..2777b20 100644 --- a/lib/sistypes.cpp +++ b/lib/sistypes.cpp @@ -40,33 +40,33 @@ void createCRCTable() } } -uint16 updateCrc(uint16 crc, uchar value) +uint16_t updateCrc(uint16_t crc, uint8_t value) { return (crc << 8) ^ s_crcTable[((crc >> 8) ^ value) & 0xff]; } -uint16 calcCRC(uchar* data, int len) +uint16_t calcCRC(uint8_t* data, int len) { - uint16 crc = 0; + uint16_t crc = 0; for (int i = 0; i < len; ++i) { - uchar value = data[i]; + uint8_t value = data[i]; crc = (crc << 8) ^ s_crcTable[((crc >> 8) ^ value) & 0xff]; } return crc; } -uint16 read16(uchar* p) +uint16_t read16(uint8_t* p) { return p[0] | (p[1] << 8); } -uint32 read32(uchar* p) +uint32_t read32(uint8_t* p) { return p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24); } -void write16(uchar* p, int val) +void write16(uint8_t* p, int val) { p[0] = val & 255; p[1] = (val >> 8) & 255; diff --git a/lib/sistypes.h b/lib/sistypes.h index c763c4f..12f237b 100644 --- a/lib/sistypes.h +++ b/lib/sistypes.h @@ -1,4 +1,4 @@ -/** -*-c++-*- +/* -*-c++-*- * $Id$ * * This file is part of plptools. @@ -23,9 +23,7 @@ #ifndef _SISTYPES_H #define _SISTYPES_H -typedef unsigned short uint16; -typedef unsigned int uint32; -typedef unsigned char uchar; +#include "plp_inttypes.h" /** * Return Codes. @@ -36,15 +34,15 @@ enum SisRC { SIS_CORRUPTED, }; -extern uint16 read16(uchar* p); +extern uint16_t read16(uint8_t* p); -extern uint32 read32(uchar* p); +extern uint32_t read32(uint8_t* p); -extern void write16(uchar* p, int val); +extern void write16(uint8_t* p, int val); extern void createCRCTable(); -extern uint16 updateCrc(uint16 crc, uchar value); +extern uint16_t updateCrc(uint16_t crc, uint8_t value); extern int logLevel; @@ -54,7 +52,7 @@ extern int logLevel; */ struct LangTableEntry { - uint16 m_no; + uint16_t m_no; char m_code[3]; char* m_name; }; |