blob: 4347f9ccce48ef8f700f3cc9bbdbb56235e5bab0 [file] [log] [blame]
Nico Huber34e783a2023-02-11 00:30:27 +01001/*
2 * This file is part of the flashprog project.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 */
14
15#ifndef FLASHPROG_CLI_H
16#define FLASHPROG_CLI_H
17
Nico Huber0da839b2023-02-11 01:40:07 +010018#include "libflashprog.h"
19
Nico Huber34e783a2023-02-11 00:30:27 +010020enum {
Nico Huberdf6ce9f2023-02-11 16:16:04 +010021 OPTION_VERBOSE = 'V',
22 OPTION_LOGFILE = 'o',
Nico Huber34e783a2023-02-11 00:30:27 +010023 OPTION_CHIP = 'c',
24 OPTION_PROGRAMMER = 'p',
Nico Huberd91822a2023-02-11 00:43:54 +010025 OPTION_LAYOUT = 'l',
Nico Hubere7899a92023-02-11 00:39:47 +010026
27 /* Options below have only long option names, i.e. no single char: */
28 OPTION_IFD = 0x0100,
29 OPTION_FMAP,
30 OPTION_FMAP_FILE,
31 OPTION_FLASH_CONTENTS,
32 OPTION_FLASH_NAME,
33 OPTION_FLASH_SIZE,
34 OPTION_PROGRESS,
Nico Huber34e783a2023-02-11 00:30:27 +010035};
36
Nico Huberdf6ce9f2023-02-11 16:16:04 +010037struct log_args {
38 enum flashprog_log_level screen_level;
39 enum flashprog_log_level logfile_level;
40 char *logfile;
41};
42
Nico Huber34e783a2023-02-11 00:30:27 +010043struct flash_args {
44 char *chip;
45 char *prog_name;
46 char *prog_args;
47};
48
Nico Huberd91822a2023-02-11 00:43:54 +010049struct layout_args {
50 bool ifd;
51 bool fmap;
52 char *fmapfile;
53 char *layoutfile;
54};
55
56int cli_check_filename(const char *filename, const char *type);
57
Nico Huberdf6ce9f2023-02-11 16:16:04 +010058int cli_parse_log_args(struct log_args *, int opt, const char *optarg);
Nico Huber34e783a2023-02-11 00:30:27 +010059int cli_parse_flash_args(struct flash_args *, int opt, const char *optarg);
Nico Huberd91822a2023-02-11 00:43:54 +010060int cli_parse_layout_args(struct layout_args *, int opt, const char *optarg);
Nico Huber0da839b2023-02-11 01:40:07 +010061int cli_process_layout_args(struct flashprog_layout **, struct flashprog_flashctx *, const struct layout_args *);
Nico Huber34e783a2023-02-11 00:30:27 +010062
Nico Huberd39c7d62023-02-11 00:53:08 +010063int cli_init(void);
64
Nico Hubera7050432023-02-11 18:01:26 +010065int flashprog_classic_main(int argc, char *argv[]);
66
Nico Huberb82aadc2023-02-11 18:27:30 +010067extern enum flashprog_log_level verbose_screen;
68extern enum flashprog_log_level verbose_logfile;
69int open_logfile(const char * const filename);
70int close_logfile(void);
71void start_logging(void);
72
Nico Huber24c09772024-11-02 13:46:21 +010073void print_generic_options(void);
74
Nico Huber34e783a2023-02-11 00:30:27 +010075#endif