Справочник по консольным командам Toybox для Android 12


  Ver.0.8.4     Ver.0.8.9     Pending  

Путь: Toys/POSIX, команды версии: Ver.4     Ver.9


uuencode

Комментарии в файле uuencode.c :

usage: uuencode [-m] [INFILE] ENCODE_FILENAME

Uuencode stdin (или INFILE) в stdout с ENCODE_FILENAME на выходе.
  • -m Base64

  • usage: uuencode [-m] [INFILE] ENCODE_FILENAME

    Uuencode stdin (or INFILE) to stdout, with ENCODE_FILENAME in the output.
  • -m Base64

  • Исходный текст в файле 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");
    }