From owner-p4-projects@FreeBSD.ORG Sat Jun 13 07:57:25 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id BCC071065670; Sat, 13 Jun 2009 07:57:24 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7BD89106564A for ; Sat, 13 Jun 2009 07:57:24 +0000 (UTC) (envelope-from zhaoshuai@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 69CD38FC15 for ; Sat, 13 Jun 2009 07:57:24 +0000 (UTC) (envelope-from zhaoshuai@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id n5D7vOj0055831 for ; Sat, 13 Jun 2009 07:57:24 GMT (envelope-from zhaoshuai@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id n5D7vO5B055829 for perforce@freebsd.org; Sat, 13 Jun 2009 07:57:24 GMT (envelope-from zhaoshuai@FreeBSD.org) Date: Sat, 13 Jun 2009 07:57:24 GMT Message-Id: <200906130757.n5D7vO5B055829@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to zhaoshuai@FreeBSD.org using -f From: Zhao Shuai To: Perforce Change Reviews Cc: Subject: PERFORCE change 164243 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 13 Jun 2009 07:57:26 -0000 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); }