X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=odr%2Ftest.c;h=013eefbb8a79fb9bf810386093b9a3022cd96255;hp=894ef1bd3b2381e8e2b9d7947c05efcf460bb265;hb=e8464a391ad260860795a69bcd1bcf6940cc17de;hpb=32226b4f15d634d5e48b1306aeeb26a370c8f5c5 diff --git a/odr/test.c b/odr/test.c index 894ef1b..013eefb 100644 --- a/odr/test.c +++ b/odr/test.c @@ -2,6 +2,8 @@ #include #include +#if 0 + typedef Odr_bitmask Z_ReferenceId; typedef struct Z_InitRequest @@ -49,6 +51,38 @@ int z_InitRequest(ODR o, Z_InitRequest **p, int opt) odr_sequence_end(o); } +struct A +{ + int which; + union + { + int *b; /* integer */ + char *c; /* visstring */ + } u; +}; + +int f_A(ODR o, struct A **p, int opt) +{ + int res; + Odr_arm arm[] = + { + { -1, -1, -1, 0, (Odr_fun) odr_integer }, + { ODR_IMPLICIT, ODR_CONTEXT, 200, 1, (Odr_fun) odr_visiblestring }, + { -1, -1, -1, -1, 0 } + }; + + if (o->direction == ODR_DECODE && !*p) + *p = odr_malloc(o, sizeof(**p)); + res = odr_choice(o, arm, &(*p)->u, &(*p)->which); + if (!res) + { + *p = 0; + return opt; + } + return 1; +} + +#if 0 int main() { int i; @@ -86,13 +120,47 @@ int main() o.buf = buf; o.bp=o.buf; o.left = o.buflen = 1024; - o.direction = ODR_ENCODE; + o.direction = ODR_PRINT; + o.print = stdout; o.t_class = -1; odr_oid(&o, &oidp1, 0); + exit(0); + o.direction = ODR_DECODE; o.bp = o.buf; odr_oid(&o, &oidp2, 0); } +#endif + +#endif + +int main() +{ + Odr_bitmask a; + char command; + int val; + char line[100]; + + ODR_MASK_ZERO(&a); + while (gets(line)) + { + int i; + + sscanf(line, "%c %d", &command, &val); + switch (command) + { + case 's': ODR_MASK_SET(&a, val); break; + case 'c': ODR_MASK_CLEAR(&a, val); break; + case 'g': printf("%d\n", ODR_MASK_GET(&a, val)); break; + case 'l': break; + default: printf("enter c or s or l\n"); continue; + } + printf("top is %d\n", a.top); + for (i = 0; i <= a.top; i++) + printf("%2.2x ", a.bits[i] ); + printf("\n"); + } +}