aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/plpdirent.cc28
-rw-r--r--lib/plpdirent.h22
-rw-r--r--lib/psitime.cc14
-rw-r--r--lib/psitime.h19
4 files changed, 52 insertions, 31 deletions
diff --git a/lib/plpdirent.cc b/lib/plpdirent.cc
index d78260c..fa97232 100644
--- a/lib/plpdirent.cc
+++ b/lib/plpdirent.cc
@@ -3,7 +3,6 @@
*
* This file is part of plptools.
*
- * Copyright (C) 1999 Philip Proudman <philip.proudman@btinternet.com>
* Copyright (C) 1999-2001 Fritz Elfert <felfert@to.com>
*
* This program is free software; you can redistribute it and/or modify
@@ -21,7 +20,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
-#include <plpdirent.h>
+#include "plpdirent.h"
#include <stream.h>
#include <iomanip>
@@ -29,16 +28,20 @@ PlpUID::PlpUID() {
memset(uid, 0, sizeof(uid));
}
-PlpUID::PlpUID(const long u1, const long u2, const long u3) {
+PlpUID::PlpUID(const u_int32_t u1, const u_int32_t u2, const u_int32_t u3) {
uid[0] = u1; uid[1] = u2; uid[2] = u3;
}
-long PlpUID::
+u_int32_t PlpUID::
operator[](int idx) {
assert ((idx > -1) && (idx < 3));
return uid[idx];
}
+PlpDirent::PlpDirent()
+ : size(0), attr(0), name(""), time(0L), attrstr("") {
+}
+
PlpDirent::PlpDirent(const PlpDirent &e) {
size = e.size;
attr = e.attr;
@@ -48,17 +51,28 @@ PlpDirent::PlpDirent(const PlpDirent &e) {
attrstr = e.attrstr;
}
-long PlpDirent::
+PlpDirent::PlpDirent(const u_int32_t _size, const u_int32_t _attr,
+ const u_int32_t tHi, const u_int32_t tLo,
+ const char * const _name) {
+ size = _size;
+ attr = _attr;
+ time = PsiTime(tHi, tLo);
+ UID = PlpUID();
+ name = _name;
+ attrstr = "";
+}
+
+u_int32_t PlpDirent::
getSize() {
return size;
}
-long PlpDirent::
+u_int32_t PlpDirent::
getAttr() {
return attr;
}
-long PlpDirent::
+u_int32_t PlpDirent::
getUID(int uididx) {
if ((uididx >= 0) && (uididx < 4))
return UID[uididx];
diff --git a/lib/plpdirent.h b/lib/plpdirent.h
index 3c9fb40..9224ebe 100644
--- a/lib/plpdirent.h
+++ b/lib/plpdirent.h
@@ -49,7 +49,7 @@ public:
* Constructor.
* Create an instance, presetting all thre uid values.
*/
- PlpUID(const long u1, const long u2, const long u3);
+ PlpUID(const u_int32_t u1, const u_int32_t u2, const u_int32_t u3);
/**
* Retrieve a UID value.
@@ -57,7 +57,7 @@ public:
* @param idx The index of the desired UID. Range must be (0..2),
* otherwise an assertion is triggered.
*/
- long operator[](int idx);
+ u_int32_t operator[](int idx);
private:
long uid[3];
@@ -83,7 +83,7 @@ public:
/**
* Default constructor
*/
- PlpDirent() : size(0), attr(0), name(""), time(0L), attrstr("") { };
+ PlpDirent();
/**
* A copy constructor.
@@ -94,6 +94,12 @@ public:
PlpDirent(const PlpDirent &d);
/**
+ * Initializing Constructor
+ */
+ PlpDirent(const u_int32_t size, const u_int32_t attr, const u_int32_t tHi,
+ const u_int32_t tLo, const char * const name);
+
+ /**
* Default destructor.
*/
~PlpDirent() {};
@@ -103,14 +109,14 @@ public:
*
* @returns The file size in bytes.
*/
- long getSize();
+ u_int32_t getSize();
/**
* Retrieves the file attributes of a directory entry.
*
* @returns The generic attributes ( @ref rfsv:file_attribs ).
*/
- long getAttr();
+ u_int32_t getAttr();
/**
* Retrieves the UIDs of a directory entry.
@@ -120,7 +126,7 @@ public:
*
* @returns The selected UID or 0 if the index is out of range.
*/
- long getUID(int uididx);
+ u_int32_t getUID(int uididx);
/**
* Retrieves the @ref PlpUID object of a directory entry.
@@ -172,8 +178,8 @@ public:
friend ostream &operator<<(ostream &o, const PlpDirent &e);
private:
- long size;
- long attr;
+ u_int32_t size;
+ u_int32_t attr;
PlpUID UID;
PsiTime time;
string attrstr;
diff --git a/lib/psitime.cc b/lib/psitime.cc
index f239fe6..e776ab9 100644
--- a/lib/psitime.cc
+++ b/lib/psitime.cc
@@ -50,7 +50,7 @@ PsiTime::PsiTime(psi_timeval *_ptv, psi_timezone *_ptz) {
psi2unix();
}
-PsiTime::PsiTime(const unsigned long _ptvHi, const unsigned long _ptvLo) {
+PsiTime::PsiTime(const u_int32_t _ptvHi, const u_int32_t _ptvLo) {
ptv.tv_high = _ptvHi;
ptv.tv_low = _ptvLo;
ptzValid = false;
@@ -106,7 +106,7 @@ void PsiTime::setPsiTime(psi_timeval *_ptv) {
psi2unix();
}
-void PsiTime::setPsiTime(const unsigned long _ptvHi, const unsigned long _ptvLo) {
+void PsiTime::setPsiTime(const u_int32_t _ptvHi, const u_int32_t _ptvLo) {
ptv.tv_high = _ptvHi;
ptv.tv_low = _ptvLo;
psi2unix();
@@ -132,11 +132,11 @@ psi_timeval &PsiTime::getPsiTimeval(void) {
return ptv;
}
-const unsigned long PsiTime::getPsiTimeLo(void) {
+const u_int32_t PsiTime::getPsiTimeLo(void) {
return ptv.tv_low;
}
-const unsigned long PsiTime::getPsiTimeHi(void) {
+const u_int32_t PsiTime::getPsiTimeHi(void) {
return ptv.tv_high;
}
@@ -168,7 +168,7 @@ ostream &operator<<(ostream &s, const PsiTime &t) {
static unsigned long long
evalOffset(psi_timezone ptz, time_t time, bool valid) {
- unsigned long long offset = 0;
+ u_int64_t offset = 0;
if (valid) {
offset = ptz.utc_offset;
@@ -204,7 +204,7 @@ evalOffset(psi_timezone ptz, time_t time, bool valid) {
}
void PsiTime::psi2unix(void) {
- unsigned long long micro = ptv.tv_high;
+ u_int64_t micro = ptv.tv_high;
micro = (micro << 32) | ptv.tv_low;
/* Substract Psion's idea of UTC offset */
@@ -216,7 +216,7 @@ void PsiTime::psi2unix(void) {
}
void PsiTime::unix2psi(void) {
- unsigned long long micro = utv.tv_sec * 1000000 + utv.tv_usec;
+ u_int64_t micro = utv.tv_sec * 1000000 + utv.tv_usec;
/* Add Psion's idea of UTC offset */
micro += evalOffset(ptz, utv.tv_sec, ptzValid);
diff --git a/lib/psitime.h b/lib/psitime.h
index a6c4f4f..bf5b3cb 100644
--- a/lib/psitime.h
+++ b/lib/psitime.h
@@ -29,6 +29,7 @@
#include <sys/time.h>
#include <unistd.h>
+#include <sys/types.h>
#include <ostream.h>
#include <intl.h>
@@ -45,7 +46,7 @@ typedef struct psi_timeval_t {
*/
friend ostream &operator<<(ostream &o, const psi_timeval_t &ptv) {
ostream::fmtflags old = o.flags();
- unsigned long long micro = ptv.tv_high;
+ u_int64_t micro = ptv.tv_high;
micro = (micro << 32) | ptv.tv_low;
micro /= 1000000;
int s = micro % 60;
@@ -73,11 +74,11 @@ typedef struct psi_timeval_t {
/**
* The lower 32 bits
*/
- unsigned long tv_low;
+ u_int32_t tv_low;
/**
* The upper 32 bits
*/
- unsigned long tv_high;
+ u_int32_t tv_high;
} psi_timeval;
/**
@@ -151,10 +152,10 @@ public:
/**
* Contructs a new instance.
*
- * @param _ptvHi The high 16 bits of a Psion time value for initialization.
- * @param _ptvLo The low 16 bits of a Psion time value for initialization.
+ * @param _ptvHi The high 32 bits of a Psion time value for initialization.
+ * @param _ptvLo The low 32 bits of a Psion time value for initialization.
*/
- PsiTime(const unsigned long _ptvHi, const unsigned long _ptvLo);
+ PsiTime(const u_int32_t _ptvHi, const u_int32_t _ptvLo);
/**
* Constructs a new instance, initializing to now.
@@ -184,7 +185,7 @@ public:
* @param _ptvHi The high 32 bits of a Psion time.
* @param _ptvLo The low 32 bits of a Psion time.
*/
- void setPsiTime(const unsigned long _ptvHi, const unsigned long _ptvLo);
+ void setPsiTime(const u_int32_t _ptvHi, const u_int32_t _ptvLo);
/**
* Sets the Psion time zone of this instance.
@@ -244,7 +245,7 @@ public:
* @returns The instance's current time as lower 32 bits of
* a Psion struct psi_timeval_t.
*/
- const unsigned long getPsiTimeLo(void);
+ const u_int32_t getPsiTimeLo(void);
/**
* Retrieves the instance's current value
@@ -253,7 +254,7 @@ public:
* @returns The instance's current time as upper 32 bits of
* a Psion struct psi_timeval_t.
*/
- const unsigned long getPsiTimeHi(void);
+ const u_int32_t getPsiTimeHi(void);
/**
* Prints the instance's value in human readable format.