include iostream include cstdio include cstring include errno include

 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
77
78
79
80
81
82
83
84
85
86
#include <iostream>
#include <cstdio>
#include <cstring>
#include <errno.h>
#include <unistd.h>
#include <zip.h>
#include <dirent.h>
#include <sys/types.h>
#include <sys/stat.h>
#define FILE_BUFFER_SIZE (1024 * 8)
#define MESSAGE_CONNECTION "javax/wireless/messaging/MessageConnection"
#define TEXT_MESSAGE "javax/wireless/messaging/TextMessage"
#define MIDLET "javax/microedition/midlet/MIDlet"
#define PLATFOM_REQUEST "platformRequest"
enum {
CONST_HACK_KEYWORD = 1,
CONST_HACK_REPLACED = 2,
CONST_HACK_NONE = 0
};
enum Errors {
E_OK = 0,
E_OK_CHANGED,
E_IO_ERROR,
E_CLASS_MAGIC,
E_UNKNOWN_CONST_TYPE,
E_OPEN_ZIP,
E_ZIP_STAT_FILE,
E_ZIP_OPEN_FILE,
E_ZIP_REPLACE_FILE,
E_ZIP_CREATE_SRC
};
enum ConstantType {
CONST_CLASS = 0x07,
CONST_FIELD_REF = 0x09,
CONST_METHOD_REF = 0x0a,
CONST_INTERFACE_METHOD_REF = 0x0b,
CONST_STRING = 0x08,
CONST_INTEGER = 0x03,
CONST_FLOAT = 0x04,
CONST_LONG = 0x05,
CONST_DOUBLE = 0x06,
CONST_NAME_AND_TYPE = 0x0c,
CONST_UTF8 = 0x01,
};
inline bool read_byte(void *i, FILE *fp) {
int ret = fread(i, sizeof(unsigned char), 1, fp);
return ret == 1;
}
inline bool read_int(void *i, FILE *fp) {
unsigned char tmp[4];
int ret = fread(tmp, sizeof(tmp), 1, fp);
if (ret == 1)
*((unsigned int *)i) = (tmp[0] << 24) | (tmp[1] << 16) | (tmp[2] << 8) | tmp[3];
return ret == 1;
}
inline bool read_long(void *i, FILE *fp) {
unsigned char tmp[8];
int ret = fread(tmp, sizeof(tmp), 1, fp);
if (ret == 1)
*((unsigned long *)i) =
(unsigned long) tmp[0] << 56 |
(unsigned long) tmp[1] << 48 |
(unsigned long) tmp[2] << 40 |
(unsigned long) tmp[3] << 32 |
(unsigned long) tmp[4] << 24 |
(unsigned long) tmp[5] << 16 |
(unsigned long) tmp[6] << 8 |
(unsigned long) tmp[7];
return ret == 1;
}
inline bool read_short(void *i, FILE *fp) {
unsigned char tmp[2];
int ret = fread(tmp, sizeof(tmp), 1, fp);
if (ret == 1)
*((unsigned short *)i) = (tmp[0] << 8) | tmp[1];
return ret == 1;
}