aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDaniel Brahneborg <basic@chello.se>2002-03-08 19:44:37 +0000
committerDaniel Brahneborg <basic@chello.se>2002-03-08 19:44:37 +0000
commit7378f5ddf46ef0317343ad310d703c4f4ff8d703 (patch)
tree5bdaf343a46d73c43dadc319d2806454097f6464 /lib
parent0f623548115340cf5f2d39abf9098bf27b822b68 (diff)
downloadplptools-7378f5ddf46ef0317343ad310d703c4f4ff8d703.tar.gz
plptools-7378f5ddf46ef0317343ad310d703c4f4ff8d703.tar.bz2
plptools-7378f5ddf46ef0317343ad310d703c4f4ff8d703.zip
Initial stuff for checking requisites and previous versions.
Diffstat (limited to 'lib')
-rw-r--r--lib/sisfile.cpp6
-rw-r--r--lib/sisfile.h13
-rw-r--r--lib/sisfileheader.cpp16
-rw-r--r--lib/sisfileheader.h5
-rw-r--r--lib/sistypes.h6
5 files changed, 46 insertions, 0 deletions
diff --git a/lib/sisfile.cpp b/lib/sisfile.cpp
index ec8adb8..634266f 100644
--- a/lib/sisfile.cpp
+++ b/lib/sisfile.cpp
@@ -28,6 +28,12 @@
#include <stdio.h>
SisRC
+SISFile::compareApp(SISFile* other)
+{
+ return m_header.compareApp(&other->m_header);
+}
+
+SisRC
SISFile::fillFrom(uint8_t* buf, off_t len)
{
int ix = 0;
diff --git a/lib/sisfile.h b/lib/sisfile.h
index cae00ee..2bfcea5 100644
--- a/lib/sisfile.h
+++ b/lib/sisfile.h
@@ -38,6 +38,14 @@ class SISReqRecord;
class SISFile
{
public:
+
+ /**
+ * Compare uid and version number of this file, with another.
+ *
+ * @see SISFileHeader::compareApp()
+ */
+ SisRC compareApp(SISFile* other);
+
/**
* Populate the fields.
*
@@ -63,6 +71,11 @@ public:
uint8_t* getName();
/**
+ * Is this the same application?
+ */
+ bool sameApp(SISFile* other);
+
+ /**
* Set the installed drive.
*/
void setDrive(char drive);
diff --git a/lib/sisfileheader.cpp b/lib/sisfileheader.cpp
index 19724c3..97e0687 100644
--- a/lib/sisfileheader.cpp
+++ b/lib/sisfileheader.cpp
@@ -29,6 +29,22 @@ const int OFF_NUMBER_OF_FILES = 26;
const int OFF_INSTALLATION_DRIVE = 28;
SisRC
+SISFileHeader::compareApp(SISFileHeader* other)
+{
+ if (m_uid1 != other->m_uid1)
+ return SIS_DIFFERENT_APP;
+ if ((m_major < other->m_major) ||
+ ((m_major == other->m_major) &&
+ (m_minor < other->m_minor)))
+ return SIS_VER_EARLIER;
+ if ((m_major == other->m_major) &&
+ (m_minor == other->m_minor) &&
+ (m_variant != other->m_variant))
+ return SIS_OTHER_VARIANT;
+ return SIS_SAME_OR_LATER;
+}
+
+SisRC
SISFileHeader::fillFrom(uint8_t* buf, int* base, off_t len)
{
if (*base + 68 > len)
diff --git a/lib/sisfileheader.h b/lib/sisfileheader.h
index 6b5fa3f..0c2d635 100644
--- a/lib/sisfileheader.h
+++ b/lib/sisfileheader.h
@@ -36,6 +36,11 @@ class SISFileHeader
public:
/**
+ * Compare uid and version number of this file, with another.
+ */
+ SisRC compareApp(SISFileHeader* other);
+
+ /**
* Populate the fields.
*
* @param buf The buffer to read from.
diff --git a/lib/sistypes.h b/lib/sistypes.h
index 12f237b..a5d008f 100644
--- a/lib/sistypes.h
+++ b/lib/sistypes.h
@@ -32,6 +32,12 @@ enum SisRC {
SIS_OK = 0,
SIS_TRUNCATED,
SIS_CORRUPTED,
+ SIS_FAILED,
+ SIS_ABORTED,
+ SIS_DIFFERENT_APP,
+ SIS_VER_EARLIER,
+ SIS_SAME_OR_LATER,
+ SIS_OTHER_VARIANT,
};
extern uint16_t read16(uint8_t* p);