Doesn't diw when the constructor of the perl filter is failed
[idzebra-moved-to-github.git] / recctrl / perlread.c
index 152beeb..40e2a61 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: perlread.c,v 1.2 2002-11-15 22:01:42 adam Exp $
+/* $Id: perlread.c,v 1.5 2003-02-26 11:40:04 pop Exp $
    Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
    Index Data Aps
 
@@ -21,7 +21,6 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 */
 
 #if HAVE_PERL
-#define PERL_IMPLICIT_CONTEXT     
 #include "perlread.h"
 #include "EXTERN.h"
 #include "perl.h"
@@ -71,7 +70,7 @@ void Filter_create (struct perl_context *context)
   sv_setref_pv(msv, "_p_perl_context", (void*)context);
   XPUSHs(msv) ;
   PUTBACK ;
-  call_method("new", 0);
+  call_method("new", G_EVAL);
 
   SPAGAIN ;
   context->filterRef = POPs;
@@ -170,12 +169,12 @@ void grs_perl_endf(struct perl_context *context, off_t offset) {
 }
 
 /* Get pointers from the context. Easyer to wrap this by SWIG */
-data1_handle grs_perl_get_dh(struct perl_context *context) {
-  return(context->dh);
+data1_handle *grs_perl_get_dh(struct perl_context *context) {
+  return(&context->dh);
 }
 
-NMEM grs_perl_get_mem(struct perl_context *context) {
-  return(context->mem);
+NMEM *grs_perl_get_mem(struct perl_context *context) {
+  return(&context->mem);
 }
 
 /* Set the result in the context */
@@ -276,6 +275,10 @@ static data1_node *grs_read_perl (struct grs_read_info *p)
      the filter object reference may go out of scope... */
   if (!SvOK(context->filterRef)) Filter_create(context);
 
+  if (!SvTRUE(context->filterRef)) {
+    logf (LOG_WARN,"Failed to initialize perl filter %s",context->filterClass);
+    return (0);
+  }
 
   /* call the process method */
   Filter_process(context);