- while ((opt = getopt(argc, argv, "ctxT:X:C:f:Opvz")) != -1) {
- switch (opt) {
- /* One and only one of these is required */
-#ifdef CONFIG_FEATURE_TAR_CREATE
- case 'c':
- tar_create = TRUE;
- break;
-#endif
- case 't':
- if ((tar_handle->action_header == header_list) ||
- (tar_handle->action_header == header_verbose_list)) {
- tar_handle->action_header = header_verbose_list;
- } else {
- tar_handle->action_header = header_list;
- }
- break;
- case 'x':
+
+ /* Initialise default values */
+ tar_handle = init_handle();
+ tar_handle->flags = ARCHIVE_CREATE_LEADING_DIRS | ARCHIVE_PRESERVE_DATE | ARCHIVE_EXTRACT_UNCONDITIONAL;
+
+ 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;
+ } else {
+ tar_handle->action_header = header_list;
+ }
+ }
+ if(ctx_flag & CTX_EXTRACT) {
+ if (tar_handle->action_data != data_extract_to_stdout)