From 82d29d4c2a56dabfcb66b64d9d9c498e1d78e77c Mon Sep 17 00:00:00 2001 From: Mathieu Malaterre Date: Mon, 29 Oct 2012 16:24:39 +0000 Subject: [PATCH] [trunk] Remove bool.h, use opj_bool instead Fix remaining opj_calloc/malloc/free issues --- src/bin/jpip/opj_jpip_transcode.c | 8 +- src/bin/jpip/opj_server.c | 4 +- src/lib/openjpip/auxtrans_manager.c | 44 +++++----- src/lib/openjpip/auxtrans_manager.h | 3 +- src/lib/openjpip/bool.h | 52 ------------ src/lib/openjpip/cachemodel_manager.c | 34 ++++---- src/lib/openjpip/cachemodel_manager.h | 15 ++-- src/lib/openjpip/dec_clientmsg_handler.c | 4 +- src/lib/openjpip/imgsock_manager.c | 2 +- src/lib/openjpip/imgsock_manager.h | 4 +- src/lib/openjpip/index_manager.c | 101 +++++++++++------------ src/lib/openjpip/index_manager.h | 3 +- src/lib/openjpip/j2kheader_manager.c | 46 +++++------ src/lib/openjpip/j2kheader_manager.h | 7 +- src/lib/openjpip/jp2k_encoder.c | 44 +++++----- src/lib/openjpip/jpip_parser.c | 70 ++++++++-------- src/lib/openjpip/jpip_parser.h | 11 ++- src/lib/openjpip/msgqueue_manager.c | 22 ++--- src/lib/openjpip/msgqueue_manager.h | 7 +- src/lib/openjpip/openjpip.c | 52 ++++++------ src/lib/openjpip/openjpip.h | 15 ++-- src/lib/openjpip/query_parser.c | 50 +++++------ src/lib/openjpip/query_parser.h | 16 ++-- src/lib/openjpip/session_manager.c | 12 +-- src/lib/openjpip/session_manager.h | 5 +- src/lib/openjpip/sock_manager.h | 1 - src/lib/openjpip/target_manager.c | 2 +- src/lib/openjpip/target_manager.h | 5 +- 28 files changed, 289 insertions(+), 350 deletions(-) delete mode 100644 src/lib/openjpip/bool.h diff --git a/src/bin/jpip/opj_jpip_transcode.c b/src/bin/jpip/opj_jpip_transcode.c index 55ec2182..825c087a 100644 --- a/src/bin/jpip/opj_jpip_transcode.c +++ b/src/bin/jpip/opj_jpip_transcode.c @@ -53,7 +53,7 @@ static int jpip_to_jp2(int argc,char *argv[]) return -1; } - dec = init_jpipdecoder( true); + dec = init_jpipdecoder( OPJ_TRUE); if(!( fread_jpip( argv[1], dec))) return -1; @@ -63,7 +63,7 @@ static int jpip_to_jp2(int argc,char *argv[]) if(!(fwrite_jp2k( argv[2], dec))) return -1; - output_log( true, false, true, dec); + output_log( OPJ_TRUE, OPJ_FALSE, OPJ_TRUE, dec); destroy_jpipdecoder( &dec); @@ -92,7 +92,7 @@ static int jpip_to_j2k(int argc,char *argv[]) return -1; } - dec = init_jpipdecoder( false); + dec = init_jpipdecoder( OPJ_FALSE); if(!( fread_jpip( argv[1], dec))) return -1; @@ -102,7 +102,7 @@ static int jpip_to_j2k(int argc,char *argv[]) if(!( fwrite_jp2k( argv[2], dec))) return -1; - /* output_log( true, false, false, dec); */ + /* output_log( OPJ_TRUE, OPJ_FALSE, OPJ_FALSE, dec); */ destroy_jpipdecoder( &dec); diff --git a/src/bin/jpip/opj_server.c b/src/bin/jpip/opj_server.c index 1666a94f..b5cc87d7 100644 --- a/src/bin/jpip/opj_server.c +++ b/src/bin/jpip/opj_server.c @@ -84,7 +84,7 @@ int main(void) #endif { QR_t *qr; - bool parse_status; + opj_bool parse_status; #ifdef SERVER query_string = getenv("QUERY_STRING"); @@ -98,7 +98,7 @@ int main(void) parse_status = process_JPIPrequest( server_record, qr); #ifndef SERVER - local_log( true, true, parse_status, false, qr, server_record); + local_log( OPJ_TRUE, OPJ_TRUE, parse_status, OPJ_FALSE, qr, server_record); #endif if( parse_status) diff --git a/src/lib/openjpip/auxtrans_manager.c b/src/lib/openjpip/auxtrans_manager.c index 91c06ac4..07aef1c7 100644 --- a/src/lib/openjpip/auxtrans_manager.c +++ b/src/lib/openjpip/auxtrans_manager.c @@ -90,7 +90,7 @@ typedef struct aux_response_param{ #endif } aux_response_param_t; -aux_response_param_t * gene_auxresponse( bool istcp, auxtrans_param_t auxtrans, const char cid[], void *data, OPJ_SIZE_T datalen, OPJ_SIZE_T maxlenPerFrame); +aux_response_param_t * gene_auxresponse( opj_bool istcp, auxtrans_param_t auxtrans, const char cid[], void *data, OPJ_SIZE_T datalen, OPJ_SIZE_T maxlenPerFrame); void delete_auxresponse( aux_response_param_t **auxresponse); @@ -101,7 +101,7 @@ unsigned __stdcall aux_streaming( void *arg); void * aux_streaming( void *arg); #endif -void send_responsedata_on_aux( bool istcp, auxtrans_param_t auxtrans, const char cid[], void *data, OPJ_SIZE_T datalen, OPJ_SIZE_T maxlenPerFrame) +void send_responsedata_on_aux( opj_bool istcp, auxtrans_param_t auxtrans, const char cid[], void *data, OPJ_SIZE_T datalen, OPJ_SIZE_T maxlenPerFrame) { aux_response_param_t *auxresponse; #ifdef _WIN32 @@ -133,11 +133,11 @@ void send_responsedata_on_aux( bool istcp, auxtrans_param_t auxtrans, const char fprintf( FCGI_stderr, "Error: error in send_responsedata_on_aux(), udp not implemented\n"); } -aux_response_param_t * gene_auxresponse( bool istcp, auxtrans_param_t auxtrans, const char cid[], void *data, OPJ_SIZE_T datalen, OPJ_SIZE_T maxlenPerFrame) +aux_response_param_t * gene_auxresponse( opj_bool istcp, auxtrans_param_t auxtrans, const char cid[], void *data, OPJ_SIZE_T datalen, OPJ_SIZE_T maxlenPerFrame) { aux_response_param_t *auxresponse; - auxresponse = (aux_response_param_t *)malloc( sizeof(aux_response_param_t)); + auxresponse = (aux_response_param_t *)opj_malloc( sizeof(aux_response_param_t)); auxresponse->cid = strdup( cid); auxresponse->data = data; @@ -150,9 +150,9 @@ aux_response_param_t * gene_auxresponse( bool istcp, auxtrans_param_t auxtrans, void delete_auxresponse( aux_response_param_t **auxresponse) { - free( (*auxresponse)->cid); - free( (*auxresponse)->data); - free( *auxresponse); + opj_free( (*auxresponse)->cid); + opj_free( (*auxresponse)->data); + opj_free( *auxresponse); } /** @@ -163,9 +163,9 @@ void delete_auxresponse( aux_response_param_t **auxresponse) * @param [in] fp file pointer for log of aux stream * @return true if identified, false otherwise */ -bool identify_cid( SOCKET connected_socket, char refcid[], FILE *fp); +opj_bool identify_cid( SOCKET connected_socket, char refcid[], FILE *fp); -bool recv_ack( SOCKET connected_socket, void *data); +opj_bool recv_ack( SOCKET connected_socket, void *data); #ifdef _WIN32 unsigned __stdcall aux_streaming( void *arg) @@ -186,7 +186,7 @@ void * aux_streaming( void *arg) pthread_detach( pthread_self()); #endif - chunk = (unsigned char *)malloc( auxresponse->maxlenPerFrame); + chunk = (unsigned char *)opj_malloc( auxresponse->maxlenPerFrame); maxLenOfBody = auxresponse->maxlenPerFrame - headlen; remlen = auxresponse->datalen; @@ -216,7 +216,7 @@ void * aux_streaming( void *arg) break; } } - free( chunk); + opj_free( chunk); delete_auxresponse( &auxresponse); @@ -230,38 +230,38 @@ void * aux_streaming( void *arg) } -bool identify_cid( SOCKET connected_socket, char refcid[], FILE *fp) +opj_bool identify_cid( SOCKET connected_socket, char refcid[], FILE *fp) { char *cid; - bool succeed; + opj_bool succeed; if(!(cid = receive_string( connected_socket))){ fprintf( fp, "Error: error in identify_cid(), while receiving cid from client\n"); - return false; + return OPJ_FALSE; } - succeed = false; + succeed = OPJ_FALSE; if( strncmp( refcid, cid, strlen( refcid)) == 0) - succeed = true; + succeed = OPJ_TRUE; - free( cid); + opj_free( cid); return succeed; } -bool recv_ack( SOCKET connected_socket, void *data) +opj_bool recv_ack( SOCKET connected_socket, void *data) { char *header; - bool succeed; + opj_bool succeed; header = receive_stream( connected_socket, 8); if( memcmp( header, data, 8) != 0) - succeed = false; + succeed = OPJ_FALSE; else - succeed = true; + succeed = OPJ_TRUE; - free( header); + opj_free( header); return succeed; } diff --git a/src/lib/openjpip/auxtrans_manager.h b/src/lib/openjpip/auxtrans_manager.h index c80988a9..4642ab1d 100644 --- a/src/lib/openjpip/auxtrans_manager.h +++ b/src/lib/openjpip/auxtrans_manager.h @@ -32,6 +32,7 @@ # define AUXTRANS_MANAGER_H_ #include "sock_manager.h" +#include "opj_includes.h" /** auxiliary transport setting parameters*/ typedef struct auxtrans_param{ @@ -67,6 +68,6 @@ void close_aux_transport( auxtrans_param_t auxtrans); * @param[in] length length of data * @param[in] maxlenPerFrame maximum data length to send per frame */ -void send_responsedata_on_aux( bool istcp, auxtrans_param_t auxtrans, const char cid[], void *data, OPJ_SIZE_T length, OPJ_SIZE_T maxlenPerFrame); +void send_responsedata_on_aux( opj_bool istcp, auxtrans_param_t auxtrans, const char cid[], void *data, OPJ_SIZE_T length, OPJ_SIZE_T maxlenPerFrame); #endif /* !AUXTRANS_MANAGER_H_ */ diff --git a/src/lib/openjpip/bool.h b/src/lib/openjpip/bool.h deleted file mode 100644 index c3adf580..00000000 --- a/src/lib/openjpip/bool.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * $Id$ - * - * Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium - * Copyright (c) 2002-2011, Professor Benoit Macq - * Copyright (c) 2010-2011, Kaori Hagihara - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef BOOL_H_ -# define BOOL_H_ - -#ifndef false -#define false 0 -#endif - -#ifndef FALSE -#define FALSE 0 -#endif - -#ifndef true -#define true (!false) -#endif - -#ifndef TRUE -#define TRUE (!FALSE) -#endif - -typedef char bool; - -#endif /* !BOOL_H_ */ diff --git a/src/lib/openjpip/cachemodel_manager.c b/src/lib/openjpip/cachemodel_manager.c index 70bbb2c3..65de4980 100644 --- a/src/lib/openjpip/cachemodel_manager.c +++ b/src/lib/openjpip/cachemodel_manager.c @@ -56,7 +56,7 @@ cachemodellist_param_t * gene_cachemodellist(void) return cachemodellist; } -cachemodel_param_t * gene_cachemodel( cachemodellist_param_t *cachemodellist, target_param_t *target, bool reqJPP) +cachemodel_param_t * gene_cachemodel( cachemodellist_param_t *cachemodellist, target_param_t *target, opj_bool reqJPP) { cachemodel_param_t *cachemodel; faixbox_param_t *tilepart; @@ -71,27 +71,27 @@ cachemodel_param_t * gene_cachemodel( cachemodellist_param_t *cachemodellist, ta if( reqJPP){ if( target->jppstream) - cachemodel->jppstream = true; + cachemodel->jppstream = OPJ_TRUE; else - cachemodel->jppstream = false; + cachemodel->jppstream = OPJ_FALSE; } else{ /* reqJPT */ if( target->jptstream) - cachemodel->jppstream = false; + cachemodel->jppstream = OPJ_FALSE; else - cachemodel->jppstream = true; + cachemodel->jppstream = OPJ_TRUE; } - cachemodel->mhead_model = false; + cachemodel->mhead_model = OPJ_FALSE; tilepart = target->codeidx->tilepart; numOftiles = get_m( tilepart); numOfelem = get_nmax( tilepart)*numOftiles; - cachemodel->tp_model = (bool *)opj_calloc( 1, numOfelem*sizeof(bool)); - cachemodel->th_model = (bool *)opj_calloc( 1, numOftiles*sizeof(bool)); - cachemodel->pp_model = (bool **)opj_malloc( target->codeidx->SIZ.Csiz*sizeof(bool *)); + cachemodel->tp_model = (opj_bool *)opj_calloc( 1, numOfelem*sizeof(opj_bool)); + cachemodel->th_model = (opj_bool *)opj_calloc( 1, numOftiles*sizeof(opj_bool)); + cachemodel->pp_model = (opj_bool **)opj_malloc( target->codeidx->SIZ.Csiz*sizeof(opj_bool *)); for( i=0; icodeidx->SIZ.Csiz; i++){ precpacket = target->codeidx->precpacket[i]; - cachemodel->pp_model[i] = (bool *)opj_calloc( 1, get_nmax(precpacket)*get_m(precpacket)*sizeof(bool)); + cachemodel->pp_model[i] = (opj_bool *)opj_calloc( 1, get_nmax(precpacket)*get_m(precpacket)*sizeof(opj_bool)); } cachemodel->next = NULL; @@ -196,7 +196,7 @@ void delete_cachemodel( cachemodel_param_t **cachemodel) opj_free( *cachemodel); } -bool is_allsent( cachemodel_param_t cachemodel) +opj_bool is_allsent( cachemodel_param_t cachemodel) { target_param_t *target; Byte8_t TPnum; /* num of tile parts in each tile */ @@ -207,30 +207,30 @@ bool is_allsent( cachemodel_param_t cachemodel) target = cachemodel.target; if( !cachemodel.mhead_model) - return false; + return OPJ_FALSE; TPnum = get_nmax( target->codeidx->tilepart); if( cachemodel.jppstream){ for( i=0; icodeidx->SIZ.XTnum*target->codeidx->SIZ.YTnum; i++){ if( !cachemodel.th_model[i]) - return false; + return OPJ_FALSE; for( j=0; jcodeidx->SIZ.Csiz; j++){ Pmax = get_nmax( target->codeidx->precpacket[j]); for( k=0; kcodeidx->SIZ.YTnum; i++) for( j=0; jcodeidx->SIZ.XTnum; j++) for( k=0; k #include -#include "bool.h" #include "opj_inttypes.h" #include "index_manager.h" #include "box_manager.h" @@ -59,7 +58,7 @@ * @param[in] toplev_boxlist top level box list * @return if correct (true) or wrong (false) */ -bool check_JP2boxidx( boxlist_param_t *toplev_boxlist); +opj_bool check_JP2boxidx( boxlist_param_t *toplev_boxlist); /** * set code index parameters (parse cidx box) @@ -69,7 +68,7 @@ bool check_JP2boxidx( boxlist_param_t *toplev_boxlist); * @param[out] codeidx pointer to index parameters * @return if succeeded (true) or failed (false) */ -bool set_cidxdata( box_param_t *cidx_box, index_param_t *codeidx); +opj_bool set_cidxdata( box_param_t *cidx_box, index_param_t *codeidx); index_param_t * parse_jp2file( int fd) { @@ -205,7 +204,7 @@ void delete_COD( CODmarker_param_t COD) if( COD.YPsiz) opj_free( COD.YPsiz); } -bool check_JP2boxidx( boxlist_param_t *toplev_boxlist) +opj_bool check_JP2boxidx( boxlist_param_t *toplev_boxlist) { box_param_t *iptr, *fidx, *prxy; box_param_t *cidx, *jp2c; @@ -247,7 +246,7 @@ bool check_JP2boxidx( boxlist_param_t *toplev_boxlist) ni = fetch_DBox1byte( prxy, pos); if( ni != 1){ fprintf( FCGI_stderr, "Multiple indexes not supported\n"); - return false; + return OPJ_FALSE; } pos += 1; @@ -264,7 +263,7 @@ bool check_JP2boxidx( boxlist_param_t *toplev_boxlist) opj_free(prxy); - return true; + return OPJ_TRUE; } /** @@ -275,7 +274,7 @@ bool check_JP2boxidx( boxlist_param_t *toplev_boxlist) * @param[out] jp2idx pointer to index parameters * @return if succeeded (true) or failed (false) */ -bool set_cptrdata( box_param_t *cidx_box, index_param_t *jp2idx); +opj_bool set_cptrdata( box_param_t *cidx_box, index_param_t *jp2idx); /** * set code index parameters from mhix box for main header @@ -286,7 +285,7 @@ bool set_cptrdata( box_param_t *cidx_box, index_param_t *jp2idx); * @param[out] jp2idx pointer to index parameters * @return if succeeded (true) or failed (false) */ -bool set_mainmhixdata( box_param_t *cidx_box, codestream_param_t codestream, index_param_t *jp2idx); +opj_bool set_mainmhixdata( box_param_t *cidx_box, codestream_param_t codestream, index_param_t *jp2idx); /** * set code index parameters from tpix box @@ -296,7 +295,7 @@ bool set_mainmhixdata( box_param_t *cidx_box, codestream_param_t codestream, ind * @param[out] jp2idx pointer to index parameters * @return if succeeded (true) or failed (false) */ -bool set_tpixdata( box_param_t *cidx_box, index_param_t *jp2idx); +opj_bool set_tpixdata( box_param_t *cidx_box, index_param_t *jp2idx); /** * set code index parameters from thix box @@ -306,7 +305,7 @@ bool set_tpixdata( box_param_t *cidx_box, index_param_t *jp2idx); * @param[out] jp2idx pointer to index parameters * @return if succeeded (true) or failed (false) */ -bool set_thixdata( box_param_t *cidx_box, index_param_t *jp2idx); +opj_bool set_thixdata( box_param_t *cidx_box, index_param_t *jp2idx); /** * set code index parameters from ppix box @@ -316,9 +315,9 @@ bool set_thixdata( box_param_t *cidx_box, index_param_t *jp2idx); * @param[out] jp2idx pointer to index parameters * @return if succeeded (true) or failed (false) */ -bool set_ppixdata( box_param_t *cidx_box, index_param_t *jp2idx); +opj_bool set_ppixdata( box_param_t *cidx_box, index_param_t *jp2idx); -bool set_cidxdata( box_param_t *cidx_box, index_param_t *jp2idx) +opj_bool set_cidxdata( box_param_t *cidx_box, index_param_t *jp2idx) { box_param_t *manf_box; manfbox_param_t *manf; @@ -334,51 +333,51 @@ bool set_cidxdata( box_param_t *cidx_box, index_param_t *jp2idx) if( !search_boxheader( "mhix", manf)){ fprintf( FCGI_stderr, "Error: mhix box not present in manfbox\n"); opj_free(jp2idx); - return false; + return OPJ_FALSE; } set_mainmhixdata( cidx_box, codestream, jp2idx); if( !search_boxheader( "tpix", manf)){ fprintf( FCGI_stderr, "Error: tpix box not present in manfbox\n"); opj_free(jp2idx); - return false; + return OPJ_FALSE; } set_tpixdata( cidx_box, jp2idx); if( !search_boxheader( "thix", manf)){ fprintf( FCGI_stderr, "Error: thix box not present in manfbox\n"); opj_free(jp2idx); - return false; + return OPJ_FALSE; } set_thixdata( cidx_box, jp2idx); if( !search_boxheader( "ppix", manf)){ fprintf( FCGI_stderr, "Error: ppix box not present in manfbox\n"); opj_free(jp2idx); - return false; + return OPJ_FALSE; } set_ppixdata( cidx_box, jp2idx); delete_manfbox( &manf); opj_free( manf_box); - return true; + return OPJ_TRUE; } -bool set_cptrdata( box_param_t *cidx_box, index_param_t *jp2idx) +opj_bool set_cptrdata( box_param_t *cidx_box, index_param_t *jp2idx) { box_param_t *box; /**< cptr box*/ Byte2_t dr, cont; if( !(box = gene_boxbyType( cidx_box->fd, get_DBoxoff( cidx_box), get_DBoxlen( cidx_box), "cptr"))) - return false; + return OPJ_FALSE; /* DR: Data Reference. */ /* If 0, the codestream or its Fragment Table box exists in the current file*/ if(( dr = fetch_DBox2bytebigendian( box, 0))){ fprintf( FCGI_stderr, "Error: Codestream not present in current file\n"); opj_free( box); - return false; + return OPJ_FALSE; } /* CONT: Container Type*/ @@ -387,7 +386,7 @@ bool set_cptrdata( box_param_t *cidx_box, index_param_t *jp2idx) if(( cont = fetch_DBox2bytebigendian( box, 2))){ fprintf( FCGI_stderr, "Error: Can't cope with fragmented codestreams yet\n"); opj_free( box); - return false; + return OPJ_FALSE; } jp2idx->offset = (OPJ_OFF_T)fetch_DBox8bytebigendian( box, 4); @@ -395,7 +394,7 @@ bool set_cptrdata( box_param_t *cidx_box, index_param_t *jp2idx) opj_free( box); - return true; + return OPJ_TRUE; } @@ -409,7 +408,7 @@ bool set_cptrdata( box_param_t *cidx_box, index_param_t *jp2idx) * @param[out] SIZ SIZ marker parameters pointer * @return if succeeded (true) or failed (false) */ -bool set_SIZmkrdata( markeridx_param_t *sizmkidx, codestream_param_t codestream, SIZmarker_param_t *SIZ); +opj_bool set_SIZmkrdata( markeridx_param_t *sizmkidx, codestream_param_t codestream, SIZmarker_param_t *SIZ); /** * set code index parameters from COD marker in codestream @@ -421,9 +420,9 @@ bool set_SIZmkrdata( markeridx_param_t *sizmkidx, codestream_param_t codestream, * @param[out] COD COD marker parameters pointer * @return if succeeded (true) or failed (false) */ -bool set_CODmkrdata( markeridx_param_t *codmkidx, codestream_param_t codestream, CODmarker_param_t *COD); +opj_bool set_CODmkrdata( markeridx_param_t *codmkidx, codestream_param_t codestream, CODmarker_param_t *COD); -bool set_mainmhixdata( box_param_t *cidx_box, codestream_param_t codestream, index_param_t *jp2idx) +opj_bool set_mainmhixdata( box_param_t *cidx_box, codestream_param_t codestream, index_param_t *jp2idx) { box_param_t *mhix_box; mhixbox_param_t *mhix; @@ -431,7 +430,7 @@ bool set_mainmhixdata( box_param_t *cidx_box, codestream_param_t codestream, ind markeridx_param_t *codmkidx; if( !(mhix_box = gene_boxbyType( cidx_box->fd, get_DBoxoff( cidx_box), get_DBoxlen( cidx_box), "mhix"))) - return false; + return OPJ_FALSE; jp2idx->mhead_length = fetch_DBox8bytebigendian( mhix_box, 0); @@ -446,22 +445,22 @@ bool set_mainmhixdata( box_param_t *cidx_box, codestream_param_t codestream, ind delete_mhixbox( &mhix); - return true; + return OPJ_TRUE; } -bool set_tpixdata( box_param_t *cidx_box, index_param_t *jp2idx) +opj_bool set_tpixdata( box_param_t *cidx_box, index_param_t *jp2idx) { box_param_t *tpix_box; /**< tpix box*/ box_param_t *faix_box; /**< faix box*/ if( !(tpix_box = gene_boxbyType( cidx_box->fd, get_DBoxoff( cidx_box), get_DBoxlen( cidx_box), "tpix"))){ fprintf( FCGI_stderr, "Error: tpix box not present in cidx box\n"); - return false; + return OPJ_FALSE; } if( !(faix_box = gene_boxbyType( tpix_box->fd, get_DBoxoff( tpix_box), get_DBoxlen( tpix_box), "faix"))){ fprintf( FCGI_stderr, "Error: faix box not present in tpix box\n"); - return false; + return OPJ_FALSE; } jp2idx->tilepart = gene_faixbox( faix_box); @@ -469,10 +468,10 @@ bool set_tpixdata( box_param_t *cidx_box, index_param_t *jp2idx) opj_free( tpix_box); opj_free( faix_box); - return true; + return OPJ_TRUE; } -bool set_thixdata( box_param_t *cidx_box, index_param_t *jp2idx) +opj_bool set_thixdata( box_param_t *cidx_box, index_param_t *jp2idx) { box_param_t *thix_box, *manf_box, *mhix_box; manfbox_param_t *manf; @@ -484,13 +483,13 @@ bool set_thixdata( box_param_t *cidx_box, index_param_t *jp2idx) if( !(thix_box = gene_boxbyType( cidx_box->fd, get_DBoxoff( cidx_box), get_DBoxlen( cidx_box), "thix"))){ fprintf( FCGI_stderr, "Error: thix box not present in cidx box\n"); - return false; + return OPJ_FALSE; } if( !(manf_box = gene_boxbyType( thix_box->fd, get_DBoxoff( thix_box), get_DBoxlen( thix_box), "manf"))){ fprintf( FCGI_stderr, "Error: manf box not present in thix box\n"); opj_free( thix_box); - return false; + return OPJ_FALSE; } manf = gene_manfbox( manf_box); @@ -506,7 +505,7 @@ bool set_thixdata( box_param_t *cidx_box, index_param_t *jp2idx) delete_manfbox( &manf); opj_free( manf_box); opj_free( thix_box); - return false; + return OPJ_FALSE; } mhix = gene_mhixbox( mhix_box); @@ -521,10 +520,10 @@ bool set_thixdata( box_param_t *cidx_box, index_param_t *jp2idx) opj_free( manf_box); opj_free( thix_box); - return true; + return OPJ_TRUE; } -bool set_ppixdata( box_param_t *cidx_box, index_param_t *jp2idx) +opj_bool set_ppixdata( box_param_t *cidx_box, index_param_t *jp2idx) { box_param_t *ppix_box, *faix_box, *manf_box; manfbox_param_t *manf; /**< manf*/ @@ -535,14 +534,14 @@ bool set_ppixdata( box_param_t *cidx_box, index_param_t *jp2idx) if( !(ppix_box = gene_boxbyType( cidx_box->fd, get_DBoxoff( cidx_box), get_DBoxlen( cidx_box), "ppix"))){ fprintf( FCGI_stderr, "Error: ppix box not present in cidx box\n"); - return false; + return OPJ_FALSE; } inbox_offset = get_DBoxoff( ppix_box); if( !(manf_box = gene_boxbyType( ppix_box->fd, inbox_offset, get_DBoxlen( ppix_box), "manf"))){ fprintf( FCGI_stderr, "Error: manf box not present in ppix box\n"); opj_free( ppix_box); - return false; + return OPJ_FALSE; } opj_free( ppix_box); @@ -558,12 +557,12 @@ bool set_ppixdata( box_param_t *cidx_box, index_param_t *jp2idx) for( comp_idx=0; bh!=NULL; bh=bh->next, comp_idx++){ if( jp2idx->SIZ.Csiz <= comp_idx ){ fprintf( FCGI_stderr, "Error: num of faix boxes is not identical to num of components in ppix box\n"); - return false; + return OPJ_FALSE; } if( !(faix_box = gene_boxbyOffset( cidx_box->fd, inbox_offset))){ fprintf( FCGI_stderr, "Error: faix box not present in ppix box\n"); - return false; + return OPJ_FALSE; } faix = gene_faixbox( faix_box); @@ -575,10 +574,10 @@ bool set_ppixdata( box_param_t *cidx_box, index_param_t *jp2idx) delete_manfbox( &manf); - return true; + return OPJ_TRUE; } -bool set_SIZmkrdata( markeridx_param_t *sizmkidx, codestream_param_t codestream, SIZmarker_param_t *SIZ) +opj_bool set_SIZmkrdata( markeridx_param_t *sizmkidx, codestream_param_t codestream, SIZmarker_param_t *SIZ) { marker_param_t sizmkr; int i; @@ -589,7 +588,7 @@ bool set_SIZmkrdata( markeridx_param_t *sizmkidx, codestream_param_t codestream, if( sizmkidx->length != SIZ->Lsiz){ fprintf( FCGI_stderr, "Error: marker %#x index is not correct\n", sizmkidx->code); - return false; + return OPJ_FALSE; } SIZ->Rsiz = fetch_marker2bytebigendian( sizmkr, 2); @@ -611,10 +610,10 @@ bool set_SIZmkrdata( markeridx_param_t *sizmkidx, codestream_param_t codestream, SIZ->XRsiz[i] = fetch_marker1byte( sizmkr, 39+i*3); SIZ->YRsiz[i] = fetch_marker1byte( sizmkr, 40+i*3); } - return true; + return OPJ_TRUE; } -bool set_CODmkrdata( markeridx_param_t *codmkidx, codestream_param_t codestream, CODmarker_param_t *COD) +opj_bool set_CODmkrdata( markeridx_param_t *codmkidx, codestream_param_t codestream, CODmarker_param_t *COD) { marker_param_t codmkr; int i; @@ -625,7 +624,7 @@ bool set_CODmkrdata( markeridx_param_t *codmkidx, codestream_param_t codestream, if( codmkidx->length != COD->Lcod){ fprintf( FCGI_stderr, "Error: marker %#x index is not correct\n", codmkidx->code); - return false; + return OPJ_FALSE; } COD->Scod = fetch_marker1byte( codmkr, 2); @@ -649,7 +648,7 @@ bool set_CODmkrdata( markeridx_param_t *codmkidx, codestream_param_t codestream, COD->XPsiz[0] = COD->YPsiz[0] = pow(2,15); } - return true; + return OPJ_TRUE; } @@ -723,10 +722,10 @@ Byte4_t min( Byte4_t n1, Byte4_t n2) return n2; } -bool isJPTfeasible( index_param_t index) +opj_bool isJPTfeasible( index_param_t index) { if( 1 < get_nmax( index.tilepart)) - return true; + return OPJ_TRUE; else - return false; + return OPJ_FALSE; } diff --git a/src/lib/openjpip/index_manager.h b/src/lib/openjpip/index_manager.h index 049f0771..7783157e 100644 --- a/src/lib/openjpip/index_manager.h +++ b/src/lib/openjpip/index_manager.h @@ -38,7 +38,6 @@ #include "faixbox_manager.h" #include "metadata_manager.h" #include "mhixbox_manager.h" -#include "bool.h" /** progression order */ #if 0 @@ -187,6 +186,6 @@ Byte4_t get_tile_YSiz( SIZmarker_param_t SIZ, Byte4_t tile_id, int level); * @param[in] index index parameters * @return true if JPT-stream is feasible */ -bool isJPTfeasible( index_param_t index); +opj_bool isJPTfeasible( index_param_t index); #endif /* !INDEX_MANAGER_H_ */ diff --git a/src/lib/openjpip/j2kheader_manager.c b/src/lib/openjpip/j2kheader_manager.c index b61da5ef..38760644 100644 --- a/src/lib/openjpip/j2kheader_manager.c +++ b/src/lib/openjpip/j2kheader_manager.c @@ -49,17 +49,17 @@ SIZmarker_param_t get_SIZmkrdata_from_j2kstream( Byte_t *SIZstream); CODmarker_param_t get_CODmkrdata_from_j2kstream( Byte_t *CODstream); -bool get_mainheader_from_j2kstream( Byte_t *j2kstream, SIZmarker_param_t *SIZ, CODmarker_param_t *COD) +opj_bool get_mainheader_from_j2kstream( Byte_t *j2kstream, SIZmarker_param_t *SIZ, CODmarker_param_t *COD) { if( *j2kstream++ != 0xff || *j2kstream++ != 0x4f){ fprintf( FCGI_stderr, "Error, j2kstream is not starting with SOC marker\n"); - return false; + return OPJ_FALSE; } if( SIZ){ *SIZ = get_SIZmkrdata_from_j2kstream( j2kstream); if( SIZ->Lsiz == 0) - return false; + return OPJ_FALSE; j2kstream += (SIZ->Lsiz+2); } @@ -70,9 +70,9 @@ bool get_mainheader_from_j2kstream( Byte_t *j2kstream, SIZmarker_param_t *SIZ, C *COD = get_CODmkrdata_from_j2kstream( j2kstream); if( COD->Lcod == 0) - return false; + return OPJ_FALSE; } - return true; + return OPJ_TRUE; } SIZmarker_param_t get_SIZmkrdata_from_j2kstream( Byte_t *SIZstream) @@ -145,38 +145,38 @@ CODmarker_param_t get_CODmkrdata_from_j2kstream( Byte_t *CODstream) } -bool modify_SIZmkrstream( SIZmarker_param_t SIZ, int difOfdecomplev, Byte_t *SIZstream); +opj_bool modify_SIZmkrstream( SIZmarker_param_t SIZ, int difOfdecomplev, Byte_t *SIZstream); Byte2_t modify_CODmkrstream( CODmarker_param_t COD, int numOfdecomp, Byte_t *CODstream); -bool modify_mainheader( Byte_t *j2kstream, int numOfdecomp, SIZmarker_param_t SIZ, CODmarker_param_t COD, Byte8_t *j2klen) +opj_bool modify_mainheader( Byte_t *j2kstream, int numOfdecomp, SIZmarker_param_t SIZ, CODmarker_param_t COD, Byte8_t *j2klen) { Byte2_t newLcod; if( *j2kstream++ != 0xff || *j2kstream++ != 0x4f){ fprintf( FCGI_stderr, "Error, j2kstream is not starting with SOC marker\n"); - return false; + return OPJ_FALSE; } if(!modify_SIZmkrstream( SIZ, COD.numOfdecomp-numOfdecomp, j2kstream)) - return false; + return OPJ_FALSE; j2kstream += SIZ.Lsiz+2; if( !(newLcod = modify_CODmkrstream( COD, numOfdecomp, j2kstream))) - return false; + return OPJ_FALSE; memmove( j2kstream+2+newLcod, j2kstream+2+COD.Lcod, *j2klen - (Byte8_t)(SIZ.Lsiz+COD.Lcod+6)); *j2klen -= (Byte8_t)( COD.Lcod - newLcod); - return true; + return OPJ_TRUE; } -bool modify_SIZmkrstream( SIZmarker_param_t SIZ, int difOfdecomplev, Byte_t *SIZstream) +opj_bool modify_SIZmkrstream( SIZmarker_param_t SIZ, int difOfdecomplev, Byte_t *SIZstream) { int i; if( *SIZstream++ != 0xff || *SIZstream++ != 0x51){ fprintf( FCGI_stderr, "Error, SIZ marker not found in the reconstructed j2kstream\n"); - return false; + return OPJ_FALSE; } for( i=0; i 255 ) return false; + if( numOfdecomp < 0 || numOfdecomp > 255 ) return OPJ_FALSE; if( *COCstream++ != 0xff || *COCstream++ != 0x53){ fprintf( FCGI_stderr, "Error, COC marker not found in the reconstructed j2kstream\n"); - return false; + return OPJ_FALSE; } *oldLcoc = big2( COCstream); @@ -291,5 +291,5 @@ bool modify_COCmkrstream( int numOfdecomp, Byte_t *COCstream, Byte2_t Csiz, Byte *COCstream = (Byte_t)numOfdecomp; - return true; + return OPJ_TRUE; } diff --git a/src/lib/openjpip/j2kheader_manager.h b/src/lib/openjpip/j2kheader_manager.h index a6146c64..71dbeee9 100644 --- a/src/lib/openjpip/j2kheader_manager.h +++ b/src/lib/openjpip/j2kheader_manager.h @@ -32,7 +32,6 @@ #ifndef J2KHEADER_MANAGER_H_ # define J2KHEADER_MANAGER_H_ -#include "bool.h" #include "byte_manager.h" #include "index_manager.h" @@ -44,7 +43,7 @@ * @param[out] COD COD marker pointer * @return if succeeded (true) or failed (false) */ -bool get_mainheader_from_j2kstream( Byte_t *j2kstream, SIZmarker_param_t *SIZ, CODmarker_param_t *COD); +opj_bool get_mainheader_from_j2kstream( Byte_t *j2kstream, SIZmarker_param_t *SIZ, CODmarker_param_t *COD); /** * modify main header in j2k codestream to fit with the new number of decompositions @@ -56,7 +55,7 @@ bool get_mainheader_from_j2kstream( Byte_t *j2kstream, SIZmarker_param_t *SIZ, C * @param[out] j2klen pointer to the length of j2k code stream * @return if succeeded (true) or failed (false) */ -bool modify_mainheader( Byte_t *j2kstream, int numOfdecomp, SIZmarker_param_t SIZ, CODmarker_param_t COD, Byte8_t *j2klen); +opj_bool modify_mainheader( Byte_t *j2kstream, int numOfdecomp, SIZmarker_param_t SIZ, CODmarker_param_t COD, Byte8_t *j2klen); /** * modify tile header in j2k codestream to fit with the tile part length, and new number of decompositions for multi-componet images @@ -68,6 +67,6 @@ bool modify_mainheader( Byte_t *j2kstream, int numOfdecomp, SIZmarker_param_t SI * @param[out] j2klen pointer to the length of j2k code stream * @return if succeeded (true) or failed (false) */ -bool modify_tileheader( Byte_t *j2kstream, Byte8_t SOToffset, int numOfdecomp, Byte2_t Csiz, Byte8_t *j2klen); +opj_bool modify_tileheader( Byte_t *j2kstream, Byte8_t SOToffset, int numOfdecomp, Byte2_t Csiz, Byte8_t *j2klen); #endif /* !J2KHEADER_MANAGER_H_ */ diff --git a/src/lib/openjpip/jp2k_encoder.c b/src/lib/openjpip/jp2k_encoder.c index 9241f713..1c3f4680 100644 --- a/src/lib/openjpip/jp2k_encoder.c +++ b/src/lib/openjpip/jp2k_encoder.c @@ -127,7 +127,7 @@ Byte_t * recons_jp2( msgqueue_param_t *msgqueue, Byte_t *jpipstream, Byte8_t csn return jp2stream; } -bool isJPPstream( Byte8_t csn, msgqueue_param_t *msgqueue); +opj_bool isJPPstream( Byte8_t csn, msgqueue_param_t *msgqueue); Byte_t * recons_codestream_from_JPTstream( msgqueue_param_t *msgqueue, Byte_t *jpipstream, Byte8_t csn, int fw, int fh, Byte8_t *j2klen); Byte_t * recons_codestream_from_JPPstream( msgqueue_param_t *msgqueue, Byte_t *jpipstream, Byte8_t csn, int fw, int fh, Byte8_t *j2klen); @@ -142,7 +142,7 @@ Byte_t * recons_codestream( msgqueue_param_t *msgqueue, Byte_t *jpipstream, Byte return recons_codestream_from_JPTstream( msgqueue, jpipstream, csn, fw, fh, codelen); } -bool isJPPstream( Byte8_t csn, msgqueue_param_t *msgqueue) +opj_bool isJPPstream( Byte8_t csn, msgqueue_param_t *msgqueue) { message_param_t *msg; @@ -150,28 +150,28 @@ bool isJPPstream( Byte8_t csn, msgqueue_param_t *msgqueue) while( msg){ if( msg->csn == csn){ if( msg->class_id <= 2) - return true; + return OPJ_TRUE; else if( msg->class_id == 4 || msg->class_id == 5) - return false; + return OPJ_FALSE; } msg = msg->next; } fprintf( FCGI_stderr, "Error, message of csn %" PRId64 " not found\n", csn); - return false; + return OPJ_FALSE; } Byte_t * add_mainhead_msgstream( msgqueue_param_t *msgqueue, Byte_t *origstream, Byte_t *j2kstream, Byte8_t csn, Byte8_t *j2klen); -Byte8_t get_last_tileID( msgqueue_param_t *msgqueue, Byte8_t csn, bool isJPPstream); +Byte8_t get_last_tileID( msgqueue_param_t *msgqueue, Byte8_t csn, opj_bool isJPPstream); Byte_t * add_emptytilestream( const Byte8_t tileID, Byte_t *j2kstream, Byte8_t *j2klen); Byte_t * recons_codestream_from_JPTstream( msgqueue_param_t *msgqueue, Byte_t *jpipstream, Byte8_t csn, int fw, int fh, Byte8_t *j2klen) { Byte_t *j2kstream = NULL; Byte8_t last_tileID, tileID; - bool found; + opj_bool found; Byte8_t binOffset; message_param_t *ptr; SIZmarker_param_t SIZ; @@ -188,16 +188,16 @@ Byte_t * recons_codestream_from_JPTstream( msgqueue_param_t *msgqueue, Byte_t *j else mindeclev = (OPJ_SIZE_T)comp_decomplev( fw, fh, (int)SIZ.Xsiz, (int)SIZ.Ysiz); - last_tileID = get_last_tileID( msgqueue, csn, false); + last_tileID = get_last_tileID( msgqueue, csn, OPJ_FALSE); for( tileID=0; tileID <= last_tileID; tileID++){ - found = false; + found = OPJ_FALSE; binOffset = 0; ptr = msgqueue->first; while(( ptr = search_message( TILE_MSG, tileID, csn, ptr))!=NULL){ if( ptr->bin_offset == binOffset){ - found = true; + found = OPJ_TRUE; j2kstream = add_msgstream( ptr, jpipstream, j2kstream, j2klen); binOffset += ptr->length; } @@ -207,7 +207,7 @@ Byte_t * recons_codestream_from_JPTstream( msgqueue_param_t *msgqueue, Byte_t *j while(( ptr = search_message( EXT_TILE_MSG, tileID, csn, ptr))!=NULL){ if( ptr->aux > mindeclev){ /* FIXME: pointer comparison ? */ if( ptr->bin_offset == binOffset){ - found = true; + found = OPJ_TRUE; j2kstream = add_msgstream( ptr, jpipstream, j2kstream, j2klen); binOffset += ptr->length; } @@ -234,7 +234,7 @@ Byte_t * recons_codestream_from_JPPstream( msgqueue_param_t *msgqueue, Byte_t *j Byte_t *j2kstream = NULL; Byte8_t tileID, last_tileID; Byte8_t SOToffset; - bool foundTH; + opj_bool foundTH; Byte8_t binOffset; message_param_t *ptr; SIZmarker_param_t SIZ; @@ -253,19 +253,19 @@ Byte_t * recons_codestream_from_JPPstream( msgqueue_param_t *msgqueue, Byte_t *j mindeclev = comp_decomplev( fw, fh, (int)SIZ.Xsiz, (int)SIZ.Ysiz); max_reslev = -1; - last_tileID = get_last_tileID( msgqueue, csn, true); + last_tileID = get_last_tileID( msgqueue, csn, OPJ_TRUE); for( tileID=0; tileID <= last_tileID; tileID++){ ptr = msgqueue->first; binOffset = 0; - foundTH = false; + foundTH = OPJ_FALSE; SOToffset = *j2klen; while(( ptr = search_message( TILE_HEADER_MSG, tileID, csn, ptr))!=NULL){ if( ptr->bin_offset == binOffset){ j2kstream = add_SOTmkr( j2kstream, j2klen); j2kstream = add_msgstream( ptr, jpipstream, j2kstream, j2klen); - foundTH = true; + foundTH = OPJ_TRUE; binOffset += ptr->length; } ptr = ptr->next; @@ -526,7 +526,7 @@ Byte_t * recons_packet( msgqueue_param_t *msgqueue, Byte_t *jpipstream, Byte_t * { Byte8_t seqID, precID, binOffset; message_param_t *ptr; - bool foundPrec; + opj_bool foundPrec; int l; seqID = comp_seqID( tileID, SIZ, COD, res_idx, prct_idx); @@ -534,14 +534,14 @@ Byte_t * recons_packet( msgqueue_param_t *msgqueue, Byte_t *jpipstream, Byte_t * ptr = msgqueue->first; binOffset = 0; - foundPrec = false; + foundPrec = OPJ_FALSE; l = 0; while(( ptr = search_message( PRECINCT_MSG, precID, csn, ptr))!=NULL){ if( ptr->bin_offset == binOffset){ if( lay_idx == l){ j2kstream = add_msgstream( ptr, jpipstream, j2kstream, j2klen); - foundPrec = true; + foundPrec = OPJ_TRUE; if( *max_reslev < res_idx) *max_reslev = res_idx; @@ -565,19 +565,19 @@ Byte_t * recons_precinct( msgqueue_param_t *msgqueue, Byte_t *jpipstream, Byte_t { Byte8_t precID, binOffset; message_param_t *ptr; - bool foundPrec; + opj_bool foundPrec; precID = comp_precinct_id( (int)tileID, comp_idx, (int)seqID, (int)SIZ.Csiz, (int)SIZ.XTnum*(int)SIZ.YTnum); ptr = msgqueue->first; binOffset = 0; - foundPrec = false; + foundPrec = OPJ_FALSE; while(( ptr = search_message( PRECINCT_MSG, precID, csn, ptr))!=NULL){ if( ptr->bin_offset == binOffset){ j2kstream = add_msgstream( ptr, jpipstream, j2kstream, j2klen); - foundPrec = true; + foundPrec = OPJ_TRUE; binOffset += ptr->length; if( *max_reslev < res_idx) *max_reslev = res_idx; @@ -608,7 +608,7 @@ Byte8_t comp_seqID( Byte8_t tileID, SIZmarker_param_t SIZ, CODmarker_param_t COD return seqID; } -Byte8_t get_last_tileID( msgqueue_param_t *msgqueue, Byte8_t csn, bool isJPPstream) +Byte8_t get_last_tileID( msgqueue_param_t *msgqueue, Byte8_t csn, opj_bool isJPPstream) { Byte8_t last_tileID = 0; message_param_t *msg; diff --git a/src/lib/openjpip/jpip_parser.c b/src/lib/openjpip/jpip_parser.c index 663214e4..8d548d30 100644 --- a/src/lib/openjpip/jpip_parser.c +++ b/src/lib/openjpip/jpip_parser.c @@ -46,37 +46,37 @@ #endif /*SERVER*/ -bool identify_target( query_param_t query_param, targetlist_param_t *targetlist, target_param_t **target) +opj_bool identify_target( query_param_t query_param, targetlist_param_t *targetlist, target_param_t **target) { if( query_param.tid){ if( strcmp( query_param.tid, "0") != 0 ){ if( query_param.cid[0] != '\0'){ fprintf( FCGI_stdout, "Reason: Target can not be specified both through tid and cid\r\n"); fprintf( FCGI_stdout, "Status: 400\r\n"); - return false; + return OPJ_FALSE; } if( ( *target = search_targetBytid( query_param.tid, targetlist))) - return true; + return OPJ_TRUE; } } if( query_param.target) if( !( *target = search_target( query_param.target, targetlist))) if(!( *target = gene_target( targetlist, query_param.target))) - return false; + return OPJ_FALSE; if( *target){ fprintf( FCGI_stdout, "JPIP-tid: %s\r\n", (*target)->tid); - return true; + return OPJ_TRUE; } else{ fprintf( FCGI_stdout, "Reason: target not found\r\n"); fprintf( FCGI_stdout, "Status: 400\r\n"); - return false; + return OPJ_FALSE; } } -bool associate_channel( query_param_t query_param, +opj_bool associate_channel( query_param_t query_param, sessionlist_param_t *sessionlist, session_param_t **cursession, channel_param_t **curchannel) @@ -88,12 +88,12 @@ bool associate_channel( query_param_t query_param, } else{ fprintf( FCGI_stderr, "Error: process canceled\n"); - return false; + return OPJ_FALSE; } - return true; + return OPJ_TRUE; } -bool open_channel( query_param_t query_param, +opj_bool open_channel( query_param_t query_param, sessionlist_param_t *sessionlist, auxtrans_param_t auxtrans, target_param_t *target, @@ -107,7 +107,7 @@ bool open_channel( query_param_t query_param, *cursession = gene_session( sessionlist); if( !( cachemodel = search_cachemodel( target, (*cursession)->cachemodellist))) if( !(cachemodel = gene_cachemodel( (*cursession)->cachemodellist, target, query_param.return_type==JPPstream))) - return false; + return OPJ_FALSE; } else if( *curchannel) @@ -115,12 +115,12 @@ bool open_channel( query_param_t query_param, *curchannel = gene_channel( query_param, auxtrans, cachemodel, (*cursession)->channellist); if( *curchannel == NULL) - return false; + return OPJ_FALSE; - return true; + return OPJ_TRUE; } -bool close_channel( query_param_t query_param, +opj_bool close_channel( query_param_t query_param, sessionlist_param_t *sessionlist, session_param_t **cursession, channel_param_t **curchannel) @@ -134,7 +134,7 @@ bool close_channel( query_param_t query_param, #endif /* all channels associatd with the session will be closed */ if( !delete_session( cursession, sessionlist)) - return false; + return OPJ_FALSE; } else{ /* check if all entry belonging to the same session */ @@ -144,12 +144,12 @@ bool close_channel( query_param_t query_param, /* In case of the first entry of close cid */ if( *cursession == NULL){ if( !search_session_and_channel( cclose, sessionlist, cursession, curchannel)) - return false; + return OPJ_FALSE; } else /* second or more entry of close cid */ if( !(*curchannel=search_channel( cclose, (*cursession)->channellist))){ fprintf( FCGI_stdout, "Reason: Cclose id %s is from another session\r\n", cclose); - return false; + return OPJ_FALSE; } } @@ -163,7 +163,7 @@ bool close_channel( query_param_t query_param, /* In case of empty session */ delete_session( cursession, sessionlist); } - return true; + return OPJ_TRUE; } @@ -183,10 +183,10 @@ void enqueue_imagedata( query_param_t query_param, msgqueue_param_t *msgqueue); * @param[in,out] msgqueue message queue pointer * @return if succeeded (true) or failed (false) */ -bool enqueue_metabins( query_param_t query_param, metadatalist_param_t *metadatalist, msgqueue_param_t *msgqueue); +opj_bool enqueue_metabins( query_param_t query_param, metadatalist_param_t *metadatalist, msgqueue_param_t *msgqueue); -bool gene_JPIPstream( query_param_t query_param, +opj_bool gene_JPIPstream( query_param_t query_param, target_param_t *target, session_param_t *cursession, channel_param_t *curchannel, @@ -197,15 +197,15 @@ bool gene_JPIPstream( query_param_t query_param, if( !cursession || !curchannel){ /* stateless */ if( !target) - return false; + return OPJ_FALSE; if( !(cachemodel = gene_cachemodel( NULL, target, query_param.return_type==JPPstream))) - return false; - *msgqueue = gene_msgqueue( true, cachemodel); + return OPJ_FALSE; + *msgqueue = gene_msgqueue( OPJ_TRUE, cachemodel); } else{ /* session */ cachemodel = curchannel->cachemodel; target = cachemodel->target; - *msgqueue = gene_msgqueue( false, cachemodel); + *msgqueue = gene_msgqueue( OPJ_FALSE, cachemodel); } codeidx = target->codeidx; @@ -225,10 +225,10 @@ bool gene_JPIPstream( query_param_t query_param, /*meta*/ if( query_param.box_type[0][0] != 0 && query_param.len != 0) if( !enqueue_metabins( query_param, codeidx->metadatalist, *msgqueue)) - return false; + return OPJ_FALSE; if( query_param.metadata_only) - return true; + return OPJ_TRUE; /* main header */ if( !cachemodel->mhead_model && query_param.len != 0) @@ -238,7 +238,7 @@ bool gene_JPIPstream( query_param_t query_param, if( (query_param.fx > 0 && query_param.fy > 0)) enqueue_imagedata( query_param, *msgqueue); - return true; + return OPJ_TRUE; } @@ -257,7 +257,7 @@ bool gene_JPIPstream( query_param_t query_param, * @param[in] msgqueue message queue * @return */ -void enqueue_precincts( int xmin, int xmax, int ymin, int ymax, int tile_id, int level, int lastcomp, bool *comps, int layers, msgqueue_param_t *msgqueue); +void enqueue_precincts( int xmin, int xmax, int ymin, int ymax, int tile_id, int level, int lastcomp, opj_bool *comps, int layers, msgqueue_param_t *msgqueue); /** * enqueue all precincts inside a tile into the queue @@ -270,7 +270,7 @@ void enqueue_precincts( int xmin, int xmax, int ymin, int ymax, int tile_id, int * @param[in] msgqueue message queue * @return */ -void enqueue_allprecincts( int tile_id, int level, int lastcomp, bool *comps, int layers, msgqueue_param_t *msgqueue); +void enqueue_allprecincts( int tile_id, int level, int lastcomp, opj_bool *comps, int layers, msgqueue_param_t *msgqueue); void enqueue_imagedata( query_param_t query_param, msgqueue_param_t *msgqueue) { @@ -347,7 +347,7 @@ void enqueue_imagedata( query_param_t query_param, msgqueue_param_t *msgqueue) } -void enqueue_precincts( int xmin, int xmax, int ymin, int ymax, int tile_id, int level, int lastcomp, bool *comps, int layers, msgqueue_param_t *msgqueue) +void enqueue_precincts( int xmin, int xmax, int ymin, int ymax, int tile_id, int level, int lastcomp, opj_bool *comps, int layers, msgqueue_param_t *msgqueue) { index_param_t *codeidx; int c, u, v, res_lev, dec_lev; @@ -406,7 +406,7 @@ void enqueue_precincts( int xmin, int xmax, int ymin, int ymax, int tile_id, int } } -void enqueue_allprecincts( int tile_id, int level, int lastcomp, bool *comps, int layers, msgqueue_param_t *msgqueue) +void enqueue_allprecincts( int tile_id, int level, int lastcomp, opj_bool *comps, int layers, msgqueue_param_t *msgqueue) { index_param_t *codeidx; int c, i, res_lev, dec_lev; @@ -435,14 +435,14 @@ void enqueue_allprecincts( int tile_id, int level, int lastcomp, bool *comps, in } } -bool enqueue_metabins( query_param_t query_param, metadatalist_param_t *metadatalist, msgqueue_param_t *msgqueue) +opj_bool enqueue_metabins( query_param_t query_param, metadatalist_param_t *metadatalist, msgqueue_param_t *msgqueue) { int i; for( i=0; query_param.box_type[i][0]!=0 && ilast_byte = true; + msg->last_byte = OPJ_TRUE; msg->in_class_id = 0; msg->class_id = MAINHEADER_MSG; assert( target->csn >= 0 ); @@ -151,7 +151,7 @@ void enqueue_mainheader( msgqueue_param_t *msgqueue) enqueue_message( msg, msgqueue); - cachemodel->mhead_model = true; + cachemodel->mhead_model = OPJ_TRUE; } void enqueue_tileheader( int tile_id, msgqueue_param_t *msgqueue) @@ -167,7 +167,7 @@ void enqueue_tileheader( int tile_id, msgqueue_param_t *msgqueue) if( !cachemodel->th_model[ tile_id]){ msg = (message_param_t *)opj_malloc( sizeof(message_param_t)); - msg->last_byte = true; + msg->last_byte = OPJ_TRUE; assert( tile_id >= 0 ); msg->in_class_id = (Byte8_t)tile_id; msg->class_id = TILE_HEADER_MSG; @@ -181,7 +181,7 @@ void enqueue_tileheader( int tile_id, msgqueue_param_t *msgqueue) msg->next = NULL; enqueue_message( msg, msgqueue); - cachemodel->th_model[ tile_id] = true; + cachemodel->th_model[ tile_id] = OPJ_TRUE; } } @@ -189,7 +189,7 @@ void enqueue_tile( Byte4_t tile_id, int level, msgqueue_param_t *msgqueue) { cachemodel_param_t *cachemodel; target_param_t *target; - bool *tp_model; + opj_bool *tp_model; Byte8_t numOftparts; /* num of tile parts par tile*/ Byte8_t numOftiles; index_param_t *codeidx; @@ -236,7 +236,7 @@ void enqueue_tile( Byte4_t tile_id, int level, msgqueue_param_t *msgqueue) enqueue_message( msg, msgqueue); - tp_model[i] = true; + tp_model[i] = OPJ_TRUE; } binOffset += binLength; } @@ -283,7 +283,7 @@ void enqueue_precinct( int seq_id, int tile_id, int comp_id, int layers, msgqueu enqueue_message( msg, msgqueue); - cachemodel->pp_model[comp_id][tile_id*(int)nmax+seq_id*numOflayers+layer_id] = true; + cachemodel->pp_model[comp_id][tile_id*(int)nmax+seq_id*numOflayers+layer_id] = OPJ_TRUE; } binOffset += binLength; } @@ -323,7 +323,7 @@ void enqueue_metadata( Byte8_t meta_id, msgqueue_param_t *msgqueue) if( metadata->boxcontents) enqueue_boxcontents( meta_id, metadata->boxcontents, msgqueue, &binOffset); - msgqueue->last->last_byte = true; + msgqueue->last->last_byte = OPJ_TRUE; } message_param_t * gene_metamsg( Byte8_t meta_id, Byte8_t binoffset, Byte8_t length, OPJ_OFF_T res_offset, placeholder_param_t *phld, Byte8_t csn); @@ -378,7 +378,7 @@ message_param_t * gene_metamsg( Byte8_t meta_id, Byte8_t binOffset, Byte8_t leng msg = (message_param_t *)opj_malloc( sizeof(message_param_t)); - msg->last_byte = false; + msg->last_byte = OPJ_FALSE; msg->in_class_id = meta_id; msg->class_id = METADATA_MSG; msg->csn = csn; @@ -600,7 +600,7 @@ void parse_JPIPstream( Byte_t *JPIPstream, Byte8_t streamlen, OPJ_OFF_T offset, ptr = parse_bin_id_vbas( ptr, &bb, &c, &msg->in_class_id); - msg->last_byte = c == 1 ? true : false; + msg->last_byte = c == 1 ? OPJ_TRUE : OPJ_FALSE; if( bb >= 2) ptr = parse_vbas( ptr, &class_id); diff --git a/src/lib/openjpip/msgqueue_manager.h b/src/lib/openjpip/msgqueue_manager.h index 40548d91..781fc279 100644 --- a/src/lib/openjpip/msgqueue_manager.h +++ b/src/lib/openjpip/msgqueue_manager.h @@ -32,7 +32,6 @@ #ifndef MSGQUEUE_MANAGER_H_ # define MSGQUEUE_MANAGER_H_ -#include "bool.h" #include "byte_manager.h" #include "cachemodel_manager.h" #include "placeholder_manager.h" @@ -47,7 +46,7 @@ /** message parameters */ typedef struct message_param{ - bool last_byte; /**< if message contains the last byte of the data-bin*/ + opj_bool last_byte; /**< if message contains the last byte of the data-bin*/ Byte8_t in_class_id; /**< in-class identifier A.2.3*/ Byte8_t class_id; /**< class identifiers */ Byte8_t csn; /**< index of the codestream*/ @@ -63,7 +62,7 @@ typedef struct message_param{ typedef struct msgqueue_param{ message_param_t *first; /**< first message pointer of the list*/ message_param_t *last; /**< last message pointer of the list*/ - bool stateless; /**< if this is a stateless message queue*/ + opj_bool stateless; /**< if this is a stateless message queue*/ cachemodel_param_t *cachemodel; /**< reference cachemodel pointer*/ } msgqueue_param_t; @@ -74,7 +73,7 @@ typedef struct msgqueue_param{ * @param[in] cachemodel cachemodel pointer * @return generated message queue pointer */ -msgqueue_param_t * gene_msgqueue( bool stateless, cachemodel_param_t *cachemodel); +msgqueue_param_t * gene_msgqueue( opj_bool stateless, cachemodel_param_t *cachemodel); /** * delete message queue diff --git a/src/lib/openjpip/openjpip.c b/src/lib/openjpip/openjpip.c index 9cc257a2..f5c720a6 100644 --- a/src/lib/openjpip/openjpip.c +++ b/src/lib/openjpip/openjpip.c @@ -88,7 +88,7 @@ QR_t * parse_querystring( const char *query_string) return qr; } -bool process_JPIPrequest( server_record_t *rec, QR_t *qr) +opj_bool process_JPIPrequest( server_record_t *rec, QR_t *qr) { target_param_t *target = NULL; session_param_t *cursession = NULL; @@ -96,30 +96,30 @@ bool process_JPIPrequest( server_record_t *rec, QR_t *qr) if( qr->query->target || qr->query->tid){ if( !identify_target( *(qr->query), rec->targetlist, &target)) - return false; + return OPJ_FALSE; } if( qr->query->cid){ if( !associate_channel( *(qr->query), rec->sessionlist, &cursession, &curchannel)) - return false; + return OPJ_FALSE; qr->channel = curchannel; } if( qr->query->cnew != non){ if( !open_channel( *(qr->query), rec->sessionlist, rec->auxtrans, target, &cursession, &curchannel)) - return false; + return OPJ_FALSE; qr->channel = curchannel; } if( qr->query->cclose) if( !close_channel( *(qr->query), rec->sessionlist, &cursession, &curchannel)) - return false; + return OPJ_FALSE; if( (qr->query->fx > 0 && qr->query->fy > 0) || qr->query->box_type[0][0] != 0 || qr->query->len > 0) if( !gene_JPIPstream( *(qr->query), target, cursession, curchannel, &qr->msgqueue)) - return false; + return OPJ_FALSE; - return true; + return OPJ_TRUE; } void add_EORmsg( int fd, QR_t *qr); @@ -190,7 +190,7 @@ void end_QRprocess( server_record_t *rec, QR_t **qr) } -void local_log( bool query, bool messages, bool sessions, bool targets, QR_t *qr, server_record_t *rec) +void local_log( opj_bool query, opj_bool messages, opj_bool sessions, opj_bool targets, QR_t *qr, server_record_t *rec) { if( query) print_queryparam( *qr->query); @@ -216,7 +216,7 @@ dec_server_record_t * OPJ_CALLCONV init_dec_server( int port) record->cachelist = gene_cachelist(); record->jpipstream = NULL; record->jpipstreamlen = 0; - record->msgqueue = gene_msgqueue( true, NULL); + record->msgqueue = gene_msgqueue( OPJ_TRUE, NULL); record->listening_socket = open_listeningsocket( (uint16_t)port); return record; @@ -247,9 +247,9 @@ client_t OPJ_CALLCONV accept_connection( dec_server_record_t *rec) return client; } -bool OPJ_CALLCONV handle_clientreq( client_t client, dec_server_record_t *rec) +opj_bool OPJ_CALLCONV handle_clientreq( client_t client, dec_server_record_t *rec) { - bool quit = false; + opj_bool quit = OPJ_FALSE; msgtype_t msgtype = identify_clientmsg( client); switch( msgtype){ @@ -286,7 +286,7 @@ bool OPJ_CALLCONV handle_clientreq( client_t client, dec_server_record_t *rec) break; case QUIT: - quit = true; + quit = OPJ_TRUE; save_codestream( rec->jpipstream, rec->jpipstreamlen, "jpt"); break; case MSGERROR: @@ -296,23 +296,23 @@ bool OPJ_CALLCONV handle_clientreq( client_t client, dec_server_record_t *rec) fprintf( stderr, "\t end of the connection\n\n"); if( close_socket(client) != 0){ perror("close"); - return false; + return OPJ_FALSE; } if( quit) - return false; + return OPJ_FALSE; - return true; + return OPJ_TRUE; } -jpip_dec_param_t * OPJ_CALLCONV init_jpipdecoder( bool jp2) +jpip_dec_param_t * OPJ_CALLCONV init_jpipdecoder( opj_bool jp2) { jpip_dec_param_t *dec; dec = (jpip_dec_param_t *)opj_calloc( 1, sizeof(jpip_dec_param_t)); - dec->msgqueue = gene_msgqueue( true, NULL); + dec->msgqueue = gene_msgqueue( OPJ_TRUE, NULL); if( jp2) dec->metadatalist = gene_metadatalist(); @@ -321,29 +321,29 @@ jpip_dec_param_t * OPJ_CALLCONV init_jpipdecoder( bool jp2) } -bool OPJ_CALLCONV fread_jpip( const char fname[], jpip_dec_param_t *dec) +opj_bool OPJ_CALLCONV fread_jpip( const char fname[], jpip_dec_param_t *dec) { int infd; if(( infd = open( fname, O_RDONLY)) == -1){ fprintf( stderr, "file %s not exist\n", fname); - return false; + return OPJ_FALSE; } if(!(dec->jpiplen = (Byte8_t)get_filesize(infd))) - return false; + return OPJ_FALSE; dec->jpipstream = (Byte_t *)opj_malloc( dec->jpiplen); if( read( infd, dec->jpipstream, dec->jpiplen) != (int)dec->jpiplen){ fprintf( stderr, "file reading error\n"); opj_free( dec->jpipstream); - return false; + return OPJ_FALSE; } close(infd); - return true; + return OPJ_TRUE; } void OPJ_CALLCONV decode_jpip( jpip_dec_param_t *dec) @@ -361,7 +361,7 @@ void OPJ_CALLCONV decode_jpip( jpip_dec_param_t *dec) dec->jp2kstream = recons_j2k( dec->msgqueue, dec->jpipstream, dec->msgqueue->first->csn, 0, 0, &dec->jp2klen); } -bool OPJ_CALLCONV fwrite_jp2k( const char fname[], jpip_dec_param_t *dec) +opj_bool OPJ_CALLCONV fwrite_jp2k( const char fname[], jpip_dec_param_t *dec) { int outfd; @@ -371,7 +371,7 @@ bool OPJ_CALLCONV fwrite_jp2k( const char fname[], jpip_dec_param_t *dec) if(( outfd = open( fname, O_WRONLY|O_CREAT, S_IRWXU|S_IRWXG)) == -1){ #endif fprintf( stderr, "file %s open error\n", fname); - return false; + return OPJ_FALSE; } if( write( outfd, dec->jp2kstream, dec->jp2klen) != (int)dec->jp2klen) @@ -379,10 +379,10 @@ bool OPJ_CALLCONV fwrite_jp2k( const char fname[], jpip_dec_param_t *dec) close(outfd); - return true; + return OPJ_TRUE; } -void OPJ_CALLCONV output_log( bool messages, bool metadata, bool ihdrbox, jpip_dec_param_t *dec) +void OPJ_CALLCONV output_log( opj_bool messages, opj_bool metadata, opj_bool ihdrbox, jpip_dec_param_t *dec) { if( messages) print_msgqueue( dec->msgqueue); diff --git a/src/lib/openjpip/openjpip.h b/src/lib/openjpip/openjpip.h index 34b0d3fc..0a1f8e5a 100644 --- a/src/lib/openjpip/openjpip.h +++ b/src/lib/openjpip/openjpip.h @@ -35,7 +35,6 @@ #include "target_manager.h" #include "query_parser.h" #include "msgqueue_manager.h" -#include "bool.h" #include "sock_manager.h" #include "auxtrans_manager.h" @@ -113,7 +112,7 @@ QR_t * parse_querystring( const char *query_string); * @param[in] qr query/response data pointer * @return true if succeed, otherwise false */ -bool process_JPIPrequest( server_record_t *rec, QR_t *qr); +opj_bool process_JPIPrequest( server_record_t *rec, QR_t *qr); /** * 3rd process; send response data JPT/JPP-stream @@ -141,7 +140,7 @@ void end_QRprocess( server_record_t *rec, QR_t **qr); * @param[in] qr query/response data pointer * @param[in] rec server static record pinter */ -void local_log( bool query, bool messages, bool sessions, bool targets, QR_t *qr, server_record_t *rec); +void local_log( opj_bool query, opj_bool messages, opj_bool sessions, opj_bool targets, QR_t *qr, server_record_t *rec); #endif /*SERVER*/ @@ -196,7 +195,7 @@ OPJ_API client_t OPJ_CALLCONV accept_connection( dec_server_record_t *rec); * @param[in] rec decoding server static record pointer * @return true if succeed */ -OPJ_API bool OPJ_CALLCONV handle_clientreq( client_t client, dec_server_record_t *rec); +OPJ_API opj_bool OPJ_CALLCONV handle_clientreq( client_t client, dec_server_record_t *rec); #endif /*SERVER*/ @@ -229,7 +228,7 @@ typedef struct jpip_dec_param{ * @param[in] jp2 true in case of jp2 file encoding, else j2k file encoding * @return JPIP decoding parameters pointer */ -OPJ_API jpip_dec_param_t * OPJ_CALLCONV init_jpipdecoder( bool jp2); +OPJ_API jpip_dec_param_t * OPJ_CALLCONV init_jpipdecoder( opj_bool jp2); /** * Destroy jpip decoding parameters @@ -245,7 +244,7 @@ OPJ_API void OPJ_CALLCONV destroy_jpipdecoder( jpip_dec_param_t **dec); * @param[in] dec JPIP decoding parameters pointer * @return true if succeed */ -OPJ_API bool OPJ_CALLCONV fread_jpip( const char fname[], jpip_dec_param_t *dec); +OPJ_API opj_bool OPJ_CALLCONV fread_jpip( const char fname[], jpip_dec_param_t *dec); /** * Decode jpip codestream @@ -261,7 +260,7 @@ OPJ_API void OPJ_CALLCONV decode_jpip( jpip_dec_param_t *dec); * @param[in] dec JPIP decoding parameters pointer * @return true if succeed */ -OPJ_API bool OPJ_CALLCONV fwrite_jp2k( const char fname[], jpip_dec_param_t *dec); +OPJ_API opj_bool OPJ_CALLCONV fwrite_jp2k( const char fname[], jpip_dec_param_t *dec); /** * Option; print out parameter values to stderr @@ -271,7 +270,7 @@ OPJ_API bool OPJ_CALLCONV fwrite_jp2k( const char fname[], jpip_dec_param_t *dec * @param[in] ihdrbox true if image header data is to be printed out * @param[in] dec JPIP decoding parameters pointer */ -OPJ_API void OPJ_CALLCONV output_log( bool messages, bool metadata, bool ihdrbox, jpip_dec_param_t *dec); +OPJ_API void OPJ_CALLCONV output_log( opj_bool messages, opj_bool metadata, opj_bool ihdrbox, jpip_dec_param_t *dec); /* * test the format of index (cidx) box in JP2 file diff --git a/src/lib/openjpip/query_parser.c b/src/lib/openjpip/query_parser.c index 20f38b69..f294b8ac 100644 --- a/src/lib/openjpip/query_parser.c +++ b/src/lib/openjpip/query_parser.c @@ -159,7 +159,7 @@ query_param_t * get_initquery(void) query_param_t *query; int i; - query = (query_param_t *)malloc( sizeof(query_param_t)); + query = (query_param_t *)opj_malloc( sizeof(query_param_t)); query->target = NULL; query->tid = NULL; @@ -179,15 +179,15 @@ query_param_t * get_initquery(void) memset( query->box_type, 0, MAX_NUMOFBOX*4); memset( query->limit, 0, MAX_NUMOFBOX*sizeof(int)); for( i=0; iw[i] = false; - query->s[i] = false; - query->g[i] = false; - query->a[i] = false; - query->priority[i] = false; + query->w[i] = OPJ_FALSE; + query->s[i] = OPJ_FALSE; + query->g[i] = OPJ_FALSE; + query->a[i] = OPJ_FALSE; + query->priority[i] = OPJ_FALSE; } query->root_bin = 0; query->max_depth = -1; - query->metadata_only = false; + query->metadata_only = OPJ_FALSE; query->return_type = UNKNOWN; query->len = -1; @@ -329,7 +329,7 @@ void parse_metareq( char *field, query_param_t *query_param) sscanf( ptr+1, "%d", &(query_param->max_depth)); if(( ptr = strstr( field, "!!"))) - query_param->metadata_only = true; + query_param->metadata_only = OPJ_TRUE; } void parse_req_box_prop( char *req_box_prop, int idx, query_param_t *query_param) @@ -352,22 +352,22 @@ void parse_req_box_prop( char *req_box_prop, int idx, query_param_t *query_param ptr++; while( *ptr=='w' || *ptr=='s' || *ptr=='g' || *ptr=='a'){ switch( *ptr){ - case 'w': query_param->w[idx] = true; break; - case 's': query_param->s[idx] = true; break; - case 'g': query_param->g[idx] = true; break; - case 'a': query_param->a[idx] = true; break; + case 'w': query_param->w[idx] = OPJ_TRUE; break; + case 's': query_param->s[idx] = OPJ_TRUE; break; + case 'g': query_param->g[idx] = OPJ_TRUE; break; + case 'a': query_param->a[idx] = OPJ_TRUE; break; } ptr++; } } else{ - query_param->g[idx] = true; - query_param->s[idx] = true; - query_param->w[idx] = true; + query_param->g[idx] = OPJ_TRUE; + query_param->s[idx] = OPJ_TRUE; + query_param->w[idx] = OPJ_TRUE; } if((ptr = strchr( req_box_prop, '!'))) - query_param->priority[idx] = true; + query_param->priority[idx] = OPJ_TRUE; idx++; } @@ -399,31 +399,31 @@ void parse_comps( char *field, query_param_t *query_param) } query_param->lastcomp = stop > aux ? stop : aux; - query_param->comps = (bool *)calloc( 1, (OPJ_SIZE_T)(query_param->lastcomp+1)*sizeof(bool)); + query_param->comps = (opj_bool *)opj_calloc( 1, (OPJ_SIZE_T)(query_param->lastcomp+1)*sizeof(opj_bool)); for( i=start; i<=stop; i++) - query_param->comps[i]=true; + query_param->comps[i]=OPJ_TRUE; if(aux!=-1) - query_param->comps[aux] = true; + query_param->comps[aux] = OPJ_TRUE; } void delete_query( query_param_t **query) { if( (*query)->target) - free( (*query)->target); + opj_free( (*query)->target); if( (*query)->tid) - free( (*query)->tid); + opj_free( (*query)->tid); if( (*query)->comps) - free((*query)->comps); + opj_free((*query)->comps); if( (*query)->cid) - free( (*query)->cid); + opj_free( (*query)->cid); if( (*query)->cclose) - free( (*query)->cclose); + opj_free( (*query)->cclose); - free( *query); + opj_free( *query); } diff --git a/src/lib/openjpip/query_parser.h b/src/lib/openjpip/query_parser.h index 112bc59a..067075da 100644 --- a/src/lib/openjpip/query_parser.h +++ b/src/lib/openjpip/query_parser.h @@ -32,7 +32,7 @@ #ifndef QUERY_PARSER_H_ # define QUERY_PARSER_H_ -#include "bool.h" +#include "opj_includes.h" /** maximum number of meta request box */ #define MAX_NUMOFBOX 10 @@ -51,21 +51,21 @@ typedef struct query_param{ int rx, ry, rw, rh; /**< roi region */ int layers; /**< quality layers */ int lastcomp; /**< last component number */ - bool *comps; /**< components (dynamic array) for jpp-stream, null means all components */ + opj_bool *comps; /**< components (dynamic array) for jpp-stream, null means all components */ char *cid; /**< channel identifier */ cnew_transport_t cnew; /**< transport name if there is new channel request, else non */ char *cclose; /**< list of closing channel identifiers, separated by '\\0' */ int numOfcclose; /**< number of closing channels */ char box_type[MAX_NUMOFBOX][4]; /**< interested box-types */ int limit[MAX_NUMOFBOX]; /**< limit value, -1: skeleton request "r", 0: entire contents */ - bool w[MAX_NUMOFBOX]; /**< Metadata request qualifier flags */ - bool s[MAX_NUMOFBOX]; - bool g[MAX_NUMOFBOX]; - bool a[MAX_NUMOFBOX]; - bool priority[MAX_NUMOFBOX]; /**< priority flag */ + opj_bool w[MAX_NUMOFBOX]; /**< Metadata request qualifier flags */ + opj_bool s[MAX_NUMOFBOX]; + opj_bool g[MAX_NUMOFBOX]; + opj_bool a[MAX_NUMOFBOX]; + opj_bool priority[MAX_NUMOFBOX]; /**< priority flag */ int root_bin; /**< root-bin */ int max_depth; /**< max-depth */ - bool metadata_only; /**< metadata-only request */ + opj_bool metadata_only; /**< metadata-only request */ image_return_t return_type; /**< image return type */ int len; /**< maximum response length */ } query_param_t; diff --git a/src/lib/openjpip/session_manager.c b/src/lib/openjpip/session_manager.c index 24b1d0ce..0fd19d85 100644 --- a/src/lib/openjpip/session_manager.c +++ b/src/lib/openjpip/session_manager.c @@ -76,7 +76,7 @@ session_param_t * gene_session( sessionlist_param_t *sessionlist) return session; } -bool search_session_and_channel( char cid[], +opj_bool search_session_and_channel( char cid[], sessionlist_param_t *sessionlist, session_param_t **foundsession, channel_param_t **foundchannel) @@ -90,7 +90,7 @@ bool search_session_and_channel( char cid[], while( *foundchannel != NULL){ if( strcmp( cid, (*foundchannel)->cid) == 0) - return true; + return OPJ_TRUE; *foundchannel = (*foundchannel)->next; } @@ -100,7 +100,7 @@ bool search_session_and_channel( char cid[], fprintf( FCGI_stdout, "Status: 503\r\n"); fprintf( FCGI_stdout, "Reason: Channel %s not found\r\n", cid); - return false; + return OPJ_FALSE; } void insert_cachemodel_into_session( session_param_t *session, cachemodel_param_t *cachemodel) @@ -118,12 +118,12 @@ void insert_cachemodel_into_session( session_param_t *session, cachemodel_param_ session->cachemodellist->last = cachemodel; } -bool delete_session( session_param_t **session, sessionlist_param_t *sessionlist) +opj_bool delete_session( session_param_t **session, sessionlist_param_t *sessionlist) { session_param_t *ptr; if( *session == NULL) - return false; + return OPJ_FALSE; if( *session == sessionlist->first) @@ -146,7 +146,7 @@ bool delete_session( session_param_t **session, sessionlist_param_t *sessionlist #endif opj_free( *session); - return true; + return OPJ_TRUE; } void delete_sessionlist( sessionlist_param_t **sessionlist) diff --git a/src/lib/openjpip/session_manager.h b/src/lib/openjpip/session_manager.h index 655d8506..b4f80dfa 100644 --- a/src/lib/openjpip/session_manager.h +++ b/src/lib/openjpip/session_manager.h @@ -31,7 +31,6 @@ #ifndef SESSION_MANAGER_H_ # define SESSION_MANAGER_H_ -#include "bool.h" #include "channel_manager.h" #include "cachemodel_manager.h" @@ -74,7 +73,7 @@ session_param_t * gene_session( sessionlist_param_t *sessionlist); * @param[in,out] foundchannel address of the found channel pointer * @return if the channel is found (true) or not (false) */ -bool search_session_and_channel( char cid[], +opj_bool search_session_and_channel( char cid[], sessionlist_param_t *sessionlist, session_param_t **foundsession, channel_param_t **foundchannel); @@ -95,7 +94,7 @@ void insert_cachemodel_into_session( session_param_t *session, cachemodel_param_ * @param[in] sessionlist session list pointer * @return if succeeded (true) or failed (false) */ -bool delete_session( session_param_t **session, sessionlist_param_t *sessionlist); +opj_bool delete_session( session_param_t **session, sessionlist_param_t *sessionlist); /** diff --git a/src/lib/openjpip/sock_manager.h b/src/lib/openjpip/sock_manager.h index ee67131e..12a43d5d 100644 --- a/src/lib/openjpip/sock_manager.h +++ b/src/lib/openjpip/sock_manager.h @@ -31,7 +31,6 @@ #ifndef SOCK_MANAGER_H_ # define SOCK_MANAGER_H_ -#include "bool.h" #include "byte_manager.h" #include "opj_stdint.h" diff --git a/src/lib/openjpip/target_manager.c b/src/lib/openjpip/target_manager.c index 92fb93cf..436d03eb 100644 --- a/src/lib/openjpip/target_manager.c +++ b/src/lib/openjpip/target_manager.c @@ -112,7 +112,7 @@ target_param_t * gene_target( targetlist_param_t *targetlist, char *targetpath) target->csn = last_csn++; target->codeidx = jp2idx; target->num_of_use = 0; - target->jppstream = true; + target->jppstream = OPJ_TRUE; target->jptstream = isJPTfeasible( *jp2idx); target->next=NULL; diff --git a/src/lib/openjpip/target_manager.h b/src/lib/openjpip/target_manager.h index 85259548..0d8fde2f 100644 --- a/src/lib/openjpip/target_manager.h +++ b/src/lib/openjpip/target_manager.h @@ -31,7 +31,6 @@ #ifndef TARGET_MANAGER_H_ # define TARGET_MANAGER_H_ -#include "bool.h" #include "index_manager.h" /** maximum length of target identifier*/ @@ -48,8 +47,8 @@ typedef struct target_param{ int csn; /**< codestream number */ index_param_t *codeidx; /**< index information of codestream */ int num_of_use; /**< numbers of sessions refering to this target */ - bool jppstream; /**< if this target can return JPP-stream */ - bool jptstream; /**< if this target can return JPP-stream */ + opj_bool jppstream; /**< if this target can return JPP-stream */ + opj_bool jptstream; /**< if this target can return JPP-stream */ struct target_param *next; /**< pointer to the next target */ } target_param_t; -- 2.30.2