#define SIZE_FOUND_LISTVAR_BUFFER   2048    // size this buffer to your needs

void cvar_ListVars_f(void)
{
    if (cmd_Argc() == 2)
    {   // additional characters specified, so use for autocomplete input
        tchar_t list[SIZE_FOUND_LISTVAR_BUFFER], *s = list;
        int count = cvar_AutoComplete(cmd_Argv(1), list, SIZE_FOUND_LISTVAR_BUFFER);

        // walk the found cvar list and print
        for (;count > 0; --count)
        {
            cvarhandle_t    hvar = cvar_Find(s);

            if (hvar)
                cvar_Print(hvar);

            s += com_strlen(s) + 1;
        }
    }
    else
    {   // walk over the list of cvars 
        int i;
        for (i=1; i<cvar_list.size; i++)
            cvar_Print(i);
    }
}

