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.
33 #include "placeholder_manager.h"
37 #include "fcgi_stdio.h"
38 #define logstream FCGI_stdout
40 #define FCGI_stdout stdout
41 #define FCGI_stderr stderr
42 #define logstream stderr
47 placeholderlist_param_t * gene_placeholderlist()
49 placeholderlist_param_t *list;
51 list = (placeholderlist_param_t *)malloc( sizeof(placeholderlist_param_t));
59 void delete_placeholderlist( placeholderlist_param_t **list)
61 placeholder_param_t *ptr, *next;
70 delete_placeholder( &ptr);
76 placeholder_param_t * gene_placeholder( box_param_t *box, int origID)
78 placeholder_param_t *placeholder;
80 placeholder = (placeholder_param_t *)malloc( sizeof(placeholder_param_t));
82 strncpy( placeholder->TBox, "phld", 4);
83 placeholder->Flags = 1; // only the access to the original contents of this box, for now
84 placeholder->OrigID = origID;
85 placeholder->OrigBH = fetch_headbytes( box);
86 placeholder->OrigBHlen = box->headlen;
87 placeholder->LBox = 20+box->headlen;
88 placeholder->next = NULL;
93 void delete_placeholder( placeholder_param_t **placeholder)
95 if( (*placeholder)->OrigBH)
96 free((*placeholder)->OrigBH);
100 void insert_placeholder_into_list( placeholder_param_t *phld, placeholderlist_param_t *phldlist)
103 phldlist->last->next = phld;
105 phldlist->first = phld;
106 phldlist->last = phld;
109 void print_placeholder( placeholder_param_t *phld)
113 fprintf( logstream, "placeholder info:\n");
114 fprintf( logstream, "\t LBox: %d %#x\n", phld->LBox, phld->LBox);
115 fprintf( logstream, "\t TBox: %.4s\n", phld->TBox);
116 fprintf( logstream, "\t Flags: %#x %#x\n", phld->Flags, phld->Flags);
117 fprintf( logstream, "\t OrigID: %lld\n", phld->OrigID);
118 fprintf( logstream, "\t OrigBH: ");
120 for( i=0; i< phld->OrigBHlen; i++)
121 fprintf( logstream, "%02x ", phld->OrigBH[i]);
122 fprintf( logstream, "\t");
124 for( i=0; i< phld->OrigBHlen; i++)
125 fprintf( logstream, "%c", phld->OrigBH[i]);
126 fprintf( logstream, "\n");
129 void print_allplaceholder( placeholderlist_param_t *list)
131 placeholder_param_t *ptr;
136 fprintf( logstream, "all placeholder info: \n");
139 print_placeholder( ptr);