24 RCSID(
"$Id: 94c47c118f47941e15b4415e193def00ee2658de $")
26 #include <freeradius-devel/libradius.h>
232 #define TOKEN_MATCH(bptr, tptr) \
233 ( (tptr)[0] == (bptr)[0] && \
234 ((tptr)[1] == (bptr)[1] || (tptr)[1] == 0))
258 while (*p && isspace((
int) *p))
269 if (tok)
for (t = tokenlist; t->
name; t++) {
271 strcpy(buf, t->
name);
272 p += strlen(t->
name);
273 while (isspace((
int) *p))
291 while (*p && buflen-- > 1) {
292 if (unescape && quote && (*p ==
'\\')) {
310 if (*p >=
'0' && *p <=
'9' &&
311 sscanf(p,
"%3o", &x) == 1) {
327 if (!unescape && quote && (*p ==
'\\')) {
339 if (quote && (*p == quote)) {
345 if (isspace((
int) *p))
348 for (t = tokenlist; t->
name; t++)
354 if (*p ==
',')
break;
366 while (*p && isspace((
int) *p))
396 int getword(
char const **ptr,
char *buf,
int buflen,
bool unescape)
398 return getthing(ptr, buf, buflen,
false, fr_tokens_table, unescape) ==
T_EOL ? 0 : 1;
407 return getthing(ptr, buf, buflen,
true, fr_tokens_table, unescape);
418 rcode =
getthing(ptr, op,
sizeof(op),
true, fr_tokens_table,
false);
419 if (!fr_assignment_op[rcode] && !fr_equality_op[rcode]) {
433 if (!ptr || !*ptr || !buf)
return T_INVALID;
437 while (*p && (isspace((
int)*p))) p++;
441 if ((*p ==
'"') || (*p ==
'\'') || (*p ==
'`')) {
442 return gettoken(ptr, buf, buflen, unescape);
445 return getthing(ptr, buf, buflen, 0, fr_tokens_table, unescape);
459 for (
this = table; this->name != NULL;
this++) {
480 for (
this = table; this->name != NULL;
this++) {
483 tlen = strlen(this->name);
488 if ((len > 0) && (len < (
int) tlen))
continue;
493 max = (len < 0) ? tlen : (
unsigned)len;
511 for (
this = table; this->
name != NULL;
this++) {
512 if (this->number == number) {
522 return fr_int2str(fr_tokens_table, token,
"???");
char const * fr_token_name(int token)
int getword(char const **ptr, char *buf, int buflen, bool unescape)
static FR_TOKEN getthing(char const **ptr, char *buf, int buflen, bool tok, FR_NAME_NUMBER const *tokenlist, bool unescape)
int fr_substr2int(FR_NAME_NUMBER const *table, char const *name, int def, int len)
FR_TOKEN gettoken(char const **ptr, char *buf, int buflen, bool unescape)
#define TOKEN_MATCH(bptr, tptr)
int strcasecmp(char *s1, char *s2)
FR_TOKEN getop(char const **ptr)
char const * fr_int2str(FR_NAME_NUMBER const *table, int number, char const *def)
int strncasecmp(char *s1, char *s2, int n)
void fr_strerror_printf(char const *,...) CC_HINT(format(printf
int fr_str2int(FR_NAME_NUMBER const *table, char const *name, int def)
const FR_NAME_NUMBER fr_tokens_table[]
const char fr_token_quote[]
Convert tokens back to a quoting character.
FR_TOKEN getstring(char const **ptr, char *buf, int buflen, bool unescape)
const bool fr_assignment_op[]
const bool fr_equality_op[]