summaryrefslogtreecommitdiff
path: root/noncore/unsupported/qpdf/gooStub.cpp
Unidiff
Diffstat (limited to 'noncore/unsupported/qpdf/gooStub.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/qpdf/gooStub.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/noncore/unsupported/qpdf/gooStub.cpp b/noncore/unsupported/qpdf/gooStub.cpp
index cc29685..edbea55 100644
--- a/noncore/unsupported/qpdf/gooStub.cpp
+++ b/noncore/unsupported/qpdf/gooStub.cpp
@@ -1,60 +1,60 @@
1 1
2extern "C" { 2extern "C" {
3 3
4#include <stdlib.h> 4#include <stdlib.h>
5#include <string.h> 5#include <string.h>
6#include <unistd.h> 6#include <unistd.h>
7#include <stdio.h> 7#include <stdio.h>
8#include <dirent.h> 8#include <dirent.h>
9#include <fcntl.h> 9#include <fcntl.h>
10 10
11#include <gmem.h> 11#include <gmem.h>
12} 12}
13 13
14#include <gfile.h> 14#include <gfile.h>
15#include <GString.h> 15#include <GString.h>
16 16
17#include <qdir.h> 17#include <qdir.h>
18 18
19 19
20// replacement stubs to simplify (and speed up) operations 20// replacement stubs to simplify (and speed up) operations
21 21
22void *gmalloc ( int size ) { return malloc ( size ); } 22void *gmalloc ( int size ) { return malloc ( size ); }
23void *grealloc ( void *p, int size ) { return realloc ( p, size ); } 23void *grealloc ( void *p, int size ) { return realloc ( p, size ); }
24void gfree ( void *p ) { free ( p ); } 24void gfree ( void *p ) { free ( p ); }
25char *copyString ( char *str ) { return strdup ( str ); } 25char *copyString ( char *str ) { return strdup ( str ); }
26char *getLine(char *buf, int size, FILE *f) { return fgets ( buf, size, f ); } 26char *getLine(char *buf, int size, FILE *f) { return fgets ( buf, size, f ); }
27GString *getHomeDir ( ) { return new GString ( QDir::home ( ). absPath ( ). local8Bit ( )); } 27GString *getHomeDir ( ) { return new GString ( QDir::home ( ). absPath ( ). local8Bit ( )); }
28GString *appendToPath ( GString *path, char *fileName ) { return new GString ( QDir ( path-> getCString ( )). absFilePath ( fileName ). local8Bit ( )); } 28GString *appendToPath ( GString *path, char *fileName ) { return new GString ( QDir ( path-> getCString ( )). absFilePath ( fileName ). local8Bit ( )); }
29 29
30// mostly taken from XPDF, but simplified... 30// mostly taken from XPDF, but simplified...
31 31
32GBool openTempFile ( GString **name, FILE **f, char *mode, char *ext ) 32GBool openTempFile ( GString **name, FILE **f, char *mode, char *ext )
33{ 33{
34 char *s, *p; 34 char *s, *p;
35 int fd; 35 int fd;
36 36
37 if ( !ext ) 37 if ( !ext )
38 ext = ".tmp"; 38 ext = ".tmp";
39 39
40 if (!( s = tmpnam ( 0 ))) 40 if (!( s = tmpnam ( 0 )))
41 return gFalse; 41 return gFalse;
42 42
43 *name = new GString ( "qpdf_" ); 43 *name = new GString ( s );
44 (*name)-> append ( s );
45 44
46 s = (*name)-> getCString ( ); 45 s = (*name)-> getCString ( );
47 if (( p = strrchr ( s, '.' ))) 46 if (( p = strrchr ( s, '.' )))
48 (*name)-> del ( p - s, (*name)-> getLength ( ) - ( p - s )); 47 (*name)-> del ( p - s, (*name)-> getLength ( ) - ( p - s ));
49 48
49 (*name)-> append ( "_qpdf" );
50 (*name)-> append ( ext ); 50 (*name)-> append ( ext );
51 51
52 fd = open ((*name)-> getCString ( ), O_WRONLY | O_CREAT | O_EXCL, 0600 ); 52 fd = open ((*name)-> getCString ( ), O_WRONLY | O_CREAT | O_EXCL, 0600 );
53 53
54 if ( fd < 0 || !( *f = fdopen ( fd, mode ))) { 54 if ( fd < 0 || !( *f = fdopen ( fd, mode ))) {
55 delete *name; 55 delete *name;
56 return gFalse; 56 return gFalse;
57 } 57 }
58 58
59 return gTrue; 59 return gTrue;
60} 60}