2 * $Id: placeholder_manager.c 53 2011-05-09 16:55:39Z kaori $
4 * Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
5 * Copyright (c) 2002-2011, Professor Benoit Macq
6 * Copyright (c) 2010-2011, Kaori Hagihara
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
34 #include "placeholder_manager.h"
35 #include "opj_inttypes.h"
38 #include "fcgi_stdio.h"
39 #define logstream FCGI_stdout
41 #define FCGI_stdout stdout
42 #define FCGI_stderr stderr
43 #define logstream stderr
48 placeholderlist_param_t * gene_placeholderlist(void)
50 placeholderlist_param_t *list;
52 list = (placeholderlist_param_t *)malloc( sizeof(placeholderlist_param_t));
60 void delete_placeholderlist( placeholderlist_param_t **list)
62 placeholder_param_t *ptr, *next;
71 delete_placeholder( &ptr);
77 placeholder_param_t * gene_placeholder( box_param_t *box, Byte8_t origID)
79 placeholder_param_t *placeholder;
81 placeholder = (placeholder_param_t *)malloc( sizeof(placeholder_param_t));
83 strncpy( placeholder->TBox, "phld", 4);
84 placeholder->Flags = 1; /* only the access to the original contents of this box, for now */
85 placeholder->OrigID = origID;
86 placeholder->OrigBH = fetch_headbytes( box);
87 placeholder->OrigBHlen = box->headlen;
88 placeholder->LBox = 20+(Byte4_t)box->headlen;
89 placeholder->next = NULL;
94 void delete_placeholder( placeholder_param_t **placeholder)
96 if( (*placeholder)->OrigBH)
97 free((*placeholder)->OrigBH);
101 void insert_placeholder_into_list( placeholder_param_t *phld, placeholderlist_param_t *phldlist)
104 phldlist->last->next = phld;
106 phldlist->first = phld;
107 phldlist->last = phld;
110 void print_placeholder( placeholder_param_t *phld)
114 fprintf( logstream, "placeholder info:\n");
115 fprintf( logstream, "\t LBox: %d %#x\n", phld->LBox, phld->LBox);
116 fprintf( logstream, "\t TBox: %.4s\n", phld->TBox);
117 fprintf( logstream, "\t Flags: %#x %#x\n", phld->Flags, phld->Flags);
118 fprintf( logstream, "\t OrigID: %" PRId64 "\n", phld->OrigID);
119 fprintf( logstream, "\t OrigBH: ");
121 for( i=0; i< phld->OrigBHlen; i++)
122 fprintf( logstream, "%02x ", phld->OrigBH[i]);
123 fprintf( logstream, "\t");
125 for( i=0; i< phld->OrigBHlen; i++)
126 fprintf( logstream, "%c", phld->OrigBH[i]);
127 fprintf( logstream, "\n");
130 void print_allplaceholder( placeholderlist_param_t *list)
132 placeholder_param_t *ptr;
137 fprintf( logstream, "all placeholder info: \n");
140 print_placeholder( ptr);