Changes in uspace/srv/net/structures/module_map.c [a000878c:aadf01e] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/structures/module_map.c
ra000878c raadf01e 47 47 #include "module_map.h" 48 48 49 GENERIC_CHAR_MAP_IMPLEMENT( modules, module_t)49 GENERIC_CHAR_MAP_IMPLEMENT(modules, module_t) 50 50 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){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){ 52 52 ERROR_DECLARE; 53 53 54 module_ref 54 module_ref tmp_module; 55 55 56 tmp_module = ( module_ref ) malloc( sizeof( module_t )); 57 if( ! tmp_module ) return ENOMEM; 56 tmp_module = (module_ref) malloc(sizeof(module_t)); 57 if(! tmp_module){ 58 return ENOMEM; 59 } 58 60 tmp_module->task_id = task_id; 59 61 tmp_module->phone = 0; … … 63 65 tmp_module->service = service; 64 66 tmp_module->connect_module = connect_module; 65 if( ERROR_OCCURRED( modules_add( modules, tmp_module->name, 0, tmp_module))){66 free( tmp_module);67 if(ERROR_OCCURRED(modules_add(modules, tmp_module->name, 0, tmp_module))){ 68 free(tmp_module); 67 69 return ERROR_CODE; 68 70 } 69 if( module ) * module = tmp_module; 71 if(module){ 72 *module = tmp_module; 73 } 70 74 return EOK; 71 75 } 72 76 73 module_ref get_running_module( modules_ref modules, char * name){74 module_ref 77 module_ref get_running_module(modules_ref modules, char * name){ 78 module_ref module; 75 79 76 module = modules_find( modules, name, 0 ); 77 if( ! module ) return NULL; 78 if( ! module->task_id ){ 79 module->task_id = spawn( module->filename ); 80 if( ! module->task_id ) return NULL; 80 module = modules_find(modules, name, 0); 81 if(! module){ 82 return NULL; 81 83 } 82 if( ! module->phone ){ 83 module->phone = module->connect_module( module->service ); 84 if(! module->task_id){ 85 module->task_id = spawn(module->filename); 86 if(! module->task_id){ 87 return NULL; 88 } 89 } 90 if(! module->phone){ 91 module->phone = module->connect_module(module->service); 84 92 } 85 93 return module; 86 94 } 87 95 88 task_id_t spawn( const char * fname){89 const char * argv[ 2];90 task_id_t 96 task_id_t spawn(const char * fname){ 97 const char * argv[2]; 98 task_id_t res; 91 99 92 argv[ 0] = fname;93 argv[ 1] = NULL;94 res = task_spawn( fname, argv);100 argv[0] = fname; 101 argv[1] = NULL; 102 res = task_spawn(fname, argv); 95 103 96 104 return res;
Note:
See TracChangeset
for help on using the changeset viewer.