1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
|
<HTML><HEAD>
<TITLE>C API Reference -- Loadable C Module Development</TITLE>
<LINK rel=Previous href="c-ch.htm">
<LINK rel=ToC href="toc.htm">
<LINK rel=Index href="master.htm">
<LINK rel=Next href="c-ch2.htm">
</HEAD><BODY BGCOLOR="#ffffff"><A NAME="topofpage"></A>
<TABLE WIDTH=100%>
<TR>
<TD ALIGN=LEFT>
<A NAME="topofpage"></A> <IMG SRC="as-c-sm.gif">
</TD>
<TD ALIGN=RIGHT>
<A href="c-ch.htm"><IMG BORDER="0" src=navbprev.gif alt="[ Previous ]"></A>
<A href=toc.htm> <IMG BORDER="0" src=navbhome.gif alt="[ Contents ]"></A>
<A href=master.htm> <IMG BORDER="0" src=navbhelp.gif alt="[ Index ]"></A>
<A href="c-ch2.htm"> <IMG BORDER="0" src=navbnext.gif alt="[ Next ]"></A>
<A name="7983"> </A>
</TD>
</TR>
</TABLE>
<a name="13333">
</a><h3>Loadable C Module Development</h3>
<p><a name="4298">
</a>The AOLserver can be extended by loading one or more C modules dynamically. You write these modules using your ordinary C code development environment and compile them as shared library modules on Unix as described below.</p>
<p><a name="4300">
</a>Each module must include an <i>initialization routine</i> that typically calls one or more AOLserver C API functions for registering the procedures within your module. The procedures within your module can handle URLs (operation procedures) or do other special-purpose functions. To register a C function in your module with the AOLserver, pass a pointer to your function as an argument to one of the AOLserver C API registration functions.</p>
<p><a name="4304">
</a>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.</p>
<a name="4306">
</a><h4>Creating a Loadable Module</h4>
<p><a name="4310">
</a>To create a dynamically loadable C module, compile your code and then link the resulting object module into a shared library module on Unix.</p>
<p><a name="4312">
</a>Your C source code file must include the <code>ns.h</code> header file, which can be found in the <code>include</code> subdirectory of the AOLserver home directory. To compile and link your module, use the following instructions specific to your architecture.</p>
<a name="699093">
</a><h4>Compile on Alpha OSF 4.0 platform</h4>
<ul><li>Compile using the optional DEC C compiler:<a name="699095">
</a>
<p></ul><pre> <a name="699096"></a>% cc -std1 -pthread -I$NS_HOMOE/include -c mymodule.c -o <br>
mymodule.o
</pre><p><ul><li>Compile using the freely available GCC compiler:<a name="699097">
</a>
<p></ul><pre> <a name="699098"></a>% gcc -D__alpha__ -D_REENTRANT -I$NS_HOME/include -c momodule.c
-o mymodule.o
</pre><p><ul><li>Link:<a name="699099">
</a>
<p></ul><pre> <a name="699100"></a>% ld -shared -expect_unresolved '*' -o mymodule.so mymodule.o
</pre><p><a name="699103">
</a><h4>Compile on HP/UX 10.20 platform</h4>
<ul><li>Compile using the optional HP-UX C comiler:<a name="699105">
</a>
<p></ul><pre> <a name="699106"></a>% cc -Ae -D__hpux__ -D__hp10 +DAportable +z -I$NS_HOME/include <br>
-c mymodule.c -o mymodule.o
</pre><p><ul><li>Link:<a name="699107">
</a>
<p></ul><pre> <a name="699108"></a>% ld -b -o mymodule.so mymodule.o
</pre><p><a name="699111">
</a><h4>Compile on SGI IRIX 6.2 platform</h4>
<ul><li>Compile using the optional SGI C compiler:<a name="699113">
</a>
<p></ul><pre> <a name="699114"></a>% cc -32 -D_SGI_MP_SOURCE -I$NS_HOME/include -c mymodule.c -o <br>
mymodule.o
</pre><p><ul><li>Compile using the freely available GCC compiler:<a name="699115">
</a>
<p></ul><pre> <a name="699116"></a>% gcc -D__unix__ -D__sgi__ -I$NS_HOME/include -c mymodule.c -o
mymodule.o
</pre><p><ul><li>Link:<a name="699606">
</a>
<p></ul><pre> <a name="699607"></a>% ld -shared -o mymodule.so mymodule.o
</pre><p><a name="699121">
</a><h4>Compile on Solaris 2.6 platform</h4>
<ul><li>Compile using the optional SUNWspro compiler:<a name="699123">
</a>
<p></ul><pre> <a name="699124"></a>% cc -D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT -KPIC <br>
-I$NS_HOME/include -c mymodule.c -o mymodule.o
</pre><p><ul><li>Compile using the freely available GCC compiler:<a name="699125">
</a>
<p></ul><pre> <a name="699126"></a>% gcc -D__unix__ -D__solaris__ -fpic -I$NS_HOME/include -c <br>
mymodule.c o mymodule.o
</pre><p><ul><li>Link:<a name="699127">
</a>
<p></ul><pre> <a name="699128"></a>% ld -dy -G -o mymodule.so mymodule.o
</pre><p><a name="699131">
</a><h4>Compile on Linux platform</h4>
<ul><li>Compile using the freely availble GCC compiler:<a name="699132">
</a>
<p></ul><pre> <a name="699133"></a>% gcc -rdynamic -I$NS_HOME/include -D_REENTRANT -c mymodule.c <br>
-o mymodule.o
</pre><p><ul><li>Link:<a name="699134">
</a>
<p></ul><pre> <a name="699135"></a>% gcc -rdynamic -shared -o mymodule.so mymodule.o
</pre><p><a name="4414">
</a><h4>Using a Loadable Module</h4>
<p><a name="4416">
</a>For each library you would like to have the AOLserver load at startup time, add an entry in the server's Module section in the AOLserver configuration file. The format of a load entry is a nickname for the module, an equal sign, the filename of the module, and, optionally, the name of an initialization routine in parentheses. For example:</p>
<pre> <a name="4418"></a>mymodule=mymodule.so(MyInit)
</pre><p><p><a name="4420">
</a>Module filenames typically end in .so on Unix platforms. 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".</p>
<TABLE BORDER="2" CELLPADDING="1" width="100%">
<TR><TD COLSPAN=3><P ALIGN=Center>
<IMG SRC="bluebult.gif">
<A HREF="#topofpage">
<FONT SIZE=-1>Top of Page</FONT></A>
<IMG SRC="bluebult.gif">
</TD></TR>
<TR><TD COLSPAN=3><P ALIGN=Center>
<A href="c-ch.htm">
<IMG BORDER="0" src=navbprev.gif alt="[ Previous ]"></A>
<A href=toc.htm>
<IMG BORDER="0" src=navbhome.gif alt="[ Contents ]"></A>
<A href=master.htm>
<IMG BORDER="0" src=navbhelp.gif alt="[ Index ]"></A>
<A href="c-ch2.htm">
<IMG BORDER="0" src=navbnext.gif alt="[ Next ]"></A>
<BR align=center>
<FONT size=-1>Copyright © 1998-99 America Online,
Inc.</FONT>
</TD></TR></TABLE></BODY></HTML>
|