summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-reader/ZText.h
authorgroucho <groucho>2003-05-07 09:01:39 (UTC)
committer groucho <groucho>2003-05-07 09:01:39 (UTC)
commit118d03d815a7615b9c53363218a7ac45b3f4c514 (patch) (side-by-side diff)
tree356953e2413cddcec0f35bd47bb6439767da7051 /noncore/apps/opie-reader/ZText.h
parent00894537decf01c5a5cdc565b2740b5e67a2e90f (diff)
downloadopie-118d03d815a7615b9c53363218a7ac45b3f4c514.zip
opie-118d03d815a7615b9c53363218a7ac45b3f4c514.tar.gz
opie-118d03d815a7615b9c53363218a7ac45b3f4c514.tar.bz2
Incorporated TimWs current source tree and make it compile
Diffstat (limited to 'noncore/apps/opie-reader/ZText.h') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-reader/ZText.h45
1 files changed, 31 insertions, 14 deletions
diff --git a/noncore/apps/opie-reader/ZText.h b/noncore/apps/opie-reader/ZText.h
index 22d3733..ab81a5e 100644
--- a/noncore/apps/opie-reader/ZText.h
+++ b/noncore/apps/opie-reader/ZText.h
@@ -1,25 +1,28 @@
#ifndef __Text_h
#define __Text_h
#include <stdio.h>
-#include "zlib/zlib.h"
+#include <zlib.h>
#include <sys/stat.h>
-
+#include "useqpe.h"
#include "CExpander.h"
class Text: public CExpander {
gzFile file;
unsigned long fsize;
public:
- virtual void suspend()
- {
+ void suspend()
+ {
+#ifdef USEQPE
bSuspended = true;
suspos = gztell(file);
gzclose(file);
file = NULL;
- sustime = time(NULL);
+ sustime = time(NULL);
+#endif
}
- virtual void unsuspend()
+ void unsuspend()
{
+#ifdef USEQPE
if (bSuspended)
{
bSuspended = false;
@@ -37,14 +40,15 @@ public:
exit(0);
}
suspos = gzseek(file, suspos, SEEK_SET);
- }
+ }
+#endif
}
Text() : file(NULL) {};
virtual ~Text()
{
if (file != NULL) gzclose(file);
}
- virtual int OpenFile(const char *src)
+ int OpenFile(const char *src)
{
if (file != NULL) gzclose(file);
struct stat _stat;
@@ -52,15 +56,28 @@ public:
fsize = _stat.st_size;
return ((file = gzopen(src,"rb")) == NULL);
}
- virtual int getch() { return gzgetc(file); }
- virtual unsigned int locate() { return gztell(file); }
- virtual void locate(unsigned int n) { gzseek(file,n,SEEK_SET); }
- virtual bool hasrandomaccess() { return true; }
- virtual void sizes(unsigned long& _file, unsigned long& _text)
+ int getch() { return gzgetc(file); }
+ unsigned int locate() { return gztell(file); }
+ void locate(unsigned int n) { gzseek(file,n,SEEK_SET); }
+ bool hasrandomaccess() { return true; }
+ void sizes(unsigned long& _file, unsigned long& _text)
{
_text = _file = fsize;
+ FILE* f = fopen(fname, "rb");
+ if (f != NULL)
+ {
+ unsigned char mn[2];
+ fread(mn, 1, 2, f);
+ if ((mn[0] == 31) && (mn[1] == 139))
+ {
+ int tmp = sizeof(_text);
+ fseek(f,-tmp,SEEK_END);
+ fread(&_text, sizeof(_text), 1, f);
+ }
+ fclose(f);
+ }
}
- virtual MarkupType PreferredMarkup()
+ MarkupType PreferredMarkup()
{
return cTEXT;
}