Diff for /libaitio/example/test_bufio.c between versions 1.1.2.1 and 1.1.2.2

version 1.1.2.1, 2012/02/02 15:32:02 version 1.1.2.2, 2012/02/02 15:36:41
Line 1 Line 1
 #include <stdio.h>  #include <stdio.h>
   #include <stdlib.h>
   #include <string.h>
 #include <fcntl.h>  #include <fcntl.h>
 #include <sys/mman.h>  #include <sys/mman.h>
 #include <aitio.h>  #include <aitio.h>
Line 12  main(int argc, char **argv) Line 14  main(int argc, char **argv)
         void *p = NULL;          void *p = NULL;
   
         if (argc < 2)          if (argc < 2)
                f = io_fmapopen(NULL, 0, 0, PROT_READ | PROT_WRITE, 0, 20000);                f = io_fmapopen(NULL, 0, 0, PROT_READ | PROT_WRITE, 0, 2000);
         else          else
                 f = io_fmapopen(argv[1], O_RDWR, 0, PROT_READ | PROT_WRITE, MAP_SHARED, 0);                  f = io_fmapopen(argv[1], O_RDWR, 0, PROT_READ | PROT_WRITE, MAP_SHARED, 0);
         if (!f) {          if (!f) {
Line 22  main(int argc, char **argv) Line 24  main(int argc, char **argv)
   
         fwrite("123456789", 10, 1, f);          fwrite("123456789", 10, 1, f);
         fseek(f, 0, SEEK_SET);          fseek(f, 0, SEEK_SET);
           memset(b, 0, sizeof b);
         fread(b, sizeof b, 1, f);          fread(b, sizeof b, 1, f);
         printf("b=%s\n", b);          printf("b=%s\n", b);
 //      fread(b, sizeof b, 1, f);  //      fread(b, sizeof b, 1, f);
Line 32  main(int argc, char **argv) Line 35  main(int argc, char **argv)
         fseek(f, -10, SEEK_END);          fseek(f, -10, SEEK_END);
         fwrite("123456789", 10, 1, f);          fwrite("123456789", 10, 1, f);
         fseek(f, -10, SEEK_END);          fseek(f, -10, SEEK_END);
           memset(b, 0, sizeof b);
         fread(b, sizeof b, 1, f);          fread(b, sizeof b, 1, f);
         printf("2.b=%s\n", b);          printf("2.b=%s\n", b);
   
Line 39  main(int argc, char **argv) Line 43  main(int argc, char **argv)
   
         // part 2          // part 2
                   
        f = io_fmemopen(&p, 10000);        f = io_fmemopen(&p, 100);
         if (!f) {          if (!f) {
                 printf("Error:: #%d - %s\n", io_GetErrno(), io_GetError());                  printf("Error:: #%d - %s\n", io_GetErrno(), io_GetError());
                 return 2;                  return 2;
Line 47  main(int argc, char **argv) Line 51  main(int argc, char **argv)
   
         fwrite("123456789", 10, 1, f);          fwrite("123456789", 10, 1, f);
         fseek(f, 0, SEEK_SET);          fseek(f, 0, SEEK_SET);
           memset(b, 0, sizeof b);
         fread(b, sizeof b, 1, f);          fread(b, sizeof b, 1, f);
         printf("b=%s\n", b);          printf("b=%s\n", b);
 //      fread(b, sizeof b, 1, f);  //      fread(b, sizeof b, 1, f);
Line 57  main(int argc, char **argv) Line 62  main(int argc, char **argv)
         fseek(f, -10, SEEK_END);          fseek(f, -10, SEEK_END);
         fwrite("123456789", 10, 1, f);          fwrite("123456789", 10, 1, f);
         fseek(f, -10, SEEK_END);          fseek(f, -10, SEEK_END);
           memset(b, 0, sizeof b);
         fread(b, sizeof b, 1, f);          fread(b, sizeof b, 1, f);
         printf("2.b=%s\n", b);          printf("2.b=%s\n", b);
   
Line 73  main(int argc, char **argv) Line 79  main(int argc, char **argv)
   
         fwrite("123456789", 10, 1, f);          fwrite("123456789", 10, 1, f);
         fseek(f, 0, SEEK_SET);          fseek(f, 0, SEEK_SET);
           memset(b, 0, sizeof b);
         fread(b, sizeof b, 1, f);          fread(b, sizeof b, 1, f);
         printf("b=%s\n", b);          printf("b=%s\n", b);
 //      fread(b, sizeof b, 1, f);  //      fread(b, sizeof b, 1, f);
Line 83  main(int argc, char **argv) Line 90  main(int argc, char **argv)
         fseek(f, -10, SEEK_END);          fseek(f, -10, SEEK_END);
         fwrite("123456789", 10, 1, f);          fwrite("123456789", 10, 1, f);
         fseek(f, -10, SEEK_END);          fseek(f, -10, SEEK_END);
           memset(b, 0, sizeof b);
         fread(b, sizeof b, 1, f);          fread(b, sizeof b, 1, f);
         printf("2.b=%s\n", b);          printf("2.b=%s\n", b);
   

Removed from v.1.1.2.1  
changed lines
  Added in v.1.1.2.2


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>