cmdl-tool #45

Merged
Gregor Weiss merged 21 commits from cmdl-tool into feat/api 2024-11-07 15:40:29 +00:00
2 changed files with 43 additions and 30 deletions
Showing only changes of commit f81807e1e3 - Show all commits

View file

@ -231,22 +231,36 @@ endian_conversion(void *value,
void void
eas3_free_data(eas3_data* data) eas3_free_data(eas3_data* data)
{ {
if(data != NULL) /*-----------------------*\
{ ! DEFINE STRUCTS: !
if (data->param_names != NULL) \*-----------------------*/
free(data->param_names); eas3_param_names *param, *temp;
if (data->field.d != NULL) if(data != NULL)
free(data->field.d); {
if (data->param_names != NULL)
{
param = data->param_names->root;
if (data->field.f != NULL) while(param != NULL)
free(data->field.f); {
temp = param;
param = param -> next;
free(temp);
}
}
if(data->aux.ptr != NULL) if (data->field.d != NULL)
free(data->aux.ptr); free(data->field.d);
free(data); if (data->field.f != NULL)
} free(data->field.f);
if(data->aux.ptr != NULL)
free(data->aux.ptr);
free(data);
}
} }
void void
@ -345,7 +359,6 @@ read_eas3_header(FILE *const fp, eas3_data *const data)
\*-----------------------*/ \*-----------------------*/
uint64 Lread; uint64 Lread;
uint64 i; uint64 i;
uint8 precision;
/*-----------------------*\ /*-----------------------*\
! DEFINE CHAR VARIABLES: ! ! DEFINE CHAR VARIABLES: !
@ -356,7 +369,6 @@ read_eas3_header(FILE *const fp, eas3_data *const data)
/*-----------------------*\ /*-----------------------*\
! DEFINE STRUCTS: ! ! DEFINE STRUCTS: !
\*-----------------------*/ \*-----------------------*/
bwc_gl_inf *info;
eas3_std_params *params; eas3_std_params *params;
/*-----------------------*\ /*-----------------------*\
@ -702,7 +714,6 @@ write_eas3_header(FILE *const fp, eas3_data *const data)
/*-----------------------*\ /*-----------------------*\
! DEFINE STRUCTS: ! ! DEFINE STRUCTS: !
\*-----------------------*/ \*-----------------------*/
bwc_gl_inf *info;
eas3_std_params *params; eas3_std_params *params;
eas3_param_names *param_names; eas3_param_names *param_names;

View file

@ -454,8 +454,6 @@ parse_opt(int key,
! DEFINE STRUCTS: ! ! DEFINE STRUCTS: !
\*-----------------------*/ \*-----------------------*/
cli_arguments *arguments; cli_arguments *arguments;
bwc_codec *codec;
bwc_stream *stream;
/*-----------------------*\ /*-----------------------*\
! DEFINE ASSERTIONS: ! ! DEFINE ASSERTIONS: !
@ -720,7 +718,7 @@ parse_opt(int key,
else else
{ {
errno = 0; errno = 0;
argp_error(state, "The specified bitrate (%d) is " argp_error(state, "The specified compression ratio (%f) is "
"out of the supported range.\n", compRatio); "out of the supported range.\n", compRatio);
} }
} }
@ -838,7 +836,7 @@ parse_opt(int key,
} }
for(token = strtok_r(arg, ",", &ptr), i = 0; for(token = strtok_r(arg, ",", &ptr), i = 0;
token != NULL, i < 4; token != NULL && i < 4;
token = strtok_r(NULL, ",", &ptr), i++) token = strtok_r(NULL, ",", &ptr), i++)
{ {
if (strcasecmp(token, "leGall") == 0) if (strcasecmp(token, "leGall") == 0)
@ -1047,6 +1045,7 @@ parse_opt(int key,
{ {
if (arguments->mode == cli_ini) if (arguments->mode == cli_ini)
argp_usage (state); argp_usage (state);
break;
} }
/* Return error if key is unknown. */ /* Return error if key is unknown. */
@ -1061,7 +1060,7 @@ parse_opt(int key,
* @details Initialize the argp struct. used to parse the command line arguments * @details Initialize the argp struct. used to parse the command line arguments
*/ */
/*================================================================================================*/ /*================================================================================================*/
static struct argp argp = {options, parse_opt, 0, doc}; static struct argp argp = {options, parse_opt, 0, doc, 0, 0, 0};
/*================================================================================================*/ /*================================================================================================*/
/** /**
@ -1087,7 +1086,7 @@ int main(int argc, char *argv[])
\*-----------------------*/ \*-----------------------*/
uint64_t size = 0; uint64_t size = 0;
uint8_t i; uint8_t i;
uint8_t error_handle; uint8_t error_handle = EXIT_SUCCESS;
/*-----------------------*\ /*-----------------------*\
! DEFINE REAL VARIABLES: ! ! DEFINE REAL VARIABLES: !
@ -1101,28 +1100,28 @@ int main(int argc, char *argv[])
char cli_buffer[1024] = {0}; char cli_buffer[1024] = {0};
char cli_verbose[4096] = {0}; char cli_verbose[4096] = {0};
char *cli_output; char *cli_output = NULL;
char *buffer; char *buffer = NULL;
unsigned char *input; unsigned char *input = NULL;
unsigned char *output; unsigned char *output = NULL;
/*-----------------------*\ /*-----------------------*\
! DEFINE FILE POINTER: ! ! DEFINE FILE POINTER: !
\*-----------------------*/ \*-----------------------*/
FILE *fp; FILE *fp = NULL;
/*-----------------------*\ /*-----------------------*\
! DEFINE DER. VARIABLES: ! ! DEFINE DER. VARIABLES: !
\*-----------------------*/ \*-----------------------*/
bwc_precision precision; bwc_precision precision;
bwc_stream *stream; bwc_stream *stream = NULL;
bwc_codec *coder; bwc_codec *coder = NULL;
/*-----------------------*\ /*-----------------------*\
! DEFINE STRUCTS: ! ! DEFINE STRUCTS: !
\*-----------------------*/ \*-----------------------*/
eas3_data *data; eas3_data *data = NULL;
cli_arguments arguments = {0}; cli_arguments arguments = {0};
/* Parse the command line arguments and invoke the appro- * /* Parse the command line arguments and invoke the appro- *
@ -1173,7 +1172,7 @@ int main(int argc, char *argv[])
printf(TYPERROR); printf(TYPERROR);
goto OUT; goto OUT;
} }
cli_output = calloc(strlen(arguments.out) - strlen(buffer) + 1, sizeof(char)); cli_output = calloc(strlen(arguments.out) - strlen(buffer) + 5, sizeof(char));
if (cli_output == NULL) if (cli_output == NULL)
{ {
error_handle = EXIT_FAILURE; error_handle = EXIT_FAILURE;
@ -1471,5 +1470,8 @@ OUT:
if (cli_output != NULL) if (cli_output != NULL)
free(cli_output); free(cli_output);
if (fp != NULL)
fclose(fp);
return error_handle; return error_handle;
} }