Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 13 Jun 2009 07:57:24 GMT
From:      Zhao Shuai <zhaoshuai@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 164243 for review
Message-ID:  <200906130757.n5D7vO5B055829@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=164243

Change 164243 by zhaoshuai@zhaoshuai on 2009/06/13 07:57:08

	-rename test_bid* to bid*
	-a little modification in rdwr.c

Affected files ...

.. //depot/projects/soc2009/fifo/fifo_test/functionality/Makefile#2 edit
.. //depot/projects/soc2009/fifo/fifo_test/functionality/bidirection1.c#1 add
.. //depot/projects/soc2009/fifo/fifo_test/functionality/bidirection2.c#1 add
.. //depot/projects/soc2009/fifo/fifo_test/functionality/rdwr.c#2 edit
.. //depot/projects/soc2009/fifo/fifo_test/functionality/test_bidirection1.c#2 delete
.. //depot/projects/soc2009/fifo/fifo_test/functionality/test_bidirection2.c#2 delete

Differences ...

==== //depot/projects/soc2009/fifo/fifo_test/functionality/Makefile#2 (text+ko) ====

@@ -1,5 +1,4 @@
-OBJS = rdwr reader1 reader2 writer1 test_bidirection1 test_bidirection2 \
-    select
+OBJS = rdwr reader1 reader2 writer1 bidirection1 bidirection2 select
 
 all : $(OBJS)
 
@@ -7,8 +6,8 @@
 reader1 : reader1.c
 reader2 : reader2.c
 writer1 : writer1.c
-test_bidirection1 : test_bidirection1.c
-test_bidirection2 : test_bidirection2.c
+bidirection1 : bidirection1.c
+bidirection2 : bidirection2.c
 select : select.c
 
 clean :

==== //depot/projects/soc2009/fifo/fifo_test/functionality/rdwr.c#2 (text+ko) ====

@@ -11,18 +11,19 @@
 
 int main(int argc, char *argv[])
 {
-	int fd;
-	char *string = "Hello World!";
-	int buffer[BUF_SIZE];
+	int fd, n;
+	int rbuf[BUF_SIZE], wbuf[BUF_SIZE];
 
 	if ((fd = open(FIFO_PATH, O_RDWR)) < 0) {
 		perror("open error");
 		return (1);
 	}
-	write(fd, string, strlen(string) + 1);
-	read(fd, buffer, BUF_SIZE);
-
-	printf("buffer content: %s\n", buffer);
+	while ((n = read(0, wbuf, BUF_SIZE)) > 0) {
+		write(fd, wbuf, n);
+		read(fd, rbuf, BUF_SIZE);
+		printf("%s", rbuf);
+		memset(rbuf, 0, BUF_SIZE);
+	}
 
 	return (0);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200906130757.n5D7vO5B055829>