Changes in uspace/lib/net/adt/module_map.c [61bfc370:6b82009] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/net/adt/module_map.c
r61bfc370 r6b82009 39 39 #include <unistd.h> 40 40 #include <errno.h> 41 42 #include <ipc/services.h>43 44 41 #include <net/modules.h> 45 46 42 #include <adt/generic_char_map.h> 47 43 #include <adt/module_map.h> … … 49 45 GENERIC_CHAR_MAP_IMPLEMENT(modules, module_t) 50 46 51 /** Add smodule to the module map.47 /** Add module to the module map. 52 48 * 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 * @return EOK on success. 62 * @return ENOMEM if there is not enough memory left. 49 * @param[out] module Module structure added. 50 * @param[in] modules Module map. 51 * @param[in] name Module name. 52 * @param[in] filename Full path filename. 53 * @param[in] service Module service. 54 * @param[in] task_id Module current task identifier. 55 * Zero means not running. 56 * @param[in] connect_module Module connecting function. 57 * 58 * @return EOK on success. 59 * @return ENOMEM if there is not enough memory left. 60 * 63 61 */ 64 int 65 add_module(module_t **module, modules_t *modules, const uint8_t *name, 62 int add_module(module_t **module, modules_t *modules, const uint8_t *name, 66 63 const uint8_t *filename, services_t service, task_id_t task_id, 67 64 connect_module_t connect_module) … … 69 66 module_t *tmp_module; 70 67 int rc; 71 68 72 69 tmp_module = (module_t *) malloc(sizeof(module_t)); 73 70 if (!tmp_module) 74 71 return ENOMEM; 75 72 76 73 tmp_module->task_id = task_id; 77 tmp_module-> phone = 0;74 tmp_module->sess = NULL; 78 75 tmp_module->usage = 0; 79 76 tmp_module->name = name; … … 81 78 tmp_module->service = service; 82 79 tmp_module->connect_module = connect_module; 83 80 84 81 rc = modules_add(modules, tmp_module->name, 0, tmp_module); 85 82 if (rc != EOK) { … … 87 84 return rc; 88 85 } 86 89 87 if (module) 90 88 *module = tmp_module; 91 89 92 90 return EOK; 93 91 } 94 92 95 /** Search es and returnsthe specified module.93 /** Search and return the specified module. 96 94 * 97 95 * If the module is not running, the module filaname is spawned. 98 96 * If the module is not connected, the connect_function is called. 99 97 * 100 * @param[in] modules The module map. 101 * @param[in] name The module name. 102 * @return The running module found. It does not have to be 103 * connected. 104 * @return NULL if there is no such module. 98 * @param[in] modules Module map. 99 * @param[in] name Module name. 100 * 101 * @return The running module found. It does not have to be 102 * connected. 103 * @return NULL if there is no such module. 104 * 105 105 */ 106 106 module_t *get_running_module(modules_t *modules, uint8_t *name) 107 107 { 108 module_t *module; 109 110 module = modules_find(modules, name, 0); 108 module_t *module = modules_find(modules, name, 0); 111 109 if (!module) 112 110 return NULL; 113 111 114 112 if (!module->task_id) { 115 113 module->task_id = net_spawn(module->filename); … … 117 115 return NULL; 118 116 } 119 if (!module->phone) 120 module->phone = module->connect_module(module->service); 121 117 118 if (!module->sess) 119 module->sess = module->connect_module(module->service); 120 122 121 return module; 123 122 }
Note:
See TracChangeset
for help on using the changeset viewer.