Roxen.git / server / modules / graphics / graphic_text.pike

version» Context lines:

Roxen.git/server/modules/graphics/graphic_text.pike:1: - constant cvs_version="$Id: graphic_text.pike,v 1.141 1998/08/10 06:26:00 js Exp $"; + constant cvs_version="$Id: graphic_text.pike,v 1.142 1998/08/14 12:20:02 neotron Exp $";   constant thread_safe=1;      #include <module.h>   #include <stat.h>   inherit "module";   inherit "roxenlib";      #ifndef VAR_MORE   #define VAR_MORE 0   #endif /* VAR_MORE */      static private int loaded; -  + int args_restored = 0;      static private string doc()   {    return !loaded?"":replace(Stdio.read_bytes("modules/tags/doc/graphic_text")    ||"", ({ "{", "}" }), ({ "&lt;", "&gt;" }));   }      array register_module()   {    return ({ MODULE_LOCATION | MODULE_PARSER,
Roxen.git/server/modules/graphics/graphic_text.pike:777:    string key = base_key+_args;    array err;    string orig_text = text;    mixed data;    mapping args = find_cached_args(_args);       if(!args)    {    throw( ({ "Internal error in gtext: Got request for non-existant gtext class", backtrace() }) );    } -  +     if(data = cache_lookup(key, text))    {    if(args->nocache) // Remove from cache. Very useful for access counters    cache_remove(key, text);    if(size) return data[1];    return data[0];    } else if(data = get_cache_file( key, text )) {    cache_set(key, text, data);    if(size) return data[1];    return data[0];    } -  +  //werror("Not cached: %O -> %O\n", key, text); +  //werror("In cache: %O\n", sort(indices(cache->cache)));    -  +     // So. We have to actually draw the thing...       err = catch    {    object img;    if(!args)    {    args=(["fg":"black","bg":"white","notrans":"1"]);    text="Please reload this page";    }
Roxen.git/server/modules/graphics/graphic_text.pike:955:    @parse_color(args->bg))->gif_add(0,0,delay);    }    res += img->gif_end();    data = ({ res, ({ len, img->ysize() }) });    }      // place in caches, as a gif image.    if(!args->nocache)    store_cache_file( key, orig_text, data );    cache_set(key, orig_text, data); +  // werror("Cache set: %O -> %O\n", key, orig_text);    if(size) return data[1];    return data[0];    };   // werror("Got error < "+_args+" <"+text+">\n");    cache_set(key, text, 0);    throw(err);   }      mapping find_file(string f, object rid); // Pike 0.5...   void restore_cached_args(); // Pike 0.5...
Roxen.git/server/modules/graphics/graphic_text.pike:980:    if(sizeof(f/"/")==1) return ({ 509,-3,time(),time(),time(),0,0 });    int len=4711;    catch(len= strlen(find_file(f,rid)->data));    return ({ 33204,len,time(),time(),time(),0,0 });   }      array find_dir(string f, object rid)   {    if(!strlen(f))    { -  restore_cached_args(); +  if(!args_restored) restore_cached_args();    return Array.map(indices(cached_args), lambda(mixed m){return (string)m;});    }    return ({"Example"});   }         mapping find_file(string f, object rid)   {    int id;   #if constant(Gz)
Roxen.git/server/modules/graphics/graphic_text.pike:1047:    break;    default:    res += sprintf("%%%02x", in[i]);    }    if(strlen(res) < strlen(option)) return url_cache[in]=res;    return url_cache[in]=option;   }      #define ARGHASH query("cache_dir")+"ARGS_"+hash(mc->name)    - int args_restored = 0; +    void restore_cached_args()   {    args_restored = 1;    object o = open(ARGHASH, "r");    if(o)    {    string data = o->read();    catch {    object q;    if(sizeof(indices(q=Gz)))
Roxen.git/server/modules/graphics/graphic_text.pike:1076:    } else {    cached_args = ([]);    number = 0;    }   }      void save_cached_args()   {    int on;    on = number; -  restore_cached_args(); +  if(!args_restored) restore_cached_args();    if(on > number) number=on;    object o = open(ARGHASH, "wct");   #ifndef __NT__   #if efun(chmod)    // FIXME: Should this error be propagated?    catch { chmod( ARGHASH, 0666 ); };   #endif   #endif    string data=encode_value(cached_args);    catch {
Roxen.git/server/modules/graphics/graphic_text.pike:1113:         int find_or_insert(mapping find)   {    mapping f2 = copy_value(find);    foreach(glob("magic_*", indices(f2)), string q) m_delete(f2,q);    if(!args_restored) restore_cached_args();    array a = indices(cached_args);    array b = values(cached_args);    int i; -  -  for(i=0; i<sizeof(a); i++) if(equal(f2, b[i])) return a[i]; +  for(i=0; i<sizeof(a); i++) if(equal(f2, b[i])) return a[i];    restore_cached_args();    for(i=0; i<sizeof(a); i++) if(equal(f2, b[i])) return a[i]; -  cached_args[number]=find; +  cached_args[number]=f2; // Save the same that you try to restore, please.    remove_call_out(save_cached_args);    call_out(save_cached_args, 10);    return number++;   }         string magic_javascript_header(object id)   {    if(!id->supports->netscape_javascript || !id->supports->images) return "";    return