Plugin architecture in C using libdl
Posted
by LukeN
on Stack Overflow
See other posts from Stack Overflow
or by LukeN
Published on 2010-05-21T14:09:29Z
Indexed on
2010/05/21
14:10 UTC
Read the original article
Hit count: 171
I've been toying around, writing a small IRC framework in C that I'm now going to expand with some core functionality - but beyond that, I'd like it to be extensible with plugins!
Up until now, whenever I wrote something IRC related (and I wrote a lot, in about 6 different languages now... I'm on fire!) and actually went ahead to implement a plugin architecture, it was inside an interpreted language that had facilities for doing (read: abusing) so, like jamming a whole script file trough eval
in Ruby (bad!).
Now I want to abuse something in C!
Basically there's three things I could do
- define a simple script language inside of my program
- use an existing one, embedding an interpreter
- use libdl to load *.so modules on runtime
I'm fond of the third one and raather avoid the other two options if possible. Maybe I'm a masochist of some sort, but I think it could be both fun and useful for learning purposes.
Logically thinking, the obvious "pain-chain" would be (lowest to highest) 2 -> 1 -> 3, for the simple reason that libdl is dealing with raw code that can (and will) explode in my face more often than not.
So this question goes out to you, fellow users of stackoverflow, do you think libdl is up to this task, or even a realistic thought?
© Stack Overflow or respective owner