I am hesitant to say that perl currently "calls back" to C. This is the process, which I think you have right:
- -server calls perl function
-perl function (ie: EVENT_SAY) adds functions/variables to cmd_queue
-perl function ends
-server runs through cmd_queue, processing each function
So, there are two big reasons for callbacks: First, to call C functions and get data back immediately; second, to get rid of a lot of overhead.
I actually just submitted a patch that deals with the command queue here:
http://www.eqemulator.net/forums/viewtopic.php?t=13906. It effectively makes SendCommands() a re-enterable function.
As far as perl calling C code, I have done this. It's been a little bit since I have looked at it, so I am a bit fuzzy, but involves XS to make the glue between perl and C. I have been able to incorporate just about all of this into the server code itself, so no external library is needed.
However, one of the things I have done is inject the "require MODULE.pm;" statement into a C perl-eval (needed so perl knows how to use package). This in turn tries to load MODULE.pm from disk. I have not been able to find a way to completely hide this in the server code. As things are now, it is all in the server code, except for that external file.
I am again looking through the different perl man pages. I think the answer may be in perlcall, which I may have overlooked before. It seems there is another way to do this. By all means investigate and try things. I am still not comfortable with all this Perl/C/XS stuff. I have only been trying to figure it out because I think it would be a huge boon to perl quests, and nobody is really doing anything with it..
In case you have not seen these, I offer some references that I have used:
I have tried to keep the posts central, but I have done a poor job of it. :cry: I am usually on the eqemu irc server in #ProjectEQ and #npcmovdb lately, nickname bleh if you are interested in that.