1. Ivan Vučica
  2. Tapper

Commits

Ivan Vučica  committed 5a46bc5

Fixed bug reopening stdin and stdout when command line arguments are present. Improved pack.sh

  • Participants
  • Parent commits 57df2e8
  • Branches default

Comments (0)

Files changed (2)

File pack.sh

View file
  • Ignore whitespace
 rm the_package.sh
 
 echo "# source code for tapper" >> the_package.sh
+echo "echo 'deploying tapper.c'" >> the_package.sh
 echo "cat << __EOF > tapper.c" >> the_package.sh
 sed 's/\$/\\$/g' tapper.c >> the_package.sh
 echo "__EOF" >> the_package.sh
 
 echo "# twinpipe.sh" >> the_package.sh
+echo "echo 'deploying twinpipe.sh'" >> the_package.sh
 echo "cat << __EOF > twinpipe.sh" >> the_package.sh
 sed 's/\$/\\$/g' twinpipe.sh >> the_package.sh
 echo "__EOF" >> the_package.sh
 
 echo "# makefile for tapper" >> the_package.sh
+echo "echo 'deploying Makefile.sh'" >> the_package.sh
 echo "cat << __EOF > Makefile" >> the_package.sh
 sed 's/\$/\\$/g' Makefile >> the_package.sh
 echo "__EOF" >> the_package.sh
 
 echo "# quick launch script" >> the_package.sh
+echo "echo 'deploying go.sh'" >> the_package.sh
 echo "cat << __EOF > go.sh" >> the_package.sh
 cat >> the_package.sh << _PACKEOF
 CC=tcc make
 _PACKEOF
 echo "__EOF" >> the_package.sh
 
+echo "echo 'applying permissions'" >> the_package.sh
 echo "chmod +x go.sh" >> the_package.sh
 echo "chmod +x twinpipe.sh" >> the_package.sh
 
+echo "echo 'launching quickstart script go.sh'" >> the_package.sh
 echo "./go.sh" >> the_package.sh
+

File tapper.c

View file
  • Ignore whitespace
 		   - file we'll use for writing in place of stdout */
 		close(0);
 		close(1);
-		fopen(argv[1], "r");
-		fopen(argv[2], "w");
+		fopen(argv[argoff], "r");
+		fopen(argv[argoff+1], "w");
 	}
 
 
 					size_t ret = read(fd_int, buf, BUFFERSIZE);
 					if (!ret) 
 					{
-						warnx("read(): nothing to read");
+						errx(100, "read(): nothing to read expecting data");
 						continue;
 					}
-					if (ret < 0) err(ERR_READ_ERR, "read(%d)", fd_int);
+					if (ret < 0) err(ERR_READ_ERR, "read(%d) for data", fd_int);
 			
 					/* using headers? then the fd_oth is the stdout. first,
 					   send the number of bytes we'll dispatch */
 						int ret = read(fd_int, &expected_size, sizeof(uint16_t));
 						if(!ret)
 						{
-							warnx("read(): nothing to read");
+							errx(101, "read(): nothing to read expecting message size");
 							continue;
 						}
-						if (ret < 0) err(ERR_READ_ERR, "read(%d)", fd_int);
+						if (ret < 0) err(ERR_READ_ERR, "read(%d) for message size", fd_int);
 						
 						expected_size = ntohs(expected_size);
 						VERBOSE("now expecting %d bytes", expected_size);
 						int ret = read(fd_int, buf + current_buffer_content_size, bytes_left);
 						if(!ret)
 						{
-							warnx("read(): nothing to read");
+							errx(102, "read(): nothing to read expecting buffer content");
 							continue;
 						}
-						if (ret < 0) err(ERR_READ_ERR, "read(%d)", fd_int);
+						if (ret < 0) err(ERR_READ_ERR, "read(%d) for buffer content", fd_int);
 
 						current_buffer_content_size += ret;
 						VERBOSE("received %d bytes; buffer now %d/%d", ret, current_buffer_content_size, expected_size);