DevelopersTips

From MLDonkey
Jump to: navigation, search

Contents

Ocaml

MLdonkey is primarily developed in the ObjectiveCaml language.

Learning functional programming

Learning Objective Caml

Contributions in C to mldonkey

Extracts from the MLD users list by MLDonkey himself :

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:

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 (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:

Sidenote : !! Adding C code is NOT the best way to contribute !!

Learning the GUI-Protocol

The GUI-Protocol is the way an external graphical interface communicate with MLDonkey using sockets and TCP/IP. You can program your own GUI in every language you like and use the GuiProtocol to control your MLDonkey. Also may want to have a look at the others user interfaces.

Guidelines for the release of a new version

As example version 2.7.3 is used. --Spiralvoice 15:53, 12 April 2006 (PDT)

  • this script is used to return the version number of used sourcecode used in other scripts
#!/bin/sh
case $# in
    1)
        cdir=$1
        ;;
    *)
        cdir=`pwd`/mldonkey
        ;;
esac
major_version=`grep -m 1 MAJOR_VERSION= $cdir/config/configure.in | cut -c 15-17`
minor_version=`grep -m 1 MINOR_VERSION= $cdir/config/configure.in | cut -c 15-17`
sub_version=`grep -m 1 SUB_VERSION= $cdir/config/configure.in | cut -c 13-14`
echo $major_version.$minor_version.$sub_version
  • Now the tarball creation script
#!/bin/sh
rm -rf ./mldonkey-cvs-create
mkdir mldonkey-cvs-create
cd mldonkey-cvs-create
cvs -z3 -d:pserver:anonymous@cvs.savannah.nongnu.org:/sources/mldonkey co -P mldonkey
version=`../mld_version.sh ./mldonkey`
mv ./mldonkey ./mldonkey-$version
cd ./mldonkey-$version/config
if [ -f ./configure ] ; then
    rm ./configure
fi
if [ -f ../Makefile ] ; then
    rm ../Makefile
fi
autoconf
m4 Makefile.in > ../Makefile
rm -rf ./autom4te.cache
cd ../..
tar --exclude=CVS --exclude=.cvsignore -cf ./mldonkey-$version.tar ./mldonkey-$version
bzip2 -zv9 mldonkey-$version.tar
  • Gentoo ~x86 is used with current autoconf/m4 to create the configure script.
  • the Linux x86, glibc-2.3.2 version is built on current Debian Sarge from a freshly downloaded sourcecode tarball
./configure --enable-checks --host=i386-pc-linux-gnu
make release.mlnet.static
make release.utils.static
  • so it can be used on older platforms as well.
  • Using Debian has the advantage that, in contrast to highly optimized Gentoo, it produces i386 binaries.
  • upload mldonkey-2.7.3.static.i386-Linux_glibc-2.3.2.tar.bz2 to Sourceforge

Developing new features

eMule >4GB support
eMule protocol obfuscation
eMule AICH support

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox