/* atascii to ascii *//*   This program is copyleft 1989   by JRD.  See COPYLEFT.JRD for   a detailed description of your   rights and responsibilities   about copying it.   Give this program and its source   away!  Help create more free   software!*/#include <stdio.h>#ifndef M6502#include <errno.h>#define delete unlink#endifchar buf1[80];char buf2[80];main(argc, argv)int argc;char ** argv;$(  char * name;  char * p;  FILE * inf;  FILE * outf;  int ch;  if (argc > 1)    $(    name = argv[1];    strcpy(buf1, name);    $)   else    $(#ifdef M6502    printf("AT2A>");    if (getname(buf1) <= 0)      exit(0);    name = buf1;#else    printf("AT2A what?\n");    exit(0);#endif    $)  fn_default(name, 0, buf1);  name = buf1;  inf = fopen(name, "r");/*  printf("open '%s'->%x\n",     name, inf);  */  if ((int)inf <= 0)    $(    printf("Can't open '%s' error %x\n", name, errno);#ifdef M6502    kbdchar();#endif    exit(0);    $)  strcpy(buf2, buf1);  p = strchr(buf2, '.');  if (!p)    p = buf2 + strlen(buf2);  strcpy(p, ".tmp");  outf = fopen(buf2, "w");/*  printf("open '%s'->%x\n",     buf2, outf);  */  while ((ch = fgetc(inf)) != EOF)    $(    switch (ch)      $(#ifdef M6502      case '\n':   /* newline ... */#ifndef weenix        fputc(0x0D, outf);#endif        ch = 0x0A; /* ascii linefeed */        break;      case '\t':   /* tab ... */        ch = 0x09; /* ascii tab */        break;#else      case 0x9B:   /* atascii eol ...*/        ch = '\n'; /* newline */        break;      case 0x7F:   /* atascii tab ...*/        ch = '\t'; /* tab */        break;#endif      $)/*  fputc(ch, stdout);  */    fputc(ch, outf);    $)  fclose(inf);  fclose(outf);  delete(buf1);  rename(buf2, buf1);$)#ifdef M6502int getname(buf)char * buf;$(  int i;  int ch;  i = 0;    /* str idx */  for (; ((ch = kbdchar()) != '\n') ; )    $(    if (ch == '\b')      $(      if (i > 0)        $(        fputc('\b', stderr);        i--;        $)      $)     else      $(      fputc(ch, stderr);      buf[i] = ch;      i++;      $)    $)  buf[i] = '\0';  return strlen(buf);$)#endif