Пример #1
0
/*
 * Initialize all loaded modules, the initialization
 * is done *AFTER* the configuration file is parsed
 */
int init_modules(void)
{
	struct sr_module* t;
	int i;

	if(async_task_init()<0)
		return -1;

	i = init_mod(modules);
	if(i!=0)
		return i;

	for(t = modules; t; t = t->next)
		if (t->exports.response_f)
			mod_response_cbk_no++;
	mod_response_cbks=pkg_malloc(mod_response_cbk_no *
									sizeof(response_function));
	if (mod_response_cbks==0){
		LM_ERR("memory allocation failure for %d response_f callbacks\n", mod_response_cbk_no);
		return -1;
	}
	for (t=modules, i=0; t && (i<mod_response_cbk_no); t=t->next)
		if (t->exports.response_f) {
			mod_response_cbks[i]=t->exports.response_f;
			i++;
		}

	return 0;
}
Пример #2
0
static int init_mod( struct sr_module* m )
{
	if (m) {
		/* iterate through the list; if error occurs,
		 * propagate it up the stack
		 */
		if (init_mod(m->next)!=0) return -1;
			if (m->exports.init_mod_f) {
				LM_DBG("%s\n", m->exports.name);
				if (m->exports.init_mod_f()!=0) {
					LM_ERR("Error while initializing module %s (%s)\n",
								m->exports.name, m->path);
					return -1;
				} else {
					/* module correctly initialized */
					return 0;
				}
			}
			/* no init function -- proceed with success */
			return 0;
	} else {
		/* end of list */
		return 0;
	}
}
Пример #3
0
/*
 * Initialize all loaded modules, the initialization
 * is done *AFTER* the configuration file is parsed
 */
int init_modules(void)
{
	int ret;

	if (testing_framework) {
		init_unit_tests();
		solve_module_dependencies(modules);
	}

	ret = init_mod(modules, 0);

	free_module_dependencies(modules);

	return ret;
}
Пример #4
0
void Init_tokyo_messenger(){
  mTokyoMessenger = rb_define_module("TokyoMessenger");
  eTokyoMessengerError = rb_define_class("TokyoMessengerError", rb_eStandardError);
  init_mod();

  cDB = rb_define_class_under(mTokyoMessenger, "DB", rb_cObject);
  rb_include_module(cDB, mTokyoMessenger);
  init_db();

  cTable = rb_define_class_under(mTokyoMessenger, "Table", rb_cObject);
  rb_include_module(cTable, mTokyoMessenger);
  init_table();

  cQuery = rb_define_class_under(mTokyoMessenger, "Query", rb_cObject);
  init_query();
}
Пример #5
0
static int init_mod( struct sr_module* m )
{
	if (m) {
		/* iterate through the list; if error occurs,
		   propagate it up the stack
		 */
		if (init_mod(m->next)!=0) return -1;
		if (m->exports==0)
			return 0;
		if (m->exports->init_f) {
			LM_DBG("initializing module %s\n", m->exports->name);
			if (m->exports->init_f()!=0) {
				LM_ERR("failed to initialize"
					" module %s\n", m->exports->name);
				return -1;
			}
		}
		/* no init function -- proceed further */
#ifdef STATISTICS
		if (m->exports->stats) {
			LM_DBG("registering stats for %s\n", m->exports->name);
			if (register_module_stats(m->exports->name,m->exports->stats)!=0) {
				LM_ERR("failed to registering "
					"statistics for module %s\n", m->exports->name);
				return -1;
			}
		}
#endif
		/* register MI functions */
		if (m->exports->mi_cmds) {
			LM_DBG("register MI for %s\n", m->exports->name);
			if (register_mi_mod(m->exports->name,m->exports->mi_cmds)!=0) {
				LM_ERR("failed to register MI functions for module %s\n",
					m->exports->name);
			}
		}

		/* proceed with success */
		return 0;
	} else {
		/* end of list */
		return 0;
	}
}
Пример #6
0
t_env				*init_env(char *av)
{
	t_env			*e;

	e = malloc(sizeof(t_env) * 1);
	e->m = init_mod();
	e->f = init_frac(av);
	e->mlx = mlx_init();
	e->f->img = mlx_new_image(e->mlx, WIN_X, WIN_Y);
	e->win = mlx_new_window(e->mlx, WIN_X, WIN_Y, "Fractol");
	e->f->d = mlx_get_data_addr(e->f->img, &e->f->bpp, &e->f->line_size,
&e->f->endian);
	e->t = (double)time(NULL);
	e->frequency = 0.1;
	e->iter = 16;
	e->color = 2;
	e->zx = ((CXMAX - CXMIN) / (WIN_X - 1));
	e->zy = ((CYMAX - CYMIN) / (WIN_Y - 1));
	return (e);
}
Пример #7
0
/*
 * Initialize all loaded modules, the initialization
 * is done *AFTER* the configuration file is parsed
 */
int init_modules(void)
{
	return init_mod(modules);
}
Пример #8
0
static int init_mod( struct sr_module* m, int skip_others)
{
	struct sr_module_dep *dep;

	if (m) {
		/* iterate through the list; if error occurs,
		   propagate it up the stack
		 */
		if (!skip_others && init_mod(m->next, 0) != 0)
			return -1;

		/* our module might have been already init'ed through dependencies! */
		if (m->init_done)
			return 0;

		if (!m->exports)
			return 0;

		/* make sure certain modules get loaded before this one */
		for (dep = m->sr_deps; dep; dep = dep->next) {
			if (!dep->mod->init_done)
				if (init_mod(dep->mod, 1) != 0)
					return -1;
		}

		if (m->exports->init_f) {
			LM_DBG("initializing module %s\n", m->exports->name);
			if (m->exports->init_f()!=0) {
				LM_ERR("failed to initialize module %s\n", m->exports->name);
				return -1;
			}
		}

		m->init_done = 1;

		/* no init function -- proceed further */
#ifdef STATISTICS
		if (m->exports->stats) {
			LM_DBG("registering stats for %s\n", m->exports->name);
			if (register_module_stats(m->exports->name,m->exports->stats)!=0) {
				LM_ERR("failed to registering "
					"statistics for module %s\n", m->exports->name);
				return -1;
			}
		}
#endif
		/* register MI functions */
		if (m->exports->mi_cmds) {
			LM_DBG("register MI for %s\n", m->exports->name);
			if (register_mi_mod(m->exports->name,m->exports->mi_cmds)!=0) {
				LM_ERR("failed to register MI functions for module %s\n",
					m->exports->name);
			}
		}

		/* proceed with success */
		return 0;
	} else {
		/* end of list */
		return 0;
	}
}