/Home/aooliver/work/stagersvc/org.glite.data.lcg_gfal/src/gfal_testread.c File Reference

#include <fcntl.h>
#include <stdio.h>
#include "gfal_api.h"

Go to the source code of this file.

Defines

#define BLKLEN   65536

Functions

 main (int argc, char **argv)


Define Documentation

#define BLKLEN   65536
 

Definition at line 12 of file gfal_testread.c.

Referenced by main().


Function Documentation

main int  argc,
char **  argv
 

Definition at line 14 of file gfal_testread.c.

References BLKLEN, gfal_close(), gfal_open(), and gfal_read().

00015 {
00016         int fd;
00017         int i;
00018         char ibuf[BLKLEN];
00019         char obuf[BLKLEN];
00020         int rc;
00021 
00022         if (argc != 2) {
00023                 fprintf (stderr, "usage: %s filename\n", argv[0]);
00024                 exit (1);
00025         }
00026 
00027         for (i = 0; i < BLKLEN; i++)
00028                 obuf[i] = i;
00029 
00030         printf ("opening %s\n", argv[1]);
00031         if ((fd = gfal_open (argv[1], O_RDONLY, 0)) < 0) {
00032                 perror ("gfal_open");
00033                 exit (1);
00034         }
00035         printf ("open successful, fd = %d\n", fd);
00036 
00037         if ((rc = gfal_read (fd, ibuf, BLKLEN)) != BLKLEN) {
00038                 if (rc < 0)
00039                         perror ("gfal_read");
00040                 else
00041                         fprintf (stderr, "gfal_read returns %d\n", rc);
00042                 (void) gfal_close (fd);
00043                 exit (1);
00044         }
00045         printf ("read successful\n");
00046 
00047         if ((rc = gfal_close (fd)) < 0) {
00048                 perror ("gfal_close");
00049                 exit (1);
00050         }
00051         printf ("close successful\n");
00052 
00053         for (i = 0; i < BLKLEN; i++) {
00054                 if (ibuf[i] != obuf[i]) {
00055                         fprintf (stderr, "compare failed at offset %d\n", i);
00056                         exit (1);
00057                 }
00058         }
00059         printf ("compare successful\n");
00060         exit (0);
00061 }


Generated on Fri Sep 8 20:20:48 2006 for GFAL by  doxygen 1.4.6