Extend return codes for chinachip_patch().
[maemo-rb.git] / rbutil / chinachippatcher / main.c
blob0553b7d79823d84f8b6bce97d707abfd9b0b67d4
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2009 by Maurus Cuelenaere
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.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
21 #include <stdio.h>
22 #include <stdarg.h>
23 #include "chinachip.h"
25 #define VERSION "0.1"
26 #define PRINT(fmt, ...) fprintf(stderr, fmt"\n", ##__VA_ARGS__)
28 void usage(char* name)
30 PRINT("Usage:");
31 PRINT(" %s <firmware> <bootloader> <firmware_output> [backup]", name);
32 PRINT("\nExample:");
33 PRINT(" %s VX747.HXF bootloader.bin output.HXF ccpmp.bak", name);
34 PRINT(" This will copy ccpmp.bin in VX747.HXF as ccpmp.old and replace it"
35 " with bootloader.bin, the output will get written to output.HXF."
36 " The old ccpmp.bin will get written to ccpmp.bak.");
39 int main(int argc, char* argv[])
41 PRINT("ChinaChipPatcher v" VERSION " - (C) Maurus Cuelenaere 2009");
42 PRINT("This is free software; see the source for copying conditions. There is NO");
43 PRINT("warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n");
45 if(argc < 4)
47 usage(argv[0]);
48 return 1;
51 return chinachip_patch(argv[1], argv[2], argv[3], argc > 4 ? argv[4] : NULL);