summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2011-12-03 09:39:11 +0000
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2011-12-03 09:39:11 +0000
commit07da9ce5ea9ca26436db04a63e281842467ff7fd (patch)
treeb2fdb351bb954d209259bb1ee19f6f2c8bbe03ea
parentbd691efae9e73d6e5a09c70246c9b1e2574b50be (diff)
downloadrockbox-07da9ce5ea9ca26436db04a63e281842467ff7fd.tar.gz
rockbox-07da9ce5ea9ca26436db04a63e281842467ff7fd.zip
Split up chinachippatcher.
Move the command line tool parts out for simpler building as library. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31114 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--rbutil/chinachippatcher/Makefile2
-rw-r--r--rbutil/chinachippatcher/chinachip.c51
-rw-r--r--rbutil/chinachippatcher/main.c72
3 files changed, 73 insertions, 52 deletions
diff --git a/rbutil/chinachippatcher/Makefile b/rbutil/chinachippatcher/Makefile
index e19052a006..fbdb30f4b8 100644
--- a/rbutil/chinachippatcher/Makefile
+++ b/rbutil/chinachippatcher/Makefile
@@ -3,7 +3,7 @@ CC=gcc
3 3
4all: chinachip 4all: chinachip
5 5
6chinachip: chinachip.c 6chinachip: chinachip.c main.c
7 $(CC) $(CFLAGS) -o $@ $^ 7 $(CC) $(CFLAGS) -o $@ $^
8 8
9clean: 9clean:
diff --git a/rbutil/chinachippatcher/chinachip.c b/rbutil/chinachippatcher/chinachip.c
index 7237572fac..dc1d2a40bb 100644
--- a/rbutil/chinachippatcher/chinachip.c
+++ b/rbutil/chinachippatcher/chinachip.c
@@ -260,54 +260,3 @@ err:
260 return -1; 260 return -1;
261} 261}
262 262
263
264#ifdef STANDALONE
265
266#define VERSION "0.1"
267#define PRINT(fmt, ...) fprintf(stderr, fmt"\n", ##__VA_ARGS__)
268
269static void info(void* userdata, char* fmt, ...)
270{
271 (void)userdata;
272 va_list args;
273 va_start(args, fmt);
274 vfprintf(stderr, fmt, args);
275 va_end(args);
276}
277
278static void err(void* userdata, char* fmt, ...)
279{
280 (void)userdata;
281 va_list args;
282 va_start(args, fmt);
283 vfprintf(stderr, fmt, args);
284 va_end(args);
285}
286
287void usage(char* name)
288{
289 PRINT("Usage:");
290 PRINT(" %s <firmware> <bootloader> <firmware_output> [backup]", name);
291 PRINT("\nExample:");
292 PRINT(" %s VX747.HXF bootloader.bin output.HXF ccpmp.bak", name);
293 PRINT(" This will copy ccpmp.bin in VX747.HXF as ccpmp.old and replace it"
294 " with bootloader.bin, the output will get written to output.HXF."
295 " The old ccpmp.bin will get written to ccpmp.bak.");
296}
297
298int main(int argc, char* argv[])
299{
300 PRINT("ChinaChipPatcher v" VERSION " - (C) Maurus Cuelenaere 2009");
301 PRINT("This is free software; see the source for copying conditions. There is NO");
302 PRINT("warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n");
303
304 if(argc < 4)
305 {
306 usage(argv[0]);
307 return 1;
308 }
309
310 return chinachip_patch(argv[1], argv[2], argv[3], argc > 4 ? argv[4] : NULL,
311 &info, &err, NULL);
312}
313#endif
diff --git a/rbutil/chinachippatcher/main.c b/rbutil/chinachippatcher/main.c
new file mode 100644
index 0000000000..12b3a3543f
--- /dev/null
+++ b/rbutil/chinachippatcher/main.c
@@ -0,0 +1,72 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2009 by Maurus Cuelenaere
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21#include <stdio.h>
22#include <stdarg.h>
23#include "chinachip.h"
24
25#define VERSION "0.1"
26#define PRINT(fmt, ...) fprintf(stderr, fmt"\n", ##__VA_ARGS__)
27
28static void info(void* userdata, char* fmt, ...)
29{
30 (void)userdata;
31 va_list args;
32 va_start(args, fmt);
33 vfprintf(stderr, fmt, args);
34 va_end(args);
35}
36
37static void err(void* userdata, char* fmt, ...)
38{
39 (void)userdata;
40 va_list args;
41 va_start(args, fmt);
42 vfprintf(stderr, fmt, args);
43 va_end(args);
44}
45
46void usage(char* name)
47{
48 PRINT("Usage:");
49 PRINT(" %s <firmware> <bootloader> <firmware_output> [backup]", name);
50 PRINT("\nExample:");
51 PRINT(" %s VX747.HXF bootloader.bin output.HXF ccpmp.bak", name);
52 PRINT(" This will copy ccpmp.bin in VX747.HXF as ccpmp.old and replace it"
53 " with bootloader.bin, the output will get written to output.HXF."
54 " The old ccpmp.bin will get written to ccpmp.bak.");
55}
56
57int main(int argc, char* argv[])
58{
59 PRINT("ChinaChipPatcher v" VERSION " - (C) Maurus Cuelenaere 2009");
60 PRINT("This is free software; see the source for copying conditions. There is NO");
61 PRINT("warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n");
62
63 if(argc < 4)
64 {
65 usage(argv[0]);
66 return 1;
67 }
68
69 return chinachip_patch(argv[1], argv[2], argv[3], argc > 4 ? argv[4] : NULL,
70 &info, &err, NULL);
71}
72