Nico Huber | 34e783a | 2023-02-11 00:30:27 +0100 | [diff] [blame] | 1 | /* |
| 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 Huber | 0da839b | 2023-02-11 01:40:07 +0100 | [diff] [blame^] | 18 | #include "libflashprog.h" |
| 19 | |
Nico Huber | 34e783a | 2023-02-11 00:30:27 +0100 | [diff] [blame] | 20 | enum { |
| 21 | OPTION_CHIP = 'c', |
| 22 | OPTION_PROGRAMMER = 'p', |
Nico Huber | d91822a | 2023-02-11 00:43:54 +0100 | [diff] [blame] | 23 | OPTION_LAYOUT = 'l', |
Nico Huber | e7899a9 | 2023-02-11 00:39:47 +0100 | [diff] [blame] | 24 | |
| 25 | /* Options below have only long option names, i.e. no single char: */ |
| 26 | OPTION_IFD = 0x0100, |
| 27 | OPTION_FMAP, |
| 28 | OPTION_FMAP_FILE, |
| 29 | OPTION_FLASH_CONTENTS, |
| 30 | OPTION_FLASH_NAME, |
| 31 | OPTION_FLASH_SIZE, |
| 32 | OPTION_PROGRESS, |
Nico Huber | 34e783a | 2023-02-11 00:30:27 +0100 | [diff] [blame] | 33 | }; |
| 34 | |
| 35 | struct flash_args { |
| 36 | char *chip; |
| 37 | char *prog_name; |
| 38 | char *prog_args; |
| 39 | }; |
| 40 | |
Nico Huber | d91822a | 2023-02-11 00:43:54 +0100 | [diff] [blame] | 41 | struct layout_args { |
| 42 | bool ifd; |
| 43 | bool fmap; |
| 44 | char *fmapfile; |
| 45 | char *layoutfile; |
| 46 | }; |
| 47 | |
| 48 | int cli_check_filename(const char *filename, const char *type); |
| 49 | |
Nico Huber | 34e783a | 2023-02-11 00:30:27 +0100 | [diff] [blame] | 50 | int cli_parse_flash_args(struct flash_args *, int opt, const char *optarg); |
Nico Huber | d91822a | 2023-02-11 00:43:54 +0100 | [diff] [blame] | 51 | int cli_parse_layout_args(struct layout_args *, int opt, const char *optarg); |
Nico Huber | 0da839b | 2023-02-11 01:40:07 +0100 | [diff] [blame^] | 52 | int cli_process_layout_args(struct flashprog_layout **, struct flashprog_flashctx *, const struct layout_args *); |
Nico Huber | 34e783a | 2023-02-11 00:30:27 +0100 | [diff] [blame] | 53 | |
| 54 | #endif |