If your C code can be compiled to a library, then you can specify that lib to be linked in the use Inline portion of your code, as per Inline::C.
Depending upon the complexity of your c code, and the kind of perl interface you want, you might want to build an XS module for your project.
As for adding a VC++ workspace, I'm not sure about that.
Hope this helped, -v.
"Perl. There is no substitute."
| [reply] [d/l] |
My probelm is that in C MD5 there is a main program and which use diffrent header file
That shouldn't be a problem. If the C program contains:
#include <some_header.h>
then you just need to start the Inline::C section of your script with:
use Inline C => <<'EOC';
#include <some_header.h>
.
.
or perhaps:
use Inline C => <<'EOC';
#include "full/path/to/some_header.h"
.
.
Other than that, you just need to rewrite your main() program as a C function that returns the string you're after.
Cheers, Rob | [reply] [d/l] [select] |
I agree with your point and already worked on that .But the MD5 is a written in C and it has a workspace which i want to add in to my perl program.so that i just pass the argument like pszAlg, pszUser, pszRealm, pszPass, pszNonce,pszCNonce, HA1 from my perl program and obtain the value return from the C MD5.
| [reply] |
I agree with your point and already worked on that .But the MD5 is a written in C and it has a workspace which i want to add in to my perl program.
I apologize since I've not touched C in quite a lot of years, but sincerely I can't remember "workspaces" in C. So, what is a workspace? What is the corresponding Perl structure/concept/whatever it should be translated into?
so that i just pass the argument like pszAlg, pszUser, pszRealm, pszPass, pszNonce,pszCNonce, HA1 from my perl program and obtain the value return from the C MD5.
I'm not really sure if I understand what you mean:
pszAlg, pszUser, pszRealm, pszPass, pszNonce,pszCNonce, HA1
these are not valid Perl identifiers or values, unless you mean them to be subs, so I don't see how you can pass them "from your perl program", and if they are subs, then what's the problem with
my $md5=MD5_XS_sub(pszAlg, pszUser, pszRealm, pszPass, pszNonce,pszCNo
+nce, HA1); # ?!?
| [reply] [d/l] [select] |
A VC++ workspace contains projects, which contain configurations. Workspaces (now called 'Solutions' in VC .Net) are specific to that IDE, and I can't see how you (could)/(would want to) add it to Inline.c. You might be better creating an XS DLL workspace/project with your C MD5 program as part of it (assuming there is no 'main'). | [reply] |
you might want to build an XS module for your project
I've often wondered whether there is something that can be handled by XS and that cannot be handled by Inline::C. When I look at the XS file that Inline::C generates, I find that it invariably contains "PROTOTYPES: DISABLE" - which leads me to believe that there may well be instances where Inline::C fails but XS succeeds (eg those instances where one needs to specify "PROTOTYPES: ENABLE" ... if such instances exist). Does anyone have a simple example of something that can be done using XS, but cannot be done using Inline::C ?
Sorry, Velaki, this question is not addressed specifically to you. It should probably be raised as a separate thread ... which is something I may yet do.
Cheers, Rob
| [reply] |
I don't think you'll find such an example. XS compiles down to C code just like Inline::C does, so anything you can do in XS you can probably do in Inline::C too, if only by copying the generated XS C code! The critical difference is which one will be easier - XS makes some things easy (mapping complex C types into Perl and back) and Inline::C makes other things easy (writing new code in C).
-sam
| [reply] |