#include "apache_request.h" #include "apache_cookie.h" #include "mod_perl.h" typedef ApacheCookie * Apache__Cookie; static SV *cookie_bless(ApacheCookie *c) { SV *sv = newSV(0); sv_setref_pv(sv, "Apache::Cookie", (void*)c); return sv; } static ApacheCookie *sv_2cookie(SV *sv) { if (SvROK(sv) && sv_derived_from(sv, "Apache::Cookie")) { return (ApacheCookie *)SvIV((SV*)SvRV(sv)); } else { return ApacheCookie_new(perl_request_rec(NULL), NULL); } } #define cookie_push(c) \ XPUSHs(sv_2mortal(newSVpv(c->name,0))); \ XPUSHs(sv_2mortal(cookie_bless(c))) #define ApacheCookie_name(c, val) \ ApacheCookie_attr(c, "name", val) #define ApacheCookie_domain(c, val) \ ApacheCookie_attr(c, "domain", val) #define ApacheCookie_path(c, val) \ ApacheCookie_attr(c, "path", val) #define ApacheCookie_secure(c, val) \ ApacheCookie_attr(c, "secure", val) MODULE = Apache::Cookie PACKAGE = Apache::Cookie PREFIX = ApacheCookie_ PROTOTYPES: DISABLE Apache::Cookie ApacheCookie_new(class, r, ...) SV *class Apache r PREINIT: I32 i; CODE: class = class; /* -Wall */ RETVAL = ApacheCookie_new(r, NULL); for (i=2; ir, string); if (!ApacheCookieJarItems(cookies)) { XSRETURN_UNDEF; } if (GIMME == G_SCALAR) { HV *hv = newHV(); SV *sv; for (i=0; iname) { hv_store(hv, c->name, strlen(c->name), cookie_bless(c), FALSE); } } sv = newRV_noinc((SV*)hv); XPUSHs(sv_2mortal(sv)); } else { for (i=0; inelts; i++) { cookie_push(ApacheCookieJarFetch(cookies, i)); } } void ApacheCookie_value(c, val=Nullsv) Apache::Cookie c SV *val PREINIT: int i; I32 gimmes = (GIMME == G_SCALAR); PPCODE: for (i = 0; i