blob: cdccea1072277a14a1700eeeb349ee5d8351ca11 [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.
Uwe Hermann7eb845e2008-11-02 17:01:06 +000014 */
15
16#include "bayou.h"
17
18static void print_banner(void)
19{
20 printf("\e[H\e[JBayou Payload Chooser v0.3\n");
21}
22
23int main(void)
24{
25 extern unsigned long _binary_builtin_lar_start;
26 struct LAR *lar;
27
28 print_banner();
29
30 lar = openlar((void *)&_binary_builtin_lar_start);
31
32 if (lar == NULL) {
33 printf("[CHOOSER]: Unable to scan the attached LAR file\n");
34 return -1;
35 }
36
37 get_configuration(lar);
38
39 if (bayoucfg.n_entries == 0) {
40 printf("[CHOOSER]: No payloads were found in the LAR\n");
41 return -1;
42 }
43
44 /*
45 * If timeout == 0xFF, then show the menu immediately.
46 * If timeout is zero, then find and run the default item immediately.
47 * If there is no default item, then show the menu.
48 * If timeout is anything else, then show a message and wait for a
49 * keystroke. If there is no keystroke in time then run the default.
50 * If there is no default then show the menu.
51 */
52 if (bayoucfg.timeout != 0xFF) {
53 struct payload *d = payload_get_default();
54
55 if (d != NULL) {
56 if (bayoucfg.timeout == 0)
57 run_payload(d);
58 else
59 run_payload_timeout(d, bayoucfg.timeout);
60 }
61 }
62
63 menu();
64
65 return 0;
66}