forked from HACKERCHANNEL/benzin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
150 lines (133 loc) · 3.78 KB
/
main.c
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
/******************************************************************************
* main.c *
* Part of Benzin *
* The main stuff. *
* Copyright (C)2009 SquidMan (Alex Marshall) <[email protected]> *
* Copyright (C)2009 megazig (Stephen Simpson) <[email protected]> *
* Copyright (C)2009 Matt_P (Matthew Parlane) *
* Copyright (C)2009 comex *
* Copyright (C)2009 booto *
* All Rights Reserved, HACKERCHANNEL. *
******************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "brlan.h"
#include "brlyt.h"
#include "types.h"
#include "endian.h"
#include "general.h"
#ifdef DEBUGMAIN
#define dbgprintf printf
#else
#define dbgprintf //
#endif //DEBUGMAIN
int main(int argc, char* argv[])
{
u8 type = 3;
char *ext;
if (argc == 2)
{
if (strcmp(argv[1], "-v") == 0)
printf(INFORMATION_TEXT);
exit(0);
}
if (argc < 4)
{
printf("Benzin v2.1.11 mod01 BETA\n\n");
printf("Usage:\n");
printf("\n");
printf(" ./benzin <r|m> [FILE] [OUTFILE]\n");
printf("\n");
printf("Examples:\n");
printf(" ./benzin r brlytfilename.brlyt xmlytfilename.xmlyt\n");
printf(" ./benzin m xmlytfilename.xmlyt brlytfilename.brlyt\n");
printf(" ./benzin r brlytfilename.brlan xmlytfilename.xmlan\n");
printf(" ./benzin m brlytfilename.xmlan xmlytfilename.brlan\n");
exit(1);
}
if ((strcmp(argv[1], "r") == 0) || (strcmp(argv[1], "p") == 0) || (strcmp(argv[1], "m") == 0) || (strcmp(argv[1], "w") == 0))
{
ext = strrchr(argv[2], '.');
} else {
printf("Benzin v2.1.11 mod01 BETA\n\n");
printf("Usage:\n");
printf("\n");
printf(" ./benzin <r|m> [FILE] [OUTFILE]\n");
printf("\n");
printf("Examples:\n");
printf(" ./benzin r brlytfilename.brlyt xmlytfilename.xmlyt\n");
printf(" ./benzin m xmlytfilename.xmlyt brlytfilename.brlyt\n");
printf(" ./benzin r brlytfilename.brlan xmlytfilename.xmlan\n");
printf(" ./benzin m brlytfilename.xmlan xmlytfilename.brlan\n");
exit(1);
}
if(!ext)
{
printf("No extension on file\n");
printf("To see possible arguments type ./benzin\n");
exit(1);
} else {
char* temp = ext;
if(strcmp(++ext, "brlyt") == 0)
{
type = 1;
}
ext = temp;
if(strcmp(++ext, "brlan") == 0)
{
type = 2;
}
ext = temp;
if(strcmp(++ext, "xmlyt") == 0)
{
type = 1;
}
ext = temp;
if(strcmp(++ext, "xmlan") == 0)
{
type = 2;
}
if(type > 2)
{
printf("Unknown file extension\n");
exit(1);
}
}
int brlanargread;
int brlytargread;
int brlanargmake;
int brlytargmake;
int brlanargdestmake;
int brlytargdestmake;
int brlanargdestread;
int brlytargdestread;
int currentarg = 2;
if(type == 1)
{
brlytargread = currentarg;
brlytargmake = currentarg++;
brlytargdestread = currentarg;
brlytargdestmake = currentarg++;
}
if(type == 2)
{
brlanargread = currentarg;
brlanargmake = currentarg++;
brlanargdestread = currentarg;
brlanargdestmake = currentarg++;
}
printf(INFORMATION_TEXT);
if((argv[1][0] == 'r') || (argv[1][0] == 'p')) {
if(type == 1)
parse_brlyt(argv[brlytargread], argv[brlytargdestread]);
if(type == 2)
parse_brlan(argv[brlanargread], argv[brlanargdestread]);
} else if( (argv[1][0] == 'm') || (argv[1][0] == 'w') ) {
if(type == 1)
make_brlyt(argv[brlytargmake], argv[brlytargdestmake]);
if(type == 2)
make_brlan(argv[brlanargmake], argv[brlanargdestmake]);
}
return 0;
}