Exemplo n.º 1
0
Arquivo: tab.c Projeto: vcourtin/42.sh
int		tab_key(t_data *st, char **buff, int j)
{
	char	*word;
	char	*comp;
	int		ret;

	comp = NULL;
	word = get_curent_word(*buff, j - 1);
	if (word == NULL)
	{
		if ((word = bell_for_tab(*buff, j)) == NULL)
			return (j);
	}
	ret = ft_infolder(st, word, &comp);
	if (ret == 2)
	{
		delete_cmd(st, j);
		j = add_tab_to_buff(buff, j, comp, word);
		ft_putstr_term(*buff, st);
	}
	else if (ret == 3 || ret == 1)
		ft_putstr_term(*buff, st);
	else if (ret == 0)
		tputs(tgetstr("bl", NULL), 0, ft_outc);
	return (j);
}
Exemplo n.º 2
0
int
main(int argc, char *argv[]) {
	int exitstatus;

	setprogname(argv[0]);
	Pid = getpid();
	(void)setlocale(LC_ALL, "");

	euid = geteuid();
	egid = getegid();
	ruid = getuid();
	rgid = getgid();

	if (euid == ruid && ruid != 0)
		errx(ERROR_EXIT, "Not installed setuid root");

	(void)setvbuf(stderr, NULL, _IOLBF, 0);
	parse_args(argc, argv);		/* sets many globals, opens a file */
	set_cron_cwd();
	if (!allowed(RealUser, CRON_ALLOW, CRON_DENY)) {
		(void)fprintf(stderr,
			"You `%s' are not allowed to use this program `%s'\n",
			User, getprogname());
		(void)fprintf(stderr, "See crontab(1) for more information\n");
		log_it(RealUser, Pid, "AUTH", "crontab command not allowed");
		exit(ERROR_EXIT);
	}
	exitstatus = OK_EXIT;
	switch (Option) {
	case opt_unknown:
		usage("unrecognized option");
		exitstatus = ERROR_EXIT;
		break;
	case opt_list:
		list_cmd();
		break;
	case opt_delete:
		delete_cmd();
		break;
	case opt_edit:
		edit_cmd();
		break;
	case opt_replace:
		if (replace_cmd() < 0)
			exitstatus = ERROR_EXIT;
		break;
	default:
		abort();
	}
	exit(exitstatus);
	/*NOTREACHED*/
}
Exemplo n.º 3
0
int
main (int argc, char *argv[])
{
  int exitstatus;
  char *config_file;		/* Name of our configuration file;  NULL if none */

  Pid = getpid ();
  ProgramName = argv[0];

#if defined(POSIX)
  setlocale (LC_ALL, "");
#endif

#if HAVE_SETLINEBUF
  setlinebuf (stderr);
#endif /*HAVE_SETLINEBUF */
  parse_args (argc, argv, &config_file);	/* sets many globals, opens a file */

  read_config (config_file, &allow_only_root, &log_syslog, &allow_file,
	       &deny_file, &crondir, &spool_dir, &log_file, &syscrontab,
	       &lastrun_file, &pidfile, &mailprog, &mailargs);

  set_cron_cwd ();
  if (!allowed (User))
    {
      fprintf (stderr,
	       "You (%s) are not allowed to use this program (%s)\n",
	       User, ProgramName);
      fprintf (stderr, "See crontab(1) for more information\n");
      log_it (RealUser, Pid, "AUTH", "crontab command not allowed");
      exit (ERROR_EXIT);
    }
  exitstatus = OK_EXIT;
  switch (Option)
    {
    case opt_list:
      list_cmd ();
      break;
    case opt_delete:
      delete_cmd ();
      break;
    case opt_edit:
      edit_cmd ();
      break;
    case opt_replace:
      if (replace_cmd () < 0)
	exitstatus = ERROR_EXIT;
      break;
    }
  exit (0);
 /*NOTREACHED*/}
Exemplo n.º 4
0
char	*func1(t_data *st, int *i, char *newbuff, char *stdin)
{
	if (stdin[0] == 127)
	{
		if (newbuff[0] != '\0' && *i != 0)
		{
			delete_cmd(st, *i);
			newbuff = ft_delete(*i, newbuff);
			ft_putstr_complete(newbuff, st);
			back_to_j(newbuff, (*i) - 2);
			(*i)--;
		}
	}
	else
	{
		delete_cmd(st, *i);
		newbuff = add_to_tab(newbuff, stdin[0], *i);
		ft_putstr_complete(newbuff, st);
		back_to_j(newbuff, *i);
		(*i)++;
	}
	return (newbuff);
}
Exemplo n.º 5
0
static void
kod_set_os (char *arg, int from_tty, struct cmd_list_element *command)
{
  char *p;

  /* If we had already had an open OS, close it.  */
  if (gdb_kod_close)
    (*gdb_kod_close) ();

  /* Also remove the old OS's command.  */
  if (old_operating_system)
    {
      delete_cmd (old_operating_system, &infolist);
      xfree (old_operating_system);
    }

  if (! operating_system || ! *operating_system)
    {
      /* If user set operating system to empty, we want to forget we
	 had a module open.  Setting these variables is just nice for
	 debugging and clarity.  */
      gdb_kod_open = NULL;
      gdb_kod_request = NULL;
      gdb_kod_close = NULL;
    }
  else
    {
      char *kodlib;

      old_operating_system = xstrdup (operating_system);

      load_kod_library (operating_system);

      kodlib = (*gdb_kod_open) (gdb_kod_display, gdb_kod_query);

      /* Add kod related info commands to gdb.  */
      add_info (operating_system, info_kod_command,
		_("Displays information about Kernel Objects."));

      p = strrchr (kodlib, '-');
      if (p != NULL)
	p++;
      else
	p = "Unknown KOD library";
      printf_filtered ("%s - %s\n", operating_system, p);

      xfree (kodlib);
    }
}
Exemplo n.º 6
0
int
main(int argc, char *argv[])
{
	int	exitstatus;

	Pid = getpid();
	ProgramName = argv[0];

#if defined(POSIX)
	setlocale(LC_ALL, "");
#endif

#if defined(BSD)
	setlinebuf(stderr);
#endif
	parse_args(argc, argv);		/* sets many globals, opens a file */
	set_cron_uid();
	set_cron_cwd();
	if (!allowed(User)) {
		warnx("you (%s) are not allowed to use this program", User);
		log_it(RealUser, Pid, "AUTH", "crontab command not allowed");
		exit(ERROR_EXIT);
	}
	exitstatus = OK_EXIT;
	switch (Option) {
	case opt_list:		list_cmd();
				break;
	case opt_delete:	delete_cmd();
				break;
	case opt_edit:		edit_cmd();
				break;
	case opt_replace:	if (replace_cmd() < 0)
					exitstatus = ERROR_EXIT;
				break;
	case opt_unknown:
				break;
	}
	exit(exitstatus);
	/*NOTREACHED*/
}
Exemplo n.º 7
0
static void
kod_set_os (char *arg, int from_tty, struct cmd_list_element *command)
{
  char *p;

  /* NOTE: cagney/2002-03-17: The add_show_from_set() function clones
     the set command passed as a parameter.  The clone operation will
     include (BUG?) any ``set'' command callback, if present.
     Commands like ``info set'' call all the ``show'' command
     callbacks.  Unfortunately, for ``show'' commands cloned from
     ``set'', this includes callbacks belonging to ``set'' commands.
     Making this worse, this only occures if add_show_from_set() is
     called after add_cmd_sfunc() (BUG?).  */

  if (cmd_type (command) != set_cmd)
    return;

  /* If we had already had an open OS, close it.  */
  if (gdb_kod_close)
    (*gdb_kod_close) ();

  /* Also remove the old OS's command.  */
  if (old_operating_system)
    {
      delete_cmd (old_operating_system, &infolist);
      xfree (old_operating_system);
    }

  if (! operating_system || ! *operating_system)
    {
      /* If user set operating system to empty, we want to forget we
	 had a module open.  Setting these variables is just nice for
	 debugging and clarity.  */
      gdb_kod_open = NULL;
      gdb_kod_request = NULL;
      gdb_kod_close = NULL;
    }
  else
    {
      char *kodlib;

      old_operating_system = xstrdup (operating_system);

      load_kod_library (operating_system);

      kodlib = (*gdb_kod_open) (gdb_kod_display, gdb_kod_query);

      /* Add kod related info commands to gdb.  */
      add_info (operating_system, info_kod_command,
		"Displays information about Kernel Objects.");

      p = strrchr (kodlib, '-');
      if (p != NULL)
	p++;
      else
	p = "Unknown KOD library";
      printf_filtered ("%s - %s\n", operating_system, p);

      xfree (kodlib);
    }
}