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.67 1997/09/05 11:42:54 grubba Exp $"; + constant cvs_version="$Id: graphic_text.pike,v 1.68 1997/09/05 22:33:01 per Exp $";   constant thread_safe=1;      #include <module.h>   inherit "module";   inherit "roxenlib";      #if efun(_static_modules)   # define map_array Array.map   import Image;   # define Image image
Roxen.git/server/modules/graphics/graphic_text.pike:599: Inside #if defined(QUANT_DEBUG)
  #endif   }   #endif      int number=0;      mapping find_cached_args(int num);      constant nbsp = sprintf("%c",160);    - array gif_size(string d) - { -  int x,y; -  d=d[6..12]; -  x = (d[1]<<8) + d[0]; y = (d[3]<<8) + d[2]; -  return ({x,y}); - } -  +    array(int)|string write_text(int _args, string text, int size,    object id)   {    string key = base_key+_args;    array err; -  text = replace(text, ({ "\0","&ss;","&lt;","&gt;","&amp;"}),({"/",nbsp,"<", ">", "&" })); -  -  +     err = catch    {    object img;    mapping args = find_cached_args(_args);    if(!args)    {    args=(["fg":"black","bg":"white"]);    text="Please reload this page";    } -  +     if(!args->verbatim)    { -  +  text = replace(text, nbsp, "&nbsp;"); +  text = replace(text,({ "&nbsp;","&ss;","&lt;","&gt;","&amp;"}), +  ({" ",nbsp,"<", ">", "&" }));    string res="",nspace="",cspace="";    foreach(text/"\n", string line)    {    cspace="";nspace="";    foreach(line/" ", string word)    {    string nonum;    if(strlen(word) &&    (nonum = replace(word,    ({"1","2","3","4","5","6","7","8","9","0","."}),
Roxen.git/server/modules/graphics/graphic_text.pike:771:    };    cache_set(key, text, 0);    throw(err);   }         mapping find_file(string f, object rid)   {    int id;    sscanf(f,"%d/%s", id, f); +  catch(f = Gz.inflate()->inflate(MIME.decode_base64(f)));    return http_string_answer(write_text(id,f,0,rid), "image/gif");   } -  + mapping url_cache = ([]);   string quote(string in)   { -  +  if(url_cache[in]) return url_cache[in]; +  string option=MIME.encode_base64(Gz.deflate()->deflate(in)); +  if((search(in,"/")!=-1) || (search(in,"/.")!=-1)) return url_cache[in]=option;    string res="";    for(int i=0; i<strlen(in); i++)    switch(in[i])    {    case 'a'..'z':    case 'A'..'Z':    case '0'..'9':    case '.': case ',': case '!':    case ':':    res += in[i..i];    break;    default:    res += sprintf("%%%02x", in[i]);    } -  return res; +  if(strlen(res) < strlen(option)) return url_cache[in]=res; +  return url_cache[in]=option;   }      int args_restored = 0;   void restore_cached_args()   {    args_restored = 1;    object o = open(".gtext_args_"+hash(mc->name), "r");    if(o)    {    string data = o->read();