1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
|
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#include "strip_html.h"
MODULE = HTML::Strip PACKAGE = HTML::Strip
PROTOTYPES: ENABLE
Stripper *
_create()
PREINIT:
Stripper * stripper;
CODE:
Newx( stripper, 1, Stripper );
_reset( stripper );
RETVAL = stripper;
OUTPUT:
RETVAL
void
_xs_destroy( stripper )
Stripper * stripper
CODE:
Safefree( stripper );
SV *
_strip_html( stripper, text )
Stripper * stripper
SV * text
PREINIT:
char * raw = (char *)SvPV_nolen(text);
char * clean;
int size = strlen(raw)+1;
INIT:
Newx( clean, size+1, char);
CODE:
_strip_html( stripper, raw, clean, SvUTF8(text) );
RETVAL = newSVpv(clean, strlen(clean));
if( SvUTF8(text) )
SvUTF8_on(RETVAL);
OUTPUT:
RETVAL
CLEANUP:
Safefree( clean );
void
_reset( stripper )
Stripper * stripper
void
clear_striptags( stripper )
Stripper * stripper
void
add_striptag( stripper, tag )
Stripper * stripper
char * tag
void
set_emit_spaces( stripper, emit )
Stripper * stripper
int emit
CODE:
stripper->o_emit_spaces = emit;
void
set_emit_newlines( stripper, emit )
Stripper * stripper
int emit
CODE:
stripper->o_emit_newlines = emit;
void
set_decode_entities( stripper, decode )
Stripper * stripper
int decode
CODE:
stripper->o_decode_entities = decode;
int
decode_entities( stripper )
Stripper * stripper
CODE:
RETVAL = stripper->o_decode_entities;
OUTPUT:
RETVAL
void
_set_striptags_ref( stripper, tagref )
Stripper * stripper
SV * tagref
PREINIT:
AV * tags;
I32 numtags = 0;
int n;
if( (SvROK(tagref)) &&
(SvTYPE(SvRV(tagref)) == SVt_PVAV) ) {
tags = (AV *) SvRV(tagref);
} else {
XSRETURN_UNDEF;
}
numtags = av_len(tags);
if( numtags < 0 ) {
XSRETURN_UNDEF;
}
CODE:
clear_striptags( stripper );
for (n = 0; n <= numtags; n++) {
STRLEN l;
char * tag = SvPV(*av_fetch(tags, n, 0), l);
add_striptag( stripper, tag );
}
void
set_auto_reset( stripper, value )
Stripper * stripper
int value
CODE:
stripper->o_auto_reset = value;
int
auto_reset( stripper )
Stripper * stripper
CODE:
RETVAL = stripper->o_auto_reset;
OUTPUT:
RETVAL
void
set_debug( stripper, value )
Stripper * stripper
int value
CODE:
stripper->o_debug = value;
int
debug( stripper )
Stripper * stripper
CODE:
RETVAL = stripper->o_debug;
OUTPUT:
RETVAL
|