Example #1
0
static char	*replace_histo_nb(char *str, int *curs, t_history **history)
{
  char		*exp_begin;
  char		*exp_end;
  int		begin;
  char		*send;

  begin = *curs;
  while (str[++(*curs)] && str[(*curs)] != ' ' && str[(*curs)] != '\t' &&
	 str[(*curs)] != '!' && str[(*curs)] != '"');
  if ((exp_begin = cut_chain(0, begin, str)) == NULL)
    return (str);
  if ((exp_end = cut_chain(*curs, strlen(str), str)) == NULL)
    {
      xfree(exp_begin);
      return (str);
    }
  if ((send = cut_chain(begin, *curs, str)) == NULL)
    {
      xfree(exp_end);
      return (str);
    }
  if ((send = paste_str(exp_begin, send, exp_end, history)) == NULL)
    return (str);
  *curs = -1;
  return (send);
}
Example #2
0
/* Seperate standard mount options from the nonstandard string options */
static void
parse_mount_options(char *options, int *flags, char **strflags)
{
	while (options) {
		int gotone = FALSE;
		char *comma = strchr(options, ',');
		const struct mount_options *f = mount_options;

		if (comma)
			*comma = '\0';

		while (f->name != 0) {
			if (strcasecmp(f->name, options) == 0) {

				*flags &= f->and;
				*flags |= f->or;
				gotone = TRUE;
				break;
			}
			f++;
		}
#if defined BB_FEATURE_MOUNT_LOOP
		if (!strcasecmp("loop", options)) { /* loop device support */
			use_loop = TRUE;
			gotone = TRUE;
		}
#endif
		if (! gotone) {
			if (**strflags) /* have previous parsed options */
				paste_str(strflags, ",");
			paste_str(strflags, options);
		}
		if (comma) {
			*comma = ',';
			options = ++comma;
		} else {
			break;
		}
	}
}
Example #3
0
static char	*replace_com(char *str, int *curs, t_history **history)
{
  char		*exp_begin;
  char		*exp_end;
  char		*send;

  if ((exp_begin = cut_chain(0, *curs, str)) == NULL)
    return (str);
  if ((exp_end = cut_chain(*curs + 2, strlen(str), str)) == NULL)
    {
      xfree(exp_begin);
      return (str);
    }
  if ((send = cut_chain(*curs, *curs + 2, str)) == NULL)
    {
      xfree(exp_end);
      return (str);
    }
  (*curs) += 2;
  if ((send = paste_str(exp_begin, send, exp_end, history)) == NULL)
    return (str);
  *curs = -1;
  return (send);
}