Esempio n. 1
0
File: main.c Progetto: Moss-Id/RTv1
int				main(int argc, char const *argv[])
{
	t_win	*win;

	win = init_env();
	return (0);
}
Esempio n. 2
0
File: main.c Progetto: sganon/RTv1
int		main(int argc, char **argv)
{
	t_env	*e;
	t_objs	*obj;

	if (argc == 2)
	{
		e = (t_env *)malloc(sizeof(t_env));
		obj = (t_objs *)malloc(sizeof(t_objs));
		if (!e || !obj)
			ft_error("Malloc error", 2);
		if (!(init_env(e)))
			return (0);
		if (!extension(argv[1]))
			ft_error("File need .rt extension", 2);
		if (!(obj = parsing(argv[1], e, obj)))
			ft_error("Parsing error", 2);
		obj = manage_data(e, obj);
		e->begin_list = obj;
		mlx_expose_hook(e->win, expose_hook, e);
		mlx_key_hook(e->win, key_events, e);
		mlx_loop(e->mlx);
	}
	return (0);
}
Esempio n. 3
0
int				main(void)
{
	t_env	env;
	int		x;

	x = -1;
	init_env(&env);
	get_player(&env);
	while (1)
	{
		get_map(&env);
		get_piece(&env);
		if (contact_play(&env, 0, 0) != 1)
		{
			if (play(&env, 0, 0) != 1)
			{
				if (simple_play(&env) != 1)
				{
					ft_putstr("0 0\n");
					break ;
				}
			}
		}
		free_all(&env);
	}
	return (0);
}
Esempio n. 4
0
File: ft_printf.c Progetto: Selk/Dev
int		ft_printf(const char *format, ...)
{
	va_list		args;
	t_env		*env;

	va_start(args, format);
	env = init_env();
	while (format[env->i])
	{
		if (format[env->i] == '%' && env->flag == 0)
			init_flags(env);
		if (env->flag == 1 && check_flag(format[env->i]) != 0)
			add_flag(env, format[env->i], env->i);
		else if (ft_isdigit(format[env->i]) == 1 && env->flag == 1)
			env->i = get_width(format, env->i, env);
		else if (format[env->i] == '.'
			&& env->flag == 1 && ft_isdigit(format[++(env->i)]) == 1)
			env->i = get_precision(format, env->i, env);
		else if (env->flag == 1 && check_length(format[env->i]) != 0)
			add_length(env, format, &(env->i));
		else if (env->flag == 1 && check_specifier(format[env->i]) != 0)
			process(args, env, format[env->i]);
		else
			env->size += ft_putchar(format[env->i]);
		env->i++;
	}
	return (env->size);
}
Esempio n. 5
0
int		main(UNUSED int ac, UNUSED char **av, char **env)
{
  t_main	s;
  int		*jobs;

  if ((jobs = malloc(1 * sizeof(int))) == NULL)
    return (-1);
  jobs[0] = -1;
  jobs = update_jobs(jobs, 1);
  init_env(env, &s.my_env);
  init_history(&s.cmd, &s.history, &s.term, &s.stop);
  while (!s.stop && get_return_value(0, 0, 0, 0) == 0
	 && update_fils(0, -1) != -1)
    {
      save_pid(2, 0);
      get_signal();
      if ((s.paths = get_paths()) != NULL)
	end_main(&s);
      is_too_much(0);
    }
  end_shell(s.history, s.term);
  save_pid(2, 0);
  close_fg(jobs, 0);
  return (get_return_value(0, 0, 0, 1));
}
Esempio n. 6
0
int get_event_set(char *event_set, int wait) {
	int len;
	char link_path[BUF_SIZE];
	char file_path[BUF_SIZE];
	desc common_desc;

	common_desc = init_env(inot_dir, file_path, link_path);
	if ((common_desc.inot < 0) || (common_desc.file < 0) || \
			(common_desc.dir < 0) || (common_desc.link < 0)) {
		common_close(&common_desc);
		return -1;
	}
	if(test_actions(inot_dir, file_path, link_path) < 0) {
		common_close(&common_desc);
		return -1;
	}
	if (wait) {
		do_wait();
	}
	len = read_set(common_desc.inot, event_set);
	common_close(&common_desc);
#ifdef NODEL
	if (! (fDelete(file_path) == 0 &&
		fDelete(link_path) == 0 &&
		fRemDir(inot_dir) == 0))
		return -1;
#endif
	return len;
}
Esempio n. 7
0
int main() {

  init_env(); // Poorly named. Has nothing to do with env alist.
  init_mem();

  uptr_t *env = refer(NIL);
  init_syms(env);

  uptr_t *form_p = refer(NIL);
  while(1) {
    print_env(env);
    print_mem();

    printf_P(PSTR("> "));
    *form_p = read_form(stdin);
    while(getc(stdin) != '\r');
    print_form(eval(env, *form_p));
    printf_P(PSTR("\n"));

    //    print_mem();
    __GC__();
  }

  release(2); // Just a formality really...

  return 0;
}
Esempio n. 8
0
static void
print_trace(void)
{
  void *array[MAX_BACKTRACE];
  size_t size;
  char **strings;
  size_t i;

  if (backtrace_mode == 0)
    return;

  if (!mb_stream) {
    init_env();
    mb_stream = open_stream();
  }

  size = backtrace(array, backtrace_mode);
  strings = backtrace_symbols(array, size);

  fprintf(mb_stream, "# Obtained %zd stack frames.\n", size);

  for (i = 0; i < size; i++)
    fprintf(mb_stream, "# [BT] %d: %s\n", i, strings[i]);

  free (strings);
}
Esempio n. 9
0
int		main(int argc, char **argv)
{
	t_win	*window;
	t_cam	*cam;
	t_map	*map;

	/* Check argv */
	if (argc > 2 || argc == 1)
		ft_error("Too or not enough parameters in command line");
	/* Init Map */
	map = ft_init_map(argv[1]);
	/* Init Env */
	window = init_env();
	/* Init Camera */
	cam = ft_new_camera(map->start, M_PI / 2);

	/* Init img */
	window->img = init_img();

	mlx_do_key_autorepeaton(window->mlx);
	mlx_hook(window->win, 2, (1L << 0), ft_key_hook, window);
	mlx_expose_hook(window->win, ft_expose_hook, window);
	ft_draw_img();
	mlx_put_image_to_window(window->mlx, window->win, window->img->img, 0, 0);
	mlx_loop(window->mlx);


	/* Display view */
	/* Fini ! */
	return (0);
}
Esempio n. 10
0
int main(int argc, char **argv){

     signal(SIGINT, sig_trap);      

     init_env();
     
     if(argc <= 1){     
          
          in_shell();
     }
    
     else if(argc > 2){

          fprintf(stderr, "ERROR-- no more than one command line argument accepted (did not launch)\n");
          exit(-1);
     }

     else{     
  
          char f[MAX_BUFFER];              
          strcpy(f, argv[1]);  

          out_shell(f);
     }

return 0;
}
Esempio n. 11
0
int	init(t_env* env)
{
	if (init_env(env))
		return (1);
	env->status = 0;
	return 0;
}
Esempio n. 12
0
File: main.c Progetto: ale-naou/fdf
int			main(int ac, char **av)
{
	t_env	e;

	e.inf.h = 0.2;
	e.div = 2;
	if (ac >= 2 && ac <= 7)
	{
		if (ft_strcmp(av[1], "-help") == 0)
			aff_help();
		e.mlx = mlx_init();
		init_env(&e);
		read_args(&e, ac, av);
		parsing(&e, av[1]);
		e.inf.scale = (((e.arg.winx + e.arg.winy) / (e.p.lenx + e.p.leny)) / 2);
		e.inf.scale = e.inf.scale <= 0 ? 0.8 : e.inf.scale;
		e.orix = e.arg.winx / 2;
		e.oriy = e.arg.winy / e.p.leny;
		backup(&e);
		draw(&e);
	}
	else
		aff_help();
	return (0);
}
Esempio n. 13
0
int				main(int argc, char **argv, char **env_table)
{
	t_env		*env;
	char		*line;

	if (!(env = (t_env *)malloc(sizeof(t_env))))
		return (-1);
	init_env(env, env_table);
	write(1, PROMPT, sizeof(PROMPT) - 1);
	while (get_next_line(1, &env->line) > 0)
	{
		if (*env->line)
		{
			env->command = get_called_command(env->line);
			if (!strcmp(env->command, "env"))
				builtin_env(env);
			else if (!strcmp(env->command, "setenv"))
				builtin_setenv(env);
			else if (!strcmp(env->command, "unsetenv"))
				builtin_unsetenv(env);
			else if (!strcmp(env->command, "exit"))
				builtin_exit(env);
			else
				unknown_command(env->command);
		}
		write(1, PROMPT, sizeof(PROMPT) - 1);
	}
	return (0);
}
Esempio n. 14
0
File: main.c Progetto: bibop-qu/SH1
int		main(int ac, char **av, char **env)
{
	t_env	*e;
	char	*line;
	char	**cmd;
	char	**tab_e;

	e = NULL;
	line = NULL;
	tab_e = NULL;
	if (ac >= 1 && av && *env)
		e = init_env(e, env);
	while (42)
	{
		ft_putstr("$> ");
		get_next_line(0, &line);
		line = final_line(line, e);
		cmd = final_cmd(line);
		free(line);
		if (!cmd || cmd[0] == '\0')
			continue ;
		ft_loop(cmd, &e, tab_e);
	}
	return (0);
}
Esempio n. 15
0
void
mb_log(const char *fmt, ...)
{
  va_list ap;
  struct timeval tv;

  if (!mb_stream) {
    init_env();
    mb_stream = open_stream();
  }

  va_start(ap, fmt);

  if (gettimeofday(&tv, NULL) < 0)
    fprintf(stderr, "gettimeofday(2) failed: %s", strerror(errno));
  else {
    fprintf(mb_stream,
#if 0
            "%10lu:%06u.%06u:%10zu:",
            ++seq,
#else
            "%06u.%06u:%10zu:",
#endif  /* 0 */
            (unsigned)tv.tv_sec, (unsigned)tv.tv_usec, mb_allocated);
  }

  vfprintf(mb_stream, fmt, ap);
  fputc('\n', mb_stream);
  fflush(mb_stream);
  va_end(ap);
}
Esempio n. 16
0
void			apply_cd(char *command)
{
	char	**av;
	int		size;
	t_env	*env;

	av = ft_strsplit(command, ' ');
	size = av_size(av);
	env = init_env(NULL, 0);
	if (!parse_cd(av))
	{
		if (size == 1 || (size == 2 && !ft_strcmp(av[1], "-P"))
			|| (size == 2 && !ft_strcmp(av[1], "-L"))
			|| (size == 2 && !ft_strcmp(av[1], "~"))
			|| (size == 3 && !ft_strcmp(av[2], "~")))
		{
			if (!chdir(env->home))
				update_env(&env, "/nfs");
			set_flag(&env, 0);
		}
		else
			go_newdir(env, av[size - 1]);
		if (g_pid.built == -1)
			g_pid.built = 1;
	}
	del_av(av);
}
Esempio n. 17
0
int main(void)
{
	logfp = fopen(LOGFILE, "w+");
	if (NULL == logfp)
	{
		log_err("freopen failed on %s", LOGFILE);
		return 1;
	}

	errfp = freopen(ERRFILE, "w+", stderr);
	if (NULL == errfp)
	{
		log_err("freopen failed on %s", ERRFILE);
		return 1;
	}

	init_parser();
	environment = lenv_new();
	init_env(environment);

	// TODO a lot of these tests are functional tests rather than unit tests
	int ret = run_tests();

	lenv_del(environment);
	fclose(logfp);
	fclose(errfp);
	mpc_cleanup(7, Long, Double, Symbol, Qexpr, Sexpr, Expr, Lisp);
	return ret;
}
Esempio n. 18
0
/*!
 * The first call to the video code, called by oss_new() or similar.
 * Here we initialize the various components we use, namely SDL for display,
 * ffmpeg for encoding/decoding, and a local video source.
 * We do our best to progress even if some of the components are not
 * available.
 */
void console_video_start(struct video_desc *env, struct ast_channel *owner)
{
	ast_log(LOG_WARNING, "env %p chan %p\n", env, owner);
	if (env == NULL)	/* video not initialized */
		return;
	env->owner = owner;	/* work even if no owner is specified */
	if (env->vthread)
		return;		/* already initialized, nothing to do */
	init_env(env);
	env->out.enc = map_config_video_format(env->codec_name);

	ast_log(LOG_WARNING, "start video out %s %dx%d\n",
		env->codec_name, env->enc_in.w,  env->enc_in.h);
	/*
	 * Register all codecs supported by the ffmpeg library.
	 * We only need to do it once, but probably doesn't
	 * harm to do it multiple times.
	 */
	avcodec_init();
	avcodec_register_all();
	av_log_set_level(AV_LOG_ERROR);	/* only report errors */

	if (env->out.fps == 0) {
		env->out.fps = 15;
		ast_log(LOG_WARNING, "fps unset, forcing to %d\n", env->out.fps);
	}
	if (env->out.bitrate == 0) {
		env->out.bitrate = 65000;
		ast_log(LOG_WARNING, "bitrate unset, forcing to %d\n", env->out.bitrate);
	}
	/* create the thread as detached so memory is freed on termination */
	ast_pthread_create_detached_background(&env->vthread,
		NULL, video_thread, env);
}
Esempio n. 19
0
int main(int argc, char **argv)
{
  char *s;
#if 0 /* Shouldn't need this.. */
  signal(SIGHUP, SIG_IGN);
#endif

  /* initialize locale support */
  setlocale(LC_ALL, "");
  bindtextdomain(PACKAGE, LOCALEDIR);
  textdomain(PACKAGE);

  init_env();

  do_args(argc, argv);

  memset(inbuf, 0, sizeof(inbuf));

  if (argc > 2) {
    strncpy(logfname, argv[2], sizeof(logfname));
    if (argc > 3)
      strncpy(homedir, argv[3], sizeof(homedir));
    else if ((s = getenv("HOME")) != NULL)
      strncpy(homedir, s, sizeof(homedir));
    else
      homedir[0] = 0;
  }
  else
    logfname[0] = 0;

  return execscript(argv[1]) != OK;
}
Esempio n. 20
0
int				cd_fct(char *path)
{
	int			opt_p;
	char		*oldpwd;
	char		**tmp;
	t_env		*env;

	tmp = ft_strsplit(path, ' ');
	if ((opt_p = check_cd_path(&path, tmp)) < 0)
	{
		ft_putstr("cd: arguments invalid");
		del_tab(tmp);
		path = NULL;
		return (0);
	}
	oldpwd = NULL;
	oldpwd = getcwd(oldpwd, 0);
	env = init_env(NULL);
	if (change_directory(&path, env) != -1)
		update_env(path, oldpwd, env);
	else
		return (0);
	del_tab(tmp);
	return (1);
}
Esempio n. 21
0
File: main.c Progetto: adnank/RTOS
int main()
{
	int i;
	printf("Starting.....!\n");



	time_initialize();

	initialize_table();
//	printf("Initialization Table created and initialised!\n");

	init_env();
	init_timeout_Q();
	init_blkOnRsc_Q();
	init_blkOnEnv_Q();
//	printf("All Queues and Envelope Queues Initialized!\n");
    init_TraceArrays();
    init_helperprocess();
	init_ioBuffers();
	init_signals();
    printf("Initializing Signals!\n");



	init_processes();
//	printf("Initialising Processes!\n");




//	printf("KBD and CRT Processes initialized and forked!\n");

	return 0;
}
Esempio n. 22
0
static void     init_minishell(char **env)
{
  shell = xmalloc(sizeof(t_shell));
  shell->quit = 0;
  init_signals();
  init_builtins(shell);
  init_env(shell, env);
}
Esempio n. 23
0
int
main ()
{
  object *env = init_env ();
  print_version ();
  doREPL (&env);
  free_object (env);
  return 0;
}
Esempio n. 24
0
File: main.c Progetto: bloodead/Tron
int	init(t_env* env)
{
	init_env(env);
	tputs(env->cl, 1, id_put);
	init_shm(env);
	init_cadre(env);
	init_player(env);
	return (0);
}
Esempio n. 25
0
int	init(t_env* env, t_mur* mur)
{
	if (init_env(env))
		return (1);
	init_cadre(env);
	init_mur(mur, env);
	init_balle(env);
	init_barre(env);
	return 0;
}
Esempio n. 26
0
int	main(int ac, char **av)
{
	t_env	e;

	init_env(&e);
	get_opt(&e, ac, av);
	srv_create(&e, e.port);
	main_loop(&e);
	return (0);
}
Esempio n. 27
0
void	ft_draw_ceiling(int x, int y)
{
	t_win	*window;

	window = init_env();
	while (y > 0)
	{
		mlx_put_pixel_to_image(x, y, COLOR_CEILING);
		y--;
	}
}
Esempio n. 28
0
void	ft_draw_wall(int h_wall, int x, int y)
{
	t_win	*window;

	window = init_env();
	while (y < WIN_HEI / 2 + h_wall / 2 - 1)
	{
		mlx_put_pixel_to_image(x, y, COLOR_WALL);
		y++;
	}
}
Esempio n. 29
0
void	ft_draw_floor(int x, int y)
{
	t_win	*window;

	window = init_env();
	while (y < WIN_HEI - 1)
	{
		mlx_put_pixel_to_image(x, y, COLOR_FLOOR);
		y++;
	}
}
Esempio n. 30
0
File: main.c Progetto: jaybi42/fdf
static int	fdf(t_env *e, char *win_name)
{
	if (init_env(e, win_name) != 0)
		return (1);
	mlx_expose_hook(e->win, expose_hook, e);
	mlx_hook(e->win, 2, 0, key_hook, e);
	mlx_do_key_autorepeaton(e->mlx);
	mlx_loop_hook(e->mlx, loop_hook, e);
	mlx_loop(e->mlx);
	return (0);
}