1  /**
   2   * This file defines a pipeline data structure that represents a shell command
   3   * line.  A pipeline is a list of command-line stages, defined by the clstage
   4   * structure.  A stage contains the name of a command, its redirected input,
   5   * redirected output, argc, and argv.
   6   *
   7   * To see what a pipeline looks like for a shell command, run the parse-cl
   8   * program.  It will dump the pipeline structure for each command line input
   9   * after the "what? " prompt.
  10   */
  11  
  12  #ifndef PIPELINE
  13  #define PIPELINE
  14  
  15  #include <stdio.h>
  16  #include <sys/types.h>
  17  #include "stringlist.h"
  18  
  19  typedef struct clstage *clstage;
  20  
  21  struct clstage {
  22    char *inname;                 /* input filename (or NULL for stdin) */
  23    char *outname;                /* output filename (NULL for stdout)  */
  24    int  argc;                    /* argc and argv for the child        */
  25    char **argv;                  /* Array for argv                     */
  26  
  27    clstage next;                 /* link pointer for listing in the parser */
  28  };
  29  
  30  typedef struct pipeline {
  31    char           *cline;              /* the original command line  */
  32    int            length;              /* length of the pipeline     */
  33    struct clstage *stage;              /* descriptors for the stages */
  34  } *pipeline;
  35  
  36  
  37  /* prototypes for pipeline.c */
  38  extern void     print_pipeline(FILE *where, pipeline cl);
  39  extern void     free_pipeline(pipeline cl);
  40  extern pipeline parse_pipeline(char *line);
  41  extern clstage  make_stage(slist l);
  42  extern void     free_stage(clstage s);
  43  extern void     free_stagelist(clstage s);
  44  extern clstage  append_stage(clstage s, clstage t);
  45  extern pipeline make_pipeline(clstage stages);
  46  extern int      check_pipeline(pipeline pl, int lineno);
  47  
  48  #endif