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.164 1999/02/12 00:31:44 grubba Exp $"; + constant cvs_version="$Id: graphic_text.pike,v 1.165 1999/02/15 23:28:34 per 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 */
Roxen.git/server/modules/graphics/graphic_text.pike:209:    img->setcolor(0,0,0);    img = img->autocrop(amnt, 0,0,0,0, 0,0,0);       for(int i=0; i<amnt; i++)    img = img->apply_matrix( ({ ({ 0, 1, 0 }),    ({ 1, 2, 1 }),    ({ 0, 1, 0 }) }) );    return img;   }    - object outline(object on, object with, + object outline(object on, object with,    array (int) color, int radie, int x, int y)   {    int steps=10;    for(int j=0; j<=steps; j++)    on->paste_alpha_color(with, @color,    (int)(0.5+x-(sin((float)j/steps*3.145*2)*radie)),    (int)(0.5+y-(cos((float)j/steps*3.145*2)*radie)));    return on;   }   
Roxen.git/server/modules/graphics/graphic_text.pike:727:   object number_lock = Threads.Mutex();   #define NUMBER_LOCK() do { object __key = number_lock->lock()   #define NUMBER_UNLOCK() if (__key) destruct(__key); } while(0)   #else /* !THREADS */   #define NUMBER_LOCK()   #define NUMBER_UNLOCK()   #endif /* THREADS */      mapping find_cached_args(int num);    -  -  +    constant nbsp = iso88591["&nbsp;"];      constant replace_from = indices( iso88591 )+ ({"&ss;","&lt;","&gt;","&amp",});   constant replace_to = values( iso88591 ) + ({ nbsp, "<", ">", "&", });      #define simplify_text( from ) replace(from,replace_from,replace_to)      #define CACHE_SIZE 2048    - #define FNAME(a,b) (query("cache_dir")+sprintf("%x",hash(reverse(a[6..])))+sprintf("%x",hash(b))+sprintf("%x",hash(reverse(b-" ")))+sprintf("%x",hash(b[12..]))) + string FNAME(string a,string b) + { +  string base=query("cache_dir"); +  base += (cvs_version/" ")[2]-"."; +  base += sprintf("-%x%x-", hash(a),hash(b)); +  base += sprintf("%x%x", hash(b+a),hash(reverse(b)+reverse(a))); +  return base; + }      array get_cache_file(string a, string b)   {    object fd = open(FNAME(a,b), "r");    if(!fd) return 0;    catch {    array r = decode_value(fd->read());    if(r[0]==a && r[1]==b) return r[2];    };   }
Roxen.git/server/modules/graphics/graphic_text.pike:765:    catch { chmod( FNAME(a,b), 0666 ); };   #endif    if(!fd) return;    fd->write(encode_value(({a,b,data})));    destruct(fd);   }         array(int)|string write_text(int _args, string text, int size, object id)   { -  string key = base_key+_args; +  string key = base_key+(cvs_version/" ")[2]+_args;    array err;    string orig_text = text;    mixed data;    mapping args = find_cached_args(_args) || ([]);    -  if(data = cache_lookup(key, text)) +  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];    }
Roxen.git/server/modules/graphics/graphic_text.pike:960:   array find_dir(string f, object rid)   {    if(!strlen(f))    {    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)    object g;   #endif       if((rid->method != "GET")    || (sscanf(f,"%d/%s", id, f) != 2))    return 0;
Roxen.git/server/modules/graphics/graphic_text.pike:1019:    case '.': case ',': case '!':    res += in[i..i];    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) + #define ARGHASH query("cache_dir")+hash((cvs_version/" ")[2])+"ARGS_"+hash(mc->name)      int last_argstat;      void restore_cached_args()   {    args_restored = 1;    array a = file_stat(ARGHASH);    if(a && (a[ST_MTIME] > last_argstat))    {    last_argstat = a[ST_MTIME];
Roxen.git/server/modules/graphics/graphic_text.pike:1083:      mapping find_cached_args(int num)   {    if(!args_restored) restore_cached_args();    if(cached_args[num]) return cached_args[num];    restore_cached_args(); /* Not slow anymore, checks with stat... */    if(cached_args[num]) return cached_args[num];    return 0;   }    -  -  +    int find_or_insert(mapping find)   {    mapping f2 = copy_value(find);    int res;    string q;       foreach(glob("magic_*", indices(f2)), q)    m_delete(f2,q);       if(!args_restored)    restore_cached_args( );       array a=indices(f2),b=values(f2);    sort(a,b); -  q = a*""+Array.map(b, lambda(mixed x) { return (string)x; })*""; +  q = a*""+((array(string))b)*"";       if(res = cached_args[ q ])    return res;       restore_cached_args(); /* Not slow now, checks with stat.. */       if(res = cached_args[ q ])    return res;       NUMBER_LOCK();
Roxen.git/server/modules/graphics/graphic_text.pike:1331:    break;    }       // Support for <gh1> like things.    if(sscanf(t, "%s%d", t, i)==2)    if(i > 1) arg->scale = 1.0 / ((float)i*0.6);       string na = arg->name, al=arg->align;    m_delete(arg, "name"); m_delete(arg, "align");    -  // Now the 'args' mapping is modified enough.. +  // Now the 'arg' mapping is modified enough..    int num = find_or_insert( arg );       gt=contents;    rest="";       switch(t)    {    case "gh1": case "gh2": case "gh3": case "gh4":    case "gh5": case "gh6": case "gh7":    case "gh": pre="<p>"; post="<br>"; defalign="top"; break;