1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- #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];
- unsigned char sum;
- char *dstd;
- int b;
- int i;
-
- b = d->size - *offset;
- if(b>45) b = 45;
-
- sum = 0;
- for(i=0; i<b; i++) {
- srcbuf[i] = d->data[*offset + i];
- sum += srcbuf[i];
- *checksum += srcbuf[i];
- }
-
- for(i=0; i<(b & (4-1)); i++)
- srcbuf[b+i] = 0;
-
- dst[0] = ' ' + b;
- dstd = &dst[1];
-
- for(i=0; i<b; i+=3) {
- dstd[0] = srcbuf[i]>>2;
- dstd[1] = srcbuf[i]<<4 | srcbuf[i+1]>>4;
- dstd[2] = srcbuf[i+1]<<2 | srcbuf[i+2]>>6;
- dstd[3] = srcbuf[i];
- dstd += 4;
- }
-
- dstd[0] = sum;
- dstd[1] = 0;
-
- for(i=0; i<b+2; i++) {
- dst[i] &= 0x3f;
- if(dst[i])
- dst[i] += ' ';
- else
- dst[i] = '`';
- }
-
- if(*offset >= d->size)
- return 0;
-
- *offset += b;
- return 1;
- }
-
-
-
- void uudecode_line(struct sprog_data *d, const char *src, int *checksum) {
- d = 0;
- src = 0;
- checksum = 0;
- return;
- }
|