head 1.47;
access;
symbols;
locks
root:1.47; strict;
comment @ * @;
1.47
date 2014.06.08.07.52.37; author root; state Exp;
branches;
next 1.46;
1.46
date 2014.06.07.16.31.29; author root; state Exp;
branches;
next 1.45;
1.45
date 2014.06.07.16.21.15; author root; state Exp;
branches
1.45.1.1;
next 1.44;
1.44
date 2014.06.07.16.06.07; author root; state Exp;
branches;
next 1.43;
1.43
date 2014.06.07.16.05.31; author root; state Exp;
branches;
next 1.42;
1.42
date 2014.06.07.16.04.35; author root; state Exp;
branches;
next 1.41;
1.41
date 2014.06.07.16.00.50; author root; state Exp;
branches;
next 1.40;
1.40
date 2014.06.07.09.48.05; author root; state Exp;
branches;
next 1.39;
1.39
date 2014.06.06.11.25.18; author root; state Exp;
branches;
next 1.38;
1.38
date 2014.06.06.11.00.51; author root; state Exp;
branches;
next 1.37;
1.37
date 2014.06.06.10.40.07; author root; state Exp;
branches;
next 1.36;
1.36
date 2014.06.06.10.36.52; author root; state Exp;
branches;
next 1.35;
1.35
date 2014.06.06.07.30.42; author root; state Exp;
branches;
next 1.34;
1.34
date 2014.06.06.07.29.14; author root; state Exp;
branches;
next 1.33;
1.33
date 2014.06.06.06.32.11; author root; state Exp;
branches;
next 1.32;
1.32
date 2014.06.06.06.29.27; author root; state Exp;
branches;
next 1.31;
1.31
date 2014.06.06.06.25.43; author root; state Exp;
branches;
next 1.30;
1.30
date 2014.06.06.06.25.02; author root; state Exp;
branches;
next 1.29;
1.29
date 2014.06.06.06.24.11; author root; state Exp;
branches;
next 1.28;
1.28
date 2014.06.06.06.21.01; author root; state Exp;
branches;
next 1.27;
1.27
date 2014.06.06.06.18.33; author root; state Exp;
branches;
next 1.26;
1.26
date 2014.06.06.06.11.46; author root; state Exp;
branches;
next 1.25;
1.25
date 2014.06.06.06.10.41; author root; state Exp;
branches;
next 1.24;
1.24
date 2014.06.06.06.08.21; author root; state Exp;
branches;
next 1.23;
1.23
date 2014.06.06.06.01.28; author root; state Exp;
branches;
next 1.22;
1.22
date 2014.06.06.05.56.12; author root; state Exp;
branches;
next 1.21;
1.21
date 2014.06.06.05.55.18; author root; state Exp;
branches;
next 1.20;
1.20
date 2014.06.06.05.53.59; author root; state Exp;
branches;
next 1.19;
1.19
date 2014.06.06.05.47.16; author root; state Exp;
branches;
next 1.18;
1.18
date 2014.06.06.05.41.57; author root; state Exp;
branches;
next 1.17;
1.17
date 2014.06.06.05.37.18; author root; state Exp;
branches;
next 1.16;
1.16
date 2014.06.03.09.37.34; author root; state Exp;
branches;
next 1.15;
1.15
date 2014.06.03.09.32.41; author root; state Exp;
branches;
next 1.14;
1.14
date 2014.06.03.09.32.10; author root; state Exp;
branches;
next 1.13;
1.13
date 2014.06.03.09.01.19; author root; state Exp;
branches;
next 1.12;
1.12
date 2014.06.03.09.00.33; author root; state Exp;
branches;
next 1.11;
1.11
date 2014.06.03.08.57.27; author root; state Exp;
branches;
next 1.10;
1.10
date 2014.06.03.08.55.36; author root; state Exp;
branches;
next 1.9;
1.9
date 2014.06.03.08.54.19; author root; state Exp;
branches;
next 1.8;
1.8
date 2014.06.03.08.53.22; author root; state Exp;
branches;
next 1.7;
1.7
date 2014.06.03.08.52.23; author root; state Exp;
branches;
next 1.6;
1.6
date 2014.06.03.08.51.19; author root; state Exp;
branches;
next 1.5;
1.5
date 2014.06.03.08.48.55; author raman; state Exp;
branches;
next 1.4;
1.4
date 2014.06.03.08.47.22; author raman; state Exp;
branches;
next 1.3;
1.3
date 2014.06.03.08.45.30; author raman; state Exp;
branches;
next 1.2;
1.2
date 2014.06.03.08.39.27; author raman; state Exp;
branches;
next 1.1;
1.1
date 2014.06.03.07.13.37; author raman; state Exp;
branches;
next ;
1.45.1.1
date 2014.06.08.08.12.17; author root; state Exp;
branches;
next ;
desc
@creation of main funcion and open_file
@
1.47
log
@*** empty log message ***
@
text
@#include”header.h”
int open_file(char *filename)
{
int fd;
fd=open(filename,O_RDONLY);
if(fd<0)
{ perror(“file not open”);
goto out;
}
return fd;
out:
return -1;
}
char *masterarray(int fd)
{
int i=0,nread;
char *masterarr;
char ch;
masterarr=(char *)malloc(sizeof(char));
while(1)
{
int j=0,flag=0;
nread=read(fd,&ch,1);
// printf(“%c\n”,ch);
if(ch==10)
break;
// *(masterarr+j)=ch;
// masterarr=(char *)realloc(masterarr,1+i);
for(j=0;j<i;j++)
{
if(*(masterarr+j)==ch)
{
flag=1;
}
}
if(flag==0)
{
*(masterarr+i)=ch;
masterarr=realloc(masterarr,1+i);
i++;
}
flag=0;
}
printf(“\n masterarray is :%s”,masterarr);
return masterarr;
}
compression(char *p,int fd)
{
printf(“\n string is :%s”,p);
unsigned char ch,byt,byt1;
unsigned int loc=0;
int count=0,nread,nwrite,i=0,j,fdw,count1=0,count2=0;
int no_of_char;
no_of_char=lseek(fd,0,SEEK_END);
printf(“\n no. of character is :%d”,no_of_char);
lseek(fd,0,SEEK_SET);
fdw=open(“comprsd_file”,O_RDWR |O_CREAT);
printf(“\n fdw=%d”,fdw);
while(1)
{
nread=read(fd,&ch,1);
// printf(“%c”,ch);
i=0;
if(ch==10)
break;
for(i=0;*(p+i)!=ch;i++)
{
}
loc=i;
printf(“\n loc %d :%d”,count2,loc);
count2++;
// sprintf(&byt,”%d”,loc);
byt=loc;
if(count==0)
{
byt1=byt;
byt1<<=4;
count++;
}
else
{
byt<<=4;
byt>>=4;
byt=byt1|byt;
count=0;
nwrite=write(fdw,&byt,1);
printf(“\t char written :%c”,byt);
count1++;
byt^=byt;
byt1^=byt1;
}
}
close(fdw);
fdw=open(“encryption_key”,O_RDWR |O_CREAT);
nwrite=write(fdw,p,strlen(p));
printf(“\nno. of bytes write :%d”,count1);
return 0;
}
int main(int argc,char *argv[])
{
int fd;
char *masterarr;
masterarr=(char *)malloc(sizeof(char));
if(argc!=2)
{
printf(“argument error”);
goto out;
}
fd=open_file(argv[1]);
printf(“fd=%d”,fd);
masterarr=masterarray(fd);
printf(“length :%d”,strlen(masterarr));
compression(masterarr,fd);
// printf(“\n masterarray is :%s \n”,masterarr);
return 0;
out:
return -1;
}
@
1.46
log
@*** empty log message ***
@
text
@d79 1
a79 6
if(count2%2!=0 && count2==no_of_char-1 && count==0)
{
write(fdw,&byt,1);
}
else if(count==0)
@
1.45
log
@to remove the problem of last character .
if the no. of char is odd
then put the last character in byte and write it
@
text
@d79 1
a79 1
if(count2%2==0 && count2==no_of_char-1 && count==0)
@
1.45.1.1
log
@work for the last character
when no. of character is odd
@
text
@d79 6
a84 1
if(count==0)
@
1.44
log
@*** empty log message ***
@
text
@d55 1
a55 1
unsigned loc=0;
d79 6
a84 1
if(count==0)
@
1.43
log
@*** empty log message ***
@
text
@d57 1
a57 1
int no_of _char;
@
1.42
log
@corecting the error
@
text
@d57 2
a58 1
int no_of _char=lseek(fd,0,SEEK_END);
@
1.41
log
@checking the number of character.is it even or odd
@
text
@d56 1
a56 1
int count=0,nread,nwrite,i=0,j,fdw,count1=0,count2=0;i
@
1.40
log
@*** empty log message ***
@
text
@d56 3
a58 1
int count=0,nread,nwrite,i=0,j,fdw,count1=0,count2=0;
@
1.39
log
@*** empty log message ***
@
text
@d116 1
@
1.38
log
@checking encrypted code
@
text
@d74 2
a75 1
sprintf(&byt,”%d”,loc);
@
1.37
log
@*** empty log message ***
@
text
@d89 1
@
1.36
log
@*** empty log message ***
@
text
@d55 2
a56 1
int count=0,nread,nwrite,i=0,j,fdw,loc=0,count1=0,count2=0;
@
1.35
log
@*** empty log message ***
@
text
@d55 1
a55 1
int count=0,nread,nwrite,i=0,j,fdw,loc=0,count1=0;
d71 2
a72 1
printf(“\n loc :%d”,loc);
@
1.34
log
@creating encryption_key file
@
text
@d95 1
a95 1
nwrite=write(fdw,masterarr,strlen(masterarr));
@
1.33
log
@*** empty log message ***
@
text
@d93 3
@
1.32
log
@*** empty log message ***
@
text
@a67 1
loc=i;
d70 1
@
1.31
log
@*** empty log message ***
@
text
@d55 1
a55 1
int count=0,nread,nwrite,i=0,j,fdw,loc,count1=0;
@
1.30
log
@*** empty log message ***
@
text
@d69 1
a69 1
break;
@
1.29
log
@*** empty log message ***
@
text
@d66 1
a66 1
for(i=0;*(p+i)==ch;i++)
@
1.28
log
@checking location
@
text
@d69 1
a69 1
@
1.27
log
@*** empty log message ***
@
text
@d71 1
a71 1
@
1.26
log
@*** empty log message ***
@
text
@d77 1
d80 1
a80 1
if(count==1)
d91 1
a91 1
count++;
@
1.25
log
@*** empty log message ***
@
text
@d77 1
a77 1
count++;
d90 1
@
1.24
log
@*** empty log message ***
@
text
@d86 1
a86 1
d91 1
@
1.23
log
@*** empty log message ***
@
text
@d55 1
a55 1
int count=0,nread,nwrite,i=0,j,fdw,loc;
d71 1
d79 1
a79 1
if(count=1)
d86 1
@
1.22
log
@*** empty log message ***
@
text
@d66 1
a66 1
while(p[i]==ch)
d69 1
a69 1
i++;
@
1.21
log
@*** empty log message ***
@
text
@d62 2
a63 1
printf(“%c”,ch);
@
1.20
log
@*** empty log message ***
@
text
@d62 1
@
1.19
log
@*** empty log message ***
@
text
@d53 1
d58 1
@
1.18
log
@resolve error msg
@
text
@d59 25
a83 25
nread=read(fd,&ch,1);
if(ch==10)
break;
while(p[i]==ch)
{
loc=i;
i++;
}
sprintf(&byt,”%d”,loc);
if(count==0)
{
byt1=byt;
byt1<<=4;
count++;
}
if(count=1)
{
byt<<=4;
byt>>=4;
byt=byt1|byt;
count=0;
nwrite=write(fdw,&byt,1);
byt^=byt;
byt1^=byt1;
@
1.17
log
@creating the compressed file using compress function
the comprsd_file contain the encryted data
@
text
@d54 1
a54 1
int count=0,nread,nwrite,i=0,j,fdw;
d97 1
a97 1
fd=open_file(argerav[1]);
@
1.16
log
@*** empty log message ***
@
text
@d51 36
d97 1
a97 1
fd=open_file(argv[1]);
d100 1
@
1.15
log
@*** empty log message ***
@
text
@d28 2
a29 2
*(masterarr+i)=ch;
masterarr=(char *)realloc(masterarr,1+i);
d41 2
d44 2
a45 1
i++;
@
1.14
log
@*** empty log message ***
@
text
@d22 1
a22 1
int j=0;flag=0;
@
1.13
log
@*** empty log message ***
@
text
@d22 1
d30 12
d44 1
a44 1
// printf(“\n masterarray is :%s”,masterarr);
d61 1
a61 1
printf(“\n masterarray is :%s \n”,masterarr);
@
1.12
log
@*** empty log message ***
@
text
@d48 1
a48 1
printf(“\n masterarray is %s :”,masterarr);
@
1.11
log
@*** empty log message ***
@
text
@d31 1
a31 1
printf(“\n masterarray is :%s”,masterarr);
d48 1
@
1.10
log
@*** empty log message ***
@
text
@d26 1
a26 1
goto out;
d33 1
a33 2
out:
return -1;
@
1.9
log
@*** empty log message ***
@
text
@d20 1
a20 1
while(nread)
@
1.8
log
@*** empty log message ***
@
text
@d25 2
a26 2
//if(ch==10)
//goto out;
@
1.7
log
@*** empty log message ***
@
text
@d27 1
a27 1
*masterarr=ch;
@
1.6
log
@*** empty log message ***
@
text
@d23 1
a23 1
printf(“%c\n”,ch);
@
1.5
log
@*** empty log message ***
@
text
@d16 1
a16 1
int i=0;
d20 1
a20 1
while(1)
d22 1
a22 1
read(fd,&ch,1);
@
1.4
log
@*** empty log message ***
@
text
@d25 2
a26 2
if(ch==10)
goto out;
@
1.3
log
@*** empty log message ***
@
text
@d23 2
@
1.2
log
@definition of masterarray()
@
text
@d17 1
a17 1
char *p;
d19 1
a19 1
p=(char *)malloc(sizeof(char));
d24 1
a24 1
goto out;
d30 1
a30 1
return 0;
@
1.1
log
@Initial revision
@
text
@d14 20
a33 1
d37 2
d46 1
a46 1
@