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