/* * Get a string valued option. * These are given as * cl=^Z * Much decoding is done on the strings, and the strings are * placed in area, which is a ref parameter which is updated. * No checking on area overflow. */ char *tgetstr(char *id, char **area) { register char *bp = tbuf; for (;;) { bp = tskip(bp); if (!*bp) return (0); if (*bp++ != id[0] || *bp == 0 || *bp++ != id[1]) continue; if (*bp == '@') return(0); if (*bp != '=') continue; bp++; return (tdecode(bp, area)); } }
/* * Get a string valued option. * These are given as * cl=^Z * Much decoding is done on the strings, and the strings are * placed in area, which is a ref parameter which is updated. * No checking on area overflow. */ char * tgetstr(char *id, char **area) { char *bp = tbuf; for (;;) { bp = tskip(bp); if (!*bp) return (0); if (strncmp(bp, id, strlen(id)) != 0) continue; bp += strlen(id); if (*bp == '@') return (0); if (*bp != '=') continue; bp++; return (tdecode(bp, area)); } }
/* * Get a string valued option. * These are given as * %|cl=^Z|% * Much decoding is done on the strings, and the strings are * placed in area, which is a ref parameter which is updated. * No checking on area overflow. */ char *tgetstr(char *id, char **area) { register char *bp = tbuf, *i; register int eq; for (;;) { bp = tskip(bp); if (!*bp) return 0; eq=1; for (i=id; *i;) if (*i++!=*bp++) { eq=0; break; } if (!eq) continue; if (*bp == '@') return 0; if (*bp != '=') continue; bp++; return tdecode(bp, area); } }
char * tgetstr(char *id, char **area) { register char *bp; char name[2]; if (!tbuf) return NULL; bp = tbuf; for (;;) { bp = tskip(bp); if (!bp[0] || !bp[1]) break; if (bp[0] == ':' || bp[1] == ':') continue; name[0] = *bp++; name[1] = *bp++; if (id[0] != name[0] || id[1] != name[1]) continue; if (*bp == '@') continue; switch (*bp) { case '#': case ':': case 0: break; default: if (*bp != '=') continue; bp++; return tdecode(bp, area); } } return NULL; }
static void test_encdec(void *p) { ull_check(tdecode( 2, 1,2), 0x0102); ull_check(tdecode(-2, 1,2), 0x0201); ull_check(tdecode( 4, 1,2,3,4), 0x01020304); ull_check(tdecode(-4, 1,2,3,4), 0x04030201); ull_check(tdecode( 8, 1,2,3,4,5,6,7,8), 0x0102030405060708); ull_check(tdecode(-8, 1,2,3,4,5,6,7,8), 0x0807060504030201); str_check(tencode( 2, 0x0102), "01 02"); str_check(tencode(-2, 0x0102), "02 01"); str_check(tencode( 4, 0x01020304), "01 02 03 04"); str_check(tencode(-4, 0x01020304), "04 03 02 01"); str_check(tencode( 8, 0x0102030405060708ULL), "01 02 03 04 05 06 07 08"); str_check(tencode(-8, 0x0102030405060708ULL), "08 07 06 05 04 03 02 01"); end:; }