Branch: Tag:

1999-06-25

1999-06-25 17:57:52 by Per Hedbor <ph@opera.com>

Added support for multiple arguments in the image cache. store() with an array as the first argument, the draw callback will be called like callback( @your_array, id )

Rev: server/base_server/roxen.pike:1.300

1:   /* -  * $Id: roxen.pike,v 1.299 1999/06/21 19:30:52 mast Exp $ +  * $Id: roxen.pike,v 1.300 1999/06/25 17:57:52 per Exp $    *    * The Roxen Challenger main program.    *
7:    */      // ABS and suicide systems contributed freely by Francesco Chemolli - constant cvs_version="$Id: roxen.pike,v 1.299 1999/06/21 19:30:52 mast Exp $"; + constant cvs_version="$Id: roxen.pike,v 1.300 1999/06/25 17:57:52 per Exp $";      object backend_thread;   object argcache;
1679:    object conf;    array (object) new_confs = ({});    mapping config_cache = ([]); -  // werror(sprintf("%O\n", config_stat_cache)); +     int modified;       report_notice(LOCALE->reloading_config_interface());
1888:    return data_cache[i] = what;    }    +  static mixed frommapp( mapping what ) +  { +  if( what[""] ) return what[""]; +  return what; +  }       static void draw( string name, RequestID id )    { -  mapping args = argcache->lookup( name ); -  mixed reply = draw_function( copy_value(args), id ); +  mixed args; +  args = Array.map( Array.map( name/"¤", argcache->lookup ), frommapp);    -  +  mixed reply = draw_function( @copy_value(args), id ); +  +  if( arrayp( args ) ) +  args = args[0]; +     mapping meta;    string data;   
1904:    string dither = args->dither;    Image.Colortable ct;    object alpha; +  int true_alpha;       if( args->fs || dither == "fs" )    dither = "floyd_steinberg";
1923:    if( args->gamma )    reply = reply->gamma( (float)args->gamma );    +  if( args["true-alpha"] ) +  true_alpha = 1; +     if( args["opaque-value"] )    { -  +  true_alpha = 1;    int ov = (int)(((float)args["opaque-value"])*2.55);    if( ov < 0 )    ov = 0;
2005:    switch(format)    {    case "gif": -  if( alpha ) +  if( alpha && true_alpha )    { -  object ct = Image.Colortable( ({ ({ 0,0,0 }), ({ 255,255,255 }) }) ); +  object ct=Image.Colortable( ({ ({ 0,0,0 }), ({ 255,255,255 }) }) );    ct->floyd_steinberg();    alpha = ct->map( alpha );    }
2126:    return res->data;    }    -  mapping http_file_answer( string|mapping data, RequestID id, int|void nodraw ) +  mapping http_file_answer( string|mapping data, +  RequestID id, +  int|void nodraw )    {    string na = store( data,id );    mixed res; -  +     if(!( res = restore( na )) )    {    if(nodraw)
2154:    return restore_meta( na );    }    -  string store( string|mapping data, RequestID id ) +  mapping tomapp( mixed what )    { -  +  if( mappingp( what )) +  return what; +  return ([ "":what ]); +  } +  +  string store( array|string|mapping data, RequestID id ) +  {    string ci;    if( mappingp( data ) )    ci = argcache->store( data ); -  +  else if( arrayp( data ) ) +  ci = Array.map( Array.map( data, tomapp ), argcache->store )*"¤";    else    ci = data;    return ci;
2316:    if( cache[ data ] )    return cache[ data ][ CACHE_SKEY ];    - // werror(" store -> "); +     string id = create_key( data ); - // werror(id+"\n"); +     cache[ data ] = ({ 0, 0 });    cache[ data ][ CACHE_VALUE ] = copy_value( args );    cache[ data ][ CACHE_SKEY ] = id;
2336:    mapping lookup( string id )    {    LOCK(); - // werror(" lookup -> "+id+"\n"); +     if(cache[id])    return cache[cache[id]][CACHE_VALUE];   
2410: Inside #if constant(Image.JPEG) && constant(Image.JPEG.decode)
   i = Image.JPEG.decode( data );    format = "JPEG";    }; -  +    #endif      #if constant(Image.XCF) && constant(Image.XCF._decode)    if(!i) catch    { -  mixed q = Image.XCF._decode( data, ([ -  "background":tocolor, -  ])); +  mixed q = Image.XCF._decode( data,(["background":tocolor,]) );    tocolor=0;    format = "XCF Gimp file";    i = q->image;
3156:    calculations will also halt the server. In multi-threaded mode bugs such as    eternal loops will not cause the server to reboot, since only one thread is    blocked. In general there is no harm in having this option enabled. "); +     deflocaledoc("svenska", "abs_engage",    "AntiBlockSystem: Slå på AntiBlockSystemet",   #"Ska antilåssystemet vara igång? Om det är det så kommer roxen automatiskt
3293:   // Somewhat misnamed, since there can be more then one   // configuration-interface port nowdays. But, anyway, this function   // opens and listens to all configuration interface ports. -  +    void initiate_configuration_port( int|void first )   {    object o;
3834:    SET_LOCALE(default_locale);    if(root)    { - // destruct(root); + // destruct(root);   // configuration_interface()->root = configuration_interface()->Node();    configuration_interface()->    build_root(configuration_interface()->root);