firmware-utils/mktplinkfw: allow to specify firmware version
[openwrt.git] / tools / firmware-utils / src / imagetag_cmdline.h
1 /** @file imagetag_cmdline.h
2  *  @brief The header file for the command line option parser
3  *  generated by GNU Gengetopt version 2.22.4
4  *  http://www.gnu.org/software/gengetopt.
5  *  DO NOT modify this file, since it can be overwritten
6  *  @author GNU Gengetopt by Lorenzo Bettini */
7
8 #ifndef IMAGETAG_CMDLINE_H
9 #define IMAGETAG_CMDLINE_H
10
11 /* If we use autoconf.  */
12 #ifdef HAVE_CONFIG_H
13 #include "config.h"
14 #endif
15
16 #include <stdio.h> /* for FILE */
17
18 #ifdef __cplusplus
19 extern "C" {
20 #endif /* __cplusplus */
21
22 #ifndef CMDLINE_PARSER_PACKAGE
23 /** @brief the program name (used for printing errors) */
24 #define CMDLINE_PARSER_PACKAGE "imagetag"
25 #endif
26
27 #ifndef CMDLINE_PARSER_PACKAGE_NAME
28 /** @brief the complete program name (used for help and version) */
29 #define CMDLINE_PARSER_PACKAGE_NAME "imagetag"
30 #endif
31
32 #ifndef CMDLINE_PARSER_VERSION
33 /** @brief the program version */
34 #define CMDLINE_PARSER_VERSION "2.0.0"
35 #endif
36
37 /** @brief Where the command line options are stored */
38 struct gengetopt_args_info
39 {
40   const char *help_help; /**< @brief Print help and exit help description.  */
41   const char *version_help; /**< @brief Print version and exit help description.  */
42   char * kernel_arg;    /**< @brief File with LZMA compressed kernel to include in the image..  */
43   char * kernel_orig;   /**< @brief File with LZMA compressed kernel to include in the image. original value given at command line.  */
44   const char *kernel_help; /**< @brief File with LZMA compressed kernel to include in the image. help description.  */
45   char * rootfs_arg;    /**< @brief File with RootFS to include in the image..  */
46   char * rootfs_orig;   /**< @brief File with RootFS to include in the image. original value given at command line.  */
47   const char *rootfs_help; /**< @brief File with RootFS to include in the image. help description.  */
48   char * output_arg;    /**< @brief Name of output file..  */
49   char * output_orig;   /**< @brief Name of output file. original value given at command line.  */
50   const char *output_help; /**< @brief Name of output file. help description.  */
51   char * cfe_arg;       /**< @brief File with CFE to include in the image..  */
52   char * cfe_orig;      /**< @brief File with CFE to include in the image. original value given at command line.  */
53   const char *cfe_help; /**< @brief File with CFE to include in the image. help description.  */
54   char * boardid_arg;   /**< @brief Board ID to set in the image (must match what router expects, e.g. \"96345GW2\")..  */
55   char * boardid_orig;  /**< @brief Board ID to set in the image (must match what router expects, e.g. \"96345GW2\"). original value given at command line.  */
56   const char *boardid_help; /**< @brief Board ID to set in the image (must match what router expects, e.g. \"96345GW2\"). help description.  */
57   char * chipid_arg;    /**< @brief Chip ID to set in the image (must match the actual hardware, e.g. \"6345\")..  */
58   char * chipid_orig;   /**< @brief Chip ID to set in the image (must match the actual hardware, e.g. \"6345\"). original value given at command line.  */
59   const char *chipid_help; /**< @brief Chip ID to set in the image (must match the actual hardware, e.g. \"6345\"). help description.  */
60   char * flash_start_arg;       /**< @brief Flash start address. (default='0xBFC00000').  */
61   char * flash_start_orig;      /**< @brief Flash start address. original value given at command line.  */
62   const char *flash_start_help; /**< @brief Flash start address. help description.  */
63   char * image_offset_arg;      /**< @brief Offset from start address for the first byte after the CFE (in memory). (default='0x10000').  */
64   char * image_offset_orig;     /**< @brief Offset from start address for the first byte after the CFE (in memory). original value given at command line.  */
65   const char *image_offset_help; /**< @brief Offset from start address for the first byte after the CFE (in memory). help description.  */
66   char * tag_version_arg;       /**< @brief Version number for imagetag format. (default='6').  */
67   char * tag_version_orig;      /**< @brief Version number for imagetag format. original value given at command line.  */
68   const char *tag_version_help; /**< @brief Version number for imagetag format. help description.  */
69   char * signature_arg; /**< @brief Magic string (signature), for boards that need it. (default='Broadcom Corporatio').  */
70   char * signature_orig;        /**< @brief Magic string (signature), for boards that need it. original value given at command line.  */
71   const char *signature_help; /**< @brief Magic string (signature), for boards that need it. help description.  */
72   char * signature2_arg;        /**< @brief Second magic string (signature2). (default='ver. 2.0').  */
73   char * signature2_orig;       /**< @brief Second magic string (signature2). original value given at command line.  */
74   const char *signature2_help; /**< @brief Second magic string (signature2). help description.  */
75   char * block_size_arg;        /**< @brief Flash erase block size. (default='0x10000').  */
76   char * block_size_orig;       /**< @brief Flash erase block size. original value given at command line.  */
77   const char *block_size_help; /**< @brief Flash erase block size. help description.  */
78   char * load_addr_arg; /**< @brief Kernel load address..  */
79   char * load_addr_orig;        /**< @brief Kernel load address. original value given at command line.  */
80   const char *load_addr_help; /**< @brief Kernel load address. help description.  */
81   char * entry_arg;     /**< @brief Address where the kernel entry point will be for booting..  */
82   char * entry_orig;    /**< @brief Address where the kernel entry point will be for booting. original value given at command line.  */
83   const char *entry_help; /**< @brief Address where the kernel entry point will be for booting. help description.  */
84   char * layoutver_arg; /**< @brief Flash layout version (version 2.2x of the Broadcom code requires this)..  */
85   char * layoutver_orig;        /**< @brief Flash layout version (version 2.2x of the Broadcom code requires this). original value given at command line.  */
86   const char *layoutver_help; /**< @brief Flash layout version (version 2.2x of the Broadcom code requires this). help description.  */
87   char * info1_arg;     /**< @brief String for first vendor information section..  */
88   char * info1_orig;    /**< @brief String for first vendor information section. original value given at command line.  */
89   const char *info1_help; /**< @brief String for first vendor information section. help description.  */
90   char * altinfo_arg;   /**< @brief String for vendor information section (alternate/pirelli)..  */
91   char * altinfo_orig;  /**< @brief String for vendor information section (alternate/pirelli). original value given at command line.  */
92   const char *altinfo_help; /**< @brief String for vendor information section (alternate/pirelli). help description.  */
93   char * info2_arg;     /**< @brief String for second vendor information section..  */
94   char * info2_orig;    /**< @brief String for second vendor information section. original value given at command line.  */
95   const char *info2_help; /**< @brief String for second vendor information section. help description.  */
96   int root_first_flag;  /**< @brief Put the rootfs before the kernel (only for stock images, e.g. captured from the router's flash memory). (default=off).  */
97   const char *root_first_help; /**< @brief Put the rootfs before the kernel (only for stock images, e.g. captured from the router's flash memory). help description.  */
98   char * rsa_signature_arg;     /**< @brief String for RSA Signature section..  */
99   char * rsa_signature_orig;    /**< @brief String for RSA Signature section. original value given at command line.  */
100   const char *rsa_signature_help; /**< @brief String for RSA Signature section. help description.  */
101   char * second_image_flag_arg; /**< @brief Dual Image Flag (2=not-specified). (default='2').  */
102   char * second_image_flag_orig;        /**< @brief Dual Image Flag (2=not-specified). original value given at command line.  */
103   const char *second_image_flag_help; /**< @brief Dual Image Flag (2=not-specified). help description.  */
104   char * inactive_arg;  /**< @brief Inactive Flag (2=not-specified). (default='2').  */
105   char * inactive_orig; /**< @brief Inactive Flag (2=not-specified). original value given at command line.  */
106   const char *inactive_help; /**< @brief Inactive Flag (2=not-specified). help description.  */
107   char * reserved2_arg; /**< @brief String for second reserved section..  */
108   char * reserved2_orig;        /**< @brief String for second reserved section. original value given at command line.  */
109   const char *reserved2_help; /**< @brief String for second reserved section. help description.  */
110   int kernel_file_has_header_flag;      /**< @brief Indicates that the kernel file includes the kernel header with correct load address and entry point, so no changes are needed (default=off).  */
111   const char *kernel_file_has_header_help; /**< @brief Indicates that the kernel file includes the kernel header with correct load address and entry point, so no changes are needed help description.  */
112   int pad_arg;  /**< @brief Pad the image to this size if smaller (in MiB).  */
113   char * pad_orig;      /**< @brief Pad the image to this size if smaller (in MiB) original value given at command line.  */
114   const char *pad_help; /**< @brief Pad the image to this size if smaller (in MiB) help description.  */
115   
116   unsigned int help_given ;     /**< @brief Whether help was given.  */
117   unsigned int version_given ;  /**< @brief Whether version was given.  */
118   unsigned int kernel_given ;   /**< @brief Whether kernel was given.  */
119   unsigned int rootfs_given ;   /**< @brief Whether rootfs was given.  */
120   unsigned int output_given ;   /**< @brief Whether output was given.  */
121   unsigned int cfe_given ;      /**< @brief Whether cfe was given.  */
122   unsigned int boardid_given ;  /**< @brief Whether boardid was given.  */
123   unsigned int chipid_given ;   /**< @brief Whether chipid was given.  */
124   unsigned int flash_start_given ;      /**< @brief Whether flash-start was given.  */
125   unsigned int image_offset_given ;     /**< @brief Whether image-offset was given.  */
126   unsigned int tag_version_given ;      /**< @brief Whether tag-version was given.  */
127   unsigned int signature_given ;        /**< @brief Whether signature was given.  */
128   unsigned int signature2_given ;       /**< @brief Whether signature2 was given.  */
129   unsigned int block_size_given ;       /**< @brief Whether block-size was given.  */
130   unsigned int load_addr_given ;        /**< @brief Whether load-addr was given.  */
131   unsigned int entry_given ;    /**< @brief Whether entry was given.  */
132   unsigned int layoutver_given ;        /**< @brief Whether layoutver was given.  */
133   unsigned int info1_given ;    /**< @brief Whether info1 was given.  */
134   unsigned int altinfo_given ;  /**< @brief Whether altinfo was given.  */
135   unsigned int info2_given ;    /**< @brief Whether info2 was given.  */
136   unsigned int root_first_given ;       /**< @brief Whether root-first was given.  */
137   unsigned int rsa_signature_given ;    /**< @brief Whether rsa-signature was given.  */
138   unsigned int second_image_flag_given ;        /**< @brief Whether second-image-flag was given.  */
139   unsigned int inactive_given ; /**< @brief Whether inactive was given.  */
140   unsigned int reserved2_given ;        /**< @brief Whether reserved2 was given.  */
141   unsigned int kernel_file_has_header_given ;   /**< @brief Whether kernel-file-has-header was given.  */
142   unsigned int pad_given ;      /**< @brief Whether pad was given.  */
143
144 } ;
145
146 /** @brief The additional parameters to pass to parser functions */
147 struct cmdline_parser_params
148 {
149   int override; /**< @brief whether to override possibly already present options (default 0) */
150   int initialize; /**< @brief whether to initialize the option structure gengetopt_args_info (default 1) */
151   int check_required; /**< @brief whether to check that all required options were provided (default 1) */
152   int check_ambiguity; /**< @brief whether to check for options already specified in the option structure gengetopt_args_info (default 0) */
153   int print_errors; /**< @brief whether getopt_long should print an error message for a bad option (default 1) */
154 } ;
155
156 /** @brief the purpose string of the program */
157 extern const char *gengetopt_args_info_purpose;
158 /** @brief the usage string of the program */
159 extern const char *gengetopt_args_info_usage;
160 /** @brief all the lines making the help output */
161 extern const char *gengetopt_args_info_help[];
162
163 /**
164  * The command line parser
165  * @param argc the number of command line options
166  * @param argv the command line options
167  * @param args_info the structure where option information will be stored
168  * @return 0 if everything went fine, NON 0 if an error took place
169  */
170 int cmdline_parser (int argc, char **argv,
171   struct gengetopt_args_info *args_info);
172
173 /**
174  * The command line parser (version with additional parameters - deprecated)
175  * @param argc the number of command line options
176  * @param argv the command line options
177  * @param args_info the structure where option information will be stored
178  * @param override whether to override possibly already present options
179  * @param initialize whether to initialize the option structure my_args_info
180  * @param check_required whether to check that all required options were provided
181  * @return 0 if everything went fine, NON 0 if an error took place
182  * @deprecated use cmdline_parser_ext() instead
183  */
184 int cmdline_parser2 (int argc, char **argv,
185   struct gengetopt_args_info *args_info,
186   int override, int initialize, int check_required);
187
188 /**
189  * The command line parser (version with additional parameters)
190  * @param argc the number of command line options
191  * @param argv the command line options
192  * @param args_info the structure where option information will be stored
193  * @param params additional parameters for the parser
194  * @return 0 if everything went fine, NON 0 if an error took place
195  */
196 int cmdline_parser_ext (int argc, char **argv,
197   struct gengetopt_args_info *args_info,
198   struct cmdline_parser_params *params);
199
200 /**
201  * Save the contents of the option struct into an already open FILE stream.
202  * @param outfile the stream where to dump options
203  * @param args_info the option struct to dump
204  * @return 0 if everything went fine, NON 0 if an error took place
205  */
206 int cmdline_parser_dump(FILE *outfile,
207   struct gengetopt_args_info *args_info);
208
209 /**
210  * Save the contents of the option struct into a (text) file.
211  * This file can be read by the config file parser (if generated by gengetopt)
212  * @param filename the file where to save
213  * @param args_info the option struct to save
214  * @return 0 if everything went fine, NON 0 if an error took place
215  */
216 int cmdline_parser_file_save(const char *filename,
217   struct gengetopt_args_info *args_info);
218
219 /**
220  * Print the help
221  */
222 void cmdline_parser_print_help(void);
223 /**
224  * Print the version
225  */
226 void cmdline_parser_print_version(void);
227
228 /**
229  * Initializes all the fields a cmdline_parser_params structure 
230  * to their default values
231  * @param params the structure to initialize
232  */
233 void cmdline_parser_params_init(struct cmdline_parser_params *params);
234
235 /**
236  * Allocates dynamically a cmdline_parser_params structure and initializes
237  * all its fields to their default values
238  * @return the created and initialized cmdline_parser_params structure
239  */
240 struct cmdline_parser_params *cmdline_parser_params_create(void);
241
242 /**
243  * Initializes the passed gengetopt_args_info structure's fields
244  * (also set default values for options that have a default)
245  * @param args_info the structure to initialize
246  */
247 void cmdline_parser_init (struct gengetopt_args_info *args_info);
248 /**
249  * Deallocates the string fields of the gengetopt_args_info structure
250  * (but does not deallocate the structure itself)
251  * @param args_info the structure to deallocate
252  */
253 void cmdline_parser_free (struct gengetopt_args_info *args_info);
254
255 /**
256  * Checks that all the required options were specified
257  * @param args_info the structure to check
258  * @param prog_name the name of the program that will be used to print
259  *   possible errors
260  * @return
261  */
262 int cmdline_parser_required (struct gengetopt_args_info *args_info,
263   const char *prog_name);
264
265 extern const char *cmdline_parser_second_image_flag_values[];  /**< @brief Possible values for second-image-flag. */
266 extern const char *cmdline_parser_inactive_values[];  /**< @brief Possible values for inactive. */
267
268
269 #ifdef __cplusplus
270 }
271 #endif /* __cplusplus */
272 #endif /* IMAGETAG_CMDLINE_H */