Annotation of prex/usr/test/zero/zero.c, Revision 1.1
1.1 ! nbrk 1: /*
! 2: * Copyright (c) 2005, Kohsuke Ohtani
! 3: * All rights reserved.
! 4: *
! 5: * Redistribution and use in source and binary forms, with or without
! 6: * modification, are permitted provided that the following conditions
! 7: * are met:
! 8: * 1. Redistributions of source code must retain the above copyright
! 9: * notice, this list of conditions and the following disclaimer.
! 10: * 2. Redistributions in binary form must reproduce the above copyright
! 11: * notice, this list of conditions and the following disclaimer in the
! 12: * documentation and/or other materials provided with the distribution.
! 13: * 3. Neither the name of the author nor the names of any co-contributors
! 14: * may be used to endorse or promote products derived from this software
! 15: * without specific prior written permission.
! 16: *
! 17: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
! 18: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
! 19: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
! 20: * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
! 21: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
! 22: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
! 23: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
! 24: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
! 25: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
! 26: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
! 27: * SUCH DAMAGE.
! 28: */
! 29:
! 30: /*
! 31: * zero.c - test zero device driver.
! 32: */
! 33:
! 34: #include <prex/prex.h>
! 35: #include <stdio.h>
! 36: #include <string.h>
! 37:
! 38: static char buf[100];
! 39:
! 40: void
! 41: dump_buf(void)
! 42: {
! 43: int i;
! 44:
! 45: for (i = 0; i < 100; i++)
! 46: putchar(buf[i]);
! 47: putchar('\n');
! 48: }
! 49:
! 50: int
! 51: main(int argc, char *argv[])
! 52: {
! 53: device_t zero_dev;
! 54: int i, err;
! 55: size_t len;
! 56:
! 57: printf("zero test\n");
! 58:
! 59: /* 0000000000111111111122222.... */
! 60: for (i = 0; i < 100; i++)
! 61: buf[i] = '0' + i / 10;
! 62: dump_buf();
! 63:
! 64: err = device_open("zero", 0, &zero_dev);
! 65: if (err)
! 66: printf("device open error!\n");
! 67:
! 68: /* zero fill 50 character */
! 69: len = 50;
! 70: err = device_read(zero_dev, buf, &len, 0);
! 71: if (err)
! 72: printf("device read error!\n");
! 73:
! 74: /* 5555555555666666666777... */
! 75: dump_buf();
! 76:
! 77: return 0;
! 78: }
CVSweb