- while ((opt = getopt(argc, argv, "ctxT:X:C:f:Opvz")) != -1) {
- switch (opt) {
-
- /* One and only one of these is required */
- case 'c':
- untar_funct_required |= untar_create;
- break;
- case 't':
- untar_funct_required |= untar_list;
- extract_function |= extract_list |extract_unconditional;
- break;
- case 'x':
- untar_funct_required |= untar_extract;
- extract_function |= (extract_all_to_fs | extract_unconditional | extract_create_leading_dirs);
- break;
-
- /* These are optional */
- /* Exclude or Include files listed in <filename>*/
-#ifdef CONFIG_FEATURE_TAR_EXCLUDE
- case 'X':
- append_file_list_to_list(optarg, &exclude_list, &exclude_list_count);
- break;
-#endif
- case 'T':
- // by default a list is an include list
- append_file_list_to_list(optarg, &include_list, &include_list_count);
- break;
-
- case 'C': // Change to dir <optarg>
- /* Make sure dst_prefix ends in a '/' */
- dst_prefix = concat_path_file(optarg, "/");
- break;
- case 'f': // archive filename
- if (strcmp(optarg, "-") == 0) {
- src_filename = NULL;
+ /* Initialise default values */
+ tar_handle = init_handle();
+ tar_handle->flags = ARCHIVE_CREATE_LEADING_DIRS | ARCHIVE_PRESERVE_DATE;
+
+ bb_opt_complementaly = "c~tx:t~cx:x~ct:X*";
+ opt = bb_getopt_ulflags(argc, argv, tar_options,
+ NULL, /* T: arg is ignored by default
+ a list is an include list */
+ &(tar_handle->reject),
+ &base_dir, /* Change to dir <optarg> */
+ &tar_filename); /* archive filename */
+ /* Check one and only one context option was given */
+ if(opt & 0x80000000UL)
+ bb_show_usage();
+ ctx_flag = opt & (CTX_CREATE | CTX_TEST | CTX_EXTRACT);
+ if(ctx_flag & CTX_TEST) {
+ if ((tar_handle->action_header == header_list) ||
+ (tar_handle->action_header == header_verbose_list)) {
+ tar_handle->action_header = header_verbose_list;