Hi, I would try to write an adapter for G-WAN server, which can run c-scripts. This is a G-WAN handler:
#include "gwan.h" // G-WAN exported functions #include <string.h> // memcmp() int main(int argc, char *argv[]) { char *query = get_env(argv, QUERY_STRING, 0); // query: "start=200000" if(!query || memcmp(query, "start=", sizeof("start=") - 1)) // FLV query? return 200; // HTTP status (200:'OK') http_t *head = get_env(argv, HTTP_HEADERS, 0); // set HTTP bytes range head->h_range_from = atol(query + sizeof("start=") - 1); // checked by G-WAN #define FLV_HEAD "FLV\x1\x1\0\0\0\x9\0\0\0\x9" // insert the FLV Header http_header(HEAD_ADD | HEAD_AFTER, FLV_HEAD, sizeof(FLV_HEAD) - 1, argv); return 206; // HTTP status (206:'Partial Content') }
I could exchange data with Rack from a module like that. I do not how to write a Rack adapter, is there any tutorial. Should I call Ruby code from C, so should I write an wrapper to Rack methods?