Compress-Bzip2

 view release on metacpan or  search on metacpan

Bzip2.xs  view on Meta::CPAN


  PROTOTYPE: @

  INIT:
    bzFile* obj;
    SV *perlobj;
    char *class, *param;
    STRLEN lnclass, lnparam;
    int setting;

  PPCODE:
  {
    int i;

    perlobj = NULL;
    obj = NULL;
    if ( items == 0 ) {
      class = "Compress::Bzip2";
    }
    else if ( SvPOK( ST(0) ) ) {
      /* this is the name of a class */

Bzip2.xs  view on Meta::CPAN

  PROTOTYPE: $$;$

  INIT:
    PerlIO *io;
    char *filename, *mode, *class;
    STRLEN ln, lnfilename, lnclass;

    bzFile* obj;
    SV *perlobj;

  PPCODE:
  {
    int i;

    perlobj=NULL;
    obj=NULL;
    if ( items == 2 ) {
      class = "Compress::Bzip2";
    }
    else if ( SvPOK( ST(0) ) ) {
      /* this is the name of a class */

Bzip2.xs  view on Meta::CPAN

    PUSHs(perlobj);
  }

void
MY_bzclose(obj, abandon=0)
  Compress::Bzip2 obj
  int abandon

  PROTOTYPE: $;$

  PPCODE:
  {
    int i, ret, amt_collected;
    char *inp;
    int error_flag = 0;

    if ( obj->open_status != OPEN_STATUS_READSTREAM && obj->open_status != OPEN_STATUS_WRITESTREAM ) {
      ret = bzfile_close( obj, abandon );
      XPUSHs(sv_2mortal(newSViv(ret)));
    }
    else {

Bzip2.xs  view on Meta::CPAN

    }
  }

void
MY_bzflush(obj, flag=0)
  Compress::Bzip2 obj
  int flag

  PROTOTYPE: $;$

  PPCODE:
  {
    int i, ret, amt_collected;
    char *inp;

    if ( obj->open_status != OPEN_STATUS_READSTREAM && obj->open_status != OPEN_STATUS_WRITESTREAM ) {
      ret = !flag || flag!=BZ_FINISH ? bzfile_flush( obj ) : bzfile_close( obj, 0 );
      XPUSHs(sv_2mortal(newSViv(ret)));
    }
    else {
      char *firstp, *outp;

Bzip2.xs  view on Meta::CPAN

  ALIAS:
    compress_init = 1

  INIT:
    bzFile* obj = NULL;
    SV *perlobj = NULL;
    char *param;
    STRLEN lnparam;
    int setting;

  PPCODE:
  {
    int i;

    if (items % 2) croak("Compress::Bzip2::%s has odd parameter count", ix==0 ? "bzdeflateInit" : "compress_init");

    obj = bzfile_new( 0, 0, 1, 0 );
    bzfile_openstream( "w", obj );

    perlobj = newSV(0);
    sv_setref_iv( perlobj, "Compress::Bzip2", PTR2IV(obj) );

Bzip2.xs  view on Meta::CPAN

    }
  }

void
MY_bzdeflate(obj, buffer)
  Compress::Bzip2 obj
  SV *buffer

  PROTOTYPE: $$

  PPCODE:
  {
    char *firstp, *outp;
    SV *outbuf = NULL;
    STRLEN outbufl = 0;

    char *bufp, *inp;
    STRLEN bufl;

    STRLEN bytes_to_go;

Bzip2.xs  view on Meta::CPAN

  ALIAS:
    decompress_init = 1

  INIT:
    bzFile* obj = NULL;
    SV *perlobj = NULL;
    char *param;
    STRLEN lnparam;
    int setting;

  PPCODE:
  {
    int i;

    if (items % 2)
      croak("Compress::Bzip2::%s has odd parameter count", ix==0 ? "bzinflateInit" : "decompress_init");

    obj = bzfile_new( 0, 0, 1, 0 );
    bzfile_openstream( "r", obj );
    if ( obj == NULL ) {
      XPUSHs(sv_newmortal());

Bzip2.xs  view on Meta::CPAN

      XPUSHs(sv_2mortal(newSViv(global_bzip_errno)));
  }

void
MY_bzinflate(obj, buffer)
  Compress::Bzip2 obj
  SV *buffer

  PROTOTYPE: $$

  PPCODE:
  {
    char *firstp, *outp;
    SV *outbuf = NULL;
    STRLEN outbufl = 0;

    STRLEN bufl;
    char collect_buffer[1000];
    int i, amt_collected;
    char *bufp, *inp;
    int error_flag = 0;

fallback/const-xs.inc  view on Meta::CPAN

	dTARGET;
#endif
	STRLEN		len;
        int		type;
	IV		iv;
	/* NV		nv;	Uncomment this if you need to return NVs */
	/* const char	*pv;	Uncomment this if you need to return PVs */
    INPUT:
	SV *		sv;
        const char *	s = SvPV(sv, len);
    PPCODE:
        /* Change this to constant(aTHX_ s, len, &iv, &nv);
           if you need to return both NVs and IVs */
	type = constant(aTHX_ s, len, &iv);
      /* Return 1 or 2 items. First is error message, or undef if no error.
           Second, if present, is found value */
        switch (type) {
        case PERL_constant_NOTFOUND:
          sv = sv_2mortal(newSVpvf("%s is not a valid Compress::Bzip2 macro", s));
          PUSHs(sv);
          break;



( run in 1.468 second using v1.01-cache-2.11-cpan-71847e10f99 )