etch-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Marsh <>
Subject Etch c-binding array question
Date Fri, 20 Jan 2012 18:58:00 GMT
Hello all,

I am having trouble understanding the array usage in the C binding, and I hope someone can
point out the error in my understanding. I am trying to implement a service method with the
signature "void test(byte[][] data)". Unfortunately, I seem unable to provide a value from
a native char** pointer that successfully passes the validator.

After trying several implementations, I have a naïve implementation which does the following:

char **s = …; // array of variable length strings, like { "this", "is", "a", "test" }
int nelts = …; // length of 's'

etch_arrayvalue * av = new_arrayvalue(ETCHTYPEB_BYTE, NULL, 2, nelts, 1, 0, 0);

int i, j;
for (i=0; i < nelts; i++) {
int len = strlen(s[i]);
etch_arrayvalue *elt = new_arrayvalue(ETCHTYPEB_BYTE, NULL, 1, len, 1, 0, 0);
for (j=0; j < len; j++) {
etch_byte *b = new_byte(s[i][j]);
arrayvalue_add(elt, b);
arrayvalue_add(av, let);
remote->test(remote, av);

I also tried variations on arrayvalue_from with native arrays, etc., but could not get it
to work. The only thing I could get to work was to send a native array with fixed dimensions,
but that does not work for our case.

Thanks for any assistance!


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message