PApp

 view release on metacpan or  search on metacpan

Storable/Storable.xs  view on Meta::CPAN

          {
            path = ntohl (path);
            PUSHs (sv_2mortal (newSViv (path)));
          }
        
        READ_I32(h); READ_I32(l);
        gid =
          (((unsigned long long)(U32)ntohl (h)) << 32) |
            (unsigned long long)(U32)ntohl (l);
        PUSHs (sv_2mortal (newSVpvn (c, sprintf (c, "%llu", gid))));

        PUTBACK;
        count = call_pv ("Agni::storable_path_obj_by_gid", G_SCALAR | G_EVAL);
        SPAGAIN;

        if (SvTRUE (ERRSV))
          croak (NULL);

        if (count != 1)
          croak ("PApp::Storable: Agni::path_obj_by_gid did not return a single value");

        sv = SvREFCNT_inc (POPs);

        if (!SvOK (sv))
          fprintf (stderr, "WARNING: PApp::Storable: Agni::path_obj_by_gid (%d/%lld) did not return an object, probably harmless\n", path, gid);

        PUTBACK;

        SEEN(sv, cname, 0);

        return sv;
}

/* !PApp */
/***
 *** Glue with perl.
 ***/

/*
 * The Perl IO GV object distinguishes between input and output for sockets
 * but not for plain files. To allow Storable to transparently work on
 * plain files and sockets transparently, we have to ask xsubpp to fetch the
 * right object for us. Hence the OutputStream and InputStream declarations.
 *
 * Before perl 5.004_05, those entries in the standard typemap are not
 * defined in perl include files, so we do that here.
 */

#ifndef OutputStream
#define OutputStream	PerlIO *
#define InputStream		PerlIO *
#endif	/* !OutputStream */

MODULE = PApp::Storable	PACKAGE = PApp::Storable::Cxt

void
DESTROY(self)
    SV *self
PREINIT:
	stcxt_t *cxt = (stcxt_t *)SvPVX(SvRV(self));
PPCODE:
	if (kbuf)
		Safefree(kbuf);
	if (!cxt->membuf_ro && mbase)
		Safefree(mbase);
	if (cxt->membuf_ro && (cxt->msaved).arena)
		Safefree((cxt->msaved).arena);


MODULE = PApp::Storable	PACKAGE = PApp::Storable

PROTOTYPES: ENABLE

BOOT:
{
    HV *stash = gv_stashpvn("PApp::Storable", 8, GV_ADD);
    newCONSTSUB(stash, "BIN_MAJOR", newSViv(STORABLE_BIN_MAJOR));
    newCONSTSUB(stash, "BIN_MINOR", newSViv(STORABLE_BIN_MINOR));
    newCONSTSUB(stash, "BIN_WRITE_MINOR", newSViv(STORABLE_BIN_WRITE_MINOR));

    init_perinterp(aTHX);
    gv_fetchpv("PApp::Storable::drop_utf8",   GV_ADDMULTI, SVt_PV);
#ifdef DEBUGME
    /* Only disable the used only once warning if we are in debugging mode.  */
    gv_fetchpv("PApp::Storable::DEBUGME",   GV_ADDMULTI, SVt_PV);
#endif
#ifdef USE_56_INTERWORK_KLUDGE
    gv_fetchpv("PApp::Storable::interwork_56_64bit",   GV_ADDMULTI, SVt_PV);
#endif

    gv_force_path = gv_fetchpv ("PApp::Storable::force_path", GV_ADDMULTI, SVt_PV);
}

void
init_perinterp()
 CODE:
  init_perinterp(aTHX);

int
pstore(f,obj)
OutputStream	f
SV *	obj
 CODE:
  RETVAL = pstore(aTHX_ f, obj);
 OUTPUT:
  RETVAL

int
net_pstore(f,obj)
OutputStream	f
SV *	obj
 CODE:
  RETVAL = net_pstore(aTHX_ f, obj);
 OUTPUT:
  RETVAL

SV *
mstore(obj)
SV *	obj
 CODE:
  RETVAL = mstore(aTHX_ obj);



( run in 0.506 second using v1.01-cache-2.11-cpan-5511b514fd6 )