View of xos/usr/xsh/execute_cmd.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 EXECUTE_CMD_H
#define EXECUTE_CMD_H
 
struct simple_command_struct;
struct compound_command_struct;
struct command_struct;
struct pipeline_struct;
struct and_or_list_struct;
struct list_struct;
 
struct redirect_list_struct {
  struct redirect_struct *first;
  struct redirect_list_struct *next;
};
 
struct redirect_list_list_struct {
  struct redirect_list_struct *first;
  struct redirect_list_struct *last;
};
 
/* configuration de l'environnement d'execution */
struct exec_env_desc_struct {
  int line_number;              /* numero de ligne de la commande a executer */
  char *command;                /* libelle de la commande a executer */
  unsigned subshell : 1;        /* executer dans un sous-interpreteur */
  union {
    struct {
      unsigned no_fork : 1;     /* ne pas faire fork() sur une commande simple */
      unsigned builtin : 1;     /* environnement pour une commande interne */
    };
    struct {                    /* configuration du sous-interpreteur */
      struct running_pipeline_struct *running_pipeline; /* conduite courante ou NULL */
      int pipe_in_fd;           /* tube en lecture ou -1 */
      int fd_to_close;          /* descripteur de fichier a fermer ou -1 */
      int pipe_out_fd;          /* tube en ecriture ou -1 */
    };
  };
  struct redirect_list_list_struct redirect_list_list; /* redirections */
};
 
void redirect_list_list_init(struct redirect_list_list_struct *redirect_list_list);
void redirect_list_list_append(struct redirect_list_list_struct *redirect_list_list, struct redirect_list_struct *redirect_list);
 
void execute_command(const struct command_struct *command, struct exec_env_desc_struct *exec_env_desc);
void execute_pipeline(const struct pipeline_struct *pipeline, int asynchronous, struct exec_env_desc_struct *exec_env_desc);
void execute_and_or_list(const struct and_or_list_struct *and_or_list, struct exec_env_desc_struct *exec_env_desc);
void execute_list(const struct list_struct *list, struct exec_env_desc_struct *exec_env_desc);
 
#endif