mkernel 0.0.2
Micro-kernel framework, everything as a module
modmgr.c File Reference

Module manager implementation. More...

#include "modmgr.h"
#include "gettext.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <ltdl.h>
#include "debug/assert.h"
#include "debug/memory.h"
Include dependency graph for modmgr.c:

Go to the source code of this file.

Classes

struct  modules_s
 Module list item structure. More...
 

Macros

#define _(String)   gettext (String)
 
#define PATH_MAX   255
 

Typedefs

typedef struct modules_s modules_t
 Module list item structure. More...
 

Functions

int modmgr_setpath (const char *path)
 Reset and initialize the modules search path. More...
 
int modmgr_addpath (const char *path)
 Add a path at the end (lowest prio) of the search path. More...
 
int modmgr_insertpath (const char *before, const char *path)
 Insert (with higher prio) a path before the specified one (from the current search path) More...
 
const char * modmgr_getpath ()
 Get a read-only pointer on the current search path. More...
 
modmgr_module_t modmgr_load (const char *modfile)
 Load a module, initialize it, add it to the list and return an opaque handle. More...
 
void modmgr_unload (modmgr_module_t module)
 Decrement the usage counter, if last usage, remove from the module list and call onUnload. More...
 
void modmgr_list ()
 Output the list of modules. More...
 
void * modmgr_getsymbol (const modmgr_module_t module, const char *szSymbol)
 Resolve a module symbol pointer. More...
 

Detailed Description

Module manager implementation.

Date
25/11/2017
Author
François Cerbelle (Fanfan), franc.nosp@m.ois@.nosp@m.cerbe.nosp@m.lle..nosp@m.net

Definition in file modmgr.c.

Macro Definition Documentation

◆ _

#define _ (   String)    gettext (String)

Definition at line 20 of file modmgr.c.

◆ PATH_MAX

#define PATH_MAX   255

Definition at line 28 of file modmgr.c.

Typedef Documentation

◆ modules_t

typedef struct modules_s modules_t

Module list item structure.

Function Documentation

◆ modmgr_addpath()

int modmgr_addpath ( const char *  path)

Add a path at the end (lowest prio) of the search path.

Add a path to the end of the module search path.

Definition at line 141 of file modmgr.c.

Here is the caller graph for this function:

◆ modmgr_getpath()

const char * modmgr_getpath ( )

Get a read-only pointer on the current search path.

Get the current search path list.

Definition at line 181 of file modmgr.c.

◆ modmgr_getsymbol()

void * modmgr_getsymbol ( const modmgr_module_t  module,
const char *  szSymbol 
)

Resolve a module symbol pointer.

Resolve a module symbol, can be a function or a variable.

Definition at line 419 of file modmgr.c.

◆ modmgr_insertpath()

int modmgr_insertpath ( const char *  before,
const char *  path 
)

Insert (with higher prio) a path before the specified one (from the current search path)

Insert an higher priority search path before another one.

Definition at line 161 of file modmgr.c.

◆ modmgr_list()

void modmgr_list ( )

Output the list of modules.

Print the currently loaded modules list for debug and tracing.

Definition at line 379 of file modmgr.c.

Here is the caller graph for this function:

◆ modmgr_load()

modmgr_module_t modmgr_load ( const char *  modfile)

Load a module, initialize it, add it to the list and return an opaque handle.

Load a module and call the initialization with a parameter if first usage.

Todo:
critical section

Definition at line 191 of file modmgr.c.

◆ modmgr_setpath()

int modmgr_setpath ( const char *  path)

Reset and initialize the modules search path.

Initialize or reset module search path.

Definition at line 125 of file modmgr.c.

Here is the caller graph for this function:

◆ modmgr_unload()

void modmgr_unload ( modmgr_module_t  module)

Decrement the usage counter, if last usage, remove from the module list and call onUnload.

Call the unload function if last usage and tries to unload the module.

Definition at line 306 of file modmgr.c.