head 1.9;
access;
symbols;
locks
ashish:1.9;
comment @ * @;
1.9
date 2014.08.05.09.49.46; author ashish; state Exp;
branches;
next 1.8;
1.8
date 2014.08.05.08.45.35; author root; state Exp;
branches;
next 1.7;
1.7
date 2014.08.05.08.26.02; author root; state Exp;
branches;
next 1.6;
1.6
date 2014.08.05.08.18.03; author root; state Exp;
branches;
next 1.5;
1.5
date 2014.08.05.08.15.13; author root; state Exp;
branches;
next 1.4;
1.4
date 2014.08.05.08.00.44; author root; state Exp;
branches;
next 1.3;
1.3
date 2014.08.05.07.44.39; author root; state Exp;
branches;
next 1.2;
1.2
date 2014.08.05.07.36.55; author root; state Exp;
branches;
next 1.1;
1.1
date 2014.08.05.07.30.53; author root; state Exp;
branches;
next ;
desc
@added a function for opening a file
@
1.9
log
@make the proper format
@
text
@#include"header.h"
int main(int argc,char*argv[])
{
if(argc<2)
{ printf("error\n");
goto OUT;
}
fd=fileopen();
len=read_file(fd);
val=codlen(len);
returnval=compression(val);
return 0;
OUT:
return -1;
}
int fileopen()
{
int fd;
fd=open("ash", O_RDONLY);
printf("fd is %d\n",fd);
return fd;
}
int read_file(int fd)
{
int c=0,i=0,ndc=0,count=1;
char *ms,ch;
while(count)
{
count=read(fd,&ch,1);
if(ch==10)
break;
if(ndc==0)
{
ms=malloc(sizeof(char));
*(ms+ndc)=ch;
ndc++;
i++;
}
else if(ndc>=1)
{
for(i=0;i<ndc;i++)
{
if(ch==*(ms+i))
{
c=1;
break;
}
else
c=0;
}
if(c==0)
{
ms=realloc(ms,ndc+1);
*(ms+i)=ch;
ndc++;
i++;
}
}
c++;
}
printf("ms==%s\n",ms);
printf("no. of unique character is=%d\n",ndc);
return ndc;
}
int codlen(int len)
{
int k=0;
while(len)
{
len=len/2;
k++;
}
printf("code lenght =%d\n",k);
return 1;
}
int compression(int val)
{
int leng;
switch(val)
{
case 1: leng=1;
break;
case 2: leng=2;
break;
case 3: leng=3;
break;
case 4: leng=4;
break;
case 5: leng=5;
break;
case 6: leng=6;
break;
case 7: leng=7;
break;
}
return leng;
}
@
1.8
log
@declaring a function for compression
@
text
@d1 1
a1 3
#include<stdio.h>
#include<fcntl.h>
#include<stdlib.h>
a2 1
int fileopen();
a3 11
int read_file(int);
int codlen(int);
int compression(int,char,int);
{
leng= compress1(fd,ms,len);
leng= compress5(fd,ms,len);
}
a6 1
int fd,len,count=1,val,returnval;
d15 1
a15 1
d17 1
a17 1
d34 1
a34 1
int c=0,i,ndc=0,count=1;
d46 1
d54 3
a56 1
c=i;
d67 1
d79 8
a86 8
int k=0;
while(len)
{
len=len/2;
k++;
}
printf("code lenght =%d\n",k);
return 1;
d91 20
a110 11
switch(val)
{
case 1: leng=compress1(fd,ms,len);
break;
case 5: leng=compress5(fd,ms,len);
break;
//case 3: leng=3;
//break;
//case 4: leng
}
return leng;
@
1.7
log
@code lenght have been calculated
@
text
@d11 7
d21 1
a21 1
int fd,len,count=1,val;
d32 2
a33 1
d99 17
@
1.6
log
@declaring a function for calculating the codelength
@
text
@d14 1
a14 1
int fd,len,count=1;
d23 2
d80 11
@
1.5
log
@unique character have been calculated
@
text
@d9 2
@
1.4
log
@calculated the unique character in the stored array
@
text
@d3 1
d7 1
a7 1
int read(int);
d12 1
a12 1
int fd;
d14 1
a14 1
{ printf("error\n");
d16 1
a16 1
}
d19 4
a22 4
len=read(fd)
d24 1
a24 1
OUT:
d29 45
a73 45
int fd;
fd=open("ash", O_RDONLY);
printf("fd is %d\n",fd);
return fd;
}
int read(int fd)
{
int count=0,i,ndc=0;
char *ms;
while(count)
{
count=read(fd,&ch,1);
if(ch==10)
break;
if(n==0)
{
ms=malloc(sizeof(char));
*(ms+ndc)=ch;
ndc++;
}
else if(ndc>=1)
{
for(i=0;i<ndc;i++)
{
if(ch==*(ms+i))
{
c=i;
break;
}
else
c=0;
}
if(c==0)
{
ms=realloc(ms,ndc+1);
*(ms+i)=ch;
ndc++;
}
}
c++;
}
printf("ms==%s\n",ms);
printf("no. of unique character is=%d\n",ndc);
return n;
@
1.3
log
@writing in the function for storing a array from the target file
@
text
@d36 2
a37 1
d49 24
a74 1
@
1.2
log
@intialising a function for reading the target file
@
text
@d34 17
@
1.1
log
@Initial revision
@
text
@d6 2
d16 1
d19 2
@
It looks like you're new here. If you want to get involved, click one of these buttons!