1XDF_READ(3)                xdffileio library manual                XDF_READ(3)
2
3
4

NAME

6       xdf_read - Read samples from a xDF file
7

SYNOPSIS

9       #include <xdfio.h>
10
11       int xdf_read(struct xdf* xdf, unsigned int ns, ...);
12

DESCRIPTION

14       xdf_read()  reads  ns samples from the xDF file referenced by xdf. This
15       file  should  have  been  opened  with  mode  XDF_READ   and   xdf_pre‐
16       pare_arrays(3)  should have been successfully called on it.  xdf_read()
17       will fail otherwise).
18
19       The data to be read will be transferred into arrays specified by point‐
20       ers  provided  in  the variable list of arguments of the function.  The
21       function expects the same number of arrays  as  specified  by  previous
22       call  to xdf_define_arrays(3). The internal organisation of the data in
23       the  arrays  should  have  been  specified  previously  with  calls  to
24       xdf_set_chconf(3).
25
26       In  addition,  it  is  important to note that none of the arrays should
27       overlap.
28

RETURN VALUE

30       The function returns the number of the samples successfully  read  from
31       the  xDF  file  in  case  of success. The number of samples read can be
32       smaller than the number requested in the end of the file is reached. In
33       case of error, -1 is returned and errno is set appropriately.
34

ERRORS

36       EINVAL xdf is NULL
37
38       EPERM  No successfull call to xdf_prepare_transfer(3) have been done on
39              xdf or it has been opened using the mode XDF_WRITE.
40
41       EINTR  The call was interrupted by a signal before any data  was  writ‐
42              ten; see signal(7).
43
44       EIO    A low-level I/O error occurred while reading from the inode.
45
46       ESTALE Stale  file  handle.  This error can occur for NFS and for other
47              file systems
48

EXAMPLE

50              /* Assume xdf references a xDF file opened for reading whose
51              channels source their data in 2 arrays of float whose strides
52              are the length of respectively 4 and 6 float values,
53              i.e. 16 and 24 bytes (in most platforms)*/
54              #define NS    3
55              float array1[NS][4], array2[NS][6];
56              unsigned int strides = {4*sizeof(float), 6*sizeof(float)};
57              unsigned int i;
58
59              xdf_define_arrays(xdf, 2, strides);
60              if (xdf_prepare_transfer(xdf))
61                   return 1;
62
63              for (i=0; i<45; i+=NS) {
64                   /* Write the values to the file */
65                      if (xdf_write(xdf, NS, array1, array2))
66                        return 1;
67
68                   /* Use the values contained in array1 and array2*/
69                   ...
70
71              }
72
73              xdf_close(xdf);
74
75

SEE ALSO

77       xdf_set_chconf(3), xdf_define_arrays(3), xdf_prepare_transfer(3)
78
79
80
81
82
83
84EPFL                                 2010                          XDF_READ(3)
Impressum