From: Mathieu Malaterre Date: Mon, 26 Mar 2012 16:08:05 +0000 (+0000) Subject: [trunk] change char* to const char* when possible. Remove more warnings X-Git-Tag: version.2.0~429 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1228e0e925f80312a55ff76072c6c9421e1f1e72;p=openjpeg [trunk] change char* to const char* when possible. Remove more warnings --- diff --git a/applications/jpip/libopenjpip/imgsock_manager.c b/applications/jpip/libopenjpip/imgsock_manager.c index 7c8dcd6d..1ba95f51 100644 --- a/applications/jpip/libopenjpip/imgsock_manager.c +++ b/applications/jpip/libopenjpip/imgsock_manager.c @@ -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; diff --git a/applications/jpip/libopenjpip/imgsock_manager.h b/applications/jpip/libopenjpip/imgsock_manager.h index 44b9b958..044bdc53 100644 --- a/applications/jpip/libopenjpip/imgsock_manager.h +++ b/applications/jpip/libopenjpip/imgsock_manager.h @@ -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 diff --git a/applications/jpip/libopenjpip/sock_manager.c b/applications/jpip/libopenjpip/sock_manager.c index 1460d3ba..432b03fa 100644 --- a/applications/jpip/libopenjpip/sock_manager.c +++ b/applications/jpip/libopenjpip/sock_manager.c @@ -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); diff --git a/applications/jpip/libopenjpip/sock_manager.h b/applications/jpip/libopenjpip/sock_manager.h index 5caeaba2..ee67131e 100644 --- a/applications/jpip/libopenjpip/sock_manager.h +++ b/applications/jpip/libopenjpip/sock_manager.h @@ -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