View | Details | Raw Unified | Return to bug 57501
Collapse All | Expand All

(-)src/apache-2/mod_rivet.c (-34 / +43 lines)
Lines 328-343 Link Here
328
static int
328
static int
329
Rivet_ExecuteAndCheck(Tcl_Interp *interp, Tcl_Obj *tcl_script_obj, request_rec *req)
329
Rivet_ExecuteAndCheck(Tcl_Interp *interp, Tcl_Obj *tcl_script_obj, request_rec *req)
330
{
330
{
331
    rivet_server_conf *conf = Rivet_GetConf(req);
331
    int                     result;
332
    rivet_interp_globals *globals = Tcl_GetAssocData(interp, "rivet", NULL);
332
    rivet_server_conf*      conf = Rivet_GetConf(req);
333
    rivet_interp_globals*   globals = Tcl_GetAssocData(interp, "rivet", NULL);
333
334
334
    Tcl_Preserve (interp);
335
    Tcl_Preserve (interp);
335
    if ( Tcl_EvalObjEx(interp, tcl_script_obj, 0) == TCL_ERROR ) {
336
    result = Tcl_EvalObjEx(interp, tcl_script_obj, 0);
336
        Tcl_Obj *errscript;
337
        Tcl_Obj *errorCodeListObj;
338
        Tcl_Obj *errorCodeElementObj;
339
        char *errorCodeSubString;
340
337
338
    if (result == TCL_ERROR) {
339
340
        Tcl_Obj*    errscript;
341
        Tcl_Obj*    errorCodeListObj;
342
        Tcl_Obj*    errorCodeElementObj;
343
        char*       errorCodeSubString;
344
341
        /* There was an error, see if it's from Rivet and it was caused
345
        /* There was an error, see if it's from Rivet and it was caused
342
         * by abort_page.
346
         * by abort_page.
343
         */
347
         */
Lines 376-382 Link Here
376
                    {
380
                    {
377
                        CONST84 char *errorinfo = Tcl_GetVar( interp, "errorInfo", 0 );
381
                        CONST84 char *errorinfo = Tcl_GetVar( interp, "errorInfo", 0 );
378
                        TclWeb_PrintError("<b>Rivet AbortScript failed!</b>",1,globals->req);
382
                        TclWeb_PrintError("<b>Rivet AbortScript failed!</b>",1,globals->req);
379
                        TclWeb_PrintError( errorinfo, 0, globals->req );
383
                        TclWeb_PrintError(errorinfo,0,globals->req);
380
                    }
384
                    }
381
                }
385
                }
382
                goto good;
386
                goto good;
Lines 386-392 Link Here
386
        Tcl_SetVar( interp, "errorOutbuf",Tcl_GetStringFromObj( tcl_script_obj, NULL ),TCL_GLOBAL_ONLY );
390
        Tcl_SetVar( interp, "errorOutbuf",Tcl_GetStringFromObj( tcl_script_obj, NULL ),TCL_GLOBAL_ONLY );
387
391
388
        /* If we don't have an error script, use the default error handler. */
392
        /* If we don't have an error script, use the default error handler. */
389
        if (conf->rivet_error_script ) {
393
        if (conf->rivet_error_script) {
390
            errscript = conf->rivet_error_script;
394
            errscript = conf->rivet_error_script;
391
        } else {
395
        } else {
392
            errscript = conf->rivet_default_error_script;
396
            errscript = conf->rivet_default_error_script;
Lines 404-430 Link Here
404
        Tcl_DecrRefCount(errscript);
408
        Tcl_DecrRefCount(errscript);
405
    }
409
    }
406
410
407
    /* Make sure to flush the output if buffer_add was the only output */
408
good:
411
good:
409
    
412
    
410
    if (conf->after_every_script) {
411
        if (Tcl_EvalObjEx(interp,conf->after_every_script,0) == TCL_ERROR)
412
        {
413
            CONST84 char *errorinfo = Tcl_GetVar( interp, "errorInfo", 0 );
414
            TclWeb_PrintError("<b>Rivet AfterEveryScript failed!</b>",1,globals->req);
415
            TclWeb_PrintError( errorinfo, 0, globals->req );
416
        }
417
    }
418
419
    if (!globals->req->headers_set && (globals->req->charset != NULL)) {
420
        TclWeb_SetHeaderType (apr_pstrcat(globals->req->req->pool,"text/html;",globals->req->charset,NULL),globals->req);
421
    }
422
423
    /* Tcl_Flush moved to the end of Rivet_SendContent */
413
    /* Tcl_Flush moved to the end of Rivet_SendContent */
424
414
425
    Tcl_Release(interp);
415
    Tcl_Release(interp);
426
416
427
    return TCL_OK;
417
    return result;
428
}
418
}
429
419
430
/*
420
/*
Lines 605-616 Link Here
605
    }
595
    }
606
596
607
    rsc->user_scripts_updated = 0;
597
    rsc->user_scripts_updated = 0;
608
    {
598
    result = Rivet_ExecuteAndCheck(interp, outbuf, req->req);
609
        int res = 0;
599
    Tcl_DecrRefCount(outbuf);
610
        res = Rivet_ExecuteAndCheck(interp, outbuf, req->req);
600
611
        Tcl_DecrRefCount(outbuf);
601
    return result;
612
        return res;
613
    }
614
}
602
}
615
603
616
/*
604
/*
Lines 629-635 Link Here
629
int
617
int
630
Rivet_ParseExecString (TclWebRequest* req, Tcl_Obj* inbuf)
618
Rivet_ParseExecString (TclWebRequest* req, Tcl_Obj* inbuf)
631
{
619
{
632
    int res = 0;
620
    int result;
633
    Tcl_Obj* outbuf = Tcl_NewObj();
621
    Tcl_Obj* outbuf = Tcl_NewObj();
634
    Tcl_Interp *interp = req->interp;
622
    Tcl_Interp *interp = req->interp;
635
623
Lines 644-653 Link Here
644
632
645
    Tcl_AppendToObj(outbuf, "\n", -1);
633
    Tcl_AppendToObj(outbuf, "\n", -1);
646
634
647
    res = Rivet_ExecuteAndCheck(interp, outbuf, req->req);
635
    result = Rivet_ExecuteAndCheck(interp, outbuf, req->req);
648
    Tcl_DecrRefCount(outbuf);
636
    Tcl_DecrRefCount(outbuf);
649
637
650
    return res;
638
    return result;
651
}
639
}
652
640
653
static void
641
static void
Lines 1494-1499 Link Here
1494
                     Tcl_GetVar(interp, "errorInfo", 0));
1482
                     Tcl_GetVar(interp, "errorInfo", 0));
1495
    }
1483
    }
1496
1484
1485
    /* We execute also the AfterEveryScript if one was set */
1486
1487
1488
    if (rsc->after_every_script) {
1489
        if (Rivet_ExecuteAndCheck(interp, rsc->after_every_script,r) == TCL_ERROR)
1490
        {
1491
            CONST84 char *errorinfo = Tcl_GetVar( interp, "errorInfo", 0 );
1492
            TclWeb_PrintError("<b>Rivet AfterEveryScript failed!</b>",1,globals->req);
1493
            TclWeb_PrintError( errorinfo, 0, globals->req );
1494
        }
1495
    }
1496
1497
    if (request_cleanup == NULL) {
1497
    if (request_cleanup == NULL) {
1498
        request_cleanup = Tcl_NewStringObj("::Rivet::cleanup_request\n", -1);
1498
        request_cleanup = Tcl_NewStringObj("::Rivet::cleanup_request\n", -1);
1499
        Tcl_IncrRefCount(request_cleanup);
1499
        Tcl_IncrRefCount(request_cleanup);
Lines 1506-1516 Link Here
1506
    }
1506
    }
1507
1507
1508
    /* Reset globals */
1508
    /* Reset globals */
1509
    Rivet_CleanupRequest( r );
1509
    Rivet_CleanupRequest(r);
1510
1510
1511
    retval = OK;
1511
    retval = OK;
1512
sendcleanup:
1512
sendcleanup:
1513
1513
1514
    /* Let's set the charset in the headers if one was set in the configuration  */
1515
1516
    if (!globals->req->headers_set && (globals->req->charset != NULL)) {
1517
        TclWeb_SetHeaderType (apr_pstrcat(globals->req->req->pool,"text/html;",
1518
                              globals->req->charset,NULL),
1519
                              globals->req);
1520
    }
1521
1522
1514
    /* Everything is done and we flush the rivet channel before resetting the status */
1523
    /* Everything is done and we flush the rivet channel before resetting the status */
1515
1524
1516
    TclWeb_PrintHeaders(globals->req);
1525
    TclWeb_PrintHeaders(globals->req);
(-)src/rivetcmds/rivetCore.c (-5 / +1 lines)
Lines 241-251 Link Here
241
        return TCL_ERROR;
241
        return TCL_ERROR;
242
    }
242
    }
243
243
244
    if (Rivet_ParseExecFile(globals->req, filename, 0) == TCL_OK) {
244
    return Rivet_ParseExecFile(globals->req, filename, 0); 
245
        return TCL_OK;
246
    } else {
247
        return TCL_ERROR;
248
    }
249
}
245
}
250
246
251
/*
247
/*

Return to bug 57501