pike.git / lib / modules / Search.pmod / Utils.pmod

version» Context lines:

pike.git/lib/modules/Search.pmod/Utils.pmod:1:   // This file is part of Roxen Search   // Copyright © 2001 Roxen IS. All rights reserved.   // - // $Id: Utils.pmod,v 1.28 2001/08/20 19:52:54 js Exp $ + // $Id: Utils.pmod,v 1.29 2001/08/22 19:33:47 nilsson Exp $      #if !constant(report_error)   #define report_error werror   #endif      public array(string) tokenize_and_normalize( string what )   //! This can be optimized quite significantly when compared to   //! tokenize( normalize( x ) ) in the future, currently it's not all   //! that much faster, but still faster.   {
pike.git/lib/modules/Search.pmod/Utils.pmod:200:    //! @value -1    //! The profile is deleted.    //! @value 0    //! The profile is not up to date.    //! @value 1    //! The profile is up to date.    //! @endint    int(-1..1) up_to_datep(int profile_id) {    // werror("Called up-to-date...\n");    array(mapping(string:string)) res; -  res = get_db()->query("SELECT altered,type FROM wf_profile WHERE id=%d", profile_id); +  res = get_db()->query("SELECT altered,type FROM profile WHERE id=%d", profile_id);       // The profile is deleted. In such a rare event we take the    // trouble to review all our cached values.    if(!sizeof(res)) { -  array(int) existing = (array(int))get_db()->query("SELECT id FROM wf_profile")->id; +  array(int) existing = (array(int))get_db()->query("SELECT id FROM profile")->id;       foreach(indices(value_cache), int id)    if(!has_value(existing, id))    m_delete(value_cache, id);       foreach(indices(entry_cache), string id) {    int dbp, qp;    sscanf(id, "%d:%d", dbp, qp);    if(!has_value(existing, dbp))    m_delete(entry_cache, id);
pike.git/lib/modules/Search.pmod/Utils.pmod:259:    return 0;    }       //! Returns the profile number for the given database profile.    int get_db_profile_number(string name) {    int db_profile;    if(db_profile=db_profile_names[name])    return db_profile;       array res = get_db()-> -  query("SELECT id FROM wf_profile WHERE name=%s AND type=2", name); +  query("SELECT id FROM profile WHERE name=%s AND type=2", name);    if(!sizeof(res))    THROW("No database profile " + name + " found.\n");       return db_profile_names[name] = (int)res[0]->id;    }       //! Returns the profile number for the given query profile.    int get_query_profile_number(string name)    {    int query_profile;    if( query_profile=query_profile_names[name] )    return query_profile;       array res = get_db()-> -  query("SELECT id FROM wf_profile WHERE name=%s AND type=1", name); +  query("SELECT id FROM profile WHERE name=%s AND type=1", name);    if(!sizeof(res))    THROW("No query profile " + name + " found.\n");       return query_profile_names[name] = (int)res[0]->id;    }       private int last_db_prof_stat = 0; // 1970       //! Returns a list of available database profiles.    array(string) list_db_profiles() {    if (time(1) - last_db_prof_stat < 5*60)    return indices(db_profile_names); -  array res = get_db()->query("SELECT name, id FROM wf_profile WHERE type=2"); +  array res = get_db()->query("SELECT name, id FROM profile WHERE type=2");    db_profile_names = mkmapping(    res->name,    map(res->id, lambda(string s) { return (int) s; } ));    if(sizeof(res))    last_db_prof_stat = time(1);    return res->name;    }       private int last_query_prof_stat = 0; // 1970       //! Returns a list of available query profiles.    array(string) list_query_profiles()    {    if (time(1) - last_query_prof_stat >= 5*60) { -  array res = get_db()->query("SELECT name, id FROM wf_profile WHERE type=1"); +  array res = get_db()->query("SELECT name, id FROM profile WHERE type=1");    query_profile_names = mkmapping( res->name, (array(int)) res->id );    if(sizeof(query_profile_names))    last_query_prof_stat = time(1);    }    return indices(query_profile_names);    }       // Used when decoding text encoded pike data types.    private object compile_handler = class {    mapping(string:mixed) get_default_module() {
pike.git/lib/modules/Search.pmod/Utils.pmod:340:    return compile_string("mixed foo=" + str + ";", 0, compile_handler)()->foo;    }       //! Returns the value mapping for the given profile.    mapping get_value_mapping(int profile) {    mapping val;    if(val=copy_value(value_cache[profile]))    return val;       array res = get_db()-> -  query("SELECT name,value FROM wf_value WHERE pid=%d", profile); +  query("SELECT name,value FROM value WHERE pid=%d", profile);       val = mkmapping( res->name, map(res->value, reacodec_decode) );    value_cache[profile] = copy_value(val);    return val;    }       //! Returns a @[ProfileEntry] object with the states needed for    //! commiting searches in the database profile @[db_name] with    //! the rules from query profile @[query_name].    ProfileEntry get_profile_entry(string db_name, void|string query_name) {