feat/api #46

Open
Gregor Weiss wants to merge 56 commits from feat/api into main
Showing only changes of commit e0bc0d8839 - Show all commits

View file

@ -303,13 +303,12 @@ typedef struct
* *
* @retval -1 Error * @retval -1 Error
* @retval 0 OK * @retval 0 OK
*/
/*================================================================================================*/
static error_t static error_t
parse_opt(int key, parse_opt(int key,
char *arg, char *arg,
struct argp_state *state) struct argp_state *state)
{ {
*/
/*-----------------------*\ /*-----------------------*\
! DEFINE INT VARIABLES: ! ! DEFINE INT VARIABLES: !
\*-----------------------*/ \*-----------------------*/
@ -317,44 +316,56 @@ parse_opt(int key,
//uint64_t multiplier; //uint64_t multiplier;
//uint16_t buffI; //uint16_t buffI;
/*
uint8_t i; uint8_t i;
//uint8_t length, shift; //uint8_t length, shift;
*/
/*-----------------------*\ /*-----------------------*\
! DEFINE REAL VARIABLES: ! ! DEFINE REAL VARIABLES: !
\*-----------------------*/ \*-----------------------*/
/*
float bitrate; float bitrate;
*/
/*-----------------------*\ /*-----------------------*\
! DEFINE REAL VARIABLES: ! ! DEFINE REAL VARIABLES: !
\*-----------------------*/ \*-----------------------*/
/*
char *end; char *end;
*/
/*-----------------------*\ /*-----------------------*\
! DEFINE STRUCTS: ! ! DEFINE STRUCTS: !
\*-----------------------*/ \*-----------------------*/
/*
cli_arguments *arguments; cli_arguments *arguments;
bwc_codec *codec; bwc_codec *codec;
bwc_stream *stream; bwc_stream *stream;
*/
/*-----------------------*\ /*-----------------------*\
! DEFINE ASSERTIONS: ! ! DEFINE ASSERTIONS: !
\*-----------------------*/ \*-----------------------*/
/*
assert(state); assert(state);
*/
/*--------------------------------------------------------*\ /*--------------------------------------------------------*\
! Save frequently used variables/structures to temporary ! ! Save frequently used variables/structures to temporary !
! variables to make the code more readable. ! ! variables to make the code more readable. !
\*--------------------------------------------------------*/ \*--------------------------------------------------------*/
/*
arguments = state->input; arguments = state->input;
codec = arguments->codec; codec = arguments->codec;
stream = arguments->stream; stream = arguments->stream;
*/
/*--------------------------------------------------------*\ /*--------------------------------------------------------*\
! Parse the cli arguments according to the supplied opt. ! ! Parse the cli arguments according to the supplied opt. !
\*--------------------------------------------------------*/ \*--------------------------------------------------------*/
/*
switch(key) switch(key)
{ {
case 'c': case 'c':
@ -487,6 +498,7 @@ parse_opt(int key,
} }
case 'D': case 'D':
{ {
*/
/* remove_deliminator(arg, end, '/'); /* remove_deliminator(arg, end, '/');
for(buff_LL = strtoll(arg, &end, 10), i = 0; arg != end && i < 4; for(buff_LL = strtoll(arg, &end, 10), i = 0; arg != end && i < 4;
@ -521,6 +533,7 @@ parse_opt(int key,
argp_error(state, "The codeblock argument expects either a " argp_error(state, "The codeblock argument expects either a "
"single global or 4 directional values\n"); "single global or 4 directional values\n");
}*/ }*/
/*
break; break;
} }
case 'n': case 'n':
@ -587,6 +600,7 @@ parse_opt(int key,
break; break;
case ARGP_KEY_END: case ARGP_KEY_END:
*/
/*if(!((arguments->analysis != NULL) && (arguments->comp == NULL) /*if(!((arguments->analysis != NULL) && (arguments->comp == NULL)
&& (arguments->decomp == NULL) && (arguments->decomp == NULL)
&& (arguments->header == NULL) && (arguments->header == NULL)
@ -609,6 +623,7 @@ parse_opt(int key,
argp_error(state, "The User supplied options do not fit the " argp_error(state, "The User supplied options do not fit the "
"supported use cases.\n"); "supported use cases.\n");
}*/ }*/
/*
break; break;
default: default:
@ -616,9 +631,10 @@ parse_opt(int key,
} }
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
*/
// initialize the argp struct. Which will be used to parse and use the args. // initialize the argp struct. Which will be used to parse and use the args.
static struct argp argp = {options, parse_opt, 0, doc}; //static struct argp argp = {options, parse_opt, 0, doc};
/*================================================================================================*/ /*================================================================================================*/
/** /**
@ -697,27 +713,27 @@ int main(int argc, char *argv[])
/*--------------------------------------------------------*\ /*--------------------------------------------------------*\
! Initialize the arguments structure. ! ! Initialize the arguments structure. !
\*--------------------------------------------------------*/ \*--------------------------------------------------------*/
arguments.stream = calloc(1, sizeof(bwc_stream)); //arguments.stream = calloc(1, sizeof(bwc_stream));
arguments.codec = calloc(1, sizeof(bwc_codec)); //arguments.codec = calloc(1, sizeof(bwc_codec));
if((arguments.stream == NULL) || //if((arguments.stream == NULL) ||
(arguments.codec == NULL)) //(arguments.codec == NULL))
{ //{
// memory allocation error // memory allocation error
fprintf(stderr, MEMERROR); //fprintf(stderr, MEMERROR);
return EXIT_FAILURE; //return EXIT_FAILURE;
} //}
/*--------------------------------------------------------*\ /*--------------------------------------------------------*\
! Parse the cli arguments. ! ! Parse the cli arguments. !
\*--------------------------------------------------------*/ \*--------------------------------------------------------*/
argp_parse(&argp, argc, argv, 0, 0, &arguments); //argp_parse(&argp, argc, argv, 0, 0, &arguments);
if(arguments.mode == cli_err) //if(arguments.mode == cli_err)
{ //{
return EXIT_FAILURE; //return EXIT_FAILURE;
} //}
for(i = 0; i < 10; ++i) //for(i = 0; i < 10; ++i)
printf("bitrate %d:\t%f\n",i,arguments.bitrate[i]); //printf("bitrate %d:\t%f\n",i,arguments.bitrate[i]);