/Users/maurits/Documents/studie/afstuderen/biosphere/tests/test_module.c

Go to the documentation of this file.
00001 /*
00002  * Author: MA Hartman
00003  * Date: apr 12, 2007
00004  * 
00005  * Function:
00006  * Test program for the module subsystem.
00007  * 
00008  * License information:
00009  * 
00010  * Copyright (c) 2006 Maurits Hartman
00011  *
00012  * Permission is hereby granted, free of charge, to any person
00013  * obtaining a copy of this software and associated documentation
00014  * files (the "Software"), to deal in the Software without
00015  * restriction, including without limitation the rights to use,
00016  * copy, modify, merge, publish, distribute, sublicense, and/or sell
00017  * copies of the Software, and to permit persons to whom the
00018  * Software is furnished to do so, subject to the following
00019  * conditions:
00020  * 
00021  * The above copyright notice and this permission notice shall be
00022  * included in all copies or substantial portions of the Software.
00023  * 
00024  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00025  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
00026  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00027  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
00028  * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
00029  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
00030  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
00031  * OTHER DEALINGS IN THE SOFTWARE.
00032  * 
00033  */
00034 
00035 #include <module.h>
00036 #include <apr_pools.h>
00037 #include <stdio.h>
00038 #include <unistd.h>
00039 
00040 apr_pool_t *global_mp;
00041 
00042 
00043 int main(int argc, char *argv[])
00044 {
00045         bs_status rv;
00046         /* TODO need to fix this: */
00047         char *modname = "/home/maurits/biosphere/modules/dummy/.libs/bsmod_dummy.so";
00048         bs_module *mod;
00049         
00050         apr_initialize();
00051         apr_pool_create(&global_mp, NULL);
00052 
00053         /* Construct pathname: */
00054         
00055 
00056         /* Init modules: */
00057         rv = init_module(global_mp);
00058         if (rv != BS_OK) return rv;
00059         
00060         /* Try to load a dummy module (this path is guessed): */
00061         rv = load_module(modname);
00062         if (rv != BS_OK) return rv;
00063         
00064         /* Get some information: */
00065         mod = get_module_info(modname);
00066         printf("%s %d.%d (Bio-SPHERE %d.%d) by %s\n",
00067                         mod->name, mod->bsapi_major, mod->bsapi_minor,
00068                         mod->module_major, mod->module_minor, mod->author);
00069         
00070         /* Unload the module afterwards: */
00071         rv = unload_module(modname);
00072         if (rv != BS_OK) return rv;
00073 
00074         apr_pool_destroy(global_mp);
00075         apr_terminate();
00076         return BS_OK;   
00077 }

Generated on Tue Jul 17 09:50:53 2007 for Bio-SPHERE by  doxygen 1.5.1