Branch: Tag:

2004-03-03

2004-03-03 16:26:15 by Henrik Grubbström (Grubba) <grubba@grubba.org>

The recur_func can now terminate the loop early.

Rev: server/modules/misc/webdav.pike:1.6

1:   // Protocol support for RFC 2518   // - // $Id: webdav.pike,v 1.5 2004/03/01 19:38:15 grubba Exp $ + // $Id: webdav.pike,v 1.6 2004/03/03 16:26:15 grubba Exp $   //   // 2003-09-17 Henrik Grubbström   
9:   #include <module.h>   #include <request_trace.h>    - constant cvs_version = "$Id: webdav.pike,v 1.5 2004/03/01 19:38:15 grubba Exp $"; + constant cvs_version = "$Id: webdav.pike,v 1.6 2004/03/03 16:26:15 grubba Exp $";   constant thread_safe = 1;   constant module_name = "DAV: Protocol support";   constant module_type = MODULE_FIRST;
132:    // RoxenModule module    // RequestID id    // mixed ... extras -  function(string,string,int,RoxenModule,MultiStatus,RequestID,mixed ...:void) -  recur_func; +  function(string,string,int,RoxenModule,MultiStatus,RequestID, +  mixed ...:mapping(string:mixed)) recur_func;    array(mixed) extras = ({});       switch(id->method) {
216:    recur_func = lambda(string path, string dest, int d, RoxenModule module,    MultiStatus stat, RequestID id,    mapping(string:int(-1..1))|void behavior) { -  module->recurse_copy_files(path, d, 0, "", +  return module->recurse_copy_files(path, d, 0, "",    behavior||([]),    stat, id);    };
243:    recur_func = lambda(string path, string ignored, int d,    RoxenModule module,    MultiStatus stat, RequestID id) { -  module->recurse_find_properties(path, "DAV:propname", d, -  stat, id); +  module->recurse_find_properties(path, +  "DAV:propname", +  d, stat, id); +  return 0;    };    break;    case "DAV:allprop":
254:    RoxenModule module,    MultiStatus stat, RequestID id,    multiset(string)|void filt) { -  module->recurse_find_properties(path, "DAV:allprop", d, -  stat, id, filt); +  module->recurse_find_properties(path, +  "DAV:allprop", +  d, stat, id, +  filt); +  return 0;    };    break;    case "DAV:prop":
265:    RoxenModule module,    MultiStatus stat, RequestID id,    multiset(string) filt) { -  module->recurse_find_properties(path, "DAV:prop", d, -  stat, id, filt); +  module->recurse_find_properties(path, +  "DAV:prop", +  d, stat, id, +  filt); +  return 0;    };    // FALL_THROUGH    case "http://sapportals.com/xmlns/cm/webdavinclude":
295:    recur_func = lambda(string path, string ignored, int d,    RoxenModule module,    MultiStatus stat, RequestID id) { -  module->recurse_find_properties(path, "DAV:allprop", d, -  stat, id); +  module->recurse_find_properties(path, +  "DAV:allprop", +  d, stat, id); +  return 0;    };    }    break;
348:    array(PatchPropertyCommand) instructions) {    // NOTE: RFC 2518 does not support depth header    // with PROPPATCH, thus no recursion wrapper. -  module->patch_properties(path, instructions, stat, id); +  return module->patch_properties(path, instructions, +  stat, id);    };    extras = ({ instructions });    break;
411:   #endif    RoxenModule c = function_object(fun);    TRACE_ENTER("Performing the work...", c); +  mapping(string:mixed) ret =    recur_func(path, dest, d, c,    id->method=="COPY"?result->prefix(dest):result->prefix(loc),    id, @extras); -  +  if (ret) { +  TRACE_LEAVE("Short circuit return.");    TRACE_LEAVE("Done."); -  +  TRACE_LEAVE("DAV request done."); +  return ret; +  }    TRACE_LEAVE("Done."); -  +  TRACE_LEAVE("Done.");    }    TRACE_LEAVE("DAV request done.");    return result->http_answer();   }