For 'decode' call, I am passing char pointer of exi stream which is length of 850 bytes.
Since INPUT_BUFFER_SIZE is 200. It is able to decode only 200 bytes of exi stream, later it was stopping.
If I increase that INPUT_BUFFER_SIZE to 1000. Now I can able to decode that exi stream
In case of more than 1000 bytes of exi stream, again problem comes.
If I use code as it is taking FILE pointer, then there was no issue with this size, we can keep INPUT_BUFFER_SIZE as 200.
But, when pass exi stream as char pointer then problem coming.
I am writing an interface by using decoder examples which takes char pointer as input(exi) and char pointer as output(xml). As like this
User can call this function outside library by passing schemaPtr, inStream which is exi content, outStream which is decoded version of exi content (xml)
Regards,
SK
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Your second function readFileInputStream() must return 200, then 200, 200, 200 and then 50 (indicating to EXIP this is the end of data 50 returned < 200 requested) : total = 850
Denis
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
As I understand, you have a buffer in memory, instead of a file.
This is the same process : when EXIP ask you X bytes, you must return X bytes.
If you return less that X bytes, EXIP understand you haven't data anymore and stops.
Try this :
typedef struct {
char *data;
int len;
int current;
} memoryStream_t;
size_t readMemInputStream(void buf, size_t readSize, void stream) {
memoryStream_t ms = (memoryStream_t )stream;
if (!ms->data)
return 0;
int how = ms->len - ms->current;
if (how > readSize)
how = readSize;
//printf ("readMemInputStream %d how=%d\n", readSize, how);
memcpy (buf, ms->data+ms->current, how);
ms->current += how;
return how;
}
decode() {
memoryStream_t ms;
ms.data = <the big buffer>;
ms.len = <size of the big buffer>;
ms.current = 0;
buffer.ioStrm.readWriteToStream = readMemInputStream;
buffer.ioStrm.stream = &ms;
...
Denis
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Rumen,
This information is regarding https://sourceforge.net/p/exip/bugs/8/
I have changed decoder code something like bellow.
Existing prototype :
Modified prototype :
Existing readFileInputStream :
Modified readFileInputStream :
For 'decode' call, I am passing char pointer of exi stream which is length of 850 bytes.
Since INPUT_BUFFER_SIZE is 200. It is able to decode only 200 bytes of exi stream, later it was stopping.
If I increase that INPUT_BUFFER_SIZE to 1000. Now I can able to decode that exi stream
In case of more than 1000 bytes of exi stream, again problem comes.
If I use code as it is taking FILE pointer, then there was no issue with this size, we can keep INPUT_BUFFER_SIZE as 200.
But, when pass exi stream as char pointer then problem coming.
I am writing an interface by using decoder examples which takes char pointer as input(exi) and char pointer as output(xml). As like this
User can call this function outside library by passing schemaPtr, inStream which is exi content, outStream which is decoded version of exi content (xml)
Regards,
SK
Your second function readFileInputStream() must return 200, then 200, 200, 200 and then 50 (indicating to EXIP this is the end of data 50 returned < 200 requested) : total = 850
Denis
Hi Denis,
What you said is correct incase of FILE* as input.
But in my case, I am getting first 200 only and then it stops.
Regards,
SK
As I understand, you have a buffer in memory, instead of a file.
This is the same process : when EXIP ask you X bytes, you must return X bytes.
If you return less that X bytes, EXIP understand you haven't data anymore and stops.
Try this :
typedef struct {
char *data;
int len;
int current;
} memoryStream_t;
size_t readMemInputStream(void buf, size_t readSize, void stream) {
memoryStream_t ms = (memoryStream_t )stream;
if (!ms->data)
return 0;
int how = ms->len - ms->current;
if (how > readSize)
how = readSize;
//printf ("readMemInputStream %d how=%d\n", readSize, how);
memcpy (buf, ms->data+ms->current, how);
ms->current += how;
return how;
}
decode() {
memoryStream_t ms;
...
Denis