Hello,

In my XSub first I check something
e.g:

CODE:
{
        if(!foo(b))
        {
        sprintf(tmp1,"Wrong parameter!",);
        sv_setpvn(perror, tmp1, strlen(tmp1));
        XPUSHs(sv_2mortal(newSViv(-1)));
        RETVAL = -1;
        } else
        {

        }
        RETVAL=1;
}

So if I want to avoid these if - else statements can I do the following?
(not working source code)

int foo(int b)
{
   if(b != 1) return 0;
   return 1;
}

int
_baar(IN x, OUT y, perror)
int x;
SV* y;
SV* perror;
PREINIT:
char tmp1[256];
CODE:
{
if(!foo(x))
{
sprintf(tmp1,"Wrong parameter!",);
sv_setpvn(perror, tmp1, strlen(tmp1));
XPUSHs(sv_2mortal(newSViv(-1)));
XSRETURN_IV(-1);
}


        // some code to fill SV* y
        
        RETVAL = 1;
}
OUTPUT:
y
perror
RETVAL

What I want to have is that if an error ocure that the perror variable will be 
filled with an error message and the XSub returns with -1


mit freundlichen Grüßen, with my best regards, Reinhard

--



Reply via email to