blob: f7bcceff9cc068b426a6d2c90ded78f5be7f5085 [file] [log] [blame]
Uwe Hermann7eb845e2008-11-02 17:01:06 +00001/*
2 * This file is part of the bayou project.
3 *
4 * Copyright (C) 2008 Advanced Micro Devices, Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
Paul Menzela46a7122013-02-23 18:37:27 +010017 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Uwe Hermann7eb845e2008-11-02 17:01:06 +000018 */
19
20#include "bayou.h"
21
22static void print_banner(void)
23{
24 printf("\e[H\e[JBayou Payload Chooser v0.3\n");
25}
26
27int main(void)
28{
29 extern unsigned long _binary_builtin_lar_start;
30 struct LAR *lar;
31
32 print_banner();
33
34 lar = openlar((void *)&_binary_builtin_lar_start);
35
36 if (lar == NULL) {
37 printf("[CHOOSER]: Unable to scan the attached LAR file\n");
38 return -1;
39 }
40
41 get_configuration(lar);
42
43 if (bayoucfg.n_entries == 0) {
44 printf("[CHOOSER]: No payloads were found in the LAR\n");
45 return -1;
46 }
47
48 /*
49 * If timeout == 0xFF, then show the menu immediately.
50 * If timeout is zero, then find and run the default item immediately.
51 * If there is no default item, then show the menu.
52 * If timeout is anything else, then show a message and wait for a
53 * keystroke. If there is no keystroke in time then run the default.
54 * If there is no default then show the menu.
55 */
56 if (bayoucfg.timeout != 0xFF) {
57 struct payload *d = payload_get_default();
58
59 if (d != NULL) {
60 if (bayoucfg.timeout == 0)
61 run_payload(d);
62 else
63 run_payload_timeout(d, bayoucfg.timeout);
64 }
65 }
66
67 menu();
68
69 return 0;
70}