#include <aio.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <unistd.h>

struct aiocb * cb[2];

int main(void)
{
    struct sigaction action;
    //Create a buffer to store the read data
    char * foo = calloc(1,20);
    FILE * file = fopen("bar", "r+");

    //Allocate space for the aio control blocks
    cb[0] = calloc(1,sizeof(struct aiocb));
    cb[1] = calloc(1,sizeof(struct aiocb));
    //Somewhere to store the result
    cb[0]->aio_buf = foo;
    cb[1]->aio_buf = foo + 10;
    //The file to read from
    cb[0]->aio_fildes = fileno(file);
    cb[1]->aio_fildes = fileno(file);
    //The number of bytes to read, and the offset
    cb[0]->aio_nbytes = 10;
    cb[1]->aio_nbytes = 10;
    cb[0]->aio_offset = 0;
    cb[1]->aio_offset = 10;
    //Specify that these are read operations
    cb[0]->aio_lio_opcode = LIO_READ;
    cb[1]->aio_lio_opcode = LIO_READ;
    lio_listio(LIO_WAIT, cb, 2, NULL);
}