Click Dynamic loading (fwd)

Eddie Kohler eddietwo at cag.lcs.mit.edu
Thu Apr 20 10:04:32 EDT 2000


BENJIE!

They are creating their own archive. so they want to know how the
downloadable package stuff works in general.

The way to include dynamically loadable packages is to use 'ar'.

If you have a Click configuration in 'FILE.click', the steps are something
like this. I'll write it down as if you were doing it by hand. This all
assumes that you are using the Linux kernel module. If you are using the
'click' user-level program, write back. Some things are different.

(1) Check to see if 'FILE.click' is an ar(1) archive. ar(1) archives begin
with the magic string "!<arch>\n".

If it is NOT an archive, turn it into an archive in the following way:

   % mv FILE.click /tmp/config
   % ar cr FILE.click /tmp/config

(2) Add `myclass.cc' to the archive. Also add 'myclass.hh' if you have that

   % ar r FILE.click myclass.cc [myclass.hh]

NOTE: You do not need to add the .o file. click-install will compile it
from the source automatically.

(3) Extract the configuration and add a _requirement_. This will force
click-install to download myclass.o.

   % echo 'require(myclass)' > /tmp/config
   % ar p FILE.click config >> /tmp/config
   % ar r FILE.click /tmp/config

(4) You are now done and can run 'click-install FILE.click'.

HOWEVER!!!!!!!!!!!!!!!

The myclass.cc file needs to follow some guidelines to work efffectively as
a downloadable module. It must have init_module and cleanup_module
functions. It must call click_provide and click_unprovide (in init_module
and cleanup_module, respectively) to inform the main Click module when it
is loaded and unloaded. Finally, if your module contains new element types,
you need to write code that informs the Click module that the new element
types exist, and that removes the element types when the module is
unloaded. This sounds like a lot but it is not that hard. I advise you to
create a very simple configuration containing one Classifier element. Then
run that configuration through 'click-fastclassifier' and look at its
output. The output will be an archive including source code; the source
code demonstrates what you need to do.

Please write back if this is confusing.
love,
ed




More information about the click mailing list