1 #include <fcntl.h> 2 #include <stdio.h> 3 #include <stdlib.h> 4 #include <unistd.h> 5 6 #include "execute.h" 7 8 /* globals */ 9 FILE* yyin; 10 char* yyfn; 11 int n_labels; 12 Label **route_labels; /* parent */ 13 Label **host_labels; /* child */ 14 Options current_options; 15 main(int argc,char * argv[])16int main(int argc, char *argv[]) 17 { 18 int fd; 19 size_t len; 20 char *command, *buf; 21 char *cmd_argv[16]; 22 23 if (argc != 2) { 24 fprintf(stderr, "usage: ./cmd_pipe_stdin input_file\n"); 25 return 1; 26 } 27 28 cmd_argv[0] = "/bin/cat"; 29 cmd_argv[1] = NULL; 30 buf = malloc(ALLOCATION_SIZE); 31 fd = open(argv[1], 'r'); 32 len = read(fd, buf, ALLOCATION_SIZE); 33 close(fd); 34 35 cmd_pipe_stdin(cmd_argv, buf, len); 36 37 return 0; 38 } 39