]> www.fi.muni.cz Git - evince.git/blobdiff - pdf/goo/gfile.h
Fix for a number of integer overflow bugs discovered by Chris Evans.
[evince.git] / pdf / goo / gfile.h
index bb4dbe095464cb4c2ddcc7b3a8759335e2aa41a3..d364d8d44f82d2c0781a990db77ebd715ff8538d 100644 (file)
@@ -4,23 +4,27 @@
 //
 // Miscellaneous file and directory name manipulation.
 //
 //
 // Miscellaneous file and directory name manipulation.
 //
-// Copyright 1996 Derek B. Noonburg
+// Copyright 1996-2003 Glyph & Cog, LLC
 //
 //========================================================================
 
 #ifndef GFILE_H
 #define GFILE_H
 
 //
 //========================================================================
 
 #ifndef GFILE_H
 #define GFILE_H
 
-extern "C" {
+#include <stdio.h>
 #include <stdlib.h>
 #include <stddef.h>
 #include <stdlib.h>
 #include <stddef.h>
+extern "C" {
 #if defined(WIN32)
 #if defined(WIN32)
-#  ifdef _MSC_VER
-#    include <windows.h>
+#  include <sys/stat.h>
+#  ifdef FPTEX
+#    include <win32lib.h>
 #  else
 #  else
-#    include <kpathsea/win32lib.h>
+#    include <windows.h>
 #  endif
 #elif defined(ACORN)
 #  endif
 #elif defined(ACORN)
+#elif defined(MACOS)
+#  include <ctime.h>
 #else
 #  include <unistd.h>
 #  include <sys/types.h>
 #else
 #  include <unistd.h>
 #  include <sys/types.h>
@@ -28,10 +32,10 @@ extern "C" {
 #    include "vms_dirent.h"
 #  elif HAVE_DIRENT_H
 #    include <dirent.h>
 #    include "vms_dirent.h"
 #  elif HAVE_DIRENT_H
 #    include <dirent.h>
-#    define NAMLEN(dirent) strlen((dirent)->d_name)
+#    define NAMLEN(d) strlen((d)->d_name)
 #  else
 #    define dirent direct
 #  else
 #    define dirent direct
-#    define NAMLEN(dirent) (dirent)->d_namlen
+#    define NAMLEN(d) (d)->d_namlen
 #    if HAVE_SYS_NDIR_H
 #      include <sys/ndir.h>
 #    endif
 #    if HAVE_SYS_NDIR_H
 #      include <sys/ndir.h>
 #    endif
@@ -69,7 +73,26 @@ extern GBool isAbsolutePath(char *path);
 
 // Make this path absolute by prepending current directory (if path is
 // relative) or prepending user's directory (if path starts with '~').
 
 // Make this path absolute by prepending current directory (if path is
 // relative) or prepending user's directory (if path starts with '~').
-GString *makePathAbsolute(GString *path);
+extern GString *makePathAbsolute(GString *path);
+
+// Get the modification time for <fileName>.  Returns 0 if there is an
+// error.
+extern time_t getModTime(char *fileName);
+
+// Create a temporary file and open it for writing.  If <ext> is not
+// NULL, it will be used as the file name extension.  Returns both the
+// name and the file pointer.  For security reasons, all writing
+// should be done to the returned file pointer; the file may be
+// reopened later for reading, but not for writing.  The <mode> string
+// should be "w" or "wb".  Returns true on success.
+extern GBool openTempFile(GString **name, FILE **f, char *mode, char *ext);
+
+// Execute <command>.  Returns true on success.
+extern GBool executeCommand(char *cmd);
+
+// Just like fgets, but handles Unix, Mac, and/or DOS end-of-line
+// conventions.
+extern char *getLine(char *buf, int size, FILE *f);
 
 //------------------------------------------------------------------------
 // GDir and GDirEntry
 
 //------------------------------------------------------------------------
 // GDir and GDirEntry
@@ -78,7 +101,7 @@ GString *makePathAbsolute(GString *path);
 class GDirEntry {
 public:
 
 class GDirEntry {
 public:
 
-  GDirEntry(char *dirPath, char *name1, GBool doStat);
+  GDirEntry(char *dirPath, char *nameA, GBool doStat);
   ~GDirEntry();
   GString *getName() { return name; }
   GBool isDir() { return dir; }
   ~GDirEntry();
   GString *getName() { return name; }
   GBool isDir() { return dir; }
@@ -92,7 +115,7 @@ private:
 class GDir {
 public:
 
 class GDir {
 public:
 
-  GDir(char *name, GBool doStat1 = gTrue);
+  GDir(char *name, GBool doStatA = gTrue);
   ~GDir();
   GDirEntry *getNextEntry();
   void rewind();
   ~GDir();
   GDirEntry *getNextEntry();
   void rewind();
@@ -105,6 +128,7 @@ private:
   WIN32_FIND_DATA ffd;
   HANDLE hnd;
 #elif defined(ACORN)
   WIN32_FIND_DATA ffd;
   HANDLE hnd;
 #elif defined(ACORN)
+#elif defined(MACOS)
 #else
   DIR *dir;                    // the DIR structure from opendir()
 #ifdef VMS
 #else
   DIR *dir;                    // the DIR structure from opendir()
 #ifdef VMS