[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Mldonkey-users] Contributions in C to mldonkey
From: |
MLdonkey |
Subject: |
[Mldonkey-users] Contributions in C to mldonkey |
Date: |
Fri, 31 Jan 2003 12:47:41 +0100 |
mldonkey really suffers from its lack of developers. Since the main
problem is that a lot of people don't know ocaml, I think there is
still a way for them to contribute to mldonkey development: simply by
writting C code to perform the actions they want. The only problem
will be that:
- the C code has no access to mldonkey internals
- the C code cannot communicate (open sockets, read/write, etc)
However, a lot of things can be performed this way: for example, a
parser for jigle pages or sharereactor html pages could be done like that:
a structure (a C struct) containing the search would be passed to a
first C function to generate the url to be queried:
struct search {
search_keywords: char*;
search_num : int;
};
void search_jiggle(struct search *s){
char *url;
...
... save somewhere the url with the search_num associated ...
mldonkey_download_url(url, "jiggle_callback");
free(url);
}
We suppose here that mldonkey provides a function
'mldonkey_download_url' to declare urls to
be downloaded in the future.
void jiggle_callback(char *url, char *page)
{
... the page is the one that would be returned by wget for example ...
... some code to find the search_num associated with the url ...
while(1){
... parsing the page ...
mldonkey_add_search_result(search_num, result);
free_result(result)
}
}
where we suppose that mldonkey provides a function
'mldonkey_add_search_result' to add results to a search. Of course,
the jiggle_callback function could also recall 'mldonkey_download_url'
to recursively fetch other urls (but these urls will not be downloaded
immediatly !)
Such 'mldonkey_' functions could easily be written by ocaml devs (on C
devs requests), while the C code would be written by C devs. The stubs
to call the C functions from the ocaml code would also be written by
ocaml devs. So, no need of ocaml knowledge to do that. The only
requirements are:
- The C functions must be called with well-defined arguments (strings,
int, simple structs)
- The 'mldonkey_' functions cannot do anything except storing the
results, until the C function code is completely executed (in this
example, the URL will be downloaded after 'search_jiggle' has been
executed, and the results will really be added when
'jiggle_callback' has completely been executed).
- The C code is responsible for desallocating any data allocated by
itself.
I don't know if this short explanation can help some contributors, but
if you have ideas about how to use this scheme, just ask (I'll be back
on monday :)
- MLDonkey