Путь: Toys/POSIX, команды версии: Ver.4 Ver.9 uuencode Комментарии в файле uuencode.c :
Исходный текст в файле uuencode.c #define FOR_uuencode #include "toys.h" void uuencode_main(void) { char *name = toys.optargs[toys.optc-1], buf[(76/4)*3]; int i, m = FLAG(m), fd = 0; if (toys.optc > 1) fd = xopenro(toys.optargs[0]); base64_init(toybuf); xprintf("begin%s 744 %s\n", m ? "-base64" : "", name); for (;;) { char *in; if (!(i = xread(fd, buf, m ? sizeof(buf) : 45))) break; if (!m) xputc(i+32); in = buf; for (in = buf; in-buf < i; ) { int j, x, bytes = i - (in-buf); if (bytes > 3) bytes = 3; for (j = x = 0; j<4; j++) { int out; if (j < bytes) x |= (*(in++) & 0x0ff) << (8*(2-j)); out = (x>>((3-j)*6)) & 0x3f; xputc(m ? (j > bytes ? '=' : toybuf[out]) : (out ? out + 0x20 : 0x60)); } } xputc('\n'); } xputs(m ? "====" : "end"); } |