Check that one and only one of the [cxt] options is given
This commit is contained in:
parent
441e7efc72
commit
ec87d37305
@ -597,6 +597,10 @@ static const llist_t *append_file_list_to_list(const char *filename, const llist
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define CTX_CREATE 1
|
||||||
|
#define CTX_TEST 2
|
||||||
|
#define CTX_EXTRACT 4
|
||||||
|
|
||||||
int tar_main(int argc, char **argv)
|
int tar_main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
char (*get_header_ptr)(archive_handle_t *) = get_header_tar;
|
char (*get_header_ptr)(archive_handle_t *) = get_header_tar;
|
||||||
@ -604,10 +608,7 @@ int tar_main(int argc, char **argv)
|
|||||||
int opt;
|
int opt;
|
||||||
char *base_dir = NULL;
|
char *base_dir = NULL;
|
||||||
const char *tar_filename = "-";
|
const char *tar_filename = "-";
|
||||||
|
unsigned char ctx_flag = 0;
|
||||||
#ifdef CONFIG_FEATURE_TAR_CREATE
|
|
||||||
unsigned char tar_create = FALSE;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
show_usage();
|
show_usage();
|
||||||
@ -630,10 +631,11 @@ int tar_main(int argc, char **argv)
|
|||||||
/* One and only one of these is required */
|
/* One and only one of these is required */
|
||||||
#ifdef CONFIG_FEATURE_TAR_CREATE
|
#ifdef CONFIG_FEATURE_TAR_CREATE
|
||||||
case 'c':
|
case 'c':
|
||||||
tar_create = TRUE;
|
ctx_flag |= CTX_CREATE;
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
case 't':
|
case 't':
|
||||||
|
ctx_flag |= CTX_TEST;
|
||||||
if ((tar_handle->action_header == header_list) ||
|
if ((tar_handle->action_header == header_list) ||
|
||||||
(tar_handle->action_header == header_verbose_list)) {
|
(tar_handle->action_header == header_verbose_list)) {
|
||||||
tar_handle->action_header = header_verbose_list;
|
tar_handle->action_header = header_verbose_list;
|
||||||
@ -642,6 +644,7 @@ int tar_main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'x':
|
case 'x':
|
||||||
|
ctx_flag |= CTX_EXTRACT;
|
||||||
tar_handle->action_data = data_extract_all;
|
tar_handle->action_data = data_extract_all;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -691,6 +694,11 @@ int tar_main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Check one and only one context option was given */
|
||||||
|
if ((ctx_flag != CTX_CREATE) && (ctx_flag != CTX_TEST) && (ctx_flag != CTX_EXTRACT)) {
|
||||||
|
show_usage();
|
||||||
|
}
|
||||||
|
|
||||||
/* Check if we are reading from stdin */
|
/* Check if we are reading from stdin */
|
||||||
if ((argv[optind]) && (*argv[optind] == '-')) {
|
if ((argv[optind]) && (*argv[optind] == '-')) {
|
||||||
/* Default is to read from stdin, so just skip to next arg */
|
/* Default is to read from stdin, so just skip to next arg */
|
||||||
@ -710,7 +718,7 @@ int tar_main(int argc, char **argv)
|
|||||||
|
|
||||||
#ifdef CONFIG_FEATURE_TAR_CREATE
|
#ifdef CONFIG_FEATURE_TAR_CREATE
|
||||||
/* create an archive */
|
/* create an archive */
|
||||||
if (tar_create == TRUE) {
|
if (ctx_flag == CTX_CREATE) {
|
||||||
int verboseFlag = FALSE;
|
int verboseFlag = FALSE;
|
||||||
int gzipFlag = FALSE;
|
int gzipFlag = FALSE;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user