View of xos/usr/xsh/command.h


XOS | Parent Directory | View | Download

/* Copyright (C) 2008  Emmanuel Varoquaux
 
   This file is part of XOS.
 
   This program is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.
 
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
 
   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>. */
 
#ifndef COMMAND_H
#define COMMAND_H
 
/* types de redirections */
enum {RT_REDIRECT_INPUT, RT_REDIRECT_OUTPUT, RT_REDIRECT_OUTPUT_FORCE, RT_REDIRECT_OUTPUT_APPEND, RT_DUPLICATE_INPUT, RT_DUPLICATE_OUTPUT, RT_READ_WRITE};
 
/* types de commandes */
enum {CT_SIMPLE, CT_COMPOUND};
 
/* types de commandes composees */
enum {CC_SUBSHELL};
 
/* operateurs des listes AND-OR */
enum {AO_AND, AO_OR};
 
struct argument_struct {
  char *word;
  struct argument_struct *next;
};
 
struct redirect_struct {
  int fd;
  int type;
  char *filename;
  struct redirect_struct *next;
};
 
struct simple_command_struct {
  char *command_name;
  struct argument_struct *first_argument; /* si command_name n'est pas nul */
  struct redirect_struct *first_redirect;
};
 
struct compound_command_struct {
  int type;
  union {
    struct list_struct *list;   /* subshell */
  };
  struct redirect_struct *first_redirect;
};
 
struct command_struct {
  int line_number;
  int type;
  union {
    struct simple_command_struct simple_command;
    struct compound_command_struct compound_command;
  };
  struct command_struct *next;
};
 
struct pipeline_struct {
  int line_number;
  struct command_struct *first_command;
  struct pipeline_struct *next;
  int operator;                 /* AND ou OR, si next n'est pas nul */
};
 
struct and_or_list_struct {
  int line_number;
  struct pipeline_struct *first_pipeline;
  int asynchronous;             /* non nul si la liste est asynchrone */
  struct and_or_list_struct *next;
};
 
struct list_struct {
  int line_number;
  struct and_or_list_struct *first_and_or_list;
};
 
#endif