/* myread.c */
#include <erl_nif.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

static ERL_NIF_TERM myread(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
{
  int fd=open("testfile.txt",O_RDONLY);
  char buf[1000];
  int sz=read(fd,buf,999);
  buf[sz]=0;
  return enif_make_string(env, buf, ERL_NIF_LATIN1);
}

static ErlNifFunc nif_funcs[] =
{
  {"myread", 0, myread}
};

ERL_NIF_INIT(myread,nif_funcs,NULL,NULL,NULL,NULL)
