forked from zrax/pycdc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
data.h
61 lines (46 loc) · 1.17 KB
/
data.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#ifndef _PYC_FILE_H
#define _PYC_FILE_H
#include <cstdio>
#ifdef WIN32
typedef __int64 Pyc_INT64;
#else
typedef long long Pyc_INT64;
#endif
class PycData {
public:
PycData() { }
virtual ~PycData() { }
virtual bool isOpen() const = 0;
virtual bool atEof() const = 0;
virtual int getByte() = 0;
virtual int getBuffer(int bytes, void* buffer) = 0;
int get16();
int get32();
Pyc_INT64 get64();
};
class PycFile : public PycData {
public:
PycFile(const char* filename);
~PycFile() { if (m_stream) fclose(m_stream); }
bool isOpen() const { return (m_stream != 0); }
bool atEof() const;
int getByte();
int getBuffer(int bytes, void* buffer);
private:
FILE* m_stream;
};
class PycBuffer : public PycData {
public:
PycBuffer(const void* buffer, int size)
: m_buffer((const unsigned char*)buffer), m_size(size), m_pos(0) { }
~PycBuffer() { }
bool isOpen() const { return (m_buffer != 0); }
bool atEof() const { return (m_pos == m_size); }
int getByte();
int getBuffer(int bytes, void* buffer);
private:
const unsigned char* m_buffer;
int m_size, m_pos;
};
extern FILE* pyc_output;
#endif