-
Notifications
You must be signed in to change notification settings - Fork 0
/
decompression2.c,v
130 lines (102 loc) · 2.34 KB
/
decompression2.c,v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
head 1.1;
access;
symbols;
locks
root:1.1; strict;
comment @ * @;
1.1
date 2017.11.13.17.03.49; author root; state Exp;
branches;
next ;
desc
@this is 2-bit decompression file
@
1.1
log
@Initial revision
@
text
@// this is decompression of 2 bytei
#include"header.h"
#include"prototype.h"
int decompression2()
{
printf("in function----->%s\n",__func__);
unsigned char *buff=NULL,ch,d,c,e,f;
unsigned int efd,efd2,fd2,fd3,i=0,count,count1,length,j,n,r;
efd=open("compression",O_RDONLY);
efd2=open("ranjan",O_RDONLY);
fd2=open("encrypted_file",O_RDONLY);
fd3=open("compressed_file",O_RDWR);
count=lseek(efd2,0,SEEK_END); //main file nikhil
count1=lseek(efd,0,SEEK_END); //master array
length=lseek(fd2,0,SEEK_END); //encrypted file
lseek(efd2,0,SEEK_SET);
lseek(efd,0,SEEK_SET);
lseek(fd2,0,SEEK_SET);
printf("no. of characters in actual file && encrypted file is : %d && %d\n",count,length);
buff=(char*)malloc(sizeof(char)*(count1));
count1=read(efd,buff,(count1));
printf("master array is : %s\n and no. of characters-----: %d\n",buff,count1);
j=1;
// count = count-1;
while(i<length)
{
r =read(fd2,&ch,1);
if(r=1)
{
printf("character is read......yeah!----->%c && %d\n",ch,ch);
c = ch;
d = ch;
e = ch;
f = ch;
c = c >> 6;
d = d << 2;
d = d >> 6;
e = e << 4;
e = e >> 6;
f = f << 6;
f = f >> 6;
}
else
printf("character is not readed from file....oops!!\n");
if(j<count)
{
printf("the locationn is ------>%d\n",c);
write(fd3,(buff+c),1);
printf("the written charracter is %c\n",*(buff+c));
printf("the no. of characters had witten---->%d\n",j);
j++;
}
if(j<count)
{
printf("the location is -------->%d\n",d);
write(fd3,(buff+d),1);
printf("the written character is %c\n",*(buff+d));
printf("the no. of characters had witten---->%d\n",j);
j++;
}
if(j<count)
{
printf("the locationn is ------>%d\n",e);
write(fd3,(buff+e),1);
printf("the written charracter is %c\n",*(buff+e));
printf("the no. of characters had witten---->%d\n",j);
j++;
}
if(j<count)
{
printf("the location is -------->%d\n",f);
write(fd3,(buff+f),1);
printf("the written character is %c\n",*(buff+f));
printf("the no. of characters had witten---->%d\n",j);
j++;
}
i++;
}
close(fd2);
close(fd3);
close(efd);
return 0;
}
@