Пример #1
0
int env_universal_remove( const wchar_t *name )
{
	int res;
	
	message_t *msg;
	if( !init )
		return 1;
		
	CHECK( name, 1 );

	res = !env_universal_common_get( name );
	debug( 3,
		   L"env_universal_remove( \"%ls\" )",
		   name );
		
	if( is_dead() )
	{
		env_universal_common_remove( wcstring(name) );
	}
	else
	{
		msg= create_message( ERASE, name, 0);
		msg->count=1;
        env_universal_server.unsent->push(msg);
		env_universal_barrier();
	}
	
	return res;
}
Пример #2
0
int env_universal_remove(const wchar_t *name)
{
    int res;

    if (!s_env_univeral_inited)
        return 1;

    CHECK(name, 1);

    wcstring name_str = name;
    res = env_universal_common_get(name_str).missing();
    debug(3,
          L"env_universal_remove( \"%ls\" )",
          name);

    if (! synchronizes_via_fishd() || is_dead())
    {
        env_universal_common_remove(name_str);
    }
    else
    {
        message_t *msg = create_message(ERASE, name, 0);
        msg->count=1;
        env_universal_server.unsent.push(msg);
        env_universal_barrier();
    }

    return res;
}
Пример #3
0
/**
   Remove all universal variables.
*/
static void env_universal_remove_all()
{
    size_t i;
    wcstring_list_t lst;
    env_universal_common_get_names(lst, true, true);
    for (i=0; i<lst.size(); i++)
    {
        const wcstring &key = lst.at(i);
        env_universal_common_remove(key);
    }

}
Пример #4
0
void env_universal_common_set(const wchar_t *key, const wchar_t *val, int exportv)
{
    var_uni_entry_t *entry;

    CHECK(key,);
    CHECK(val,);

    entry = new var_uni_entry_t;

    entry->exportv=exportv;
    entry->val = val;
    env_universal_common_remove(key);

    env_universal_var[key] = entry;
    if (callback)
    {
        callback(exportv?SET_EXPORT:SET, key, val);
    }
}
Пример #5
0
/**
   Parse message msg
*/
static void parse_message(wchar_t *msg,
                          connection_t *src)
{
//  debug( 3, L"parse_message( %ls );", msg );

    if (msg[0] == L'#')
        return;

    if (match(msg, SET_STR) || match(msg, SET_EXPORT_STR))
    {
        wchar_t *name, *tmp;
        int exportv = match(msg, SET_EXPORT_STR);

        name = msg+(exportv?wcslen(SET_EXPORT_STR):wcslen(SET_STR));
        while (wcschr(L"\t ", *name))
            name++;

        tmp = wcschr(name, L':');
        if (tmp)
        {
            wchar_t *key;
            wchar_t *val;

            key = (wchar_t *)malloc(sizeof(wchar_t)*(tmp-name+1));
            memcpy(key, name, sizeof(wchar_t)*(tmp-name));
            key[tmp-name]=0;

            val = tmp+1;
            val = unescape(val, 0);

            if (key && val)
                env_universal_common_set(key, val, exportv);

            free(val);
            free(key);
        }
        else
        {
            debug(1, PARSE_ERR, msg);
        }
    }
    else if (match(msg, ERASE_STR))
    {
        wchar_t *name, *tmp;

        name = msg+wcslen(ERASE_STR);
        while (wcschr(L"\t ", *name))
            name++;

        tmp = name;
        while (iswalnum(*tmp) || *tmp == L'_')
            tmp++;

        *tmp = 0;

        if (!wcslen(name))
        {
            debug(1, PARSE_ERR, msg);
        }

        env_universal_common_remove(name);

        if (callback)
        {
            callback(ERASE, name, 0);
        }
    }
    else if (match(msg, BARRIER_STR))
    {
        message_t *msg = create_message(BARRIER_REPLY, 0, 0);
        msg->count = 1;
        src->unsent->push(msg);
        try_send_all(src);
    }
    else if (match(msg, BARRIER_REPLY_STR))
    {
        if (callback)
        {
            callback(BARRIER_REPLY, 0, 0);
        }
    }
    else
    {
        debug(1, PARSE_ERR, msg);
    }
}