From 8dc3f3755b15494426d6f044084ab45a4fea2922 Mon Sep 17 00:00:00 2001 From: Michael Meeks Date: Sun, 15 Aug 1999 21:09:14 +0000 Subject: [PATCH] files I forgot ... doh. --- pdf/xpdf/BaseFile.h | 87 ++++++++++++++++++++++++++++++++++++++++ pdf/xpdf/BonoboFile.cc | 90 ++++++++++++++++++++++++++++++++++++++++++ pdf/xpdf/BonoboFile.h | 30 ++++++++++++++ 3 files changed, 207 insertions(+) create mode 100644 pdf/xpdf/BaseFile.h create mode 100644 pdf/xpdf/BonoboFile.cc create mode 100644 pdf/xpdf/BonoboFile.h diff --git a/pdf/xpdf/BaseFile.h b/pdf/xpdf/BaseFile.h new file mode 100644 index 00000000..c596b428 --- /dev/null +++ b/pdf/xpdf/BaseFile.h @@ -0,0 +1,87 @@ +//======================================================================== +// +// BaseFile.h +// +// Copyright 1999 Derek B. Noonburg assigned by Michael Meeks. +// +//======================================================================== + +#ifndef BASEFILE_H +#define BASEFILE_H + +#include +#include + +#include "Error.h" + +//#ifdef BONOBO_IO +# include "BonoboFile.h" +/*#else + +typedef FILE * BaseFile; + +static inline BaseFile +bxpdfopen (GString *fileName1) +{ + GString *fileName2; + // try to open file + fileName2 = NULL; + BaseFile file; + +#ifdef VMS + if (!(file = fopen(fileName->getCString(), "rb", "ctx=stm"))) { + error(-1, "Couldn't open file '%s'", fileName->getCString()); + return NULL; + } +#else + if (!(file = fopen(fileName1->getCString(), "rb"))) { + fileName2 = fileName1->copy(); + fileName2->lowerCase(); + if (!(file = fopen(fileName2->getCString(), "rb"))) { + fileName2->upperCase(); + if (!(file = fopen(fileName2->getCString(), "rb"))) { + error(-1, "Couldn't open file '%s'", fileName1->getCString()); + delete fileName2; + return NULL; + } + } + delete fileName2; + } +#endif + return file; +} + +static inline void +bfclose (BaseFile file) +{ + fclose (file); +} + +static inline size_t +bfread (void *ptr, size_t size, size_t nmemb, BaseFile file) +{ + return fread (ptr, size, nmemb, file); +} + +static inline int +bfseek (BaseFile file, long offset, int whence) +{ + return fseek (file, offset, whence); +} + +static inline void +brewind (BaseFile file) +{ + rewind (file); +} + +static inline long +bftell (BaseFile file) +{ + return ftell (file); +}*/ + +//#endif /* BONOBO_IO not defined */ +#endif /* BASEFILE_H */ + + diff --git a/pdf/xpdf/BonoboFile.cc b/pdf/xpdf/BonoboFile.cc new file mode 100644 index 00000000..fd724d0e --- /dev/null +++ b/pdf/xpdf/BonoboFile.cc @@ -0,0 +1,90 @@ +//======================================================================== +// +// BonoboFile.cc +// +// Copyright 1999 Derek B. Noonburg assigned by Michael Meeks. +// +//======================================================================== + +#ifdef __GNUC__ +#pragma implementation +#endif + +#include +#include +#include +#ifndef WIN32 +#include +#endif +#include +#include + +#include "BaseFile.h" + +//#define HARD_DEBUG + +/* The open/close is done for you by the Bonobo server */ + +void +bfclose (BaseFile file) +{ +} + +size_t +bfread (void *ptr, size_t size, size_t nmemb, BaseFile file) +{ + CORBA_long len; + CORBA_Environment ev; + GNOME_Stream_iobuf *buffer = NULL; + + g_return_val_if_fail (ptr != NULL, 0); + +#ifdef HARD_DEBUG + printf ("read %p %d %d to %p\n", file, size, nmemb, ptr); +#endif + len = GNOME_Stream_read (file, size*nmemb, &buffer, &ev); + g_return_val_if_fail (ev._major == CORBA_NO_EXCEPTION, 0); + +#ifdef HARD_DEBUG + printf ("Read %d bytes %p %d\n", len, buffer->_buffer, buffer->_length); +#endif + memcpy (ptr, buffer->_buffer, buffer->_length); + + return len; +} + +int +bfseek (BaseFile file, long offset, int whence) +{ + CORBA_Environment ev; +#ifdef HARD_DEBUG + printf ("Seek %p %d %d\n", file, offset, whence); +#endif + return GNOME_Stream_seek (file, offset, whence, &ev); +} + +void +brewind (BaseFile file) +{ + CORBA_Environment ev; +#ifdef HARD_DEBUG + printf ("rewind %p\n", file); +#endif + GNOME_Stream_seek (file, 0, SEEK_SET, &ev); +} + +long +bftell (BaseFile file) +{ + CORBA_Environment ev; + CORBA_long pos; +#ifdef HARD_DEBUG + printf ("tell %p\n", file); +#endif + pos = GNOME_Stream_seek (file, 0, SEEK_CUR, &ev); +#ifdef HARD_DEBUG + printf ("tell returns %d\n", pos); +#endif + + return pos; +} diff --git a/pdf/xpdf/BonoboFile.h b/pdf/xpdf/BonoboFile.h new file mode 100644 index 00000000..d834d044 --- /dev/null +++ b/pdf/xpdf/BonoboFile.h @@ -0,0 +1,30 @@ +//======================================================================== +// +// BonoboFile.h +// +// Copyright 1999 Derek B. Noonburg assigned by Michael Meeks. +// +//======================================================================== + +#ifndef BONOBOFILE_H +#define BONOBOFILE_H + +extern "C" { +#define GString G_String +#include +#include +#include +#undef GString +} + +typedef GNOME_Stream BaseFile; + +/* The open/close is done for you by the Bonobo server */ + +extern void bfclose (BaseFile file); +extern size_t bfread (void *ptr, size_t size, size_t nmemb, BaseFile file); +extern int bfseek (BaseFile file, long offset, int whence); +extern void brewind (BaseFile file); +extern long bftell (BaseFile file); + +#endif /* BONOBOFILE_H */ -- 2.43.5