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",
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;
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);
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);
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;
* @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
* @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
* @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