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.43 2004/08/25 12:05:28 js Exp $ + // $Id: Utils.pmod,v 1.44 2004/09/20 13:40:56 mast Exp $      #if !constant(report_error)   #define report_error werror   #define report_debug werror   #define report_warning werror   #endif      #ifdef SEARCH_DEBUG   # define WERR(X) report_debug("search: "+(X)+"\n");   #else
pike.git/lib/modules/Search.pmod/Utils.pmod:32:         public string normalize(string in)   //! Normalize the input string. Performs unicode NFKD normalization   //! and then lowercases the whole string   {    return Unicode.normalize( lower_case(in), "KD" );   }       - #define THROW(X) throw( ({ (X), backtrace() }) ) -  +    //! A result entry from the @[ProfileCache].   class ProfileEntry {       private int last_stat;       private int database_profile_id;    private int query_profile_id;    private ProfileCache my_cache;       private mapping(string:mixed) database_values;
pike.git/lib/modules/Search.pmod/Utils.pmod:95:    return query_values[index];    }       //! Returns a cached search database for the current database profile.    Search.Database.MySQL get_database() {    if(!db) {   #if constant(DBManager)    db = Search.Database.MySQL( DBManager.db_url( get_database_value("db_name"), 1) );   #endif    if(!db) -  THROW("Could not aquire the database URL to database " + +  error("Could not aquire the database URL to database " +    get_database_value("db_name") + ".\n");    }    return db;    }       //! Returns a cached ranking profile for the current database and    //! query profile.    Search.RankingProfile get_ranking() {    if(!ranking)    ranking = Search.RankingProfile(get_query_value("fi_cut"),
pike.git/lib/modules/Search.pmod/Utils.pmod:147:    map((array)out, sub);    return this_object();    }       mixed cast(string to) {    switch(to) {    case "object": return this_object();    case "array": return indices(vals);    case "multiset": return (multiset)indices(vals);    default: -  THROW("Can not cast ADTSet to "+to+".\n"); +  error("Can not cast ADTSet to "+to+".\n");    }    }    }       //! Returns a cached array of stop words for the current query profile.    array(string) get_stop_words() {    if(!stop_words) {    ADTSet words = ADTSet();    foreach(get_query_value("sw_lists"), string fn) {    string file = Stdio.read_file(fn);
pike.git/lib/modules/Search.pmod/Utils.pmod:190:    private mapping(int:mapping(string:mixed)) value_cache = ([]);    private mapping(string:int) db_profile_names = ([]);    private mapping(string:int) query_profile_names = ([]);    private mapping(int:int) profile_stat = ([]);       private Sql.Sql get_db() {    Sql.Sql db;   #if constant(DBManager)    db = DBManager.cached_get(db_name);   #endif -  if(!db) THROW("Could not connect to database " + db_name + ".\n"); +  if(!db) error("Could not connect to database " + db_name + ".\n");    return db;    }       //! Checks if the profile @[profile_id] has been changed, and clears    //! related caches if so.    //! @returns    //! @int    //! @value -1    //! The profile is deleted.    //! @value 0
pike.git/lib/modules/Search.pmod/Utils.pmod:268:       //! 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 profile WHERE name=%s AND type=2", name);    if(!sizeof(res)) -  THROW("No database profile " + name + " found.\n"); +  error("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 profile WHERE name=%s AND type=1", name);    if(!sizeof(res)) -  THROW("No query profile " + name + " found.\n"); +  error("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() - last_db_prof_stat < 5*60)