]>
git.ipfire.org Git - thirdparty/cups.git/blob - pdftops/FoFiBase.cxx
1 //========================================================================
5 // Copyright 1999-2003 Glyph & Cog, LLC
7 //========================================================================
11 #ifdef USE_GCC_PRAGMAS
12 #pragma implementation
19 //------------------------------------------------------------------------
21 //------------------------------------------------------------------------
23 FoFiBase::FoFiBase(char *fileA
, int lenA
, GBool freeFileDataA
) {
24 fileData
= file
= (Guchar
*)fileA
;
26 freeFileData
= freeFileDataA
;
29 FoFiBase::~FoFiBase() {
35 char *FoFiBase::readFile(char *fileName
, int *fileLen
) {
40 if (!(f
= fopen(fileName
, "rb"))) {
43 fseek(f
, 0, SEEK_END
);
45 fseek(f
, 0, SEEK_SET
);
46 buf
= (char *)gmalloc(n
);
47 if ((int)fread(buf
, 1, n
, f
) != n
) {
57 int FoFiBase::getS8(int pos
, GBool
*ok
) {
60 if (pos
< 0 || pos
>= len
) {
71 int FoFiBase::getU8(int pos
, GBool
*ok
) {
72 if (pos
< 0 || pos
>= len
) {
79 int FoFiBase::getS16BE(int pos
, GBool
*ok
) {
82 if (pos
< 0 || pos
+1 >= len
) {
87 x
= (x
<< 8) + file
[pos
+1];
94 int FoFiBase::getU16BE(int pos
, GBool
*ok
) {
97 if (pos
< 0 || pos
+1 >= len
) {
102 x
= (x
<< 8) + file
[pos
+1];
106 int FoFiBase::getS32BE(int pos
, GBool
*ok
) {
109 if (pos
< 0 || pos
+3 >= len
) {
114 x
= (x
<< 8) + file
[pos
+1];
115 x
= (x
<< 8) + file
[pos
+2];
116 x
= (x
<< 8) + file
[pos
+3];
117 if (x
& 0x80000000) {
123 Guint
FoFiBase::getU32BE(int pos
, GBool
*ok
) {
126 if (pos
< 0 || pos
+3 >= len
) {
131 x
= (x
<< 8) + file
[pos
+1];
132 x
= (x
<< 8) + file
[pos
+2];
133 x
= (x
<< 8) + file
[pos
+3];
137 Guint
FoFiBase::getUVarBE(int pos
, int size
, GBool
*ok
) {
141 if (pos
< 0 || pos
+ size
> len
) {
146 for (i
= 0; i
< size
; ++i
) {
147 x
= (x
<< 8) + file
[pos
+ i
];
152 GBool
FoFiBase::checkRegion(int pos
, int size
) {