cvs commit: modperl-2.0/xs/maps apache_functions.map modperl_functions.map
dougm 01/05/02 23:21:00 Modified:xs/maps apache_functions.map modperl_functions.map Added: t/response/TestAPI aplog.pm xs/Apache/Log Apache__Log.h Log: add Apache::Log api and tests Revision ChangesPath 1.1 modperl-2.0/t/response/TestAPI/aplog.pm Index: aplog.pm === package TestAPI::aplog; use strict; use warnings FATAL => 'all'; use Apache::Log (); use Apache::Test; my @LogLevels = qw(emerg alert crit error warn notice info debug); my $package = __PACKAGE__; sub handler { my $r = shift; plan $r, tests => (@LogLevels * 2) + 3; my $rlog = $r->log; ok $rlog->isa('Apache::Log::Request'); my $slog = $r->server->log; ok $slog->isa('Apache::Log::Server'); $rlog->info($package, " test in progress"); for my $method (@LogLevels) { #wrap in sub {}, else Test.pm tries to run the return value of ->can ok sub { $rlog->can($method) }; ok sub { $slog->can($method) }; } $slog->info(sub { ok 1; "$package test done" }); Apache::OK; } 1; 1.1 modperl-2.0/xs/Apache/Log/Apache__Log.h Index: Apache__Log.h === static void mpxs_Apache__Log_BOOT(pTHXo) { av_push(get_av("Apache::Log::Request::ISA",TRUE), newSVpv("Apache::Log",11)); av_push(get_av("Apache::Log::Server::ISA",TRUE), newSVpv("Apache::Log",11)); } #define croak_inval_obj() \ Perl_croak(aTHX_ "Argument is not an Apache::RequestRec " \ "or Apache::Server object") static void mpxs_ap_log_error(pTHX_ int level, SV *sv, SV *msg) { char *file = NULL; int line = 0; char *str; SV *svstr = Nullsv; STRLEN n_a; int lmask = level & APLOG_LEVELMASK; server_rec *s; request_rec *r = NULL; if (SvROK(sv) && sv_isa(sv, "Apache::Log::Request")) { r = (request_rec *)SvObjIV(sv); s = r->server; } else if (SvROK(sv) && sv_isa(sv, "Apache::Log::Server")) { s = (server_rec *)SvObjIV(sv); } else { croak_inval_obj(); } if ((lmask == APLOG_DEBUG) && (s->loglevel >= APLOG_DEBUG)) { COP *cop = cxstack[1].blk_oldcop; file = CopFILE(cop); /* (caller)[1] */ line = CopLINE(cop); /* (caller)[2] */ } if ((s->loglevel >= lmask) && SvROK(msg) && (SvTYPE(SvRV(msg)) == SVt_PVCV)) { dSP; ENTER;SAVETMPS; PUSHMARK(sp); (void)call_sv(msg, G_SCALAR); SPAGAIN; svstr = POPs; (void)SvREFCNT_inc(svstr); PUTBACK; FREETMPS;LEAVE; str = SvPV(svstr,n_a); } else { str = SvPV(msg,n_a); } if (r) { ap_log_rerror(file, line, APLOG_NOERRNO|level, 0, r, "%s", str); } else { ap_log_error(file, line, APLOG_NOERRNO|level, 0, s, "%s", str); } if (svstr) { SvREFCNT_dec(svstr); } } #define MP_LOG_REQUEST 1 #define MP_LOG_SERVER 2 static SV *mpxs_Apache__Log_log(pTHX_ SV *sv, int logtype) { SV *svretval; void *retval; char *pclass; if (!SvROK(sv)) { Perl_croak(aTHX_ "Argument is not a reference"); } switch (logtype) { case MP_LOG_REQUEST: pclass = "Apache::Log::Request"; retval = (void *)modperl_sv2request_rec(aTHX_ sv); break; case MP_LOG_SERVER: pclass = "Apache::Log::Server"; retval = (void *)SvObjIV(sv); break; default: croak_inval_obj(); }; svretval = newSV(0); sv_setref_pv(svretval, pclass, (void*)retval); return svretval; } #define mpxs_Apache__RequestRec_log(sv) \ mpxs_Apache__Log_log(aTHX_ sv, MP_LOG_REQUEST) #define mpxs_Apache__Server_log(sv) \ mpxs_Apache__Log_log(aTHX_ sv, MP_LOG_SERVER) static XS(MPXS_Apache__Log_dispatch) { dXSARGS; SV *msgsv; int level; char *name = GvNAME(CvGV(cv)); if (items < 2) { Perl_croak(aTHX_ "usage: %s::%s(obj, ...)", mpxs_cv_name()); } if (items > 2) { msgsv = newSV(0); do_join(msgsv, &PL_sv_no, MARK+1, SP); } else { msgsv = ST(1); (void)SvREFCNT_inc(msgsv); } switch (*name) { case 'e': if (*(name + 1) == 'r') { level = APLOG_ERR; break; } level = APLOG_EMERG; break; case 'w': level = APLOG_WARNING; break; case 'n': level = APLOG_NOTICE; break; case 'i': level = APLOG_INFO;
cvs commit: modperl-2.0/xs/maps apache_functions.map modperl_functions.map
dougm 01/11/06 10:41:46 Modified:todo api.txt xs/Apache/RequestIO Apache__RequestIO.h xs/maps apache_functions.map modperl_functions.map Log: add Apache::RequestIO::{printf,PRINTF} methods Revision ChangesPath 1.13 +1 -1 modperl-2.0/todo/api.txt Index: api.txt === RCS file: /home/cvs/modperl-2.0/todo/api.txt,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- api.txt 2001/10/29 01:19:16 1.12 +++ api.txt 2001/11/06 18:41:46 1.13 @@ -3,7 +3,7 @@ -- tied filehandle interface: - -CLOSE, GETC, PRINTF, READLINE + -CLOSE, GETC, READLINE $r->finfo: need apr_finfo_t <-> struct stat conversion (might already be there, 1.18 +30 -1 modperl-2.0/xs/Apache/RequestIO/Apache__RequestIO.h Index: Apache__RequestIO.h === RCS file: /home/cvs/modperl-2.0/xs/Apache/RequestIO/Apache__RequestIO.h,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- Apache__RequestIO.h 2001/11/06 17:50:56 1.17 +++ Apache__RequestIO.h 2001/11/06 18:41:46 1.18 @@ -1,7 +1,8 @@ #define mpxs_Apache__RequestRec_TIEHANDLE(stashsv, sv) \ modperl_newSVsv_obj(aTHX_ stashsv, sv) -#define mpxs_Apache__RequestRec_PRINT mpxs_Apache__RequestRec_print +#define mpxs_Apache__RequestRec_PRINT mpxs_Apache__RequestRec_print +#define mpxs_Apache__RequestRec_PRINTF mpxs_ap_rprintf #define mpxs_output_flush(r, rcfg) \ /* if ($|) */ \ @@ -55,6 +56,34 @@ mpxs_output_flush(r, rcfg); +return bytes; +} + +static MP_INLINE +apr_size_t mpxs_ap_rprintf(pTHX_ I32 items, SV **MARK, SV **SP) +{ +modperl_config_req_t *rcfg; +request_rec *r; +apr_size_t bytes = 0; +SV *sv; + +mpxs_usage_va(2, r, "$r->printf($fmt, ...)"); + +rcfg = modperl_config_req_get(r); + +/* XXX: we could have an rcfg->sprintf_buffer to reuse this SV + * across requests + */ +sv = newSV(0); +modperl_perl_do_sprintf(aTHX_ sv, items, MARK); +bytes = SvCUR(sv); + +modperl_wbucket_write(&rcfg->wbucket, SvPVX(sv), &bytes); + +mpxs_output_flush(r, rcfg); + +SvREFCNT_dec(sv); + return bytes; } 1.35 +1 -1 modperl-2.0/xs/maps/apache_functions.map Index: apache_functions.map === RCS file: /home/cvs/modperl-2.0/xs/maps/apache_functions.map,v retrieving revision 1.34 retrieving revision 1.35 diff -u -r1.34 -r1.35 --- apache_functions.map 2001/10/22 02:46:55 1.34 +++ apache_functions.map 2001/11/06 18:41:46 1.35 @@ -92,7 +92,7 @@ ap_rflush PREFIX=ap_r ~ap_rwrite -~ap_rprintf + ap_rprintf | mpxs_ | ... !ap_rputc ~ap_rputs ap_rvputs | mpxs_ | ... | puts 1.26 +3 -2 modperl-2.0/xs/maps/modperl_functions.map Index: modperl_functions.map === RCS file: /home/cvs/modperl-2.0/xs/maps/modperl_functions.map,v retrieving revision 1.25 retrieving revision 1.26 diff -u -r1.25 -r1.26 --- modperl_functions.map 2001/10/29 01:19:16 1.25 +++ modperl_functions.map 2001/11/06 18:41:46 1.26 @@ -25,8 +25,9 @@ mpxs_Apache_request | | classname, svr=Nullsv MODULE=Apache::RequestIO PACKAGE=Apache::RequestRec - SV *:DEFINE_TIEHANDLE | | SV *:stashsv, SV *:sv=Nullsv - apr_size_t:DEFINE_PRINT | | ... + SV *:DEFINE_TIEHANDLE| | SV *:stashsv, SV *:sv=Nullsv + apr_size_t:DEFINE_PRINT | | ... + apr_size_t:DEFINE_PRINTF | | ... mpxs_Apache__RequestRec_sendfile | | r, filename=r->filename, offset=0, len=0 mpxs_Apache__RequestRec_read | | r, buffer, bufsiz, offset=0 long:DEFINE_READ | | request_rec *:r, SV *:buffer, int:bufsiz, int:offset=0
cvs commit: modperl-2.0/xs/maps apache_functions.map modperl_functions.map
stas02/01/21 00:27:30 Modified:xs/Apache/Response Apache__Response.h xs/maps apache_functions.map modperl_functions.map Log: - write a wrapper for $r->set_last_modified() to be the same as in 1.x - specify default values for $r->set_content_length and $r->update_mtime as in 1.x Revision ChangesPath 1.6 +9 -0 modperl-2.0/xs/Apache/Response/Apache__Response.h Index: Apache__Response.h === RCS file: /home/cvs/modperl-2.0/xs/Apache/Response/Apache__Response.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- Apache__Response.h6 Jan 2002 22:23:24 - 1.5 +++ Apache__Response.h21 Jan 2002 08:27:30 - 1.6 @@ -25,3 +25,12 @@ rcfg->wbucket->header_parse = 0; /* turn off PerlOptions +ParseHeaders */ } + +static MP_INLINE void +mpxs_Apache__RequestRec_set_last_modified(request_rec *r, apr_time_t mtime) +{ +if (mtime) { +ap_update_mtime(r, mtime); +} +ap_set_last_modified(r); +} 1.42 +3 -3 modperl-2.0/xs/maps/apache_functions.map Index: apache_functions.map === RCS file: /home/cvs/modperl-2.0/xs/maps/apache_functions.map,v retrieving revision 1.41 retrieving revision 1.42 diff -u -r1.41 -r1.42 --- apache_functions.map 20 Jan 2002 18:37:05 - 1.41 +++ apache_functions.map 21 Jan 2002 08:27:30 - 1.42 @@ -100,16 +100,16 @@ MODULE=Apache::Response PACKAGE=guess ap_make_etag | | r, force_weak=0 - ap_set_content_length + ap_set_content_length | | r, length=r->finfo.csize ap_set_etag ap_meets_conditions ap_rationalize_mtime - ap_update_mtime + ap_update_mtime | | r, dependency_mtime=0 ap_send_error_response ~ap_send_fd ap_send_mmap | | r, mm, offset, length ap_set_keepalive - ap_set_last_modified +-ap_set_last_modified ap_custom_response MODULE=Apache::Access PACKAGE=Apache::RequestRec 1.33 +2 -0 modperl-2.0/xs/maps/modperl_functions.map Index: modperl_functions.map === RCS file: /home/cvs/modperl-2.0/xs/maps/modperl_functions.map,v retrieving revision 1.32 retrieving revision 1.33 diff -u -r1.32 -r1.33 --- modperl_functions.map 8 Jan 2002 22:48:38 - 1.32 +++ modperl_functions.map 21 Jan 2002 08:27:30 - 1.33 @@ -43,6 +43,8 @@ MODULE=Apache::Response PACKAGE=Apache::RequestRec DEFINE_send_cgi_header | | request_rec *:r, SV *:buffer mpxs_Apache__RequestRec_send_http_header | | r, type=NULL + mpxs_Apache__RequestRec_set_last_modified | | r, mtime=0 + MODULE=Apache::ServerUtil PACKAGE=guess mpxs_Apache__Server_push_handlers