Branch: Tag:

2000-06-29

2000-06-29 22:00:16 by Martin Stjernholm <mast@lysator.liu.se>

Implemented the general tag argument "help", module level security and
tracing for newstyle tags.

Rev: server/etc/modules/RXML.pmod/module.pmod:1.92

2:   //!   //! Created 1999-07-30 by Martin Stjernholm.   //! - //! $Id: module.pmod,v 1.91 2000/06/23 16:50:13 mast Exp $ + //! $Id: module.pmod,v 1.92 2000/06/29 22:00:16 mast Exp $      //! Kludge: Must use "RXML.refs" somewhere for the whole module to be   //! loaded correctly.
19:   //#pragma strict_types // Disabled for now since it doesn't work well enough.      #include <config.h> + #include <request_trace.h>      #ifdef RXML_OBJ_DEBUG   # define MARK_OBJECT \
1003:    if (id && id->conf)    while (evaluator) {    if (evaluator->report_error && evaluator->type->free_text) { -  string msg = (err->type == "run" ? +  string msg = err->type == "help" ? err->msg : +  (err->type == "run" ?    ([function(Backtrace,Type:string)]    ([object] id->conf)->handle_run_error) :    ([function(Backtrace,Type:string)]
1774:    {    Frame this = this_object();    Context ctx = parser->context; +  RequestID id = ctx->id;       // Unwind state data:    //raw_content
1849:   #undef PRE_INIT_ERROR    ctx->frame = this;    +  do { // Target for breaks (goto wouldn't be all bad, really). +  if (tag) { +  if ((raw_args || args)->help) { +  TRACE_ENTER ("tag &lt;" + tag->name + " help&gt;", tag); +  string help = id->conf->find_tag_doc (tag->name, id); +  TRACE_LEAVE (""); +  ctx->handle_exception ( // Will throw if necessary. +  Backtrace ("help", help, ctx), parser); +  break; +  } +  +  TRACE_ENTER("tag &lt;" + tag->name + "&gt;", tag); +  + #ifdef MODULE_LEVEL_SECURITY +  if (id->conf->check_security (tag, id, id->misc->seclevel)) { +  TRACE_LEAVE("access denied"); +  break; +  } + #endif +  } +     if (raw_args) {    if (sizeof (raw_args)) {    // Note: Code duplication in Tag.eval_args().
1934:    mixed err = catch {    switch (eval_state) {    case EVSTAT_BEGIN: -  if (array|function(RequestID,void|mixed:array) do_enter = -  [array|function(RequestID,void|mixed:array)] this->do_enter) { +  if (array|function(RequestID:array) do_enter = +  [array|function(RequestID:array)] this->do_enter) {    if (!exec) { -  exec = do_enter (ctx->id); // Might unwind. +  exec = arrayp (do_enter) ? [array] do_enter : +  ([function(RequestID:array)] do_enter) ( +  id); // Might unwind.    if (ctx->new_runtime_tags)    _handle_runtime_tags (ctx, parser);    }
1950: Inside #if defined(DEBUG)
   fatal_error ("Internal error: Clobbering unwind_state "    "to do streaming.\n");    if (piece != Void) -  fatal_error ("Internal error: Thanks, we think about how nice it must " -  "be to play the harmonica...\n"); +  fatal_error ("Internal error: Thanks, we think about how nice " +  "it must be to play the harmonica...\n");   #endif    if (result_type->quoting_scheme != parser->type->quoting_scheme)    res = parser->type->quote (res);
1976:    }    else {    iter = (/*[function(RequestID:int)]HMM*/ do_iterate) ( -  ctx->id); // Might unwind. +  id); // Might unwind.    if (ctx->new_runtime_tags)    _handle_runtime_tags (ctx, parser);    if (!iter) eval_state = EVSTAT_LAST_ITER;
2013:    this->do_process) &&    !arrayp (do_process)) {    if (!exec) { -  exec = do_process (ctx->id, piece); // Might unwind. +  exec = do_process (id, piece); // Might unwind.    if (ctx->new_runtime_tags)    _handle_runtime_tags (ctx, parser);    }
2067:    if (!exec) {    exec = arrayp (do_process) ? [array] do_process :    ([function(RequestID,void|mixed:array)] do_process) ( -  ctx->id); // Might unwind. +  id); // Might unwind.    if (ctx->new_runtime_tags)    _handle_runtime_tags (ctx, parser);    }
2103:    eval_state = EVSTAT_ITER_DONE; // Only need to record this state here.    if (!exec) {    exec = arrayp (do_return) ? [array] do_return : -  ([function(RequestID:array)] do_return) (ctx->id); // Might unwind. +  ([function(RequestID:array)] do_return) (id); // Might unwind.    if (ctx->new_runtime_tags)    _handle_runtime_tags (ctx, parser);    }
2177:       ustate[this] = ({err, eval_state, iter, raw_content, subparser, piece,    exec, orig_tag_set, ctx->new_runtime_tags}); +  if (id->misc->trace_leave && tag) +  TRACE_LEAVE (action);    }    else { -  +  if (id->misc->trace_leave && tag) +  TRACE_LEAVE ("exception");    ctx->handle_exception (err, parser); // Will rethrow unknown errors.    action = "return";    }
2199:    fatal_error ("Internal error: Don't you come here and %O on me!\n", action);    }    } +  else +  if (id->misc->trace_leave && tag) +  TRACE_LEAVE (""); +  } while (0); // Breaks go here.       if (orig_tag_set) ctx->tag_set = orig_tag_set;    ctx->frame = up;