X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=odr%2Ftest.c;h=013eefbb8a79fb9bf810386093b9a3022cd96255;hp=77506f9c707a5f479569f12de015212a0f52fb24;hb=0ff5815242556923f24a9dcbbad9ebe30e64f165;hpb=10981b2f116449523a9f628c20a78212ce91553e diff --git a/odr/test.c b/odr/test.c index 77506f9..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 @@ -70,7 +72,7 @@ int f_A(ODR o, struct A **p, int opt) }; if (o->direction == ODR_DECODE && !*p) - *p = nalloc(o, sizeof(**p)); + *p = odr_malloc(o, sizeof(**p)); res = odr_choice(o, arm, &(*p)->u, &(*p)->which); if (!res) { @@ -133,30 +135,32 @@ int main() } #endif +#endif + int main() { - struct A ch, *chp1, *chp2; - int b = 9999; - char *c = "Nu tester vi en satans forpulet CHOICE!"; - struct odr o; - unsigned char buf[4096]; - - ch.u.c = c; - ch.which = 1; - chp1 = &ch; - - o.buf = buf; - o.bp=o.buf; - o.left = o.buflen = 1024; - o.direction = ODR_ENCODE; - o.t_class = -1; - - f_A(&o, &chp1, 0); - - o.direction = ODR_DECODE; - o.bp = o.buf; + Odr_bitmask a; + char command; + int val; + char line[100]; - f_A(&o, &chp2, 0); - - return 0; + 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"); + } }