mikfire has asked for the wisdom of the Perl Monks concerning the following question:
I have been playing with Inline::C, trying to wrap an API so I could access it via perl. I have read the docs for Inline::C and explored the cookbook enough to figure out what I needed to do. I have been also able to get the examples contained within the cookbook working.
I wrote my code and, after getting rid of several stupid typos ( I am still trying to convince my fingers to stop adding a "$" in front of variable names :), the code compiled but returned an error. I worked at it for a little while and then decided to extract the C code, write a simple main() and see what happened.
It compiled, ran and returned without the error.
I am now very confused. I am dead certain I have missed something very silly - this is the first time I have tried to use Inline and my three previous attempts at using XS all failed
This is the code:
And this is the main() I wrote to test the C code directly:#!/usr/local/bin/perl -w use strict; use Inline C => Config => LIBS => "-lpdadminapi", PREFIX => 'my_', INC => "-I/usr/include/PolicyDirector"; use Inline C => << 'END_C'; #include <ivadminapi.h> /* So named in case there is some conflict of which I am unaware */ int my_create_context( char* user, char* passwd ) { ivadmin_context ctx; ivadmin_response rsp; unsigned long status; int i; printf("Establising context as %s (%s)\n", user, passwd ); /* This is the call that is failing */ status = ivadmin_context_createdefault(user,passwd,&ctx,&rsp); if ( ivadmin_response_getok(rsp) ) { printf("ivadmin_context_createdefault succeeded\n" ); } else { for(i=0; i<ivadmin_response_getcount(rsp);i++) { printf( "ivadmin_context_createdefault : (%d) %s\n", ivadmin_response_getcode( rsp, i ), ivadmin_response_getmessage( rsp, i ) ); } } ivadmin_free( rsp ); return status; } END_C my ( $foo, $user, $passwd ); $user = 'xxxxxxxx'; $passwd = 'xxxxxxxx'; $foo = create_context( $user, $passwd ); print "status = $foo\n";
If anybody could give me a pointer, I would appreciate it to no end. Again, I am quite certain this is my mistake but I really have no idea how to approach it.int main() { int stat; stat = create_context("xxxxxxxx", "xxxxxxxx" ); printf( "Stat = %d\n", stat ); return 0; }
Thanks,
mikfire
|
---|
Replies are listed 'Best First'. | |
---|---|
(Ovid) Re: Inline::C code doesn't work, but the C code does
by Ovid (Cardinal) on Dec 28, 2001 at 23:39 UTC | |
by mikfire (Deacon) on Dec 29, 2001 at 00:35 UTC |