123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- #include <sprog.h>
- #include <uucode.h>
- /* aaaa aa|aa bbbb|bbbb cc|cc cccc */
- int uuencode_line(const struct sprog_data *d, char *dst, int *offset, int *checksum) {
- char srcbuf[64];
- char *dstd;
- int b;
- int n;
- int i;
-
- if(*offset >= d->size)
- return 0;
-
- b = d->size - *offset;
- if(b>45) b = 45;
- for(i=0; i<b; i++) {
- srcbuf[i] = d->data[*offset + i];
- *checksum += (unsigned char) srcbuf[i];
- }
-
- for(i=0; i<3; i++)
- srcbuf[b+i] = 0;
-
- dst[0] = b;
-
- dstd = &dst[1];
-
- n = 0;
- for(i=0; i<b; i+=3) {
- dstd[0] = (srcbuf[i]>>2) & 0x3f;
- dstd[1] = (srcbuf[i]<<4 & 0x30) | (srcbuf[i+1]>>4 & 0x0f);
- dstd[2] = (srcbuf[i+1]<<2 &0x3c) | (srcbuf[i+2]>>6 & 0x03);
- dstd[3] = srcbuf[i+2] & 0x3f;
- dstd += 4;
- n += 4;
- }
-
-
- for(i=0; i<n+1; i++) {
- if(dst[i])
- dst[i] += ' ';
- else
- dst[i] = '`';
- }
-
- dstd[0] = 0;
-
- *offset += b;
-
- if(*offset >= d->size)
- return 2;
-
- return 1;
- }
-
-
-
- void uudecode_line(struct sprog_data *d, const char *src, int *checksum) {
- d = 0;
- src = 0;
- checksum = 0;
- return;
- }
|