I am trying to do an interpreter between perl and C (win32). The proplem is that none of the examples found at the www, perldoc and etc do not show
how to pass a typedef structures from C to perl, manipulate the data, and then return the data back to the C.
For example If defined structure in C is
typedef struct {
int Msg;
short uid;
short LineType;
char *Line; // pointer to text
char Sound; // 0 for no sound, otherwise sound #
char *Cmd; // String of command including !
char OpOnly; // Is the command for ops only?
char *HelpFile; // Help Filename for this command
int CmdID; // CmdID - The bot core doesn't care about this
+,
} BOTMSG;
I would love to see this stucture in perl like a HASH or OO.
For example
sub set_struct {
xxxxx = @_; # <-- ???
$BOTMSG{Msg} = "1";
$BOTMSG{uid} = "1024";
$BOTMSG{LineType} = "100";
$BOTMSG{Line} = "Hello World\n";
$BOTMSG{Cmd} = "/!say";
$BOTMSG{OpOnly} = "yes";
$BOTMSG{HelpFile} = "C\tmp\help\help1.txt";
$BOTMSG{CmdID} = "1234567890";
return %BOTMSG;
};
The given examples in Perlembed documentation only show how to pass a single pointer, an integer, or an string value but it do not say anything about
passing complex structures and how to manipulate those in perl.
I appreciate all help you can give me,
-jari-
jari@subspace.nu
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.