On 07/07/2003 16:09:21 perl-win32-users-admin wrote:

[snip]
>
>I am really hoping for the "fastest" solution and not necessarily the
>easiest.
>I'm wondering if I can do something like:
>
>eval_pv(use Mail::SpamAssassin);
>eval_pv(my $spamobj = Mail::SpamAssassin->new());
>eval_pv(my $status = $spamobj->check_message_text($input));
>eval_pv(my $output = sprintf ...... );
>
>within C and then pass the "output" string back from Perl like you
suggest?

I think that (lots of individual eval_pv) won't work because e.g. $spamobj
will not survive the end of second eval_pv. However, one big eval_pv
might work :

/* begin C code */
eval_pv("use Mail::SpamAssassin;"
        "my $spamobj = Mail::SpamAssassin->new();"
        "my $status = $spamobj->check_message_text($input);"
        "my $output = sprintf( ... );"
       );
/* end C code */

(This is really one line as far as Perl is concerned).

Fetching the return value from the eval_pv above is well described
in perlembed. I can't see how you can pass data to a chunk of code like
that.

>
>I'm hoping to avoid calling an external *.pl file from C,  for speed

Try defining a subroutine with eval_pv, then calling it with call_pv:

/* begin C code */
eval_pv("use Mail::SpamAssassin;"
        "sub check_for_spam{
        "my $spamobj = Mail::SpamAssassin->new();"
        "my $status = $spamobj->check_message_text($input);"
        "my $output = sprintf( ... );"
        "}"
       );

// lots of code here from perlembed to manipulate the stack
call_pv("check_for_spam", G_SCALAR)
// lots of code here from perlembed to manipulate the stack
/* end C code */


--
Csaba Ráduly, Software Engineer, Sophos Anti-Virus
Email: [EMAIL PROTECTED], Tel: 01235 559933, Web: www.sophos.com
Add live virus info to your website: http://www.sophos.com/link/vfeed



_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to