Changes in uspace/lib/net/adt/module_map.c [25d2de69:d9fae235] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/net/adt/module_map.c
r25d2de69 rd9fae235 27 27 */ 28 28 29 /** @addtogroup libnet30 * @{29 /** @addtogroup net 30 * @{ 31 31 */ 32 32 33 33 /** @file 34 * Character string to module map implementation.34 * Character string to module map implementation. 35 35 */ 36 36 … … 38 38 #include <task.h> 39 39 #include <unistd.h> 40 #include <err.h>41 40 42 41 #include <ipc/services.h> 43 42 44 #include <net/modules.h> 43 #include <net_err.h> 44 #include <net_modules.h> 45 45 46 46 #include <adt/generic_char_map.h> … … 49 49 GENERIC_CHAR_MAP_IMPLEMENT(modules, module_t) 50 50 51 /** Adds module to the module map. 52 * 53 * @param[out] module The module structure added. 54 * @param[in] modules The module map. 55 * @param[in] name The module name. 56 * @param[in] filename The full path filename. 57 * @param[in] service The module service. 58 * @param[in] task_id The module current task identifier. Zero means not 59 * running. 60 * @param[in] connect_module The module connecting function. 61 * @returns EOK on success. 62 * @returns ENOMEM if there is not enough memory left. 63 */ 64 int 65 add_module(module_ref *module, modules_ref modules, const char *name, 66 const char *filename, services_t service, task_id_t task_id, 67 connect_module_t connect_module) 68 { 51 int add_module(module_ref * module, modules_ref modules, const char * name, const char * filename, services_t service, task_id_t task_id, connect_module_t connect_module){ 69 52 ERROR_DECLARE; 70 53 … … 72 55 73 56 tmp_module = (module_ref) malloc(sizeof(module_t)); 74 if (!tmp_module)57 if(! tmp_module){ 75 58 return ENOMEM; 76 59 } 77 60 tmp_module->task_id = task_id; 78 61 tmp_module->phone = 0; … … 82 65 tmp_module->service = service; 83 66 tmp_module->connect_module = connect_module; 84 85 if (ERROR_OCCURRED(modules_add(modules, tmp_module->name, 0, 86 tmp_module))) { 67 if(ERROR_OCCURRED(modules_add(modules, tmp_module->name, 0, tmp_module))){ 87 68 free(tmp_module); 88 69 return ERROR_CODE; 89 70 } 90 if (module)71 if(module){ 91 72 *module = tmp_module; 92 73 } 93 74 return EOK; 94 75 } 95 76 96 /** Searches and returns the specified module. 97 * 98 * If the module is not running, the module filaname is spawned. 99 * If the module is not connected, the connect_function is called. 100 * 101 * @param[in] modules The module map. 102 * @param[in] name The module name. 103 * @returns The running module found. It does not have to be 104 * connected. 105 * @returns NULL if there is no such module. 106 */ 107 module_ref get_running_module(modules_ref modules, char *name) 108 { 77 module_ref get_running_module(modules_ref modules, char * name){ 109 78 module_ref module; 110 79 111 80 module = modules_find(modules, name, 0); 112 if (!module)81 if(! module){ 113 82 return NULL; 114 115 if (!module->task_id){83 } 84 if(! module->task_id){ 116 85 module->task_id = spawn(module->filename); 117 if (!module->task_id)86 if(! module->task_id){ 118 87 return NULL; 88 } 119 89 } 120 if (!module->phone)90 if(! module->phone){ 121 91 module->phone = module->connect_module(module->service); 122 92 } 123 93 return module; 124 94 } 125 95 126 /** Starts the given module.127 *128 * @param[in] fname The module full or relative path filename.129 * @returns The new module task identifier on success.130 * @returns Zero if there is no such module.131 */132 96 task_id_t spawn(const char *fname) 133 97 {
Note:
See TracChangeset
for help on using the changeset viewer.