示例#1
0
文件: init_all.c 项目: gauthierf/42sh
int	init_all(t_mini *elem, char **env)
{
  elem->is_env_exec = FAILURE;
  elem->secret_env = NULL;
  elem->need_exit = -1;
  if (env == NULL || env[0] == NULL)
    if ((env = create_default_env()) == NULL)
      return (FAILURE);
  if (!(elem->env = create_new_env(env)))
    return (FAILURE);
  elem->have_tty = isatty(0);
  elem->prompt = NULL;
  parse_rc_file(elem);
  return (SUCCESS);
}
示例#2
0
文件: ospfd.c 项目: hgn/ospfd
int main(int ac, char **av)
{
	int ret;
	struct ospfd *ospfd;
	int ev_flags = 0;

	ospfd = alloc_ospfd();

	ret = parse_cli_options(ospfd, ac, av);
	if (ret != SUCCESS)
		err_msg_die(EXIT_FAILURE, "Can't parse command line");

	msg(ospfd, GENTLE, PROGRAMNAME " - " VERSIONSTRING);

	/* seed pseudo number randon generator */
	init_pnrg(ospfd);

	/* initialize event subsystem. In this case this belongs
	 * to open a epoll filedescriptor */
	ospfd->ev = ev_new();
	if (!ospfd->ev)
		err_msg_die(EXIT_FAILURE, "Can't initialize event subsystem");


	ret = parse_rc_file(ospfd);
	if (ret != SUCCESS)
		err_msg_die(EXIT_FAILURE, "Can't parse configuration file");


	ret = init_network(ospfd);
	if (ret != SUCCESS)
		err_msg_die(EXIT_FAILURE, "Can't initialize network subsystem");

	/* and branch into the main loop
	 * This loop will never return (with the exception of SIGINT or failure
	 * condition) */
	ret = ev_loop(ospfd->ev, ev_flags);
	if (ret != SUCCESS)
		err_msg_die(EXIT_FAILURE, "Main loop returned unexpected - exiting now");


	fini_network(ospfd);
	free_options(ospfd);
	ev_free(ospfd->ev);
	free_ospfd(ospfd);

	return EXIT_SUCCESS;
}