MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / register_module

Function register_module

sr_module.c:149–203  ·  view source on GitHub ↗

registers a module, register_f= module register functions * returns <0 on error, 0 on success */

Source from the content-addressed store, hash-verified

147/* registers a module, register_f= module register functions
148 * returns <0 on error, 0 on success */
149int register_module(const struct module_exports* e, char* path, void* handle)
150{
151 int ret;
152 struct sr_module* mod;
153
154 ret=-1;
155
156 /* add module to the list */
157 if ((mod=pkg_malloc(sizeof(struct sr_module)))==0){
158 LM_ERR("no more pkg memory\n");
159 ret=E_OUT_OF_MEM;
160 goto error;
161 }
162 memset(mod,0, sizeof(struct sr_module));
163 mod->path=path;
164 mod->handle=handle;
165 mod->exports=e;
166 mod->next=modules;
167 modules=mod;
168
169 /* register module pseudo-variables */
170 if (e->items) {
171 LM_DBG("register_pv: %s\n", e->name);
172 if (register_pvars_mod(e->name, e->items)!=0) {
173 LM_ERR("failed to register pseudo-variables for module %s\n",
174 e->name);
175 pkg_free(mod);
176 return -1;
177 }
178 }
179
180 /* register module transformations */
181 if (e->trans) {
182 LM_DBG("register_trans: %s\n", e->name);
183 if (register_trans_mod(e->name, e->trans) !=0) {
184 LM_ERR("failed to register transformations for module %s\n",
185 e->name);
186 pkg_free(mod);
187 return -1;
188 }
189 }
190
191 /* register all module dependencies */
192 if (e->deps) {
193 ret = add_module_dependencies(mod);
194 if (ret != 0) {
195 LM_CRIT("failed to add module dependencies [%d]\n", ret);
196 return ret;
197 }
198 }
199
200 return 0;
201error:
202 return ret;
203}
204
205
206static inline int version_control(const struct module_exports* exp, char *path)

Callers 3

register_builtin_modulesFunction · 0.85
sr_load_moduleFunction · 0.85
load_static_moduleFunction · 0.85

Calls 3

register_pvars_modFunction · 0.85
register_trans_modFunction · 0.85
add_module_dependenciesFunction · 0.85

Tested by

no test coverage detected