-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclass.h
76 lines (52 loc) · 1.47 KB
/
class.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#ifndef _CLASS_H_
#define _CLASS_H_
#include <stdint.h>
typedef uint8_t u1;
typedef uint16_t u2;
typedef uint32_t u4;
typedef struct {
u1 tag;
u1 *info;
} cp_info;
typedef struct {
u2 test;
} attribute_info;
typedef struct {
u2 access_flags;
u2 name_index;
u2 descriptor_index;
u2 attributes_count;
} field_info;
typedef struct {
uint8_t test;
} method_info;
#define CLASS_MAGIC 0xCAFEBABE
typedef struct {
u4 magic;
u2 minor_version;
u2 major_version;
u2 constant_pool_count;
cp_info *constant_pool;
u2 access_flags;
u2 this_class;
u2 super_class;
u2 interfaces_count;
u2 *interfaces;
u2 fields_count;
field_info *fields;
u2 methods_count;
method_info *methods;
u2 attributes_count;
attribute_info *attributes;
} ClassFile;
/* Internal errors. */
#define CLASS_OK 0x000
#define CLASS_ERROR_SUCCESS 0x000
#define CLASS_ERROR_BADMAGIC 0x201
#define CLASS_ERROR_ENOENT 0x202
#define CLASS_ERROR_IOFAIL 0x203
#define CLASS_ERROR_NOMEM 0x204
#define CLASS_ERROR_DEBUG 0x210
extern void jclass_free(ClassFile *class);
extern int jclass_read(const char *path, ClassFile **class);
#endif /* _CLASS_H_ */