summaryrefslogtreecommitdiff
path: root/src/lib/openjpip/metadata_manager.c
diff options
context:
space:
mode:
authorAntonin Descampe <antonin@gmail.com>2016-01-25 23:22:06 +0100
committerAntonin Descampe <antonin@gmail.com>2016-01-25 23:22:06 +0100
commit0febbff19e05cb1a6c2613eee76ad46a669c96cd (patch)
treeb6442d01348e2ba6404d0fd6abcc4eb6d6cc1390 /src/lib/openjpip/metadata_manager.c
parentbede1568b197021bb576b935422af6c1d0a79e21 (diff)
processed all c/h files through astyle with opj_astyle.cfgcodingstyle
Diffstat (limited to 'src/lib/openjpip/metadata_manager.c')
-rw-r--r--src/lib/openjpip/metadata_manager.c298
1 files changed, 149 insertions, 149 deletions
diff --git a/src/lib/openjpip/metadata_manager.c b/src/lib/openjpip/metadata_manager.c
index e4666622..672d6727 100644
--- a/src/lib/openjpip/metadata_manager.c
+++ b/src/lib/openjpip/metadata_manager.c
@@ -48,206 +48,206 @@
metadatalist_param_t * gene_metadatalist(void)
{
- metadatalist_param_t *list;
+ metadatalist_param_t *list;
- list = (metadatalist_param_t *)malloc( sizeof(metadatalist_param_t));
-
- list->first = NULL;
- list->last = NULL;
+ list = (metadatalist_param_t *)malloc( sizeof(metadatalist_param_t));
- return list;
+ list->first = NULL;
+ list->last = NULL;
+
+ return list;
}
metadatalist_param_t * const_metadatalist( int fd)
{
- metadatalist_param_t *metadatalist;
- metadata_param_t *metabin;
- boxlist_param_t *toplev_boxlist;
- box_param_t *box, *next;
- placeholderlist_param_t *phldlist;
- placeholder_param_t *phld;
- Byte8_t idx;
- Byte8_t filesize;
-
- if(!(filesize = (Byte8_t)get_filesize( fd)))
- return NULL;
-
- if( !(toplev_boxlist = get_boxstructure( fd, 0, filesize))){
- fprintf( FCGI_stderr, "Error: Not correctl JP2 format\n");
- return NULL;
- }
-
- phldlist = gene_placeholderlist();
- metadatalist = gene_metadatalist();
-
- box = toplev_boxlist->first;
- idx = 0;
- while( box){
- next = box->next;
- if( strncmp( box->type, "jP ",4)!=0 && strncmp( box->type, "ftyp",4)!=0 && strncmp( box->type, "jp2h",4)!=0){
- boxlist_param_t *boxlist = NULL;
- boxcontents_param_t *boxcontents = NULL;
-
- phld = gene_placeholder( box, ++idx);
- insert_placeholder_into_list( phld, phldlist);
-
- boxlist = get_boxstructure( box->fd, get_DBoxoff( box), get_DBoxlen(box));
- if( !boxlist)
- boxcontents = gene_boxcontents( get_DBoxoff( box), get_DBoxlen(box));
-
- delete_box_in_list( &box, toplev_boxlist);
- metabin = gene_metadata( idx, boxlist, NULL, boxcontents);
- insert_metadata_into_list( metabin, metadatalist);
+ metadatalist_param_t *metadatalist;
+ metadata_param_t *metabin;
+ boxlist_param_t *toplev_boxlist;
+ box_param_t *box, *next;
+ placeholderlist_param_t *phldlist;
+ placeholder_param_t *phld;
+ Byte8_t idx;
+ Byte8_t filesize;
+
+ if(!(filesize = (Byte8_t)get_filesize( fd)))
+ return NULL;
+
+ if( !(toplev_boxlist = get_boxstructure( fd, 0, filesize))) {
+ fprintf( FCGI_stderr, "Error: Not correctl JP2 format\n");
+ return NULL;
+ }
+
+ phldlist = gene_placeholderlist();
+ metadatalist = gene_metadatalist();
+
+ box = toplev_boxlist->first;
+ idx = 0;
+ while( box) {
+ next = box->next;
+ if( strncmp( box->type, "jP ",4)!=0 && strncmp( box->type, "ftyp",4)!=0 && strncmp( box->type, "jp2h",4)!=0) {
+ boxlist_param_t *boxlist = NULL;
+ boxcontents_param_t *boxcontents = NULL;
+
+ phld = gene_placeholder( box, ++idx);
+ insert_placeholder_into_list( phld, phldlist);
+
+ boxlist = get_boxstructure( box->fd, get_DBoxoff( box), get_DBoxlen(box));
+ if( !boxlist)
+ boxcontents = gene_boxcontents( get_DBoxoff( box), get_DBoxlen(box));
+
+ delete_box_in_list( &box, toplev_boxlist);
+ metabin = gene_metadata( idx, boxlist, NULL, boxcontents);
+ insert_metadata_into_list( metabin, metadatalist);
+ }
+ box = next;
}
- box = next;
- }
- metabin = gene_metadata( 0, toplev_boxlist, phldlist, NULL);
- insert_metadata_into_list( metabin, metadatalist);
+ metabin = gene_metadata( 0, toplev_boxlist, phldlist, NULL);
+ insert_metadata_into_list( metabin, metadatalist);
- return metadatalist;
+ return metadatalist;
}
void delete_metadatalist( metadatalist_param_t **list)
{
- metadata_param_t *ptr, *next;
+ metadata_param_t *ptr, *next;
- ptr = (*list)->first;
+ ptr = (*list)->first;
- while( ptr != NULL){
- next=ptr->next;
- delete_metadata( &ptr);
- ptr=next;
- }
- free( *list);
+ while( ptr != NULL) {
+ next=ptr->next;
+ delete_metadata( &ptr);
+ ptr=next;
+ }
+ free( *list);
}
metadata_param_t * gene_metadata( Byte8_t idx, boxlist_param_t *boxlist, placeholderlist_param_t *phldlist, boxcontents_param_t *boxcontents)
{
- metadata_param_t *bin;
-
- bin = (metadata_param_t *)malloc( sizeof(metadata_param_t));
- bin->idx = idx;
- bin->boxlist = boxlist;
- bin->placeholderlist = phldlist;
- bin->boxcontents = boxcontents;
- bin->next = NULL;
-
- return bin;
+ metadata_param_t *bin;
+
+ bin = (metadata_param_t *)malloc( sizeof(metadata_param_t));
+ bin->idx = idx;
+ bin->boxlist = boxlist;
+ bin->placeholderlist = phldlist;
+ bin->boxcontents = boxcontents;
+ bin->next = NULL;
+
+ return bin;
}
void delete_metadata( metadata_param_t **metadata)
{
- delete_boxlist( &((*metadata)->boxlist));
- delete_placeholderlist( &((*metadata)->placeholderlist));
- if((*metadata)->boxcontents)
- free((*metadata)->boxcontents);
+ delete_boxlist( &((*metadata)->boxlist));
+ delete_placeholderlist( &((*metadata)->placeholderlist));
+ if((*metadata)->boxcontents)
+ free((*metadata)->boxcontents);
#ifndef SERVER
- /* fprintf( logstream, "local log: Metadata-bin: %d deleted\n", (*metadata)->idx);*/
+ /* fprintf( logstream, "local log: Metadata-bin: %d deleted\n", (*metadata)->idx);*/
#endif
- free( *metadata);
+ free( *metadata);
}
void insert_metadata_into_list( metadata_param_t *metabin, metadatalist_param_t *metadatalist)
{
- if( metadatalist->first)
- metadatalist->last->next = metabin;
- else
- metadatalist->first = metabin;
- metadatalist->last = metabin;
+ if( metadatalist->first)
+ metadatalist->last->next = metabin;
+ else
+ metadatalist->first = metabin;
+ metadatalist->last = metabin;
}
void print_metadata( metadata_param_t *metadata)
{
- boxcontents_param_t *boxcont;
- fprintf( logstream, "metadata-bin %" PRIu64 " info:\n", metadata->idx);
- print_allbox( metadata->boxlist);
- print_allplaceholder( metadata->placeholderlist);
-
- boxcont = metadata->boxcontents;
- if( boxcont)
- fprintf( logstream, "box contents:\n"
- "\t offset: %" PRId64 " %#" PRIx64 "\n"
- "\t length: %" PRId64 " %#" PRIx64 "\n", boxcont->offset,
- boxcont->offset, boxcont->length, boxcont->length);
+ boxcontents_param_t *boxcont;
+ fprintf( logstream, "metadata-bin %" PRIu64 " info:\n", metadata->idx);
+ print_allbox( metadata->boxlist);
+ print_allplaceholder( metadata->placeholderlist);
+
+ boxcont = metadata->boxcontents;
+ if( boxcont)
+ fprintf( logstream, "box contents:\n"
+ "\t offset: %" PRId64 " %#" PRIx64 "\n"
+ "\t length: %" PRId64 " %#" PRIx64 "\n", boxcont->offset,
+ boxcont->offset, boxcont->length, boxcont->length);
}
void print_allmetadata( metadatalist_param_t *list)
{
- metadata_param_t *ptr;
-
- fprintf( logstream, "all metadata info: \n");
- ptr = list->first;
- while( ptr != NULL){
- print_metadata( ptr);
- ptr=ptr->next;
- }
+ metadata_param_t *ptr;
+
+ fprintf( logstream, "all metadata info: \n");
+ ptr = list->first;
+ while( ptr != NULL) {
+ print_metadata( ptr);
+ ptr=ptr->next;
+ }
}
boxcontents_param_t * gene_boxcontents( OPJ_OFF_T offset, OPJ_SIZE_T length)
{
- boxcontents_param_t *contents;
+ boxcontents_param_t *contents;
- contents = (boxcontents_param_t *)malloc( sizeof(boxcontents_param_t));
+ contents = (boxcontents_param_t *)malloc( sizeof(boxcontents_param_t));
- contents->offset = offset;
- contents->length = length;
+ contents->offset = offset;
+ contents->length = length;
- return contents;
+ return contents;
}
metadata_param_t * search_metadata( Byte8_t idx, metadatalist_param_t *list)
-{
- metadata_param_t *found;
-
- found = list->first;
-
- while( found){
-
- if( found->idx == idx)
- return found;
-
- found = found->next;
- }
- return NULL;
+{
+ metadata_param_t *found;
+
+ found = list->first;
+
+ while( found) {
+
+ if( found->idx == idx)
+ return found;
+
+ found = found->next;
+ }
+ return NULL;
}
Byte8_t search_metadataidx( char boxtype[4], metadatalist_param_t *list)
{
- /* MM FIXME: what is the return type of this function ?
- Byte8_t or int ? */
- metadata_param_t *ptr;
- int i;
-
- for( i=0; i<4; i++)
- if( boxtype[i] == '_')
- boxtype[i] = ' ';
-
- ptr = list->first;
- while( ptr){
- if( ptr->boxlist){
- box_param_t *box = ptr->boxlist->first;
- while( box){
- if( strncmp ( boxtype, box->type, 4) == 0)
- return ptr->idx;
- box = box->next;
- }
+ /* MM FIXME: what is the return type of this function ?
+ Byte8_t or int ? */
+ metadata_param_t *ptr;
+ int i;
+
+ for( i=0; i<4; i++)
+ if( boxtype[i] == '_')
+ boxtype[i] = ' ';
+
+ ptr = list->first;
+ while( ptr) {
+ if( ptr->boxlist) {
+ box_param_t *box = ptr->boxlist->first;
+ while( box) {
+ if( strncmp ( boxtype, box->type, 4) == 0)
+ return ptr->idx;
+ box = box->next;
+ }
+ }
+ ptr = ptr->next;
}
- ptr = ptr->next;
- }
-
- ptr = list->first;
- while( ptr){
- if( ptr->placeholderlist){
- placeholder_param_t *phld = ptr->placeholderlist->first;
- while( phld){
- if( strncmp ( boxtype, (char *)phld->OrigBH+4, 4) == 0){
- return phld->OrigID;
- }
- phld = phld->next;
- }
+
+ ptr = list->first;
+ while( ptr) {
+ if( ptr->placeholderlist) {
+ placeholder_param_t *phld = ptr->placeholderlist->first;
+ while( phld) {
+ if( strncmp ( boxtype, (char *)phld->OrigBH+4, 4) == 0) {
+ return phld->OrigID;
+ }
+ phld = phld->next;
+ }
+ }
+ ptr = ptr->next;
}
- ptr = ptr->next;
- }
- return (Byte8_t)-1;
+ return (Byte8_t)-1;
}