Mail-Box-Parser-C
view release on metacpan or search on metacpan
# push_separator
#
void
MBPC_push_separator(int boxnr, char *line_start)
PREINIT:
Mailbox *box;
Separator *sep;
PPCODE:
box = get_box(boxnr);
if(box==NULL) return;
/*fprintf(stderr, "separator %s\n", line_start);*/
New(0, sep, 1, Separator);
sep->length = strlen(line_start);
/*fprintf(stderr, "separator %ld\n", (long)sep->length+1);*/
New(0, sep->line, sep->length+1, char);
strcpy(sep->line, line_start);
void
MBPC_read_header(int boxnr)
PREINIT:
Mailbox * box;
SV * name;
SV * content;
SV * end;
PPCODE:
box = get_box(boxnr);
if(box==NULL || box->file==NULL) return;
XPUSHs(sv_2mortal(newSViv((IV)file_position(box))));
XPUSHs(end = sv_newmortal());
while(read_header_line(box, &name, &content))
{ AV * field = newAV();
av_push(field, name); /* av_push does not increase refcount */
av_push(field, content);
#
void
MBPC_read_separator(int boxnr)
PREINIT:
Mailbox *box;
Separator *sep;
char *line;
PPCODE:
box = get_box(boxnr);
if(box==NULL)
XSRETURN_EMPTY;
sep = box->separators; /* Never success when there is no sep */
if(sep==NULL)
XSRETURN_EMPTY;
line = get_one_line(box); /* Get first real line. */
while(line!=NULL && line[0]=='\n' && line[1]==EOL)
PREINIT:
Mailbox *box;
SV *result;
char **lines;
int nr_lines = 0;
int nr_chars = 0;
int line_nr;
long begin;
PPCODE:
box = get_box(boxnr);
if(box==NULL)
XSRETURN_EMPTY;
begin = file_position(box);
if(!box->dosmode && !box->strip_gt && expect_chars >=0)
{
long end = begin + expect_chars;
PREINIT:
Mailbox *box;
char **lines;
int nr_lines = 0;
int nr_chars = 0;
int line_nr;
long begin;
AV * results;
PPCODE:
box = get_box(boxnr);
if(box==NULL)
XSRETURN_EMPTY;
begin = file_position(box);
lines = read_stripped_lines(box, expect_chars, expect_lines,
&nr_chars, &nr_lines);
if(lines==NULL) return;
MBPC_body_as_file(int boxnr, FILE *out, int expect_chars, int expect_lines)
PREINIT:
Mailbox *box;
char **lines;
int nr_lines=0;
int nr_chars=0;
int line_nr;
long begin;
PPCODE:
box = get_box(boxnr);
if(box==NULL)
XSRETURN_EMPTY;
begin = file_position(box);
lines = read_stripped_lines(box, expect_chars, expect_lines,
&nr_chars, &nr_lines);
if(lines==NULL)
XSRETURN_EMPTY;
void
MBPC_body_delayed(int boxnr, int expect_chars, int expect_lines)
PREINIT:
Mailbox *box;
int nr_lines = 0;
int nr_chars = 0;
long begin;
PPCODE:
box = get_box(boxnr);
if(box==NULL)
XSRETURN_EMPTY;
begin = file_position(box);
if(expect_chars >=0)
{
long end = begin + expect_chars;
if(is_good_end(box, end))
( run in 0.517 second using v1.01-cache-2.11-cpan-5511b514fd6 )