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