feat/api #46

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

View file

@ -1057,7 +1057,7 @@ read_eas3_header(FILE *const fp, eas3_data *const data)
! !
\*----------------------------------------------------------------------------------------------------------*/
static uchar
write_eas3_header(bwc_data *const data)
write_eas3_header(FILE *const fp, eas3_data *const data)
{
/*-----------------------*\
! DEFINE INT VARIABLES: !
@ -1075,25 +1075,13 @@ write_eas3_header(bwc_data *const data)
bwc_gl_inf *info;
bitstream *aux;
eas3_std_params *params;
bwc_cmd_opts_ll *param;
/*-----------------------*\
! DEFINE FILE POINTER: !
\*-----------------------*/
FILE *fp;
eas3_param_names *param_names;
/*-----------------------*\
! DEFINE ASSERTIONS: !
\*-----------------------*/
assert(data);
/*--------------------------------------------------------*\
! Save the file pointer and data info structure in tempo- !
! rary variables to make the code more readable. !
\*--------------------------------------------------------*/
fp = data->fp;
info = &data->info;
/*--------------------------------------------------------*\
! Write the valid EAS3 identifier to the specified file. !
\*--------------------------------------------------------*/
@ -1107,8 +1095,7 @@ write_eas3_header(bwc_data *const data)
/*--------------------------------------------------------*\
! Initialize the auxiliary information stream. !
\*--------------------------------------------------------*/
aux = init_stream(data->codestream.aux->memory,
data->codestream.aux->size, 'd');
aux = init_stream(data->aux->memory, data->aux->size, 'd');
/*--------------------------------------------------------*\
! Get the standard parameters from the auxiliary informa- !
@ -1142,7 +1129,7 @@ write_eas3_header(bwc_data *const data)
! the timestep array from the auxiliary information block !
! and write it to the file stream. !
\*--------------------------------------------------------*/
buffer_char = get_chunck(aux, info->nTS * sizeof(uint64));
buffer_char = get_chunck(aux, data->params.nts * sizeof(uint64));
if(!buffer_char)
{
// memory allocation error
@ -1151,7 +1138,7 @@ write_eas3_header(bwc_data *const data)
return 1;
}
if(fwrite(buffer_char, sizeof(uint64), info->nTS, fp) != info->nTS)
if(fwrite(buffer_char, sizeof(uint64), data->params.nts, fp) != data->params.nts)
{
// invalid read
fprintf(stderr, WRTERROR);
@ -1171,7 +1158,7 @@ write_eas3_header(bwc_data *const data)
! the timestep attribute array from the auxiliary informa- !
! tion block and write it to the file stream. !
\*--------------------------------------------------------*/
buffer_char = get_chunck(aux, info->nTS * ATTRLEN);
buffer_char = get_chunck(aux, data->params.nts * ATTRLEN);
if(!buffer_char)
{
// memory allocation error
@ -1180,7 +1167,7 @@ write_eas3_header(bwc_data *const data)
return 1;
}
if(fwrite(buffer_char, sizeof(uchar), info->nTS * ATTRLEN, fp) != (info->nTS * ATTRLEN))
if(fwrite(buffer_char, sizeof(uchar), data->params.nts * ATTRLEN, fp) != (data->params.nts * ATTRLEN))
{
// invalid read
fprintf(stderr, WRTERROR);
@ -1192,17 +1179,17 @@ write_eas3_header(bwc_data *const data)
/*--------------------------------------------------------*\
! Loop through the parameter array and... !
\*--------------------------------------------------------*/
if(data->info.parameter)
if(data->param_names)
{
param = data->info.parameter->root;
param_names = data->param_names->root;
while(param != NULL)
while(param_names != NULL)
{
/*--------------------------------------------------------*\
! ... write the parameter name from the info structure to !
! the file stream. !
\*--------------------------------------------------------*/
if(fwrite(param->name, sizeof(char), ATTRLEN, fp) != ATTRLEN)
if(fwrite(param_names->name, sizeof(char), ATTRLEN, fp) != ATTRLEN)
{
// invalid read
fprintf(stderr, WRTERROR);
@ -1210,7 +1197,7 @@ write_eas3_header(bwc_data *const data)
return 1;
}
param = param -> next;
param_names = param_names->next;
}
}
}