summaryrefslogtreecommitdiff
path: root/utils/MTP/beastpatcher/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'utils/MTP/beastpatcher/main.c')
-rw-r--r--utils/MTP/beastpatcher/main.c93
1 files changed, 93 insertions, 0 deletions
diff --git a/utils/MTP/beastpatcher/main.c b/utils/MTP/beastpatcher/main.c
new file mode 100644
index 0000000000..56d1a1e94c
--- /dev/null
+++ b/utils/MTP/beastpatcher/main.c
@@ -0,0 +1,93 @@
1/*
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 *
9 * $Id$
10 *
11 * Copyright (c) 2009, Dave Chapman
12 * All rights reserved.
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions are
16 * met:
17 *
18 * * Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 *
21 * * Redistributions in binary form must reproduce the above
22 * copyright notice, this list of conditions and the following
23 * disclaimer in the documentation and/or other materials provided
24 * with the distribution.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
29 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
30 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
31 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
32 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
33 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
34 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 *
38 ****************************************************************************/
39
40#include <stdio.h>
41#include "beastpatcher.h"
42#include "mtp_common.h"
43
44#if defined(__WIN32__) || defined(_WIN32)
45#include <windows.h>
46#endif
47
48#define VERSION "1.0 with v1 bootloader"
49
50#include "../MTP_DLL/MTP_DLL.h"
51
52static void print_usage(void)
53{
54 fprintf(stderr,"Usage: beastpatcher [action]\n");
55 fprintf(stderr,"\n");
56 fprintf(stderr,"Where [action] is one of the following options:\n");
57 fprintf(stderr," -i, --install (default)\n");
58 fprintf(stderr," -h, --help\n");
59 fprintf(stderr," -s, --send nk.bin\n");
60 fprintf(stderr,"\n");
61}
62
63
64int main(int argc, char* argv[])
65{
66 int res;
67 char yesno[4];
68 struct mtp_info_t mtp_info;
69
70 fprintf(stderr,"beastpatcher v" VERSION " - (C) 2009 by the Rockbox developers\n");
71 fprintf(stderr,"This is free software; see the source for copying conditions. There is NO\n");
72 fprintf(stderr,"warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n");
73
74 if(argc == 1 || strcmp(argv[1],"-i")==0 || strcmp(argv[1],"--install")==0) {
75 res = beastpatcher();
76 /* don't ask for enter if started with command line arguments */
77 if(argc == 1) {
78 printf("\nPress ENTER to exit beastpatcher: ");
79 fgets(yesno,4,stdin);
80 }
81 }
82 else if((argc > 2) && ((strcmp(argv[1],"-s")==0) || (strcmp(argv[1],"--send")==0))) {
83 res = mtp_send_file(&mtp_info, argv[2]);
84 }
85 else {
86 print_usage();
87 res = -1;
88 }
89
90 return res;
91}
92
93