/* * 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; }
/* * 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); }
/* * 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); }
/* * 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); }
/* * 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; }
/* * 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); }
/* * 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; }