• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-WNDR4500-V1.0.1.40_1.0.68/ap/gpl/minidlna/flac-1.2.1/src/metaflac/

Lines Matching defs:options

23 #include "options.h"
35 share__getopt format struct; note we don't use short options so we just
39 /* global options */
101 static FLAC__bool parse_option(int option_index, const char *option_argument, CommandLineOptions *options);
102 static void append_new_operation(CommandLineOptions *options, Operation operation);
103 static void append_new_argument(CommandLineOptions *options, Argument argument);
104 static Operation *append_major_operation(CommandLineOptions *options, OperationType type);
105 static Operation *append_shorthand_operation(CommandLineOptions *options, OperationType type);
106 static Argument *find_argument(CommandLineOptions *options, ArgumentType type);
107 static Operation *find_shorthand_operation(CommandLineOptions *options, OperationType type);
108 static Argument *append_argument(CommandLineOptions *options, ArgumentType type);
123 void init_options(CommandLineOptions *options)
125 options->preserve_modtime = false;
129 options->prefix_with_filename = 2;
131 options->utf8_convert = true;
132 options->use_padding = true;
133 options->cued_seekpoints = true;
134 options->show_long_help = false;
135 options->show_version = false;
136 options->application_data_format_is_hexdump = false;
138 options->ops.operations = 0;
139 options->ops.num_operations = 0;
140 options->ops.capacity = 0;
142 options->args.arguments = 0;
143 options->args.num_arguments = 0;
144 options->args.capacity = 0;
146 options->args.checks.num_shorthand_ops = 0;
147 options->args.checks.num_major_ops = 0;
148 options->args.checks.has_block_type = false;
149 options->args.checks.has_except_block_type = false;
151 options->num_files = 0;
152 options->filenames = 0;
155 FLAC__bool parse_options(int argc, char *argv[], CommandLineOptions *options)
164 had_error |= !parse_option(option_index, share__optarg, options);
176 if(options->prefix_with_filename == 2)
177 options->prefix_with_filename = (argc - share__optind > 1);
179 if(share__optind >= argc && !options->show_long_help && !options->show_version) {
185 options->num_files = argc - share__optind;
187 if(options->num_files > 0) {
189 if(0 == (options->filenames = (char**)safe_malloc_mul_2op_(sizeof(char*), /*times*/options->num_files)))
192 options->filenames[i++] = local_strdup(argv[share__optind++]);
195 if(options->args.checks.num_major_ops > 0) {
196 if(options->args.checks.num_major_ops > 1) {
200 else if(options->args.checks.num_shorthand_ops > 0) {
206 /* check for only one FLAC file used with certain options */
207 if(options->num_files > 1) {
208 if(0 != find_shorthand_operation(options, OP__IMPORT_CUESHEET_FROM)) {
212 if(0 != find_shorthand_operation(options, OP__EXPORT_CUESHEET_TO)) {
216 if(0 != find_shorthand_operation(options, OP__EXPORT_PICTURE_TO)) {
221 0 != find_shorthand_operation(options, OP__IMPORT_VC_FROM) &&
222 0 == strcmp(find_shorthand_operation(options, OP__IMPORT_VC_FROM)->argument.filename.value, "-")
229 if(options->args.checks.has_block_type && options->args.checks.has_except_block_type) {
242 if(options->cued_seekpoints) {
243 Operation *op = find_shorthand_operation(options, OP__IMPORT_CUESHEET_FROM);
245 Operation *op2 = find_shorthand_operation(options, OP__ADD_SEEKPOINT);
247 op2 = append_shorthand_operation(options, OP__ADD_SEEKPOINT);
255 void free_options(CommandLineOptions *options)
261 FLAC__ASSERT(0 == options->ops.operations || options->ops.num_operations > 0);
262 FLAC__ASSERT(0 == options->args.arguments || options->args.num_arguments > 0);
264 for(i = 0, op = options->ops.operations; i < options->ops.num_operations; i++, op++) {
307 for(i = 0, arg = options->args.arguments; i < options->args.num_arguments; i++, arg++) {
327 if(0 != options->ops.operations)
328 free(options->ops.operations);
330 if(0 != options->args.arguments)
331 free(options->args.arguments);
333 if(0 != options->filenames) {
334 for(i = 0; i < options->num_files; i++) {
335 if(0 != options->filenames[i])
336 free(options->filenames[i]);
338 free(options->filenames);
346 FLAC__bool parse_option(int option_index, const char *option_argument, CommandLineOptions *options)
354 options->preserve_modtime = true;
357 options->prefix_with_filename = true;
360 options->prefix_with_filename = false;
363 options->utf8_convert = false;
366 options->use_padding = false;
369 options->cued_seekpoints = false;
372 (void) append_shorthand_operation(options, OP__SHOW_MD5SUM);
375 (void) append_shorthand_operation(options, OP__SHOW_MIN_BLOCKSIZE);
378 (void) append_shorthand_operation(options, OP__SHOW_MAX_BLOCKSIZE);
381 (void) append_shorthand_operation(options, OP__SHOW_MIN_FRAMESIZE);
384 (void) append_shorthand_operation(options, OP__SHOW_MAX_FRAMESIZE);
387 (void) append_shorthand_operation(options, OP__SHOW_SAMPLE_RATE);
390 (void) append_shorthand_operation(options, OP__SHOW_CHANNELS);
393 (void) append_shorthand_operation(options, OP__SHOW_BPS);
396 (void) append_shorthand_operation(options, OP__SHOW_TOTAL_SAMPLES);
399 op = append_shorthand_operation(options, OP__SET_MD5SUM);
409 op = append_shorthand_operation(options, OP__SET_MIN_BLOCKSIZE);
418 op = append_shorthand_operation(options, OP__SET_MAX_BLOCKSIZE);
427 op = append_shorthand_operation(options, OP__SET_MIN_FRAMESIZE);
436 op = append_shorthand_operation(options, OP__SET_MAX_FRAMESIZE);
445 op = append_shorthand_operation(options, OP__SET_SAMPLE_RATE);
454 op = append_shorthand_operation(options, OP__SET_CHANNELS);
463 op = append_shorthand_operation(options, OP__SET_BPS);
472 op = append_shorthand_operation(options, OP__SET_TOTAL_SAMPLES);
481 (void) append_shorthand_operation(options, OP__SHOW_VC_VENDOR);
485 op = append_shorthand_operation(options, OP__SHOW_VC_FIELD);
494 (void) append_shorthand_operation(options, OP__REMOVE_VC_ALL);
498 op = append_shorthand_operation(options, OP__REMOVE_VC_FIELD);
508 op = append_shorthand_operation(options, OP__REMOVE_VC_FIRSTFIELD);
518 op = append_shorthand_operation(options, OP__SET_VC_FIELD);
529 op = append_shorthand_operation(options, OP__SET_VC_FIELD);
539 op = append_shorthand_operation(options, OP__IMPORT_VC_FROM);
547 op = append_shorthand_operation(options, OP__EXPORT_VC_TO);
555 if(0 != find_shorthand_operation(options, OP__IMPORT_CUESHEET_FROM)) {
559 op = append_shorthand_operation(options, OP__IMPORT_CUESHEET_FROM);
567 op = append_shorthand_operation(options, OP__EXPORT_CUESHEET_TO);
575 op = append_shorthand_operation(options, OP__IMPORT_PICTURE_FROM);
583 const Argument *arg = find_argument(options, ARG__BLOCK_NUMBER);
584 op = append_shorthand_operation(options, OP__EXPORT_PICTURE_TO);
602 op = find_shorthand_operation(options, OP__ADD_SEEKPOINT);
604 op = append_shorthand_operation(options, OP__ADD_SEEKPOINT);
611 (void) append_shorthand_operation(options, OP__ADD_REPLAY_GAIN);
623 op = append_shorthand_operation(options, OP__REMOVE_VC_FIELD);
628 op = append_shorthand_operation(options, OP__ADD_PADDING);
636 options->show_long_help = true;
639 options->show_version = true;
642 (void) append_major_operation(options, OP__LIST);
645 (void) append_major_operation(options, OP__APPEND);
648 (void) append_major_operation(options, OP__REMOVE);
651 (void) append_major_operation(options, OP__REMOVE_ALL);
654 (void) append_major_operation(options, OP__MERGE_PADDING);
657 (void) append_major_operation(options, OP__SORT_PADDING);
660 arg = append_argument(options, ARG__BLOCK_NUMBER);
668 arg = append_argument(options, ARG__BLOCK_TYPE);
674 options->args.checks.has_block_type = true;
677 arg = append_argument(options, ARG__EXCEPT_BLOCK_TYPE);
683 options->args.checks.has_except_block_type = true;
686 arg = append_argument(options, ARG__DATA_FORMAT);
695 if(!parse_application_data_format(option_argument, &(options->application_data_format_is_hexdump))) {
701 arg = append_argument(options, ARG__FROM_FILE);
712 void append_new_operation(CommandLineOptions *options, Operation operation)
714 if(options->ops.capacity == 0) {
715 options->ops.capacity = 50;
716 if(0 == (options->ops.operations = (Operation*)malloc(sizeof(Operation) * options->ops.capacity)))
718 memset(options->ops.operations, 0, sizeof(Operation) * options->ops.capacity);
720 if(options->ops.capacity <= options->ops.num_operations) {
721 unsigned original_capacity = options->ops.capacity;
722 if(options->ops.capacity > SIZE_MAX / 2) /* overflow check */
724 options->ops.capacity *= 2;
725 if(0 == (options->ops.operations = (Operation*)safe_realloc_mul_2op_(options->ops.operations, sizeof(Operation), /*times*/options->ops.capacity)))
727 memset(options->ops.operations + original_capacity, 0, sizeof(Operation) * (options->ops.capacity - original_capacity));
730 options->ops.operations[options->ops.num_operations++] = operation;
733 void append_new_argument(CommandLineOptions *options, Argument argument)
735 if(options->args.capacity == 0) {
736 options->args.capacity = 50;
737 if(0 == (options->args.arguments = (Argument*)malloc(sizeof(Argument) * options->args.capacity)))
739 memset(options->args.arguments, 0, sizeof(Argument) * options->args.capacity);
741 if(options->args.capacity <= options->args.num_arguments) {
742 unsigned original_capacity = options->args.capacity;
743 if(options->args.capacity > SIZE_MAX / 2) /* overflow check */
745 options->args.capacity *= 2;
746 if(0 == (options->args.arguments = (Argument*)safe_realloc_mul_2op_(options->args.arguments, sizeof(Argument), /*times*/options->args.capacity)))
748 memset(options->args.arguments + original_capacity, 0, sizeof(Argument) * (options->args.capacity - original_capacity));
751 options->args.arguments[options->args.num_arguments++] = argument;
754 Operation *append_major_operation(CommandLineOptions *options, OperationType type)
759 append_new_operation(options, op);
760 options->args.checks.num_major_ops++;
761 return options->ops.operations + (options->ops.num_operations - 1);
764 Operation *append_shorthand_operation(CommandLineOptions *options, OperationType type)
769 append_new_operation(options, op);
770 options->args.checks.num_shorthand_ops++;
771 return options->ops.operations + (options->ops.num_operations - 1);
774 Argument *find_argument(CommandLineOptions *options, ArgumentType type)
777 for(i = 0; i < options->args.num_arguments; i++)
778 if(options->args.arguments[i].type == type)
779 return &options->args.arguments[i];
783 Operation *find_shorthand_operation(CommandLineOptions *options, OperationType type)
786 for(i = 0; i < options->ops.num_operations; i++)
787 if(options->ops.operations[i].type == type)
788 return &options->ops.operations[i];
792 Argument *append_argument(CommandLineOptions *options, ArgumentType type)
797 append_new_argument(options, arg);
798 return options->args.arguments + (options->args.num_arguments - 1);