UU ENCODE Problems (For Beta Users of MONTANUS)

JsNO BAR---NUNN nunn at NUTMEG.CS.NTU.EDU.AU
Sat Jan 23 15:28:13 CST 1993


MONTANUS:
---------

Hello Beta Users,


Many (some) users have reported problems of not knowing how to convert
your UU encoded Mail message back to the self extracted excutable that
will unarchive the MONTANUS beta contents.

If you have access to archie.au (or any archie sit for that matter), then you
can download an MSDOS uuconverter to do the job. Or if your using a UNIX
machine, you can compile the following C source code.

To do it, cut where it says to cut, and type in the following commands
to compile it:

> cc -o uuconvert uuconvert.c


This will comple the C source code. You should then have a UNIX excutable
called "uuconvert".


to uu unencode the mail file, type in:


> uuconvert <mail file>


You should then have an MSDOS executable called "mont_12b.exe".
Transfer this to your PC machine and run it. It will then self extract
the beta package.



--uuconvert.c--------Cut Here-------

#include <stdio.h>
#include <string.h>

#define TRUE    1
#define FALSE   0
#define DEC(c)  (((c) - ' ') & 077)
#define LENGTH  150

extern void uuread();
FILE *out = NULL;
char *Outname = NULL;

void main(argc, argv)
int argc;
char *argv[];
{
  int error=FALSE;
  FILE *infile;
  char *Progname = argv[0];

  if (argv[1][0] == '-' && argv[1][1] == 'o') {
    ++argv;
    --argc;
    if (argv[0][2] == '\0') {
      if ((Outname = *++argv) == NULL) {
        fprintf(stderr, "Usage: %s [-o outputfile] [inputfile ...]\n",
 Progname);
        exit(1);
      }
      else --argc;
    }
    else Outname = argv[0] + 2;
  }
  if (argc <= 1)
    uuread(stdin);
  else
    while (--argc > 0 && !error)
      if (error = ((infile = fopen(*++argv, "r")) == NULL))
        fprintf(stderr, "%s: Can't open '%s' for input.\n", Progname, *argv);
      else
        uuread(infile), fclose(infile);
  exit(error);
}


void uuread(infile)
FILE *infile;
{
  char *s2, *s1, *s0, *tmp_s;
  int length;
  static char s[3 * (LENGTH + 1)];
  static int echo_on = FALSE, started = FALSE, just_finished = FALSE;
  static int line_length = 0, lines_to_go = 0, firstline=FALSE;

  s0 = s;
  s1 = s0 + (LENGTH + 1);
  s2 = s1 + (LENGTH + 1);

  s0[0] = s1[0] = s2[0] = '\0';  /* Clear strings */

  while (fgets(s0, LENGTH, infile) != NULL)
  {
    s0[LENGTH] = '\0';  /* Make sure string is terminated */

    if (just_finished)
      just_finished = FALSE; /* yea I don't why either */

    if (!started)
      {
        if (strncmp(s0, "begin ", 6) == 0)
          {
            int mode;
            char dest[128];
            firstline=TRUE;
            started = echo_on = TRUE, line_length = 0, lines_to_go = 0;
            sscanf(s0, "begin %o %s", &mode, dest);
            if (Outname == NULL) Outname = dest;
            if ((out = fopen(Outname, "w")) == NULL) perror(Outname), exit(4);
          }
      }
    else  /* started */
    {
      length = strlen(s0);
      if (line_length == 0)
        line_length = length;

      if (echo_on)
      {
        lines_to_go = 0;
        if (s0[0] != 'M' || length != line_length)
        {
          echo_on = FALSE;
          lines_to_go = 2;  /* Lines to go before 'end' is expected */
          if (s0[0] == ' ' || s0[0] == '`')
            lines_to_go = 1;
        }
      }
      else  /* !echo_on */
        if (s0[0] == 'M' && length == line_length
          /* Simple check for non-uuencoded line */
          && strncmp(s0+1, "essage-ID: ", 11)) /* (a3 at rivm.nl) 9 jul 1992 */
            echo_on = TRUE;
        else if (lines_to_go > 0)
          if (lines_to_go == 2)
            if (s0[0] == ' ' || s0[0] == '`')
              lines_to_go = 1;
            else
              lines_to_go = 0;  /* Unexpected line, so break off */
          else if (lines_to_go == 1)
            if (strcmp(s0, "end\n") == 0)
            {
              doaline(s2);
              doaline(s1);
              lines_to_go = 0;  /* Done. Break off */
              just_finished = TRUE;
              started = FALSE;
            }
            else
              lines_to_go = 0;  /* Unexpected line, so break off */
    }

    if (firstline)
      firstline=FALSE;
    else if (echo_on)
      doaline(s0), s0[0] = '\0';

    tmp_s = s2, s2 = s1, s1 = s0, s0 = tmp_s;
  }
}

/*
 * copy from in to out, decoding as you go along.
 */
doaline(s)
     char s[];
{
  char *bp;
  int n;
  if ((n=DEC(s[0])) > 0)
    {
      bp = &s[1];
      while (n > 0)
        outdec(bp, n), bp += 4, n -= 3;
    }
}

/*
 * output a group of 3 bytes (4 input characters).
 * the input chars are pointed to by p, they are to
 * be output to file f.  n is used to tell us not to
 * output all of them at the end of the file.
 */
outdec(p, n)
     char *p;
{
  int c1, c2, c3;

  c1 = DEC(*p) << 2 | DEC(p[1]) >> 4;
  c2 = DEC(p[1]) << 4 | DEC(p[2]) >> 2;
  c3 = DEC(p[2]) << 6 | DEC(p[3]);
  if (n >= 1) putc(c1, out);
  if (n >= 2) putc(c2, out);
  if (n >= 3) putc(c3, out);
}

--------Cut Here--------------------




----------------------Jason Nunn (aka JsNO BAR----NUNN)------------------------
    \o     Fishing TopEnd Style: "Give me a tinny, a six pack of Powers, a
-----|-D     throw net, and some hand lines, and a lot of bloody sun screen,
.\____/.\\.. I'll catch the biggest Barra you've ever seen" - I Wish :)
-------------NORTHERN TERRITORY UNIVERSITY, DARWIN, NT, AUSTRALIA--------------




More information about the Taxacom mailing list