Skip to content

Commit c469203

Browse files
committed
7-bit decompression done
1 parent 03c444d commit c469203

File tree

1 file changed

+25
-23
lines changed

1 file changed

+25
-23
lines changed

decompression7.c

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,12 @@ char decr1[]=".decompressed";
1919
strcpy(decr, str);
2020
strcat(decr, decr1);
2121
printf("decompressed file name is---> %s\n",decr);
22+
23+
2224
efd=open(open_key,O_RDONLY);
2325
efd2=open(str,O_RDONLY);
2426
fd2=open(open_encr,O_RDONLY);
25-
fd3=open(decr,O_WRONLY | O_CREAT);
27+
fd3=open(decr,O_RDWR | O_CREAT);
2628

2729

2830
count=lseek(efd2,0,SEEK_END);
@@ -31,36 +33,36 @@ char decr1[]=".decompressed";
3133
lseek(efd2,0,SEEK_SET);
3234
lseek(efd,0,SEEK_SET);
3335
lseek(fd2,0,SEEK_SET);
34-
// printf("no. of characters in actual file && encrypted file is : %d && %d\n",count,length);
36+
printf("no. of characters in actual file && encrypted file is : %d && %d\n",count,length);
3537
buff=(char*)malloc(sizeof(char)*(count1));
3638

3739
count1=read(efd,buff,(count1));
38-
// printf("master array is : %s\n and no. of characters-----: %d\n",buff,count1);
40+
printf("master array is : %s\n and no. of characters-----: %d\n",buff,count1);
3941
j=1,f=0;
4042
while(i<length)
4143
{
4244

4345
r =read(fd2,&ch,1);
4446
if(f==0)
4547
{
46-
// printf("in ---->f(0)\n");
47-
// printf("character is read......yeah!----->%c && %d\n",ch,ch);
48+
printf("in ---->f(0)\n");
49+
printf("character is read......yeah!----->%c && %d\n",ch,ch);
4850
c = ch;
4951
d = ch;
5052
c = c >> 1;
5153
if(j<count)
5254
{
5355
write(fd3,(buff+c),1);
54-
// printf("the written charracter is %c\n",*(buff+c));
56+
printf("the written charracter is %c\n",*(buff+c));
5557
j++;
5658
}
5759

5860

5961
}
6062
if(f==1)
6163
{
62-
// printf("in ---->f(1)\n");
63-
// printf("character is read......yeah!----->%c && %d\n",ch,ch);
64+
printf("in ---->f(1)\n");
65+
printf("character is read......yeah!----->%c && %d\n",ch,ch);
6466
c = ch;
6567
e = ch;
6668
d = d << 7;
@@ -71,7 +73,7 @@ char decr1[]=".decompressed";
7173
if(j<count)
7274
{
7375
write(fd3,(buff+d),1);
74-
// printf("the written charracter is %c\n",*(buff+d));
76+
printf("the written charracter is %c\n",*(buff+d));
7577
j++;
7678
}
7779

@@ -80,7 +82,7 @@ char decr1[]=".decompressed";
8082
if(f==2)
8183
{
8284

83-
// printf("in ---->f(2)\n");
85+
printf("in ---->f(2)\n");
8486
c = ch;
8587
d = ch;
8688
e = e << 6;
@@ -90,15 +92,15 @@ char decr1[]=".decompressed";
9092
if(j<count)
9193
{
9294
write(fd3,(buff+c),1);
93-
// printf("the written charracter is %c\n",*(buff+c));
95+
printf("the written charracter is %c\n",*(buff+c));
9496
j++;
9597
}
9698

9799
}
98100
if(f==3)
99101
{
100-
// printf("in ---->f(3)\n");
101-
// printf("character is read......yeah!----->%c && %d\n",ch,ch);
102+
printf("in ---->f(3)\n");
103+
printf("character is read......yeah!----->%c && %d\n",ch,ch);
102104
c = ch;
103105
e = ch;
104106
d = d << 5;
@@ -110,15 +112,15 @@ char decr1[]=".decompressed";
110112
if(j<count)
111113
{
112114
write(fd3,(buff+d),1);
113-
// printf("the written charracter is %c\n",*(buff+d));
115+
printf("the written charracter is %c\n",*(buff+d));
114116
j++;
115117
}
116118

117119
}
118120
if(f==4)
119121
{
120-
// printf("in ---->f(4)\n");
121-
// printf("character is read......yeah!----->%c && %d\n",ch,ch);
122+
printf("in ---->f(4)\n");
123+
printf("character is read......yeah!----->%c && %d\n",ch,ch);
122124
c = ch;
123125
d = ch;
124126
e = e << 4;
@@ -128,14 +130,14 @@ char decr1[]=".decompressed";
128130
if(j<count)
129131
{
130132
write(fd3,(buff+c),1);
131-
// printf("the written charracter is %c\n",*(buff+c));
133+
printf("the written charracter is %c\n",*(buff+c));
132134
j++;
133135
}
134136

135137
}
136138
if(f==5)
137139
{
138-
// printf("in ---->f(5)\n");
140+
printf("in ---->f(5)\n");
139141
c = ch;
140142
e = ch;
141143
d = d << 3;
@@ -145,15 +147,15 @@ char decr1[]=".decompressed";
145147
if(j<count)
146148
{
147149
write(fd3,(buff+d),1);
148-
// printf("the written charracter is %c\n",*(buff+d));
150+
printf("the written charracter is %c\n",*(buff+d));
149151
j++;
150152
}
151153

152154
}
153155
if(f==6)
154156
{
155-
// printf("in ---->f(6)\n");
156-
// printf("character is read......yeah!----->%c && %d\n",ch,ch);
157+
printf("in ---->f(6)\n");
158+
printf("character is read......yeah!----->%c && %d\n",ch,ch);
157159
c = ch;
158160
m = ch;
159161
e = e << 2;
@@ -165,13 +167,13 @@ char decr1[]=".decompressed";
165167
if(j<count)
166168
{
167169
write(fd3,(buff+c),1);
168-
// printf("the written charracter is %c\n",*(buff+c));
170+
printf("the written charracter is %c\n",*(buff+c));
169171
j++;
170172
}
171173
if(j<count)
172174
{
173175
write(fd3,(buff+m),1);
174-
// printf("the written charracter is %c\n",*(buff+m));
176+
printf("the written charracter is %c\n",*(buff+m));
175177
j++;
176178
}
177179

0 commit comments

Comments
 (0)