Exemplo n.º 1
0
/*
 *	Read a bare "word" - this means we don't honor
 *	tokens as delimiters.
 */
int getbareword(const char **ptr, char *buf, int buflen)
{
	FR_TOKEN token;

	token = getthing(ptr, buf, buflen, 0, NULL);
	if (token != T_BARE_WORD) {
		return 0;
	}

	return 1;
}
Exemplo n.º 2
0
/*
 *	Expect a string.
 */
FR_TOKEN getstring(const char **ptr, char *buf, int buflen)
{
	const char *p;

	if (!ptr || !*ptr || !buf) return T_OP_INVALID;
	
	p = *ptr;

	while (*p && (isspace((int)*p))) p++;

	*ptr = p;

	if ((*p == '"') || (*p == '\'') || (*p == '`')) {
		return gettoken(ptr, buf, buflen);
	}

	return getthing(ptr, buf, buflen, 0, tokens);
}
Exemplo n.º 3
0
/*
 *	Expect a string.
 */
FR_TOKEN getstring(char const **ptr, char *buf, int buflen, bool unescape)
{
	char const *p;

	if (!ptr || !*ptr || !buf) return T_OP_INVALID;

	p = *ptr;

	while (*p && (isspace((int)*p))) p++;

	*ptr = p;

	if ((*p == '"') || (*p == '\'') || (*p == '`')) {
		return gettoken(ptr, buf, buflen, unescape);
	}

	return getthing(ptr, buf, buflen, 0, fr_tokens, unescape);
}
Exemplo n.º 4
0
/*
 *	Read the next word, use tokens as delimiters.
 */
FR_TOKEN gettoken(const char **ptr, char *buf, int buflen)
{
	return getthing(ptr, buf, buflen, 1, tokens);
}
Exemplo n.º 5
0
/*
 *	Read a "word" - this means we don't honor
 *	tokens as delimiters.
 */
int getword(const char **ptr, char *buf, int buflen)
{
	return getthing(ptr, buf, buflen, 0, tokens) == T_EOL ? 0 : 1;
}
Exemplo n.º 6
0
/*
 *	Read the next word, use tokens as delimiters.
 */
FR_TOKEN gettoken(char const **ptr, char *buf, int buflen, bool unescape)
{
	return getthing(ptr, buf, buflen, 1, fr_tokens, unescape);
}
Exemplo n.º 7
0
/*
 *	Read a "word" - this means we don't honor
 *	tokens as delimiters.
 */
int getword(char const **ptr, char *buf, int buflen, bool unescape)
{
	return getthing(ptr, buf, buflen, 0, fr_tokens, unescape) == T_EOL ? 0 : 1;
}