Beispiel #1
0
std::vector<TargetObj>* TWBaseScript::get_target_objects(const char* target, sScrMsg* msg)
{
    std::vector<TargetObj>* matches = new std::vector<TargetObj>;

    // Make sure target is actually set before doing anything
    if(!target || *target == '\0') return matches;

    float radius;
    bool  lessthan;
    const char* archname;
    TargetObj newtarget = { 0, 0 };

    // Simple target/source selection.
    if(!_stricmp(target, "[me]")) {
        newtarget.obj_id = msg -> to;
        matches -> push_back(newtarget);

    } else if(!_stricmp(target, "[source]")) {
        newtarget.obj_id = msg -> from;
        matches -> push_back(newtarget);

    // linked objects
    } else if(*target == '&') {
        link_search(matches, ObjId(), &target[1]);

    // Archetype search, direct concrete and indirect concrete
    } else if(*target == '*' || *target == '@') {
        archetype_search(matches, &target[1], *target == '@');

    // Radius archetype search
    } else if(*target == '<' || *target == '>') {
        if(radius_search(target, &radius, &lessthan, &archname)) {
            const char* realname = archname;
            // Jump filter controls if needed...
            if(*archname == '*' || *archname == '@') ++realname;

            // Default behaviour for radius search is to get all decendants unless * is specified.
            archetype_search(matches, realname, *archname != '*', true, msg -> to, radius, lessthan);
        }
    // Named destination object
    } else {
        SInterface<IObjectSystem> ObjectSys(g_pScriptManager);

        newtarget.obj_id = ObjectSys -> GetObjectNamed(target);
        if(newtarget.obj_id)
            matches -> push_back(newtarget);
    }

    return matches;
}
Beispiel #2
0
// return 0: need filter
int link_filter(char *url)
{
    int depth = 0;
    char *p = NULL, *pp = NULL;
    char path[MAX_URL_LEN];

    p = url + 7;
    while (*p)
    {
        if (*p == '/')
            depth++;
        p++;
    }

    if (depth > 3 || strlen(url) > 128)
        return 0;

    if (p = strchr(url, '?'))
    {
        p++;
        if (strchr(p, '?') || strlen(url) > 64)
        {
            return 0;
        }
    } else
    {
        if (!strstr(url, "htm"))
        {
            return 0;
        }
    }

    pp = url + 7;
    while (p = strchr(pp, '/'))
    {
        p++;
        assert(p - url < MAX_URL_LEN);
        strncpy(path, url, p - url);
        *(path + (p - url)) = 0;

        if (link_search(link_dict, path) == 1)
            return 1;

        pp = p;
    }

    return 0;
}
int main(void)
{
    link_t p = make_node(10);
    link_insert(p);

    p = make_node(5);
    link_insert(p);

    p = make_node(90);
    link_insert(p);

    p = link_search(5);
    link_delete(p);
    free_node(p);
    link_traverse(link_print);

    link_destroy();
    return 0;
}