Module initialization functions can also set up any state required by your functions. For example, the AOLserver database services module's initialization routine creates a pool of database connections.
Your C source code file must include the ns.h
header file, which can be found in the include
subdirectory of the AOLserver home directory. To compile and link your module, use the following instructions specific to your architecture.
% cc -D__alpha__ -D_REENTRANT -threads -I$NS_HOME/include -c mymodule.c
% gcc -D__alpha__ -D_REENTRANT -I$NS_HOME/include -c mymodule.c
% ld -shared -expect_unresolved `*' -o mymodule.so mymodule.o % chmod a+x mymodule.so
% cc +z -Ae -D__hpux__ -D_REENTRANT -I$NS_HOME/include -c mymodule.c
% ld -b -o mymodule.so mymodule.o
% cc -D__unix__ -D__sgi__ -I$NS_HOME/include -c mymodule.c
% gcc -D__unix__ -D__sgi__ -I$NS_HOME/include -c mymodule.c
% ld -shared -o mymodule.so mymodule.o % chmod a+x mymodule.so
% ucbcc -xCC -D__unix__ -D__solaris__ -D_REENTRANT -mt -Xa -I$NS_HOME/include -c mymodule.c
% gcc -D__unix__ -D__solaris__ -fpic -I$NS_HOME/include -c mymodule.c
% ld -dy -G -o mymodule.so mymodule.o
% gcc -D__unix__ -D__sun4__ -I$NS_HOME/pthreads/include -I$NS_HOME/include -fpic -c mymodule.c
% ld -shared -o mymodule.so mymodule.o
include
subdirectory of the AOLserver home directory to the list of directories to search for header files.
nsd.lib
import library found in the bin subdirectory of the AOLserver home directory to the list of libraries to link against.
DllExport
storage class attribute:
DllExport void MyInit(void);
.DEF
) file to export your initialization routine. See Chapter 50 of the Microsoft Win32 Programmer's Reference for details.mymodule=mymodule.so(MyInit)
Module filenames typically end in .so on Unix platforms and .dll on NT. If the module filename is not an absolute path name, the AOLserver searches for the module in the bin subdirectory of the AOLserver home directory. The name of the initialization routine defaults to "Ns_ModuleInit".