1//========================================================================
2//
3// FoFiBase.h
4//
5// Copyright 1999-2003 Glyph & Cog, LLC
6//
7//========================================================================
8
9//========================================================================
10//
11// Modified under the Poppler project - http://poppler.freedesktop.org
12//
13// All changes made under the Poppler project to this file are licensed
14// under GPL version 2 or later
15//
16// Copyright (C) 2018, 2022 Albert Astals Cid <aacid@kde.org>
17// Copyright (C) 2022 Oliver Sander <oliver.sander@tu-dresden.de>
18//
19// To see a description of the changes please see the Changelog file that
20// came with your tarball or type make ChangeLog if you are building from git
21//
22//========================================================================
23
24#ifndef FOFIBASE_H
25#define FOFIBASE_H
26
27//------------------------------------------------------------------------
28
29using FoFiOutputFunc = void (*)(void *stream, const char *data, size_t len);
30
31//------------------------------------------------------------------------
32// FoFiBase
33//------------------------------------------------------------------------
34
35class POPPLER_PRIVATE_EXPORT FoFiBase
36{
37public:
38 FoFiBase(const FoFiBase &) = delete;
39 FoFiBase &operator=(const FoFiBase &other) = delete;
40
41 virtual ~FoFiBase();
42
43protected:
44 FoFiBase(const unsigned char *fileA, int lenA, bool freeFileDataA);
45 static char *readFile(const char *fileName, int *fileLen);
46
47 // S = signed / U = unsigned
48 // 8/16/32/Var = word length, in bytes
49 // BE = big endian
50 int getS8(int pos, bool *ok) const;
51 int getU8(int pos, bool *ok) const;
52 int getS16BE(int pos, bool *ok) const;
53 int getU16BE(int pos, bool *ok) const;
54 int getS32BE(int pos, bool *ok) const;
55 unsigned int getU32BE(int pos, bool *ok) const;
56 unsigned int getU32LE(int pos, bool *ok) const;
57 unsigned int getUVarBE(int pos, int size, bool *ok) const;
58
59 bool checkRegion(int pos, int size) const;
60
61 const unsigned char *file;
62 int len;
63 bool freeFileData;
64};
65
66#endif
67

source code of poppler/fofi/FoFiBase.h