int nexttoken(const char **p_out, const char **p_in, const char *delims)
{
    const char *s, *a, *e;
    char c, q;
    int delim_spc;

    delim_spc = NULL == delims || strchr(delims, ' ');

    for (a = e = s = *p_in, q = 0; 0 != (c = *s);) {
        ++s;
        if (0==q) {
            if ('\"'==c || '\''==c)
                q = c;
            else
            if (IS_SPC(c)) {
                if (e == a) {
                    a = e = s;
                    continue;
                }
                if (delim_spc)
                    break;
            }
            if (delims && strchr(delims, c))
                break;
        } else if (c==q) {
            q=0;
        }
        e = s;
    }
    while (e > a && IS_SPC(e[-1]))
        --e;
    skip_spc(&s);
    *p_out = a, *p_in = s;
    return (int)(e - a);
}
const void *exec_internal_broam(
    const char *arg,
    const struct cfgmenu *menu_root,
    const struct cfgmenu **p_menu,
    const struct cfgmenu**p_item)
{
    const void *v = NULL;
    *p_item = find_cfg_item(arg, menu_root, p_menu);
    if (NULL == *p_item)
        return v;

    v = (*p_item)->pvalue;
    if (v) {
        // scan for a possible argument to the command
        while (!IS_SPC(*arg))
            ++arg;
        skip_spc(&arg);
        // now set the appropriate variable
        if (is_fixed_string(v)) {
            strcpy((char *)v, arg);
        } else if (is_string_item(v)) {
            strcpy((char *)v, arg);
        } else if (get_int_item(v)) {
            if (*arg) *(int*)v = atoi(arg);
        } else {
            set_bool((bool*)v, arg);
        }
        // write to blackbox.rc or extensions.rc (automatic)
        Settings_WriteRCSetting(v);
    }
    return v;
}
int skip_spc(const char **pp)
{
    int c;
    while (c = **pp, IS_SPC(c) && c)
        ++*pp;
    return c;
}
Exemple #4
0
// Protected Functions
bool HttpParser::spc(bref::Buffer::const_iterator &it,
		     bref:: Buffer::const_iterator const &it_end) const {
	if (it == it_end
	    || !IS_SPC(*it))
		return false;

	++it;

	return true;
}
const char *get_special_command(const char **p_path, char *buffer, int size)
{
    const char *in, *a, *b;
    a = strstr(in = *p_path, ">>");
    if (NULL == a)
        return NULL;
    b = a + 2;
    skip_spc(&b);
    while (a > in && IS_SPC(a[-1]))
        --a;
    *p_path = extract_string(buffer, in, imin((int)(a-in), size-1));
    return b;
}
int get_string_within (char *dest, int size, const char **p_src, const char *delims)
{
    const char *a, *b, *p;
    char c, n, d, e;
    n = 0; /* balance-counter for nested pairs of delims */
    a = NULL;
    d = delims[0], e = delims[1];
    for (p = *p_src; 0 != (c = *p++); ) {
        if (c == d && 0 == n++) {
            a = p;
        } else if (c == e && 0 == --n) {
            b = (*p_src = p) - 1;
            while (a < b && IS_SPC(*a))
                ++a;
            while (b > a && IS_SPC(b[-1]))
                --b;
            extract_string(dest, a, imin((int)(b-a), size-1));
            return 1;
        }
    }
    *dest = 0;
    return 0;
}