[1.5] Change the logic in byte_manager.h. Prefer the use of stdint.h when available...
authorMathieu Malaterre <mathieu.malaterre@gmail.com>
Fri, 2 Mar 2012 16:51:10 +0000 (16:51 +0000)
committerMathieu Malaterre <mathieu.malaterre@gmail.com>
Fri, 2 Mar 2012 16:51:10 +0000 (16:51 +0000)
12 files changed:
applications/jpip/libopenjpip/auxtrans_manager.c
applications/jpip/libopenjpip/byte_manager.h
applications/jpip/libopenjpip/channel_manager.c
applications/jpip/libopenjpip/channel_manager.h
applications/jpip/libopenjpip/codestream_manager.c
applications/jpip/libopenjpip/j2kheader_manager.c
applications/jpip/libopenjpip/jp2k_decoder.c
applications/jpip/libopenjpip/manfbox_manager.c
applications/jpip/libopenjpip/marker_manager.c
applications/jpip/libopenjpip/mhixbox_manager.c
applications/jpip/libopenjpip/session_manager.c
applications/jpip/libopenjpip/session_manager.h

index 7be5e219e5ea5450ec5d0a243fc962dc8121dcdf..d32856364093dec7c7dbfc5e70dcf1ff382890fc 100644 (file)
@@ -46,7 +46,7 @@
 #define FCGI_stdout stdout
 #define FCGI_stderr stderr
 #define logstream stderr
-#endif //SERVER
+#endif /*SERVER */
 
 auxtrans_param_t init_aux_transport( int tcp_auxport, int udp_auxport)
 {
@@ -61,7 +61,7 @@ auxtrans_param_t init_aux_transport( int tcp_auxport, int udp_auxport)
     auxtrans.tcplistensock = -1;
 
   auxtrans.udplistensock = -1;
-  // open listening socket for udp later
+  /* open listening socket for udp later */
 
   return auxtrans;
 }
@@ -78,15 +78,15 @@ void close_aux_transport( auxtrans_param_t auxtrans)
 }
 
 
-//!< auxiliary response parameters
+/*!< auxiliary response parameters */
 typedef struct aux_response_param{
-  char *cid;            //!< channel ID
-  unsigned char *data;  //!< sending data
-  int datalen;          //!< length of data
-  int maxlenPerFrame;   //!< maximum data length to send per frame
-  SOCKET listensock;    //!< listeing socket
+  char *cid;            /*!< channel ID */
+  unsigned char *data;  /*!< sending data */
+  int datalen;          /*!< length of data */
+  int maxlenPerFrame;   /*!< maximum data length to send per frame */
+  SOCKET listensock;    /*!< listeing socket */
 #ifdef _WIN32
-  HANDLE hTh;           //!< thread handle
+  HANDLE hTh;           /*!< thread handle */
 #endif
 } aux_response_param_t;
 
index d06b9131a2dd7f9923fa5fd3d7e9838a7ae2c8c9..58dcb720648e549b27f981298ae34b2fc6e7f718 100644 (file)
  */
 
 #ifndef        BYTE_MANAGER_H_
-# define       BYTE_MANAGER_H_
-
+#define        BYTE_MANAGER_H_
+
+#include "opj_config.h"
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+typedef uint8_t Byte_t;
+typedef uint16_t Byte2_t;
+typedef uint32_t Byte4_t;
+typedef uint64_t Byte8_t;
+#else
+#if defined(_WIN32)
 /** 1Byte parameter type*/
-typedef unsigned char Byte_t;
-
+typedef unsigned __int8   Byte_t;
 /** 2Byte parameter type*/
-typedef unsigned short int Byte2_t;
-
+typedef unsigned __int16  Byte2_t;
 /** 4Byte parameter type*/
-typedef unsigned int Byte4_t; /* FIXME: Is this portable ? */
-
+typedef unsigned __int32  Byte4_t;
 /** 8Byte parameter type*/
-typedef unsigned long long int Byte8_t;
+typedef unsigned __int64  Byte8_t;
+#else
+#error unsupported platform
+#endif
+#endif
 
 
 /**
index 240cdd9b297e4ce444b364eb9925a0c9041cda2b..52ee047ead780ad63db9db51a06ee74273a35b53 100644 (file)
@@ -40,9 +40,9 @@
 #define FCGI_stdout stdout
 #define FCGI_stderr stderr
 #define logstream stderr
-#endif //SERVER
+#endif /*SERVER */
 
-channellist_param_t * gene_channellist()
+channellist_param_t * gene_channellist(void)
 {
   channellist_param_t *channellist;
 
@@ -68,12 +68,12 @@ channel_param_t * gene_channel( query_param_t query_param, auxtrans_param_t auxt
   channel = (channel_param_t *)malloc( sizeof(channel_param_t));
   channel->cachemodel = cachemodel;
 
-  // set channel ID and get present time
+  /* set channel ID and get present time */
   snprintf( channel->cid, MAX_LENOFCID, "%x%x", (unsigned int)time( &channel->start_tm), (unsigned int)rand());
   
   channel->aux = query_param.cnew;
   
-  // only tcp implemented for now
+  /* only tcp implemented for now */
   if( channel->aux == udp)
     channel->aux = tcp;
   
@@ -101,7 +101,9 @@ channel_param_t * gene_channel( query_param_t query_param, auxtrans_param_t auxt
 
 void set_channel_variable_param( query_param_t query_param, channel_param_t *channel)
 {
-  // set roi information
+  /* set roi information */
+  (void)query_param;
+  (void)channel;
 }
 
 
index 1cfaa9788b182e9e3e4e57305f1f63bc085f7f7a..540249708c3c3b71803eab2b82efdb9cba4b9e95 100644 (file)
@@ -62,7 +62,7 @@ typedef struct channellist_param{
  *
  * @return pointer to the generated channel list
  */
-channellist_param_t * gene_channellist();
+channellist_param_t * gene_channellist(void);
 
 
 /**
index 24898d35017f387657c51a613e98ff26f7b0a383..b9aaacdd6486425f758de4a117b5e0cf09a8690f 100644 (file)
@@ -38,7 +38,7 @@
 #define FCGI_stdout stdout
 #define FCGI_stderr stderr
 #define logstream stderr
-#endif //SERVER
+#endif /*SERVER */
 
 codestream_param_t set_codestream( int fd, Byte8_t offset, Byte8_t length)
 {
index afbb2525a6be882f4b91d4fb67d8fd5bcf2c3506..f0d16dbe079d3f2c7bf83dc8cbe351543ac7443b 100644 (file)
@@ -42,7 +42,7 @@
 #define FCGI_stdout stdout
 #define FCGI_stderr stderr
 #define logstream stderr
-#endif //SERVER
+#endif /*SERVER */
 
 
 SIZmarker_param_t get_SIZmkrdata_from_j2kstream( Byte_t *SIZstream);
@@ -76,7 +76,7 @@ bool get_mainheader_from_j2kstream( Byte_t *j2kstream, SIZmarker_param_t *SIZ, C
 
 SIZmarker_param_t get_SIZmkrdata_from_j2kstream( Byte_t *SIZstream)
 {
-  SIZmarker_param_t SIZ ={0};
+  SIZmarker_param_t SIZ = {0};
   int i;
 
   if( *SIZstream++ != 0xff || *SIZstream++ != 0x51){
@@ -129,7 +129,7 @@ CODmarker_param_t get_CODmkrdata_from_j2kstream( Byte_t *CODstream)
     COD.YPsiz = (Byte4_t *)malloc( (COD.numOfdecomp+1)*sizeof(Byte4_t));
     
     for( i=0; i<=COD.numOfdecomp; i++){
-      //precinct size
+      /*precinct size */
       COD.XPsiz[i] = pow( 2, *( CODstream+12+i) & 0x0F);
       COD.YPsiz[i] = pow( 2, (*( CODstream+12+i) & 0xF0) >> 4);
     }
@@ -188,7 +188,7 @@ bool modify_SIZmkrstream( SIZmarker_param_t SIZ, int difOfdecomplev, Byte_t *SIZ
     SIZ.YTOsiz = ceil( (double)SIZ.YTOsiz/2.0);
   }
 
-  SIZstream += 4; // skip Lsiz + Rsiz
+  SIZstream += 4; /* skip Lsiz + Rsiz */
 
   modify_4Bytecode( SIZ.Xsiz,   SIZstream);
   modify_4Bytecode( SIZ.Ysiz,   SIZstream+4);
@@ -222,9 +222,9 @@ Byte2_t modify_CODmkrstream( CODmarker_param_t COD, int numOfdecomp, Byte_t *COD
     CODstream += 2;
   }
   
-  CODstream += 5; // skip Scod & SGcod
+  CODstream += 5; /* skip Scod & SGcod */
   
-  // SPcod
+  /* SPcod */
   *CODstream++ = (Byte_t) numOfdecomp;
   
   return newLcod;
@@ -234,7 +234,7 @@ bool modify_COCmkrstream( int numOfdecomp, Byte_t *COCstream, Byte2_t Csiz, Byte
 
 bool modify_tileheader( Byte_t *j2kstream, Byte8_t SOToffset, int numOfdecomp, Byte2_t Csiz, Byte8_t *j2klen)
 {
-  Byte4_t Psot; // tile part length ref A.4.2 Start of tile-part SOT
+  Byte4_t Psot; /* tile part length ref A.4.2 Start of tile-part SOT */
   Byte_t *thstream, *SOTstream, *Psot_stream;
   Byte2_t oldLcoc, newLcoc;
   
@@ -245,14 +245,14 @@ bool modify_tileheader( Byte_t *j2kstream, Byte8_t SOToffset, int numOfdecomp, B
     return false;
   }
 
-  SOTstream += 4; // skip Lsot & Isot
+  SOTstream += 4; /* skip Lsot & Isot */
   Psot = (SOTstream[0]<<24)+(SOTstream[1]<<16)+(SOTstream[2]<<8)+(SOTstream[3]);
   Psot_stream = SOTstream;
   
-  thstream += 12; // move to next marker (SOT always 12bytes)
+  thstream += 12; /* move to next marker (SOT always 12bytes) */
   
-  while( !( *thstream == 0xff && *(thstream+1) == 0x93)){ // search SOD
-    if( numOfdecomp != -1 && *thstream == 0xff && *(thstream+1) == 0x53){ // COC
+  while( !( *thstream == 0xff && *(thstream+1) == 0x93)){ /* search SOD */
+    if( numOfdecomp != -1 && *thstream == 0xff && *(thstream+1) == 0x53){ /* COC */
       if( !modify_COCmkrstream( numOfdecomp, thstream, Csiz, &oldLcoc, &newLcoc))
        return false;
       
@@ -260,7 +260,7 @@ bool modify_tileheader( Byte_t *j2kstream, Byte8_t SOToffset, int numOfdecomp, B
       *j2klen -= ( oldLcoc - newLcoc);
     }
     thstream += 2;
-    thstream += ((thstream[0]<<8)+(thstream[1])); // marker length
+    thstream += ((thstream[0]<<8)+(thstream[1])); /* marker length */
   }
 
   if( (*j2klen)-SOToffset != Psot){
@@ -282,7 +282,7 @@ bool modify_COCmkrstream( int numOfdecomp, Byte_t *COCstream, Byte2_t Csiz, Byte
   *COCstream++ = (Byte_t)((Byte2_t)((*newLcoc) & 0xff00) >> 8);
   *COCstream++ = (Byte_t)((*newLcoc) & 0x00ff);
       
-  if( Csiz < 257) COCstream +=2; // skip Ccoc & Scoc
+  if( Csiz < 257) COCstream +=2; /* skip Ccoc & Scoc */
   else COCstream += 3;
       
   *COCstream = numOfdecomp;
index 28f3322683980c7367b146a3cb538b275e8cb557..185020ee63833ff2d3a6502f2d0f236525107028 100644 (file)
@@ -125,7 +125,8 @@ void warning_callback(const char *msg, void *client_data) {
 */
 void info_callback(const char *msg, void *client_data) {
   (void)client_data;
-  //  fprintf(stdout, "[INFO] %s", msg);
+  (void)msg;
+  /*  fprintf(stdout, "[INFO] %s", msg); */
 }
 
 
@@ -190,7 +191,7 @@ Byte_t * imagetopnm(opj_image_t *image, ihdrbox_param_t **ihdrbox)
     r = image->comps[0].data[i];
     r += (image->comps[0].sgnd ? 1 << (image->comps[0].prec - 1) : 0);
     
-    //    if( adjustR > 0)
+    /*    if( adjustR > 0) */
     *(ptr++) = (Byte_t) ((r >> adjustR)+((r >> (adjustR-1))%2));
 
     if( image->numcomps == 3){
index 51aac36e2fd30a6fb6769451f9636e18bb309d85..1365731175dafdb9791a6802e90dcb55b95ca1b1 100644 (file)
 #define FCGI_stdout stdout
 #define FCGI_stderr stderr
 #define logstream stderr
-#endif //SERVER
+#endif /*SERVER */
 
 manfbox_param_t * gene_manfbox( box_param_t *box)
 {
-  manfbox_param_t *manf;   // manifest parameters
-  boxheader_param_t *bh;   // current box pointer
-  boxheader_param_t *last; // last boxheader pointer of the list
-  int pos;                 // current position in manf_box contents;
+  manfbox_param_t *manf;   /* manifest parameters */
+  boxheader_param_t *bh;   /* current box pointer */
+  boxheader_param_t *last; /* last boxheader pointer of the list */
+  Byte8_t pos;                 /* current position in manf_box contents; */
   
   manf = ( manfbox_param_t *)malloc( sizeof( manfbox_param_t));
 
@@ -59,7 +59,7 @@ manfbox_param_t * gene_manfbox( box_param_t *box)
     bh = gene_childboxheader( box, pos);
     pos += bh->headlen;
     
-    // insert into the list
+    /* insert into the list */
     if( manf->first)
       last->next = bh;
     else
@@ -77,7 +77,7 @@ void delete_manfbox( manfbox_param_t **manf)
   while( bhPtr != NULL){
     bhNext = bhPtr->next;
 #ifndef SERVER
-    //      fprintf( logstream, "local log: boxheader %.4s deleted!\n", bhPtr->type);
+    /*      fprintf( logstream, "local log: boxheader %.4s deleted!\n", bhPtr->type); */
 #endif
       free(bhPtr);
       bhPtr = bhNext;
index e3f50f646e96ae591524b3f41a5df4f89f7754b2..845d9c5f0f8ec4e3093445dfca1923ec34e0fcc8 100644 (file)
@@ -37,7 +37,7 @@
 #define FCGI_stdout stdout
 #define FCGI_stderr stderr
 #define logstream stderr
-#endif //SERVER
+#endif /*SERVER */
 
 marker_param_t set_marker( codestream_param_t cs, Byte2_t code, Byte8_t offset, Byte2_t length)
 {
index e4f16a9fbdcd037e5e94ccf924630f3920999143..69b6c1f1a6746dfba69cf48e606ea9645645fd31 100644 (file)
 #define FCGI_stdout stdout
 #define FCGI_stderr stderr
 #define logstream stderr
-#endif //SERVER
+#endif /*SERVER */
 
 
 mhixbox_param_t * gene_mhixbox( box_param_t *box)
 {
   mhixbox_param_t *mhix;
   markeridx_param_t  *mkridx, *lastmkidx;
-  long pos = 0;
+  Byte8_t pos = 0;
 
   mhix = ( mhixbox_param_t *)malloc( sizeof( mhixbox_param_t));
   
@@ -129,7 +129,7 @@ void delete_mhixbox( mhixbox_param_t **mhix)
   while( mkPtr != NULL){
     mkNext=mkPtr->next;
 #ifndef SERVER
-    //      fprintf( logstream, "local log: marker index %#x deleted!\n", mkPtr->code);
+    /*      fprintf( logstream, "local log: marker index %#x deleted!\n", mkPtr->code); */
 #endif
       free(mkPtr);
       mkPtr=mkNext;
index 1e44a041f74831f8d549482e405ee2efe2e3e783..5c1d7588aae7660b3655144effb7261eadf55b6e 100644 (file)
 #define FCGI_stdout stdout
 #define FCGI_stderr stderr
 #define logstream stderr
-#endif //SERVER
+#endif /*SERVER */
 
 
-sessionlist_param_t * gene_sessionlist()
+sessionlist_param_t * gene_sessionlist(void)
 {
   sessionlist_param_t *sessionlist;
 
@@ -67,9 +67,9 @@ session_param_t * gene_session( sessionlist_param_t *sessionlist)
 
   session->next = NULL;
   
-  if( sessionlist->first) // there are one or more entries
+  if( sessionlist->first) /* there are one or more entries */
     sessionlist->last->next = session;
-  else                   // first entry
+  else                   /* first entry */
     sessionlist->first = session;
   sessionlist->last = session;
   
index 3187ced3529dec9dd980ab9f915b3853b3606729..03df4f4b4b62f2a82486500277e248807f3fc369 100644 (file)
@@ -54,7 +54,7 @@ typedef struct sessionlist_param{
  *
  * @return pointer to the generated session list
  */
-sessionlist_param_t * gene_sessionlist();
+sessionlist_param_t * gene_sessionlist(void);
 
 
 /**