Changes in uspace/lib/net/adt/module_map.c [6b82009:61bfc370] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/net/adt/module_map.c
r6b82009 r61bfc370 39 39 #include <unistd.h> 40 40 #include <errno.h> 41 42 #include <ipc/services.h> 43 41 44 #include <net/modules.h> 45 42 46 #include <adt/generic_char_map.h> 43 47 #include <adt/module_map.h> … … 45 49 GENERIC_CHAR_MAP_IMPLEMENT(modules, module_t) 46 50 47 /** Add module to the module map.51 /** Adds module to the module map. 48 52 * 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 * 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. 61 63 */ 62 int add_module(module_t **module, modules_t *modules, const uint8_t *name, 64 int 65 add_module(module_t **module, modules_t *modules, const uint8_t *name, 63 66 const uint8_t *filename, services_t service, task_id_t task_id, 64 67 connect_module_t connect_module) … … 66 69 module_t *tmp_module; 67 70 int rc; 68 71 69 72 tmp_module = (module_t *) malloc(sizeof(module_t)); 70 73 if (!tmp_module) 71 74 return ENOMEM; 72 75 73 76 tmp_module->task_id = task_id; 74 tmp_module-> sess = NULL;77 tmp_module->phone = 0; 75 78 tmp_module->usage = 0; 76 79 tmp_module->name = name; … … 78 81 tmp_module->service = service; 79 82 tmp_module->connect_module = connect_module; 80 83 81 84 rc = modules_add(modules, tmp_module->name, 0, tmp_module); 82 85 if (rc != EOK) { … … 84 87 return rc; 85 88 } 86 87 89 if (module) 88 90 *module = tmp_module; 89 91 90 92 return EOK; 91 93 } 92 94 93 /** Search and returnthe specified module.95 /** Searches and returns the specified module. 94 96 * 95 97 * If the module is not running, the module filaname is spawned. 96 98 * If the module is not connected, the connect_function is called. 97 99 * 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 * 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. 105 105 */ 106 106 module_t *get_running_module(modules_t *modules, uint8_t *name) 107 107 { 108 module_t *module = modules_find(modules, name, 0); 108 module_t *module; 109 110 module = modules_find(modules, name, 0); 109 111 if (!module) 110 112 return NULL; 111 113 112 114 if (!module->task_id) { 113 115 module->task_id = net_spawn(module->filename); … … 115 117 return NULL; 116 118 } 117 118 if (!module->sess) 119 module->sess = module->connect_module(module->service); 120 119 if (!module->phone) 120 module->phone = module->connect_module(module->service); 121 121 122 return module; 122 123 }
Note:
See TracChangeset
for help on using the changeset viewer.