#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <err.h>
#include "../lpi.h"

int
main(void)
{
    int fd, nwrite;
    off_t cur;

    if ((fd = open("log", O_WRONLY)) == -1)
        err(EXIT_FAILURE, "open");

    if ((cur = lseek(fd, 100, SEEK_SET)) == -1)
        err(EXIT_FAILURE, "lseek");

    printf("offset set to=%ld\n", cur);

    printf("before=%ld\n", tell(fd));

    if ((nwrite = pwrite(fd, "salam", 5, 0)) == -1)
        err(EXIT_FAILURE, "pwrite");

    printf("after=%ld\n", tell(fd));

    exit(EXIT_SUCCESS);
}
