Home | History | Annotate | Download | only in inc
      1 /*
      2  * module.h, dynamic module interface
      3  *
      4  * Copyright (c) 2009-2010 Wind River Systems, Inc.
      5  *
      6  * Licensed under the Apache License, Version 2.0 (the "License");
      7  * you may not use this file except in compliance with the License.
      8  * You may obtain a copy of the License at
      9  *
     10  * http://www.apache.org/licenses/LICENSE-2.0
     11  *
     12  * Unless required by applicable law or agreed to in writing, software
     13  * distributed under the License is distributed on an "AS IS" BASIS,
     14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     15  * See the License for the specific language governing permissions and
     16  * limitations under the License.
     17  */
     18 
     19 #ifndef __MODULE_H
     20 #define __MODULE_H
     21 
     22 #include <dlfcn.h>
     23 
     24 #ifdef __cplusplus
     25 extern "C" {
     26 #endif
     27 
     28 struct module;
     29 
     30 typedef int (*module_init_t)(struct module *module);
     31 typedef void (*module_exit_t)(struct module *module);
     32 
     33 struct module {
     34     char *name;
     35 
     36     int ref_count;
     37     void *handle;
     38 
     39     module_init_t init;
     40     module_exit_t exit;
     41 
     42     void *priv;
     43     struct module *next;
     44 };
     45 
     46 #define MODULE_LAZY RTLD_LAZY
     47 #define MODULE_NOW RTLD_NOW
     48 #define MODUEL_GLOBAL RTLD_GLOBAL
     49 
     50 struct module *module_open(const char *path, int flag);
     51 int module_close(struct module *module);
     52 void *module_symbol(struct module *module, const char *string);
     53 
     54 #ifdef __cplusplus
     55 } /* extern "C" */
     56 #endif
     57 
     58 #endif /* __MODULE_H */
     59