I have defined a fixed size array in the server like array[256].
In the write() function I write a different length string to the array, then I want to read parts or all of the array in the read() function, the process will be like the following:
string[len] str[size]
| ^
| |
--------->array[256] -----------|
but when I put the function above and compile it, there are some error happen. I have change the size_is() with length_is() or max_is(), but there still error when I compile it. I know if I define a fix array str[256] the code can be work, but I just want to use a unfixed length array to get the string.
could someone please give me some advice?if I describe the problem clearly, please let me know.
thank you!
I don't know whether I describe what I want to do clearly,so I put the simple code below:
read-client write-client
#define STR_TO 30 #define STR_FROM 30
... ...
char str_to[SRR_TO]; char str_from[STR_FROM];
... ...
read(str_to, STR_TO); write(str_from, STR_FROM);
... ...
server
#define SIZE 256
...
char string[SIZE];
...
int write(char *str_from, int str_from)
{
//write str_from size chars of str_from array to the string array which is in server
}
int read(char *str_to, int str_to)
{
//read str_to size chars from the string array which is in server to str_to
}
Then I define write functions as the above in a .idl file,but when I compile it,there will be the following error:
terminate called after throwing an instance of 'std::out_of_range'
what(): CBEMsgBuffer::IsEarlier
make[1]: *** [test-server.c] Aborted
make[1]: *** [test-server.c] Deleting file `test-sys.h'
make[1]: *** [test-server.c] Deleting file `test-client.h'
make[1]: *** [test-server.c] Deleting file `test-client.c'
make: *** [/home/l4/tudos/build/pkg/
fifo/idl/OBJ-x86-l4v2] Error 2
must we use the format as the dice manual below?:
int read([out, prealloc_client, size_is(len)] char **str, [out,in]int *len)
and when I modify the function as
int read([out, prealloc_client, prealloc_server, size_is(len)] char *str, [out,in]int *len)
there is no error when compile it,but there will be another error called :fpage
could you give me some advice for the read function?
thank you.
--
fang,