Example #1
0
static	BOOL	check(t_get *link, t_header *head, char *line)
{
  line = link->line;
  if (NMATCH(NAME_CMD_STRING, line + hempty(line)))
    head->name =  get(NAME_CMD_STRING, line, 0, link->no);
  else if (NMATCH(COMMENT_CMD_STRING, line + hempty(line)))
    head->comment = get(COMMENT_CMD_STRING, line, 1, link->no);
  else
    {
      if (nempty(line, my_strilen(line, COMMENT_CHAR)))
	return (ERROR);
      else if (nempty(line, my_strilen(line, SCOMMENT_CHAR)))
	return (ERROR);
      if (IN(line, COMMENT_CHAR))
	{
	  link->line = my_strndup(line, my_strilen(line, COMMENT_CHAR));
	  free(line);
	}
      line = link->line;
      if (IN(line, SCOMMENT_CHAR))
	{
	  link->line = my_strndup(line, my_strilen(line, SCOMMENT_CHAR));
	  free(line);
	}
      return (CLEAN);
    }
  return (ERROR);
}
Example #2
0
void	scan_export(t_alias **alias)
{
  int		no;
  BOOL		c;
  char		*s;
  FD		file;

  c = TRUE;
  no = 0;
  if ((file = open_it()) == -1)
    return ;
  while ((s = get_next_line(file)) != NULL && c)
    {
      if (NMATCH("export", s))
	c = export_env(s + my_strlen("export")
		       + hempty(s + my_strlen("export")), no);
      else if (NMATCH("alias", s))
	c = export_alias(s + my_strlen("export")
			 + hempty(s + my_strlen("export")),
			 alias, no);
      else if (!nempty(s, my_strilen(s, '#')))
	return ;
      no++;
    }
}
Example #3
0
size_t subdiv(char *s, char **bad_sintax)
{
  if (NMATCH("||", s) || NMATCH("&&", s) || NMATCH("<<", s) || NMATCH(">>", s))
    return (2);
  if (my_sstrlen(s, "<>") < my_sstrlen(s, " \\\t\"'|&;()`") &&
      (my_sstrlen(s, "<>") == 1 || !my_sstrlen(s, "<>")))
    return (redir_lenth(s));
  if (s[0] == '"' || s[0] == '\'')
    return (work_on_quote(s, bad_sintax));
  if (IN(s[0], ";|&<>()`"))
    return (1);
  if (NMATCH(s + my_strilen(s, '&'), "&&") && my_strilen(s, '&')
      < my_sstrlen(s, " \\\t\"'|;<>()`"))
    return (my_strilen(s, '&'));
  return (my_sstrlen(s, " \\\t\"'|&;<>()`"));
}
Example #4
0
static void print_complo(char *dir, char *match)
{
  struct dirent *fchr;
  DIR	*d;

  if ((d = opendir(dir)) == NULL)
    return ;
  while ((fchr = readdir(d)) != NULL)
    if (!match || NMATCH(match, fchr->d_name))
      printf("%s\n", fchr->d_name);
  closedir(d);
}
Example #5
0
char	*get_full_env(char *s)
{
  size_t	i;

  i = 0;
  if (!environ)
    return (NULL);
  while (environ[i])
    {
      if (NMATCH(s, environ[i]))
	return (environ[i]);
      i++;
    }
  return (NULL);
}
Example #6
0
char	*get_env(char *s)
{
  size_t	i;

  i = 0;
  if (!environ)
    return (NULL);
  while (environ[i])
    {
      if (NMATCH(s, environ[i]))
	return (environ[i] + my_strilen(environ[i], '=') + 1);
      i++;
    }
  return (NULL);
}
Example #7
0
size_t	last_soccur(const char *s1, const char *s2)
{
  size_t	i;
  size_t	r;

  i = 0;
  r = 0;
  while (s1[i])
    {
      if (NMATCH(s2, s1 + i))
	r = i;
      i++;
    }
  return (r);
}
Example #8
0
static void	scan_line(CLASS_DISPLAY *d, FD xml, char *s)
{
  size_t	i;

  i = 0;
  while (((d->scan)[i]).call)
    {
      if (NMATCH(((d->scan)[i]).div, s + hempty(s)))
	{
	  (((d->scan)[i]).call)(d, xml, s);
	  return ;
	}
      i++;
    }
  fprintf(stderr, "error :%s not recognized", s);
  exit(-1);
}
Example #9
0
static BOOL check_fd(char *s, FD xml, FLAG i, char **r)
{
  while (s && NMATCH(OPEN_COMMENT, s += hempty(s)))
    s = move_to_end_comment(s, xml);
  *r = s;
  if (i == INIT && MATCH("<scene>", s + hempty(s)))
    return (TRUE);
  else if (i == INIT)
    return (FALSE);
  if ((s = (*r = get_next_line(xml))) == NULL)
    (void)lerror("no </scene> close");
  if (i == END && MATCH("</scene>", s + hempty(s)))
    return (FALSE);
  else if (i == END)
    return (TRUE);
  return (FALSE);
}
Example #10
0
static BOOL move_env(char *s, size_t i)
{
  if (NMATCH(s, environ[i]) && (environ[i][my_strlen(s)] == '='))
    return (TRUE);
  return (FALSE);
}