MCPcopy Index your code
hub / github.com/NetHack/NetHack / decode

Function decode

sys/share/uudecode.c:191–225  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

189}
190
191RESTORE_WARNINGS
192
193/*
194 * copy from in to out, decoding as you go along.
195 */
196void
197decode(FILE *in, FILE *out)
198{
199 char buf[80];
200 char *bp;
201 int n, i, expected;
202
203 for (;;) {
204 /* for each input line */
205 if (fgets(buf, sizeof buf, in) == NULL) {
206 printf("Short file\n");
207 exit(10);
208 }
209 n = DEC(buf[0]);
210 if ((n <= 0) || (buf[0] == '\n'))
211 break;
212
213 /* Calculate expected # of chars and pad if necessary */
214 expected = ((n + 2) / 3) << 2;
215 for (i = (int) strlen(buf) - 1; i <= expected; i++)
216 buf[i] = ' ';
217
218 bp = &buf[1];
219 while (n > 0) {
220 outdec(bp, out, n);
221 bp += 4;
222 n -= 3;
223 }
224 }
225}
226
227/*
228 * output a group of 3 bytes (4 input characters).

Callers 1

mainFunction · 0.70

Calls 3

fgetsFunction · 0.85
printfFunction · 0.85
outdecFunction · 0.85

Tested by

no test coverage detected