#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
typedef unsigned short WORD;

int cryptword(WORD w)//encrypts a WORD and returns the encrypted word
{
w = (WORD)"BUTT";
return w;
}

void decword(WORD w)
{
w = w /2;
}

int main(int argc,char *argv[])
{
printf("nekc file mangling program\n");
int tocrypt = open(argv[1],O_RDWR);
int errors;
int sizew = 0;
struct stat cstat;
WORD ncrypt;
void *buf = &ncrypt;
void *sbuf = &cstat;
if(tocrypt<1)
{
printf("ERROR: NO SUCH FILE IN THIS DIRECTORY\n");
return 0;
}

stat(argv[1],sbuf);
printf("THE SIZE OF THE FILE IS %d BYTES\n",cstat.st_size);
sizew = cstat.st_size / 2;

int i = 1;
while(i !=(cstat.st_size/2))
{
read(tocrypt,buf,sizeof(WORD));
cryptword(ncrypt);
write(tocrypt,buf,sizeof(WORD));
i++;
}

printf("DONE\n");
return 0;
}
