]> granicus.if.org Git - openjpeg/commitdiff
[trunk] change char* to const char* when possible. Remove more warnings
authorMathieu Malaterre <mathieu.malaterre@gmail.com>
Mon, 26 Mar 2012 16:08:05 +0000 (16:08 +0000)
committerMathieu Malaterre <mathieu.malaterre@gmail.com>
Mon, 26 Mar 2012 16:08:05 +0000 (16:08 +0000)
applications/jpip/libopenjpip/imgsock_manager.c
applications/jpip/libopenjpip/imgsock_manager.h
applications/jpip/libopenjpip/sock_manager.c
applications/jpip/libopenjpip/sock_manager.h

index 7c8dcd6dd40cab6f3da87db239a21f4d5732b89c..1ba95f5135849ba527ae8ae1bcfb03c5c190a64b 100644 (file)
@@ -38,7 +38,7 @@
 
 msgtype_t identify_clientmsg( SOCKET connected_socket)
 {
-  int receive_size;
+  OPJ_SIZE_T receive_size;
   char buf[BUF_LEN];
   static const char *magicid[] = { "JPIP-stream", "PNM request", "XML request",
     "TID request", "CID request", "CID destroy", "SIZ request", "JP2 save",
@@ -66,7 +66,8 @@ msgtype_t identify_clientmsg( SOCKET connected_socket)
 Byte_t * receive_JPIPstream( SOCKET connected_socket, char **target, char **tid, char **cid, OPJ_SIZE_T *streamlen)
 {
   char buf[BUF_LEN], versionstring[] = "version 1.2";
-  int linelen, datalen;
+  int idatalen;
+  OPJ_SIZE_T linelen, datalen;
   Byte_t *jpipstream;
   
   *target = *cid = *tid = NULL;
@@ -99,8 +100,14 @@ Byte_t * receive_JPIPstream( SOCKET connected_socket, char **target, char **tid,
       return NULL;
   }
 
-  datalen = atoi( buf);
-  fprintf( stderr, "Receive Data: %d Bytes\n", datalen);
+  idatalen = atoi( buf);
+  if( idatalen < 0 )
+    {
+    fprintf( stderr, "Receive Data: %d Bytes\n", idatalen);
+    return NULL;
+    }
+  datalen = (OPJ_SIZE_T)idatalen;
+  fprintf( stdout, "Receive Data: %lu Bytes\n", datalen);
 
   jpipstream = receive_stream( connected_socket, datalen);
 
@@ -113,40 +120,40 @@ Byte_t * receive_JPIPstream( SOCKET connected_socket, char **target, char **tid,
   return jpipstream;
 }
 
-void send_XMLstream( SOCKET connected_socket, Byte_t *xmlstream, int length)
+void send_XMLstream( SOCKET connected_socket, Byte_t *xmlstream, OPJ_SIZE_T length)
 {
   Byte_t header[5];
   
   header[0] = 'X';
   header[1] = 'M';
   header[2] = 'L';
-  header[3] = (length >> 8) & 0xff;
-  header[4] = length & 0xff;
+  header[3] = (Byte_t)((length >> 8) & 0xff);
+  header[4] = (Byte_t)(length & 0xff);
 
   send_stream( connected_socket, header, 5);
   send_stream( connected_socket, xmlstream, length);
 }
 
-void send_IDstream(  SOCKET connected_socket, char *id, int idlen, const char *label);
+void send_IDstream(  SOCKET connected_socket, const char *id, OPJ_SIZE_T idlen, const char *label);
 
-void send_CIDstream( SOCKET connected_socket, char *cid, int cidlen)
+void send_CIDstream( SOCKET connected_socket, const char *cid, OPJ_SIZE_T cidlen)
 {
   send_IDstream( connected_socket, cid, cidlen, "CID");
 }
 
-void send_TIDstream( SOCKET connected_socket, char *tid, OPJ_SIZE_T tidlen)
+void send_TIDstream( SOCKET connected_socket, const char *tid, OPJ_SIZE_T tidlen)
 {
   send_IDstream( connected_socket, tid, tidlen, "TID");
 }
 
-void send_IDstream(  SOCKET connected_socket, char *id, int idlen, const char *label)
+void send_IDstream(  SOCKET connected_socket, const char *id, OPJ_SIZE_T idlen, const char *label)
 {
-  Byte_t header[4];
+  char header[4];
 
   header[0] = label[0];
   header[1] = label[1];
   header[2] = label[2];
-  header[3] = idlen & 0xff;
+  header[3] = (char)(idlen & 0xff);
 
   send_stream( connected_socket, header, 4);
   send_stream( connected_socket, id, idlen);
@@ -154,7 +161,7 @@ void send_IDstream(  SOCKET connected_socket, char *id, int idlen, const char *l
 
 void send_PNMstream( SOCKET connected_socket, Byte_t *pnmstream, unsigned int width, unsigned int height, unsigned int numofcomp, Byte_t maxval)
 { 
-  int pnmlen = 0;
+  OPJ_SIZE_T pnmlen = 0;
   Byte_t header[7];
 
   pnmlen = width*height*numofcomp;
index 44b9b9580c38d9a92a2b37d2f365a141a7a843b1..044bdc530b57db4122356e491008a042afbad20b 100644 (file)
@@ -77,7 +77,7 @@ void send_PNMstream( SOCKET connected_socket, Byte_t *pnmstream, unsigned int wi
  * @param [in]  xmlstream        xml data stream
  * @param [in]  length           legnth of the xml data stream
  */
-void send_XMLstream( SOCKET connected_socket, Byte_t *xmlstream, int length);
+void send_XMLstream( SOCKET connected_socket, Byte_t *xmlstream, OPJ_SIZE_T length);
 
 /**
  * send TID data stream to the client
@@ -86,7 +86,7 @@ void send_XMLstream( SOCKET connected_socket, Byte_t *xmlstream, int length);
  * @param [in]  tid              tid string
  * @param [in]  tidlen           legnth of the tid string
  */
-void send_TIDstream( SOCKET connected_socket, char *tid, OPJ_SIZE_T tidlen);
+void send_TIDstream( SOCKET connected_socket, const char *tid, OPJ_SIZE_T tidlen);
 
 /**
  * send CID data stream to the client
@@ -95,7 +95,7 @@ void send_TIDstream( SOCKET connected_socket, char *tid, OPJ_SIZE_T tidlen);
  * @param [in]  cid              cid string
  * @param [in]  cidlen           legnth of the cid string
  */
-void send_CIDstream( SOCKET connected_socket, char *cid, int cidlen);
+void send_CIDstream( SOCKET connected_socket, const char *cid, OPJ_SIZE_T cidlen);
 
 /**
  * send SIZ data stream to the client
index 1460d3ba8586e3e7d4b6850043c1eb1d16e8acdc..432b03fab6f2acb26eb679265f15d32b3ef1a4f1 100644 (file)
@@ -135,9 +135,9 @@ void * receive_stream( SOCKET connected_socket, OPJ_SIZE_T length)
   return stream;
 }
 
-int receive_line(SOCKET connected_socket, char *p)
+OPJ_SIZE_T receive_line(SOCKET connected_socket, char *p)
 {
-  int len = 0;
+  OPJ_SIZE_T len = 0;
   while (1){
     ssize_t ret;
     ret = recv( connected_socket, p, 1, 0);
index 5caeaba225ca264d59a007dd1d28354a76b4e871..ee67131e4c960ea50011648c5c5bceaf444eebfd 100644 (file)
@@ -67,7 +67,7 @@ SOCKET accept_socket( SOCKET listening_socket);
  * @param [out] buf              string to be stored
  * @return                       red size
  */
-int receive_line(SOCKET connected_socket, char *buf);
+OPJ_SIZE_T receive_line(SOCKET connected_socket, char *buf);
 
 /**
  * receive a string line (ending with '\n') from client, return malloc string