nostromo has asked for the wisdom of the Perl Monks concerning the following question:
and here is a little test-script using P5NCI::Library to interact with my test-library:#include <stdio.h> #include <string.h> char *hello(void) { static char result[]={"hello world"}; return result; } char *bye(char *str) { static char prefix[]={"good bye"}; static char result[32]; strcpy(result,prefix); strcat(result,str); return result; } char *return_char(int chr) { static char result[1]; sprintf(result, "%c", chr); return result; } int square(int x) { x = (x * x); return x; } int do_nothing(void) { return 1; }
#!/usr/bin/perl use P5NCI::Library; my $lib = P5NCI::Library->new( library => 'hello_world', package => 'T +EST' ); my $test = $lib->install_function( 'hello', 'tv' ); my $hello = TEST::hello(); print "for hello() i got: $hello\n"; undef $test; my $test = $lib->install_function( 'return_char', 'ti' ); my $return_char = TEST::return_char( 65 ); print "for return_char(65) i got: $return_char\n"; undef $test; my $test = $lib->install_function( 'square', 'ii' ); my $square = TEST::square( 3 ); print "for square(3) i got: $square\n"; undef $test; my $test = $lib->install_function( 'bye', 'tt' ); my $bye = TEST::bye( "thanks for all the passwords" ); print "for bye(test) i got: $bye\n"; undef $test; my $test = $lib->install_function( 'do_nothing', 'vi' ); my $do_nothing = TEST::do_nothing(); print "for do_nothing() i got: $do_nothing\n"; undef $test;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: P5NCI + void load_function-signature
by chromatic (Archbishop) on Jun 22, 2006 at 18:55 UTC | |
by nostromo (Sexton) on Jun 22, 2006 at 19:20 UTC | |
by chromatic (Archbishop) on Jun 22, 2006 at 19:53 UTC | |
by diotalevi (Canon) on Jun 22, 2006 at 20:21 UTC | |
by chromatic (Archbishop) on Jun 22, 2006 at 21:55 UTC | |
by nostromo (Sexton) on Jun 22, 2006 at 20:19 UTC | |
by samtregar (Abbot) on Jun 23, 2006 at 03:25 UTC | |
by chromatic (Archbishop) on Jun 23, 2006 at 06:44 UTC | |
| |
|
Re: P5NCI + void load_function-signature
by samtregar (Abbot) on Jun 22, 2006 at 15:35 UTC | |
by nostromo (Sexton) on Jun 22, 2006 at 15:45 UTC | |
by samtregar (Abbot) on Jun 22, 2006 at 15:47 UTC | |
by nostromo (Sexton) on Jun 22, 2006 at 16:10 UTC | |
| A reply falls below the community's threshold of quality. You may see it by logging in. |