DSF2FLAC
Defines | Enumerations | Functions | Variables
cmdline.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <getopt.h>
#include "cmdline.h"

Defines

#define FIX_UNUSED(X)   (void) (X) /* avoid warnings for unused params */

Enumerations

enum  cmdline_parser_arg_type {
  ARG_NO, ARG_FLAG, ARG_STRING, ARG_INT,
  ARG_FLOAT
}

Functions

static void clear_given (struct gengetopt_args_info *args_info)
static void clear_args (struct gengetopt_args_info *args_info)
static int cmdline_parser_internal (int argc, char **argv, struct gengetopt_args_info *args_info, struct cmdline_parser_params *params, const char *additional_error)
static int cmdline_parser_required2 (struct gengetopt_args_info *args_info, const char *prog_name, const char *additional_error)
static char * gengetopt_strdup (const char *s)
 replacement of strdup, which is not standard
static void init_args_info (struct gengetopt_args_info *args_info)
void cmdline_parser_print_version (void)
static void print_help_common (void)
void cmdline_parser_print_help (void)
void cmdline_parser_init (struct gengetopt_args_info *args_info)
void cmdline_parser_params_init (struct cmdline_parser_params *params)
struct cmdline_parser_paramscmdline_parser_params_create (void)
static void free_string_field (char **s)
static void cmdline_parser_release (struct gengetopt_args_info *args_info)
static int check_possible_values (const char *val, const char *values[])
static void write_into_file (FILE *outfile, const char *opt, const char *arg, const char *values[])
int cmdline_parser_dump (FILE *outfile, struct gengetopt_args_info *args_info)
int cmdline_parser_file_save (const char *filename, struct gengetopt_args_info *args_info)
void cmdline_parser_free (struct gengetopt_args_info *args_info)
int cmdline_parser (int argc, char **argv, struct gengetopt_args_info *args_info)
int cmdline_parser_ext (int argc, char **argv, struct gengetopt_args_info *args_info, struct cmdline_parser_params *params)
int cmdline_parser2 (int argc, char **argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required)
int cmdline_parser_required (struct gengetopt_args_info *args_info, const char *prog_name)
static int update_arg (void *field, char **orig_field, unsigned int *field_given, unsigned int *prev_given, char *value, const char *possible_values[], const char *default_value, cmdline_parser_arg_type arg_type, int check_ambiguity, int override, int no_free, int multiple_option, const char *long_opt, char short_opt, const char *additional_error)
 updates an option

Variables

const char * gengetopt_args_info_purpose = "Convert DSD audio files from DFF or DSF format into PCM flac audio."
 the purpose string of the program
const char * gengetopt_args_info_usage = "Usage: dsf2flac [OPTIONS]..."
 the usage string of the program
const char * gengetopt_args_info_description = ""
const char * gengetopt_args_info_help []
 all the lines making the help output
const char * cmdline_parser_samplerate_values []
 Possible values for samplerate.
const char * cmdline_parser_bits_values [] = { "16", "20", "24", 0 }
 Possible values for bits.
static char * package_name = 0

Define Documentation

#define FIX_UNUSED (   X)    (void) (X) /* avoid warnings for unused params */

Enumeration Type Documentation

Enumerator:
ARG_NO 
ARG_FLAG 
ARG_STRING 
ARG_INT 
ARG_FLOAT 

Function Documentation

static int check_possible_values ( const char *  val,
const char *  values[] 
) [static]
Parameters:
valthe value to check
valuesthe possible values
Returns:
the index of the matched value: -1 if no value matched, -2 if more than one value has matched
static void clear_args ( struct gengetopt_args_info args_info) [static]
static void clear_given ( struct gengetopt_args_info args_info) [static]
int cmdline_parser ( int  argc,
char **  argv,
struct gengetopt_args_info args_info 
)

The command line parser

Parameters:
argcthe number of command line options
argvthe command line options
args_infothe structure where option information will be stored
Returns:
0 if everything went fine, NON 0 if an error took place
int cmdline_parser2 ( int  argc,
char **  argv,
struct gengetopt_args_info args_info,
int  override,
int  initialize,
int  check_required 
)

The command line parser (version with additional parameters - deprecated)

Parameters:
argcthe number of command line options
argvthe command line options
args_infothe structure where option information will be stored
overridewhether to override possibly already present options
initializewhether to initialize the option structure my_args_info
check_requiredwhether to check that all required options were provided
Returns:
0 if everything went fine, NON 0 if an error took place
Deprecated:
use cmdline_parser_ext() instead
int cmdline_parser_dump ( FILE *  outfile,
struct gengetopt_args_info args_info 
)

Save the contents of the option struct into an already open FILE stream.

Parameters:
outfilethe stream where to dump options
args_infothe option struct to dump
Returns:
0 if everything went fine, NON 0 if an error took place
int cmdline_parser_ext ( int  argc,
char **  argv,
struct gengetopt_args_info args_info,
struct cmdline_parser_params params 
)

The command line parser (version with additional parameters)

Parameters:
argcthe number of command line options
argvthe command line options
args_infothe structure where option information will be stored
paramsadditional parameters for the parser
Returns:
0 if everything went fine, NON 0 if an error took place
int cmdline_parser_file_save ( const char *  filename,
struct gengetopt_args_info args_info 
)

Save the contents of the option struct into a (text) file. This file can be read by the config file parser (if generated by gengetopt)

Parameters:
filenamethe file where to save
args_infothe option struct to save
Returns:
0 if everything went fine, NON 0 if an error took place
void cmdline_parser_free ( struct gengetopt_args_info args_info)

Deallocates the string fields of the gengetopt_args_info structure (but does not deallocate the structure itself)

Parameters:
args_infothe structure to deallocate
void cmdline_parser_init ( struct gengetopt_args_info args_info)

Initializes the passed gengetopt_args_info structure's fields (also set default values for options that have a default)

Parameters:
args_infothe structure to initialize
int cmdline_parser_internal ( int  argc,
char **  argv,
struct gengetopt_args_info args_info,
struct cmdline_parser_params params,
const char *  additional_error 
) [static]

Allocates dynamically a cmdline_parser_params structure and initializes all its fields to their default values

Returns:
the created and initialized cmdline_parser_params structure

Initializes all the fields a cmdline_parser_params structure to their default values

Parameters:
paramsthe structure to initialize
void cmdline_parser_print_help ( void  )

Print the help

Print the version

static void cmdline_parser_release ( struct gengetopt_args_info args_info) [static]
int cmdline_parser_required ( struct gengetopt_args_info args_info,
const char *  prog_name 
)

Checks that all the required options were specified

Parameters:
args_infothe structure to check
prog_namethe name of the program that will be used to print possible errors
Returns:
int cmdline_parser_required2 ( struct gengetopt_args_info args_info,
const char *  prog_name,
const char *  additional_error 
) [static]
static void free_string_field ( char **  s) [static]
char * gengetopt_strdup ( const char *  s) [static]

replacement of strdup, which is not standard

static void init_args_info ( struct gengetopt_args_info args_info) [static]
static void print_help_common ( void  ) [static]
static int update_arg ( void *  field,
char **  orig_field,
unsigned int *  field_given,
unsigned int *  prev_given,
char *  value,
const char *  possible_values[],
const char *  default_value,
cmdline_parser_arg_type  arg_type,
int  check_ambiguity,
int  override,
int  no_free,
int  multiple_option,
const char *  long_opt,
char  short_opt,
const char *  additional_error 
) [static]

updates an option

Parameters:
fieldthe generic pointer to the field to update
orig_fieldthe pointer to the orig field
field_giventhe pointer to the number of occurrence of this option
prev_giventhe pointer to the number of occurrence already seen
valuethe argument for this option (if null no arg was specified)
possible_valuesthe possible values for this option (if specified)
default_valuethe default value (in case the option only accepts fixed values)
arg_typethe type of this option
check_ambiguity
See also:
cmdline_parser_params.check_ambiguity
Parameters:
override
See also:
cmdline_parser_params.override
Parameters:
no_freewhether to free a possible previous value
multiple_optionwhether this is a multiple option
long_optthe corresponding long option
short_optthe corresponding short option (or '-' if none)
additional_errorpossible further error specification
static void write_into_file ( FILE *  outfile,
const char *  opt,
const char *  arg,
const char *  values[] 
) [static]

Variable Documentation

const char* cmdline_parser_bits_values[] = { "16", "20", "24", 0 }

Possible values for bits.

Initial value:
 { "88200", "176400", "352800",
                0 }

Possible values for samplerate.

const char* gengetopt_args_info_help[]
Initial value:
                { "  -h, --help              Print help and exit",
                                "  -V, --version           Print version and exit",
                                "  -r, --samplerate=Hz     Output sample rate  (possible values=\"88200\", \n                            \"176400\", \"352800\" default=`88200')",
                                "  -b, --bits=bits         Output bitdepth  (possible values=\"16\", \"20\", \n                            \"24\" default=`24')",
                                "  -n, --nodither          Don't add dither before quantization  (default=off)",
                                "  -s, --scale=dB          Scale adjustment. Raw DSD has a modulation depth of \n                            approximately 0.5 so with no scaling the PCM peak \n                            level is approximately -6dB below 0dBFs  \n                            (default=`4')",
                                "  -i, --infile=filepath   Input DSF or DFF file",
                                "  -o, --outfile=filepath  Output FLAC file, if not specified the output file be \n                            the same as the input file with the extension \n                            changed",
                                "  -d, --dop               Encode DSD data directly into FLAC file without \n                            conversion to PCM using DoP format (DSD over PCM)  \n                            (default=off)",
                                0 }

all the lines making the help output

const char* gengetopt_args_info_purpose = "Convert DSD audio files from DFF or DSF format into PCM flac audio."

the purpose string of the program

const char* gengetopt_args_info_usage = "Usage: dsf2flac [OPTIONS]..."

the usage string of the program

char* package_name = 0 [static]
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines