[Date Prev][Date Next][Thread Prev][Thread Next]
- From: Alexey Mikhailov <karma@...>
- Date: Fri, 25 Dec 2009 15:20:11 +0300
Hello, LUA fondlers!
I'm working on some application, and I want to embed LUA for flexible
data processing. Let me describe my application briefly.
There is some binary information passed through network. My application
receives it and stores in archive in binary form and in segment of
shared memory. So basically, there are two posibilities for processing
information: off-line (through filesystem archive, for custom time
slice), on-line (real-time with shared memory segment). I have few
static C libraries: two libraries for accessing information: binary
infomation in archive and binary information in shared memory segment,
and another one parses binary information.
So basically, it can work like this:
archive_query (time_t time1, time_t time2, void (*cb) (u_int8_t *buf, size_t siz);
online_process (void (*cb) (u_int8_t 8buf, size_t siz);
Then for each given slice of information callback `cb' function is
called. Then this function can use parse binary information and process
And now I want to embed LUA here. Basically, there are two operations
I want to perform on data 'filter' (to get only needed bits of information)
and 'map' (perform some lua actions on each portion of data).
So basically I want to call something like this in LUA. (code in
foreach packet that (satisfies)CONDITION in [time1, time2]
summary_param += packet.size
(receive query in LUA -> call C function to query -> C callback will
be called and information will be parsed -> call LUA code to process
Hopefully, I described my problem clear enough, but feel free to ask
So, my questions are: is it hard to implement this scheme? are there
some examples using similiar approach? any general advices?