imagetag_cmdline.h 16 KB

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