Beispiel #1
0
VStr Info_ValueForKey(const VStr& s, const VStr& key)
{
    guard(Info_ValueForKey);
    if (s.IsEmpty() || key.IsEmpty())
    {
        return VStr();
    }

    if (s.Length() >= MAX_INFO_STRING)
    {
        Host_Error("Info_ValueForKey: oversize infostring");
    }

    int i = 0;
    if (s[i] == '\\')
        i++;
    while (1)
    {
        int Start = i;
        while (s[i] != '\\')
        {
            if (!s[i])
                return VStr();
            i++;
        }
        VStr pkey(s, Start, i - Start);
        i++;

        Start = i;
        while (s[i] != '\\' && s[i])
        {
            i++;
        }

        if (!key.ICmp(pkey))
            return VStr(s, Start, i - Start);

        if (!s[i])
            return VStr();
        i++;
    }
    unguard;
}