home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / mint / utilit~1 / tuu103d3.zoo / diffs next >
Encoding:
Text File  |  1993-01-07  |  103.9 KB  |  4,203 lines

  1. diff -ru ./bnu.c /src/t103/uucp-1.03/bnu.c
  2. --- ./bnu.c    Tue Apr  7 06:05:18 1992
  3. +++ /src/t103/uucp-1.03/bnu.c    Mon Oct 12 17:02:02 1992
  4. @@ -546,8 +546,46 @@
  5.        ztok = strrchr (qset->zport, ',');
  6.        if (ztok != NULL && ztok[1] != '\0')
  7.          {
  8. +#if 1
  9. +          /* parse stuff like gf(7,1024)...  (g parameters in brackets) */
  10. +          char *o, *p, *q, *carg[3];
  11. +
  12.            qset->zprotocols = ztok + 1;
  13.            *ztok = '\0';
  14. +
  15. +          if ((o = strrchr (qset->zport, ',')) &&
  16. +          (p = strchr (o + 1, '(')) &&
  17. +          (q = strchr (ztok + 1, ')')) && !q[1]) {
  18. +
  19. +        carg[0] = "g";
  20. +        carg[1] = "window";
  21. +        carg[2] = p + 1;
  22. +        tadd_proto_param (&qset->cproto_params,
  23. +                  &qset->qproto_params, "", 3, carg);
  24. +        *q = 0;
  25. +#if 1
  26. +        /* addition: timeout after t as in (7,1024t20)  (seconds) */
  27. +        if (q = strchr (ztok + 1, 't')) {
  28. +          *q = 0;
  29. +          carg[1] = "timeout";
  30. +          carg[2] = q + 1;
  31. +          tadd_proto_param (&qset->cproto_params,
  32. +                    &qset->qproto_params, "", 3, carg);
  33. +        }
  34. +#endif
  35. +        carg[1] = "packet-size";
  36. +        carg[2] = ztok + 1;
  37. +        tadd_proto_param (&qset->cproto_params,
  38. +                  &qset->qproto_params, "", 3, carg);
  39. +        *p = 0;
  40. +        ztok = o;
  41. +        qset->zprotocols = ztok + 1;
  42. +        *ztok = '\0';
  43. +          }
  44. +#else
  45. +          qset->zprotocols = ztok + 1;
  46. +          *ztok = '\0';
  47. +#endif
  48.          }
  49.  
  50.        ztok = strtok ((char *) NULL, " \t");
  51. diff -ru ./conf.h /src/t103/uucp-1.03/conf.h
  52. --- ./conf.h    Tue Apr  7 06:16:50 1992
  53. +++ /src/t103/uucp-1.03/conf.h    Sun Oct 11 12:50:00 1992
  54. @@ -4,11 +4,11 @@
  55.  
  56.  /* Set MAIL_PROGRAM to a program which takes a mail address as an argument
  57.     and accepts a mail message to send to that address on stdin.  */
  58. -#define MAIL_PROGRAM "/usr/ucb/mail"
  59. +#define MAIL_PROGRAM "/usr/bin/rmail.ttp"
  60.  
  61.  /* Set ECHO_PROGRAM to a program which echoes its arguments; if echo
  62.     is a shell builtin you can just use "echo".  */
  63. -#define ECHO_PROGRAM "/bin/echo"
  64. +#define ECHO_PROGRAM "echo"
  65.  
  66.  /* The following macros indicate what header files you have.  Set the
  67.     macro to 1 if you have the corresponding header file, or 0 if you
  68. @@ -24,11 +24,11 @@
  69.  #define HAVE_DIRENT_H 1       /* <dirent.h> */
  70.  #define HAVE_MEMORY_H 1       /* <memory.h> */
  71.  #define HAVE_SYS_PARAM_H 1       /* <sys/param.h> */
  72. -#define HAVE_UTIME_H 1       /* <utime.h> */
  73. +#define HAVE_UTIME_H 0       /* <utime.h> */
  74.  #define HAVE_FCNTL_H 1       /* <fcntl.h> */
  75.  #define HAVE_SYS_FILE_H 1       /* <sys/file.h> */
  76.  #define HAVE_LIBC_H 0       /* <libc.h> */
  77. -#define HAVE_SYSEXITS_H 1       /* <sysexits.h> */
  78. +#define HAVE_SYSEXITS_H 0       /* <sysexits.h> */
  79.  #define HAVE_POLL_H 0       /* <poll.h> */
  80.  #define HAVE_STROPTS_H 0       /* <stropts.h> */
  81.  
  82. @@ -128,7 +128,7 @@
  83.     FS_STATFS     the two argument statfs function with the f_fsize field
  84.     FS_GETMNT     the two argument statfs function with the fd_req field
  85.     FS_USTAT      the ustat function with 512 byte blocks.  */
  86. -#define FS_GETMNT 
  87. +#define FS_MNTENT 
  88.  
  89.  /* Set HAVE_VOID to 1 if the compiler supports declaring functions with
  90.     a return type of void and casting values to void.  */
  91. @@ -169,19 +169,19 @@
  92.  #define HAVE_STRERROR 1
  93.  #define HAVE_STRTOL 1
  94.  #define HAVE_STRSTR 1
  95. -#define HAVE_STRDUP 0
  96. -#define HAVE_STRCASECMP 1
  97. -#define HAVE_STRICMP 0
  98. -#define HAVE_STRLWR 0
  99. +#define HAVE_STRDUP 1
  100. +#define HAVE_STRCASECMP 0
  101. +#define HAVE_STRICMP 1
  102. +#define HAVE_STRLWR 1
  103.  #define HAVE_BSEARCH 1
  104.  #define HAVE_VFPRINTF 1
  105.  #define HAVE_REMOVE 1
  106. -#define HAVE_FTRUNCATE 1
  107. +#define HAVE_FTRUNCATE 0
  108.  #define HAVE_LTRUNC 0
  109.  #define HAVE_RENAME 1
  110.  #define HAVE_OPENDIR 1
  111.  #define HAVE_DUP2 1
  112. -#define HAVE_WAITPID 1
  113. +#define HAVE_WAITPID 0
  114.  #define HAVE_WAIT4 0
  115.  
  116.  /* If you have either sigsetjmp or setret, it will be used instead of
  117. @@ -188,7 +188,7 @@
  118.     setjmp.  These functions will only be used if your system restarts
  119.     system calls after interrupts (see HAVE_RESTARTABLE_SYSCALLS,
  120.     below).  */
  121. -#define HAVE_SIGSETJMP 1
  122. +#define HAVE_SIGSETJMP 0
  123.  #define HAVE_SETRET 0
  124.  
  125.  /* The code needs to know what function to use to set a signal
  126. @@ -195,14 +195,14 @@
  127.     handler.  If will try to use each of the following functions in
  128.     turn.  If none are available, it will use signal, which is assumed
  129.     to always exist.  */
  130. -#define HAVE_SIGACTION 1
  131. -#define HAVE_SIGVEC 1
  132. +#define HAVE_SIGACTION 0
  133. +#define HAVE_SIGVEC 0
  134.  #define HAVE_SIGSET 0
  135.  
  136.  /* The code will try to use each of the following functions in turn
  137.     when blocking signals from delivery.  If none are available, a
  138.     relatively unimportant race condition will exist.  */
  139. -#define HAVE_SIGPROCMASK 1
  140. +#define HAVE_SIGPROCMASK 0
  141.  #define HAVE_SIGBLOCK 1
  142.  #define HAVE_SIGHOLD 0
  143.  
  144. @@ -210,13 +210,13 @@
  145.     determine the number of file descriptors which may be open.
  146.     Otherwise, the code will use OPEN_MAX if defined, then NOFILE if
  147.     defined, then 20.  */
  148. -#define HAVE_GETDTABLESIZE 1
  149. +#define HAVE_GETDTABLESIZE 0
  150.  #define HAVE_SYSCONF 1
  151.  
  152.  /* The code will use one of the following functions when detaching
  153.     from a terminal.  One of these must exist.  */
  154.  #define HAVE_SETPGRP 1
  155. -#define HAVE_SETSID 1
  156. +#define HAVE_SETSID 0
  157.  
  158.  /* If you do not specify the local node name in the main configuration
  159.     file, Taylor UUCP will try to use each of the following functions
  160. @@ -228,8 +228,8 @@
  161.  /* The code will try to use each of the following functions in turn to
  162.     determine the current time.  If none are available, it will use
  163.     time, which is assume to always exist.  */
  164. -#define HAVE_GETTIMEOFDAY 1
  165. -#define HAVE_FTIME 1
  166. +#define HAVE_GETTIMEOFDAY 0
  167. +#define HAVE_FTIME 0
  168.  
  169.  /* If neither gettimeofday nor ftime is available, the code will use
  170.     times (if available) to measure a span of time.  See also the
  171. @@ -243,7 +243,7 @@
  172.     poll.  */
  173.  #define HAVE_NAPMS 0
  174.  #define HAVE_NAP 0
  175. -#define HAVE_USLEEP 0
  176. +#define HAVE_USLEEP 1
  177.  #define HAVE_POLL 0
  178.  #define HAVE_SELECT 1
  179.  
  180. @@ -250,11 +250,11 @@
  181.  /* If the getgrent function is available, it will be used to determine
  182.     all the groups a user belongs to when checking file access
  183.     permissions.  */
  184. -#define HAVE_GETGRENT 1
  185. +#define HAVE_GETGRENT 0
  186.  
  187.  /* If the socket function is available, TCP support code will be
  188.     compiled in.  */
  189. -#define HAVE_SOCKET 1
  190. +#define HAVE_SOCKET 0
  191.  
  192.  /* The code needs to know to how to get the name of the current
  193.     directory.  If getcwd is available it will be used, otherwise if
  194. @@ -290,7 +290,7 @@
  195.     your setpgrp calls takes 2 argument (on System V they generally
  196.     take no arguments).  You can safely set this to 1 on System V,
  197.     provided the call will compile without any errors.  */
  198. -#define HAVE_BSD_PGRP 1
  199. +#define HAVE_BSD_PGRP 0
  200.  
  201.  /* Set HAVE_UNION_WAIT to 1 if union wait is defined in the header
  202.     file <sys/wait.h>.  */
  203. @@ -301,7 +301,7 @@
  204.  
  205.  /* Set HAVE_LONG_NAMES to 1 if the system supports file names longer
  206.     than 14 characters.  */
  207. -#define HAVE_LONG_NAMES 1
  208. +#define HAVE_LONG_NAMES 0
  209.  
  210.  /* If slow system calls are restarted after interrupts, set
  211.     HAVE_RESTARTABLE_SYSCALLS to 1.  This is ignored if HAVE_SIGACTION
  212. diff -ru ./contrib/makefile /src/t103/uucp-1.03/contrib/makefile
  213. --- ./contrib/makefile    Tue Oct 13 02:14:20 1992
  214. +++ /src/t103/uucp-1.03/contrib/makefile    Thu Dec 24 15:40:30 1992
  215. @@ -0,0 +1,8 @@
  216. +CC = gcc
  217. +# gcc 1.40:
  218. +#CFLAGS = -O -Wall -fcombine-regs -fomit-frame-pointer -fstrength-reduce
  219. +# gcc 2.3.1:
  220. +CFLAGS = -O2 -Wall -fomit-frame-pointer -fstrength-reduce
  221. +
  222. +xchat.ttp: xchat.c
  223. +    $(CC) $(CFLAGS) xchat.c -o xchat.ttp
  224. diff -ru ./contrib/xchat.c /src/t103/uucp-1.03/contrib/xchat.c
  225. --- ./contrib/xchat.c    Wed Apr  1 23:25:42 1992
  226. +++ /src/t103/uucp-1.03/contrib/xchat.c    Sun Jan  3 04:48:26 1993
  227. @@ -5,9 +5,36 @@
  228.  #include <signal.h>
  229.  #include <sys/time.h>
  230.  #include <sys/ioctl.h>
  231. +#ifndef __MINT__
  232.  #include <sys/termio.h>
  233. +#endif
  234. +
  235. +#ifdef __MINT__
  236. +#include <stdlib.h>
  237. +#include <unistd.h>
  238. +#include <errno.h>
  239. +#include <osbind.h>
  240. +#include <sysvars.h>
  241. +#include <ostruct.h>
  242. +
  243. +#define MINT_DTR    1    /* same as in sys2.c */
  244. +#define MINT_BREAK    1
  245. +
  246. +#define HAVE_USLEEP    1
  247. +#define HAVE_BSD_TTY    1    /* not really used yet... */
  248. +
  249. +/* still necessary at least with MiNT 0.95: */
  250. +#ifndef RTSCTS
  251. +#define RTSCTS    0x2000
  252. +#endif
  253.  
  254. +int strip = 0x7f;
  255. +int waitcd;
  256. +
  257. +#else
  258.  #define HAVE_SETITIMER 1
  259. +#endif
  260. +
  261.  #define SIGRET int
  262.  
  263.  typedef SIGRET *sigfunc_t;
  264. @@ -80,7 +107,10 @@
  265.  #define SC_PEVN 39    /* Set port for 7-bit, even parity */
  266.  #define SC_PODD 40    /* Set port for 7-bit, odd parity */
  267.  #define SC_HUPS 41    /* Change state on HUP signal */
  268. -#define    SC_END    42    /* end of array */
  269. +#if 1
  270. +#define    SC_LOGSTR 42    /* log received string */
  271. +#endif
  272. +#define    SC_END    43    /* end of array */
  273.  
  274.      /* values for prmtype, prm2type */
  275.  
  276. @@ -136,6 +166,9 @@
  277.      {"sendstr",    SC_SNDP,    SC_INT,        SC_NONE},
  278.      {"ifstr",    SC_IF1P,    SC_INT,        SC_NWST},
  279.      {"ifnstr",    SC_IF0P,    SC_INT,        SC_NWST},
  280. +#if 1
  281. +    {"logstr",    SC_LOGSTR,    SC_XSTR,    SC_NONE},
  282. +#endif
  283.      {"table end",    SC_END,        SC_NONE,    SC_NONE}
  284.        };
  285.  
  286. @@ -174,7 +207,11 @@
  287.  static int fSalarm = FALSE;
  288.  static int fShangup = FALSE;    /* TRUE if HUP signal received */
  289.  static FILE  *dbf = NULL;
  290. +#if HAVE_BSD_TTY
  291. +static struct sgttyb old, new;
  292. +#else
  293.  static struct termio old, new;
  294. +#endif
  295.  
  296.  extern int usignal();
  297.  extern int uhup();
  298. @@ -188,7 +225,9 @@
  299.  } sigtbl[] = {
  300.               { SIGHUP,   NULL, uhup },
  301.               { SIGINT,   NULL, usignal },
  302. +#ifndef __MINT__
  303.           { SIGIOT,   NULL, usignal },
  304. +#endif
  305.               { SIGQUIT,  NULL, usignal },
  306.               { SIGTERM,  NULL, usignal },
  307.               { SIGALRM,  NULL, usalarm },
  308. @@ -665,9 +704,15 @@
  309.    time_t sc_begwait;        /* time at beg of wait */
  310.    time_t sc_secs;        /* timeout period */
  311.    
  312. -  int    expcnt;
  313. +  int    expcnt = 0;
  314.    int    expin;
  315. +#if 1
  316. +  int     logstr;
  317. +  char     *logstr_comment;
  318. +  static char expbuf[MAX_EXPCT+1];
  319. +#else
  320.    static char expbuf[MAX_EXPCT];
  321. +#endif
  322.    
  323.    dbgsave = Debug;
  324.    curstate = begin;
  325. @@ -681,6 +726,12 @@
  326.     * to a label entry
  327.     */
  328.    expin = 0;
  329. +#if 1
  330. +  logstr = 0;
  331. +#endif
  332. +#ifdef __MINT__
  333. +  waitcd = 0;
  334. +#endif
  335.    
  336.    for (curscr = curstate->next; /* point to 1st scr after label */
  337.         (curscr != (struct script *)NULL) &&  /* do until end of scr */
  338. @@ -945,10 +996,25 @@
  339.        DEBUG(DB_LGI, "Dialing, default timeout is %d millisecs\n", sc_dtmo);
  340.        ttoslow(tempstr, 0, sc_chrdly);
  341.        break;
  342. +
  343. +#if 1
  344. +    case SC_LOGSTR:
  345. +      logstr_comment = curscr->strprm;
  346. +      logstr++;
  347. +      break;
  348. +#endif
  349.        
  350. +#ifdef __MINT__
  351. +    case SC_CARR:    /* they exist */
  352. +      /* tell xgetc to wait for either a character or carrier */
  353. +      waitcd++;
  354. +    case SC_TIMO:    /* these are "expects", don't bother */
  355. +    case SC_XPCT:    /* with them yet, other than noting that */
  356. +#else
  357.      case SC_TIMO:    /* these are "expects", don't bother */
  358.      case SC_XPCT:    /* with them yet, other than noting that */
  359.      case SC_CARR:    /* they exist */
  360. +#endif
  361.        expcnt++;
  362.        break;
  363.      }
  364. @@ -1044,6 +1110,16 @@
  365.          {
  366.            charlog(curscr->strprm, curscr->intprm,
  367.                DB_LGI, "Matched");
  368. +#if 1
  369. +          if (logstr) {
  370. +            while (expin > 0 &&
  371. +               (expbuf[expin-1] == '\r' || expbuf[expin-1] == '\n'))
  372. +            --expin;
  373. +            expbuf[expin] = 0;
  374. +            logit(logstr_comment, expbuf);
  375. +            logstr = 0;
  376. +          }
  377. +#endif
  378.            goto _chgstate;
  379.          }
  380.            break;
  381. @@ -1115,8 +1191,36 @@
  382.    if (setitimer (ITIMER_REAL, &stimer, (struct itimerval *) NULL) == 0)
  383.  #endif
  384.  
  385. +#ifdef __MINT__
  386. +  /* on MiNT we do it with select() */
  387. +  clock_t endtime = clock() + tmo * CLK_TCK;
  388. +  struct timeval s = {0L, 50000L};
  389. +  int rfds, result;
  390. +
  391. +  /* ...wich actually is not `a' select but a loop of select()s because
  392. +     there is a known bug in MiNT (up to 0.95 at least) that it doesn't
  393. +     wake up a select when data becomes available on serial ports. */
  394. +  do {
  395. +    rfds = 1;
  396. +    if ((result = select (0, &rfds, (int *) NULL, (int *) NULL, &s)) < 0 ||
  397. +    ((long) endtime - (long) clock()) < 0 || (waitcd && ttcd())) {
  398. +      /* if we timed out or the select gets an error get out.  also if
  399. +     we were waiting for CD and got it */
  400. +      if (waitcd && ttcd())
  401. +    waitcd = 0;
  402. +      return '\377';
  403. +    }
  404. +
  405. +  /* else loop until we have data. */
  406. +  } while (!result);
  407. +#endif
  408. +
  409.      if(read(0, &c, 1)  <= 0)
  410.        c = '\377';
  411. +#ifdef __MINT__
  412. +    else
  413. +      c &= strip;
  414. +#endif
  415.  
  416.  #ifdef USE_ITIMER
  417.    fSalarm_ok = FALSE;
  418. @@ -1216,6 +1320,186 @@
  419.      }
  420.  }
  421.  
  422. +/* MiNT specific stuff... */
  423. +#ifdef __MINT__
  424. +/* points to 2 _IOREC structs that describe the port's read ([0]) and
  425. +   write ([1]) buffers. (def'd in <ostruct.h>) */
  426. +static _IOREC    *S_iorec;
  427. +
  428. +/* BIOS device no of the port: (used as index in the pollcd () routine)
  429. +   6 = modem1, 7 = modem2, 8 = serial1, 9 = serial2. */
  430. +static int    S_biosdev;
  431. +
  432. +/* beware: never mv these devices if you want this stuff to work...
  433. +   (there isn't yet a safer way to get the BIOS device no for a dev
  434. +   name in MiNT.) */
  435. +static char *names[] = {"midi", "", "", "modem1", "modem2",
  436. +            "serial1", "serial2", (char *) NULL};
  437. +
  438. +/* this gets the BIOS dev no and inits some variables for
  439. +   fastread() + fastwrite() (if used). */
  440. +int map_biosdev (devname)
  441. +/* device name without the "/dev/" */
  442. +char *devname;
  443. +{
  444. +  char **p;
  445. +  long stack;
  446. +
  447. +  S_iorec = 0;
  448. +
  449. +  /* find the device */
  450. +  for (p=names; *p; ++p)
  451. +    if (!strcmp(devname, *p))
  452. +      break;
  453. +  /* if not found get out. */
  454. +  if (!*p)
  455. +    return 0;
  456. +  S_biosdev = p - names + 3;
  457. +  /* enter supervisor mode */
  458. +  stack = Super (0L);
  459. +  /* if the OS version is too old (TOS 1.0 doesn't have the xcon* vectors)
  460. +     or can't set the device for Iorec(), get out. */
  461. +  if ((*(OSHEADER **) _sysbase)->os_version < 0x102 ||
  462. +      (S_biosdev != 3 && Bconmap (0) == 0l && !Bconmap (S_biosdev))) {
  463. +    (void) Super (stack);
  464. +    return 0;
  465. +  }
  466. +  S_iorec = Iorec (S_biosdev == 3 ? 2 : 0);
  467. +  (void) Super (stack);
  468. +  return S_biosdev;
  469. +}
  470. +
  471. +#if __GNUC__
  472. +/* macro to turn interrupts off, result is the original sr. */
  473. +#define intsoff() \
  474. +({                                    \
  475. +    short retvalue;                            \
  476. +                                        \
  477. +    __asm__ volatile                        \
  478. +    ("\
  479. +        movw    sr,%0;                        \
  480. +        orw     #0x700,sr; "                    \
  481. +    : "=g"(retvalue)            /* outputs */        \
  482. +    :                        /* no inputs */        \
  483. +    );                                \
  484. +    retvalue;                            \
  485. +})
  486. +
  487. +/* this turns them back on again, arg is the original sr */
  488. +#define intson(sr_) \
  489. +(void) ({                                \
  490. +    short  _sr = (short) (sr_);                    \
  491. +                                        \
  492. +    __asm__ volatile                        \
  493. +    ("\
  494. +        movw    %0,sr; "                    \
  495. +    :                    /* no output */        \
  496. +    : "g"(_sr)                    /* inputs */        \
  497. +    );                                \
  498. +})
  499. +#else /* !__GNUC__ */
  500. + #error "compiler-specific asm #defines"
  501. +#endif
  502. +
  503. +#if MINT_DTR || MINT_BREAK
  504. +/* set bits in scc register 5 */
  505. +void scc_or5 (control, or)
  506. +volatile char *control;
  507. +unsigned char or;
  508. +{
  509. +  long stack;
  510. +  short sr;
  511. +  volatile char dummy;
  512. +
  513. +  /* register 5 is normally WOM (write-only memory :-), but the driver
  514. +     keeps a copy in the iorec.  so if there is no iorec... */
  515. +  if (!S_iorec)
  516. +    return;
  517. +
  518. +  /* enter super mode... */
  519. +  stack = Super (0L);
  520. +  /* interrupts off */
  521. +  sr = intsoff();
  522. +  dummy = *((volatile char *) 0xfffffa01);
  523. +  *control = 5;
  524. +  dummy = *((volatile char *) 0xfffffa01);
  525. +  *control = (((char *) S_iorec)[0x1d] |= or);
  526. +  intson (sr);
  527. +  (void) Super (stack);
  528. +}
  529. +
  530. +/* same for clear... */
  531. +void scc_and5 (control, and)
  532. +volatile char *control;
  533. +unsigned char and;
  534. +{
  535. +  long stack;
  536. +  short sr;
  537. +  volatile char dummy;
  538. +
  539. +  /* (see above) */
  540. +  if (!S_iorec)
  541. +    return;
  542. +
  543. +  /* enter super mode... */
  544. +  stack = Super (0L);
  545. +  /* interrupts off */
  546. +  sr = intsoff();
  547. +  dummy = *((volatile char *) 0xfffffa01);
  548. +  *control = 5;
  549. +  dummy = *((volatile char *) 0xfffffa01);
  550. +  *control = (((char *) S_iorec)[0x1d] &= and);
  551. +  intson (sr);
  552. +  (void) Super (stack);
  553. +}
  554. +#endif /* MINT_DTR || MINT_BREAK */
  555. +
  556. +/* check the CD status on a serial port */
  557. +int pollcd (biosdev)
  558. +int biosdev;
  559. +{
  560. +  unsigned char result;
  561. +  volatile char dummy;
  562. +  long stack;
  563. +  short sr;
  564. +
  565. +  switch (biosdev) {
  566. +    case 1:
  567. +      /* modem1 on STs that don't have Bconmap() */
  568. +      /* fall thru */
  569. +    case 6:
  570. +      /* modem1 */
  571. +      /* CD is !bit 1 on the 68901 GPIP port */
  572. +      stack = Super (0L);
  573. +      result = (1 << 1) & ~*((volatile char *) 0xfffffa01);
  574. +      (void) Super (stack);
  575. +      break;
  576. +    case 7:
  577. +      /* modem2 */
  578. +      /* CD is bit 3 of read register 0 on SCC port B */
  579. +      stack = Super (0L);
  580. +      /* interrupts off */
  581. +      sr = intsoff();
  582. +      dummy = *((volatile char *) 0xfffffa01);
  583. +      result = (1 << 3) & *((volatile char *) 0xffff8c85L);
  584. +      intson (sr);
  585. +      (void) Super (stack);
  586. +      break;
  587. +    case 8:
  588. +      /* serial1 */
  589. +    case 9:
  590. +      /* serial2 */
  591. +      /* MiNT 0.95 has the names of serial1 and 2 reversed on Mega STes
  592. +     and they aren't real modem ports anyway, so for now we just
  593. +     fall thru. */
  594. +    default:
  595. +      /* unknown port, assume CD always on. */
  596. +      result = 1;
  597. +  }
  598. +  return result;
  599. +}
  600. +#endif /* __MINT__ */
  601. +
  602.  /*
  603.   * setup_tty()
  604.   *
  605. @@ -1224,6 +1508,24 @@
  606.   */
  607.  static void setup_tty()
  608.  {
  609. +#ifdef __MINT__
  610. +  char *dev = ttyname(0);
  611. +
  612. +  if (!strncmp("/dev/", dev, sizeof "/dev/" - 1))
  613. +    dev += sizeof "/dev/" - 1;
  614. +
  615. +  /* setup stuff for accessing DTR, CD etc */
  616. +  map_biosdev (dev);
  617. +
  618. +  ioctl(0, TIOCGETP, &old);
  619. +
  620. +  new = old;
  621. +
  622. +  new.sg_flags = RAW | ANYP | RTSCTS;
  623. +
  624. +  if (old.sg_flags != new.sg_flags)
  625. +    ioctl(0, TIOCSFLAGS, &new.sg_flags);
  626. +#else
  627.    register int i;
  628.  
  629.    ioctl(0, TCGETA, &old);
  630. @@ -1238,6 +1540,7 @@
  631.    new.c_lflag = 0;        /* No special line discipline */
  632.  
  633.    ioctl(0, TCSETA, &new);
  634. +#endif
  635.  }
  636.  
  637.  /*
  638. @@ -1246,7 +1549,12 @@
  639.  static void restore_tty(sig)
  640.  int sig;
  641.  {
  642. +#if HAVE_BSD_TTY
  643. +  if (old.sg_flags != new.sg_flags)
  644. +    ioctl(0, TIOCSFLAGS, &old.sg_flags);
  645. +#else
  646.    ioctl(0, TCSETA, &old);
  647. +#endif
  648.    return;
  649.  }
  650.  
  651. @@ -1278,7 +1586,11 @@
  652.  static void ttflui()
  653.  {
  654.    if(isatty(0))
  655. +#if HAVE_BSD_TTY
  656. +    (void) ioctl ( 0, TIOCFLUSH, 0);
  657. +#else
  658.      (void) ioctl ( 0, TCFLSH, 0);
  659. +#endif
  660.  }
  661.  
  662.  /*
  663. @@ -1288,6 +1600,10 @@
  664.   */
  665.  static int ttcd()
  666.  {
  667. +#ifdef __MINT__
  668. +  if (S_iorec)
  669. +    return pollcd (S_biosdev);
  670. +#endif
  671.    return TRUE;
  672.  }
  673.  
  674. @@ -1296,7 +1612,55 @@
  675.   */
  676.  static void tthang()
  677.  {
  678. -  if(!isatty())
  679. +#ifdef __MINT__
  680. +  struct sgttyb sbaud;
  681. +
  682. +  if(!isatty(1))
  683. +    return;
  684. +
  685. +#if MINT_DTR
  686. +  /* MiNT 0.95 doesn't know how to drop DTR on modem2... */
  687. +  if (S_iorec && S_biosdev == 7) {
  688. +    volatile char *control = (volatile char *) 0xffff8c85L;
  689. +
  690. +    /* DTR is bit 7 in register 5 */
  691. +    scc_and5 (control, ~(1 << 7));
  692. +
  693. +    /* sleep 30 ms... */
  694. +    usleep (30000L);
  695. +
  696. +    /* assert DTR */
  697. +    scc_or5 (control, (1 << 7));
  698. +
  699. +    /* Give the terminal a chance to settle.  */
  700. +    sleep (1);
  701. +
  702. +    return;
  703. +  }
  704. +#endif
  705. +
  706. +  sbaud = new;
  707. +
  708. +#if HAVE_BSD_TTY
  709. +  sbaud.sg_ispeed = B0;
  710. +  sbaud.sg_ospeed = B0;
  711. +#else /* ! HAVE_BSD_TTY */
  712. +  sbaud.c_cflag = (sbaud.c_cflag &~ CBAUD) | B0;
  713. +#endif /* ! HAVE_BSD_TTY */
  714. +
  715. +  if (ioctl (1, TIOCSETP, &sbaud))
  716. +    logit ("Can't hangup terminal:", strerror (errno));
  717. +
  718. +  /* Give the terminal a chance to settle.  */
  719. +  sleep (1);
  720. +
  721. +  if (ioctl (1, TIOCSETN, &new))
  722. +    logit ("Can't reopen terminal:", strerror (errno));
  723. +  
  724. +  return;
  725. +#else
  726. +
  727. +  if(!isatty(1))
  728.      return;
  729.  
  730.  #ifdef TCCLRDTR
  731. @@ -1304,8 +1668,7 @@
  732.    sleep (2);
  733.    (void) ioctl (1, TCSETDTR, 0);
  734.  #endif
  735. -
  736. -  return;
  737. +#endif /* MINT */
  738.  }
  739.  
  740.  /*
  741. @@ -1313,7 +1676,28 @@
  742.   */
  743.  static void ttbreak()
  744.  {
  745. +#ifdef __MINT__
  746. +#if MINT_BREAK
  747. +  /* MiNT 0.95 doesn't know how to send a break on modem2... */
  748. +  if (S_iorec && S_biosdev == 7) {
  749. +    volatile char *control = (volatile char *) 0xffff8c85L;
  750. +
  751. +    /* bit 4 in register 5 is the break condition */
  752. +    scc_or5 (control, (1 << 4));
  753. +    sleep (1);
  754. +    scc_and5 (control, ~(1 << 4));
  755. +    return;
  756. +  }
  757. +#endif
  758. +#endif
  759. +
  760. +#if HAVE_BSD_TTY
  761. +  ioctl (1, TIOCSBRK, 0);
  762. +  sleep (1);
  763. +  ioctl (1, TIOCCBRK, 0);
  764. +#else
  765.    (void) ioctl (1, TCSBRK, 0);
  766. +#endif /* HAVE_BSD_TTY */
  767.  }
  768.  
  769.  /*
  770. @@ -1323,7 +1707,11 @@
  771.   */
  772.  static int ttblind()
  773.  {
  774. +#if 1
  775. +  return !ttcd();
  776. +#else
  777.    return FALSE;
  778. +#endif
  779.  }
  780.  
  781.  /*
  782. @@ -1332,6 +1720,9 @@
  783.  static void tt7bit(enable)
  784.       int enable;
  785.  {
  786. +#ifdef __MINT__
  787. +  strip = enable ? 0x7f : 0xff;
  788. +#else
  789.    if(enable)
  790.      new.c_iflag |= ISTRIP;
  791.    else
  792. @@ -1338,6 +1729,7 @@
  793.      new.c_iflag &= ~ISTRIP;
  794.  
  795.    ioctl(0, TCSETA, &new);
  796. +#endif
  797.  }
  798.  
  799.  /*
  800. @@ -1346,6 +1738,27 @@
  801.  static void ttpar(mode)
  802.       int mode;
  803.  {
  804. +#ifdef __MINT__
  805. +  switch(mode)
  806. +    {
  807. +    case NONE:
  808. +      new.sg_flags &= ~(EVENP | ODDP);
  809. +      break;
  810. +
  811. +    case EVEN:
  812. +      new.sg_flags &= ~(EVENP | ODDP);
  813. +      new.sg_flags |= EVENP;
  814. +
  815. +      break;
  816. +
  817. +    case ODD:
  818. +      new.sg_flags &= ~(EVENP | ODDP);
  819. +      new.sg_flags |= ODDP;
  820. +      break;
  821. +    }
  822. +
  823. +  ioctl(0, TIOCSETP, &new);
  824. +#else
  825.    switch(mode)
  826.      {
  827.      case NONE:
  828. @@ -1369,6 +1782,7 @@
  829.      }
  830.  
  831.    ioctl(0, TCSETA, &new);
  832. +#endif /* !MINT */
  833.  }
  834.  
  835.  
  836. diff -ru ./copy.c /src/t103/uucp-1.03/copy.c
  837. --- ./copy.c    Tue Apr  7 06:05:20 1992
  838. +++ /src/t103/uucp-1.03/copy.c    Wed Jan  6 20:08:30 1993
  839. @@ -58,6 +58,12 @@
  840.  #include "system.h"
  841.  #include "sysdep.h"
  842.  
  843. +#ifdef __MINT__
  844. +/* make things a bit more efficient on slow GEMDOS */
  845. +#undef USE_STDIO
  846. +#define COPYBUF 0x4000
  847. +#endif
  848. +
  849.  /* External functions.  */
  850.  extern int fclose ();
  851.  
  852. @@ -139,7 +145,12 @@
  853.  {
  854.    int ofrom;
  855.    int oto;
  856. +#ifdef __MINT__
  857. +  /* save stackspace */
  858. +  char *ab = xmalloc(COPYBUF);
  859. +#else
  860.    char ab[8192];
  861. +#endif
  862.    int c;
  863.  
  864.    ofrom = open (zfrom, O_RDONLY, 0);
  865. @@ -155,7 +166,11 @@
  866.    oto = creat (zto, fpublic ? IPUBLIC_FILE_MODE : IPRIVATE_FILE_MODE);
  867.    if (oto < 0)
  868.      {
  869. +#ifdef __MINT__
  870. +      if ((errno == ENOENT || errno == EPATH) && fmkdirs)
  871. +#else
  872.        if (errno == ENOENT && fmkdirs)
  873. +#endif
  874.      {
  875.        if (! fsysdep_make_dirs (zto, fpublic))
  876.          return FALSE;
  877. @@ -170,7 +185,11 @@
  878.      }
  879.      }
  880.  
  881. +#ifdef __MINT__
  882. +  while ((c = read (ofrom, ab, COPYBUF)) > 0)
  883. +#else
  884.    while ((c = read (ofrom, ab, sizeof ab)) > 0)
  885. +#endif
  886.      {
  887.        if (write (oto, ab, c) != c)
  888.      {
  889. @@ -183,6 +202,10 @@
  890.      }
  891.  
  892.    (void) close (ofrom);
  893. +
  894. +#ifdef __MINT__
  895. +  (void) xfree (ab);
  896. +#endif
  897.  
  898.    if (close (oto) < 0)
  899.      {
  900. diff -ru ./makefile /src/t103/uucp-1.03/makefile
  901. --- ./makefile    Tue Apr  7 06:31:54 1992
  902. +++ /src/t103/uucp-1.03/makefile    Wed Jan  6 23:47:54 1993
  903. @@ -44,7 +44,7 @@
  904.  # and the Taylor configuration files, comment out the following line
  905.  # The tstuu program is only used to test the package; it is described
  906.  # further in the documentation.
  907. -TSTUU = tstuu
  908. +TSTUU = tstuu.ttp
  909.  
  910.  #
  911.  # The next few lines are set up by the configuration script.  You may
  912. @@ -55,26 +55,38 @@
  913.  # lines.  This will install uudir as an suid root program.  This is
  914.  # necessary because invoking /bin/mkdir from an suid program will
  915.  # leave the directories owned by the wrong user.
  916. -@UUDIR@UUDIR = uudir
  917. -@UUDIR@uudirdir = $(libdir)/util
  918. -@UUDIR@UUDIRFLAGS = -DUUDIR_PROGRAM=\"$(uudirdir)/$(UUDIR)\"
  919. +# UUDIR = uudir
  920. +# uudirdir = $(libdir)/util
  921. +# UUDIRFLAGS = -DUUDIR_PROGRAM=\"$(uudirdir)/$(UUDIR)\"
  922.  
  923.  # Source directory and, if necessary, VPATH
  924. -srcdir = @srcdir@
  925. -@VPATH@
  926. +srcdir = .
  927. +# @VPATH@
  928.  
  929.  # Define programs and flags
  930. -CC = @CC@
  931. -CFLAGS = @CFLAGS@
  932. -LDFLAGS = @LDFLAGS@
  933. -LIBS = @LIBS@
  934. -ALLOCA = @ALLOCA@
  935. +CC = gcc
  936. +# gcc 1.40:
  937. +#CFLAGS = -O -Wall -fcombine-regs -fomit-frame-pointer -fstrength-reduce
  938. +# LDFLAGS = @LDFLAGS@
  939. +#LIBS = -liio
  940. +
  941. +# gcc 2.3.1:
  942. +CFLAGS = -O2 -Wall -fomit-frame-pointer -fstrength-reduce
  943. +# LDFLAGS = @LDFLAGS@
  944. +LIBS = -liio
  945. +
  946. +# gcc 2.3.1 -mbaserel: (not yet)
  947. +#CFLAGS = -mbaserel -O2 -Wall -fomit-frame-pointer -fstrength-reduce
  948. +#LDFLAGS = -mbaserel
  949. +#LIBS = -lbiio
  950.  
  951. -INSTALL = @INSTALL@
  952. +# ALLOCA = @ALLOCA@
  953. +
  954. +INSTALL = cp
  955.  INSTALL_PROGRAM = $(INSTALL)
  956. -INSTALL_DATA = @INSTALLDATA@
  957. +INSTALL_DATA = $(INSTALL)
  958.  
  959. -LN_S = @LN_S@
  960. +# LN_S = @LN_S@
  961.  
  962.  #
  963.  # Nothing else to configure
  964. @@ -86,7 +98,7 @@
  965.  
  966.  MORECFLAGS = -I$(srcdir) -I. -DLIBDIR=\"$(libdir)\" -DNEWCONFIGLIB=\"$(newconfigdir)\" -DOLDCONFIGLIB=\"$(oldconfigdir)\" -DOWNER=\"$(owner)\" $(UUDIRFLAGS)
  967.  
  968. -PROGRAMS = uucico uuxqt uux uucp uuchk uustat uuname uulog
  969. +PROGRAMS = uucico.ttp uuxqt.ttp uux.ttp uucp.ttp uuchk.ttp uustat.ttp uuname.ttp uulog.ttp
  970.  
  971.  UUOBJS = uucico.o prot.o protg.o protf.o prott.o prote.o config.o v2.o bnu.o \
  972.      file.o util.o sysinf.o prtinf.o time.o log.o chat.o port.o tcp.o \
  973. @@ -117,7 +129,28 @@
  974.  
  975.  all: $(PROGRAMS) $(TSTUU) $(UUDIR)
  976.  
  977. -install: $(PROGRAMS) uucp.info $(UUDIR)
  978. +# simple install for MiNT...
  979. +install: $(PROGRAMS)
  980. +    -mkdir $(libdir) $(bindir)
  981. +    $(INSTALL_PROGRAM) uucico.ttp $(libdir)/uucico.ttp
  982. +    $(INSTALL_PROGRAM) uuxqt.ttp $(libdir)/uuxqt.ttp
  983. +    $(INSTALL_PROGRAM) uuchk.ttp $(libdir)/uuchk.ttp
  984. +    $(INSTALL_PROGRAM) uux.ttp $(bindir)/uux.ttp
  985. +    $(INSTALL_PROGRAM) uucp.ttp $(bindir)/uucp.ttp
  986. +    $(INSTALL_PROGRAM) uustat.ttp $(bindir)/uustat.ttp
  987. +    $(INSTALL_PROGRAM) uuname.ttp $(bindir)/uuname.ttp
  988. +    $(INSTALL_PROGRAM) uulog.ttp $(bindir)/uulog.ttp
  989. +    xstrip $(libdir)/uucico.ttp
  990. +    xstrip $(libdir)/uuxqt.ttp
  991. +    xstrip $(libdir)/uuchk.ttp
  992. +    xstrip $(bindir)/uux.ttp
  993. +    xstrip $(bindir)/uucp.ttp
  994. +    xstrip $(bindir)/uustat.ttp
  995. +    xstrip $(bindir)/uuname.ttp
  996. +    xstrip $(bindir)/uulog.ttp
  997. +
  998. +#install: $(PROGRAMS) uucp.info $(UUDIR)
  999. +install.ix: $(PROGRAMS) uucp.info $(UUDIR)
  1000.      -mkdir $(libdir) $(bindir)
  1001.      -ln $(libdir)/uucico $(libdir)/uucico.old
  1002.      -ln $(libdir)/uuxqt $(libdir)/uuxqt.old
  1003. @@ -173,35 +206,35 @@
  1004.      -chmod 4555 $(bindir)/uux $(bindir)/uucp $(bindir)/uustat 
  1005.      -chmod 4555 $(bindir)/uuname
  1006.  
  1007. -uucico: $(UUOBJS)
  1008. -    $(CC) $(LDFLAGS) -o uucico $(UUOBJS) $(LIBS)
  1009. +uucico.ttp: $(UUOBJS)
  1010. +    $(CC) $(LDFLAGS) -o uucico.ttp $(UUOBJS) $(LIBS)
  1011.  
  1012. -uuxqt: $(XQTOBJS)
  1013. -    $(CC) $(LDFLAGS) -o uuxqt $(XQTOBJS) $(LIBS)
  1014. +uuxqt.ttp: $(XQTOBJS)
  1015. +    $(CC) $(LDFLAGS) -o uuxqt.ttp $(XQTOBJS) $(LIBS)
  1016.  
  1017. -uux: $(UUXOBJS)
  1018. -    $(CC) $(LDFLAGS) -o uux $(UUXOBJS) $(LIBS)
  1019. +uux.ttp: $(UUXOBJS)
  1020. +    $(CC) $(LDFLAGS) -o uux.ttp $(UUXOBJS) $(LIBS)
  1021.  
  1022. -uucp: $(UUCPOBJS)
  1023. -    $(CC) $(LDFLAGS) -o uucp $(UUCPOBJS) $(LIBS)
  1024. +uucp.ttp: $(UUCPOBJS)
  1025. +    $(CC) $(LDFLAGS) -o uucp.ttp $(UUCPOBJS) $(LIBS)
  1026.  
  1027. -uuchk: $(UUCHKOBJS)
  1028. -    $(CC) $(LDFLAGS) -o uuchk $(UUCHKOBJS) $(LIBS)
  1029. +uuchk.ttp: $(UUCHKOBJS)
  1030. +    $(CC) $(LDFLAGS) -o uuchk.ttp $(UUCHKOBJS) $(LIBS)
  1031.  
  1032. -uustat: $(UUSTATOBJS)
  1033. -    $(CC) $(LDFLAGS) -o uustat $(UUSTATOBJS) $(LIBS)
  1034. +uustat.ttp: $(UUSTATOBJS)
  1035. +    $(CC) $(LDFLAGS) -o uustat.ttp $(UUSTATOBJS) $(LIBS)
  1036.  
  1037. -uuname: $(UUNAMEOBJS)
  1038. -    $(CC) $(LDFLAGS) -o uuname $(UUNAMEOBJS) $(LIBS)
  1039. +uuname.ttp: $(UUNAMEOBJS)
  1040. +    $(CC) $(LDFLAGS) -o uuname.ttp $(UUNAMEOBJS) $(LIBS)
  1041.  
  1042. -uulog: $(UULOGOBJS)
  1043. -    $(CC) $(LDFLAGS) -o uulog $(UULOGOBJS) $(LIBS)
  1044. +uulog.ttp: $(UULOGOBJS)
  1045. +    $(CC) $(LDFLAGS) -o uulog.ttp $(UULOGOBJS) $(LIBS)
  1046.  
  1047. -tstuu: $(TSTOBJS)
  1048. -    $(CC) $(LDFLAGS) -o tstuu $(TSTOBJS) $(LIBS)
  1049. +tstuu.ttp: $(TSTOBJS)
  1050. +    $(CC) $(LDFLAGS) -o tstuu.ttp $(TSTOBJS) # $(LIBS)
  1051.  
  1052. -uudir: uudir.o
  1053. -    $(CC) $(LDFLAGS) -o uudir uudir.o $(LIBS)
  1054. +uudir.ttp: uudir.o
  1055. +    $(CC) $(LDFLAGS) -o uudir.ttp uudir.o $(LIBS)
  1056.  
  1057.  .c.o:
  1058.      $(CC) -c $(CFLAGS) $(MORECFLAGS) $<
  1059. @@ -208,16 +241,16 @@
  1060.  
  1061.  .SUFFIXES: .unx
  1062.  
  1063. -sysdep.h: sysh.unx
  1064. -    rm -f sysdep.h
  1065. -    $(LN_S) sysh.unx sysdep.h
  1066. -
  1067. -.unx.c:
  1068. -    rm -f $@
  1069. -    $(LN_S) $< $@
  1070. +# sysdep.h: sysh.unx
  1071. +#    rm -f sysdep.h
  1072. +#    $(LN_S) sysh.unx sysdep.h
  1073. +
  1074. +# .unx.c:
  1075. +#    rm -f $@
  1076. +#    $(LN_S) $< $@
  1077.  
  1078.  clean:
  1079. -    rm -f $(ALLOBJS) uucico uuxqt uux uucp uuchk tstuu
  1080. +    rm -f $(ALLOBJS) uucico.ttp uuxqt.ttp uux.ttp uucp.ttp uuchk.ttp tstuu.ttp
  1081.      rm -f uucp-$(VERSION).tar.Z
  1082.      rm -rf uucp-$(VERSION)
  1083.  
  1084. diff -ru ./policy.h /src/t103/uucp-1.03/policy.h
  1085. --- ./policy.h    Tue Apr  7 06:31:54 1992
  1086. +++ /src/t103/uucp-1.03/policy.h    Wed Sep 16 14:21:56 1992
  1087. @@ -89,7 +89,7 @@
  1088.     HAVE_SYSV_TERMIO -- Use the System V termio routines
  1089.     HAVE_POSIX_TERMIOS -- Use the POSIX termios routines
  1090.     */
  1091. -#define HAVE_BSD_TTY 0
  1092. +#define HAVE_BSD_TTY 1
  1093.  #define HAVE_SYSV_TERMIO 0
  1094.  #define HAVE_POSIX_TERMIOS 0
  1095.  
  1096. @@ -136,7 +136,7 @@
  1097.     is too large, data loss may occur.  If SINGLE_WRITE is too small,
  1098.     file transfer will use more CPU time than necessary.  If you have
  1099.     no idea, 64 should work on most modern systems.  */
  1100. -#define SINGLE_WRITE 64
  1101. +#define SINGLE_WRITE 128
  1102.  
  1103.  /* Set TIMES_TICK to the fraction of a second which times(2) returns
  1104.     (for example, if times returns 100ths of a second TIMES_TICK should
  1105. @@ -159,7 +159,7 @@
  1106.     although some may complain about the 'p' option.  The second set of
  1107.     definitions are appropriate for System V.  To use the second set of
  1108.     definitions, change the ``#if 1'' to ``#if 0''.  */
  1109. -#if 1
  1110. +#if 0
  1111.  #define PS_PROGRAM "/bin/ps -lp"
  1112.  #define HAVE_PS_MULTIPLE 0
  1113.  #else
  1114. @@ -264,7 +264,7 @@
  1115.     configuration files will be read first, followed by the V2
  1116.     configuration files, followed by the BNU configuration files.  */
  1117.  #define HAVE_V2_CONFIG 0
  1118. -#define HAVE_BNU_CONFIG 0
  1119. +#define HAVE_BNU_CONFIG 1
  1120.  
  1121.  /* Exactly one of the following macros must be set to 1.  The exact
  1122.     format of the spool directories is explained in sys3.unx.
  1123. @@ -281,9 +281,9 @@
  1124.  #define SPOOLDIR_V2 0
  1125.  #define SPOOLDIR_BSD42 0
  1126.  #define SPOOLDIR_BSD43 0
  1127. -#define SPOOLDIR_BNU 0
  1128. +#define SPOOLDIR_BNU 1
  1129.  #define SPOOLDIR_ULTRIX 0
  1130. -#define SPOOLDIR_TAYLOR 1
  1131. +#define SPOOLDIR_TAYLOR 0
  1132.  
  1133.  /* You must select which type of logging you want by setting exactly
  1134.     one of the following to 1.  These control output to the log file
  1135. @@ -332,7 +332,7 @@
  1136.     exist when a new message is written out, it will be created.
  1137.     Setting CLOSE_LOGFILES to 1 will obviously require slightly more
  1138.     processing time.  */
  1139. -#define CLOSE_LOGFILES 0
  1140. +#define CLOSE_LOGFILES 1
  1141.  
  1142.  /* The name of the default spool directory.  If HAVE_TAYLOR_CONFIG is
  1143.     set to 1, this may be overridden by the ``spool'' command in the
  1144. @@ -379,7 +379,7 @@
  1145.        ``remote-receive'')
  1146.     the command will be rejected.  By default, any argument is
  1147.     permitted. */
  1148. -#define ALLOW_FILENAME_ARGUMENTS 1
  1149. +#define ALLOW_FILENAME_ARGUMENTS 0
  1150.  
  1151.  #if HAVE_TAYLOR_LOGGING
  1152.  
  1153. diff -ru ./protg.c /src/t103/uucp-1.03/protg.c
  1154. --- ./protg.c    Tue Apr  7 07:05:24 1992
  1155. +++ /src/t103/uucp-1.03/protg.c    Wed Jan  6 20:58:32 1993
  1156. @@ -1167,10 +1167,9 @@
  1157.      }
  1158.        else
  1159.      {
  1160. -      /* The read timed out.  If we're looking for a control
  1161. -         packet, assume we're looking for an ack and send the last
  1162. -         unacknowledged packet again.  Otherwise, send an RJ with
  1163. -         the last packet we received correctly.  */
  1164. +      /* The read timed out.  If we have an unacknowledged packet,
  1165. +         send it again.  Otherwise, send an RJ with the last
  1166. +         packet we received correctly.  */
  1167.  
  1168.        ++ctimeouts;
  1169.        if (ctimeouts > cretries)
  1170. @@ -1180,8 +1179,7 @@
  1171.            return FALSE;
  1172.          }
  1173.  
  1174. -      if (freturncontrol
  1175. -          && INEXTSEQ (iGremote_ack) != iGsendseq)
  1176. +      if (INEXTSEQ (iGremote_ack) != iGsendseq)
  1177.          {
  1178.            int inext;
  1179.  
  1180. @@ -1346,6 +1344,7 @@
  1181.        unsigned short ihdrcheck, idatcheck;
  1182.        const char *zfirst, *zsecond;
  1183.        int cfirst, csecond;
  1184. +      boolean fduprr;
  1185.  
  1186.        /* Look for the DLE which must start a packet.  */
  1187.  
  1188. @@ -1577,6 +1576,20 @@
  1189.        /* Store the control byte for the handshake routines.  */
  1190.        iGpacket_control = ab[IFRAME_CONTROL] & 0xff;
  1191.  
  1192. +      /* Annoyingly, some UUCP packages appear to send an RR packet
  1193. +     rather than an RJ packet when they want a packet to be
  1194. +     resent.  If we get a duplicate RR, we treat it as an RJ.  */
  1195. +      fduprr = FALSE;
  1196. +      if (CONTROL_TT (ab[IFRAME_CONTROL]) == CONTROL
  1197. +      && CONTROL_XXX (ab[IFRAME_CONTROL]) == RR
  1198. +      && iGremote_ack == CONTROL_YYY (ab[IFRAME_CONTROL])
  1199. +      && INEXTSEQ (iGremote_ack) != iGsendseq)
  1200. +    {
  1201. +      DEBUG_MESSAGE0 (DEBUG_PROTO | DEBUG_ABNORMAL,
  1202. +              "fgprocess_data: Treating duplicate RR as RJ");
  1203. +      fduprr = TRUE;
  1204. +    }
  1205. +
  1206.        /* Update the received sequence number from the yyy field of a
  1207.       data packet or an RR control packet.  If we've been delaying
  1208.       sending packets until we received an ack, this may send out
  1209. @@ -1748,6 +1761,12 @@
  1210.            (void) fgsend_control (CLOSE, 0);
  1211.          }
  1212.        return FALSE;
  1213. +    case RR:
  1214. +      /* Acknowledge receipt of a packet.  This was already handled
  1215. +         above, unless we are treating it as RJ.  */
  1216. +      if (! fduprr)
  1217. +        break;
  1218. +      /* Fall through.  */
  1219.      case RJ:
  1220.        /* The other side dropped a packet.  Begin retransmission with
  1221.           the packet following the one acknowledged.  We don't
  1222. @@ -1794,10 +1813,6 @@
  1223.          if (! fsend_data (zpack, CFRAMELEN + CPACKLEN (zpack), TRUE))
  1224.            return FALSE;
  1225.        }
  1226. -      break;
  1227. -    case RR:
  1228. -      /* Acknowledge receipt of a packet.  This was already handled
  1229. -         above.  */
  1230.        break;
  1231.      case INITC:
  1232.      case INITB:
  1233. diff -ru ./sys1.c /src/t103/uucp-1.03/sys1.c
  1234. --- ./sys1.c    Tue Apr  7 06:05:26 1992
  1235. +++ /src/t103/uucp-1.03/sys1.c    Wed Jan  6 20:06:22 1993
  1236. @@ -402,6 +402,16 @@
  1237.  #endif
  1238.  #endif /* ! HAVE_UNION_WAIT */
  1239.  
  1240. +#ifdef __MINT__
  1241. +/* bigger stack for all those alloca()s...  (sys1.o is liked everywhere) */
  1242. +long    _stksize = 0x8000;
  1243. +extern int __mint;
  1244. +
  1245. +#include <setjmp.h>
  1246. +#include <ctype.h>
  1247. +#include <osbind.h>
  1248. +#endif
  1249. +
  1250.  /* External variables.  */
  1251.  extern char **environ;
  1252.  
  1253. @@ -464,7 +474,12 @@
  1254.  int cSysdep_max_name_len = 7;
  1255.  #endif /* SPOOLDIR_V2 | SPOOLDIR_BSD42 | SPOOLDIR_BSD43 | SPOOLDIR_ULTRIX */
  1256.  #if SPOOLDIR_BNU
  1257. +#ifdef __MINT__
  1258. +/* MiNT's default filesystem is still messdos-like... */
  1259. +int cSysdep_max_name_len = 7;
  1260. +#else
  1261.  int cSysdep_max_name_len = 14;
  1262. +#endif
  1263.  #endif /* SPOOLDIR_BNU */
  1264.  #if SPOOLDIR_TAYLOR
  1265.  #if HAVE_LONG_NAMES
  1266. @@ -536,6 +551,13 @@
  1267.       systems truncate the getlogin return value to 8 characters, but
  1268.       keep the full name in the password file, so we prefer the name in
  1269.       the password file.  */
  1270. +#ifdef __MINT__
  1271. +  /* hmmm... */
  1272. +  _malloczero(1);
  1273. +
  1274. +  /* if we're root, prefer the name in $USER. */
  1275. +  if (getuid() || !(z = getenv ("USER")))
  1276. +#endif
  1277.    z = getlogin ();
  1278.    if (z == NULL)
  1279.      q = NULL;
  1280. @@ -556,6 +578,10 @@
  1281.  
  1282.    if (fdaemon)
  1283.      {
  1284. +#ifdef __MINT__
  1285. +      if (__mint < 95)
  1286. +    ulog (LOG_FATAL, "need MiNT >= 0.95 to run!  (on your friendly neighbour archive site :-)");
  1287. +#endif
  1288.        /* Set our uid to our effective uid.  There is no point in
  1289.       remembering who originally ran the program.  This won't work
  1290.       on System V, but there's nothing to be done about that and it
  1291. @@ -618,11 +644,19 @@
  1292.       exist.  */
  1293.    if (chdir (zSpooldir) < 0)
  1294.      {
  1295. +#ifdef __MINT__
  1296. +      if (errno != ENOENT && errno != EPATH)
  1297. +#else
  1298.        if (errno != ENOENT)
  1299. +#endif
  1300.      ulog (LOG_FATAL, "chdir (%s): %s", zSpooldir,
  1301.            strerror (errno));
  1302.        usmake_spool_dir ();
  1303.      }
  1304. +#ifdef __MINT__
  1305. +  /* make sure freads from stdin are binary... */
  1306. +  stdin->_flag |= _IOBIN;
  1307. +#endif
  1308.  }
  1309.  
  1310.  /* Exit the program.  */
  1311. @@ -666,6 +700,22 @@
  1312.  #define HAVE_TIOCNOTTY 0 
  1313.  #endif
  1314.  
  1315. +#ifdef __MINT__
  1316. +/* on MiNT fork and vfork both block until the child does either exec or
  1317. +   dies.  only tfork doesn't block but it works like a subroutine call... */
  1318. +static jmp_buf    tforkj;
  1319. +
  1320. +static int in_tfork(arg)
  1321. +int arg;
  1322. +{
  1323. +  /* wait for parent to die before we can longjmp back */
  1324. +  while (getppid () > 1)
  1325. +    sleep (1);
  1326. +  longjmp (tforkj, 1);
  1327. +  /*NOTREACHED*/
  1328. +}
  1329. +#endif
  1330. +
  1331.  void
  1332.  usysdep_detach ()
  1333.  {
  1334. @@ -694,6 +744,15 @@
  1335.       die.  */
  1336.        usset_signal (SIGHUP, SIG_IGN, FALSE, &fignored);
  1337.  
  1338. +#ifdef __MINT__
  1339. +      if (!setjmp(tforkj)) {
  1340. +    ipid = tfork (in_tfork, 0);
  1341. +    if (ipid < 0)
  1342. +      ulog (LOG_FATAL, "tfork: %s", strerror (errno));
  1343. +    else
  1344. +      _exit (EXIT_SUCCESS);
  1345. +      }
  1346. +#else
  1347.        ipid = isfork ();
  1348.        if (ipid < 0)
  1349.      ulog (LOG_FATAL, "fork: %s", strerror (errno));
  1350. @@ -706,6 +765,7 @@
  1351.       reenabling SIGHUP.  */
  1352.        while (getppid () != 1)
  1353.      sleep (1);
  1354. +#endif
  1355.  
  1356.        /* Restore SIGHUP catcher if it wasn't being ignored.  */
  1357.        if (! fignored)
  1358. @@ -723,11 +783,26 @@
  1359.  
  1360.    /* Reopen stdin, stdout and stderr.  */
  1361.  
  1362. +#ifdef __MINT__
  1363. +  /* i don't think open will _ever_ return fds < 6 on TOS/MiNT... */
  1364. +  { int nullfd = open ("/dev/null", O_RDWR);
  1365. +
  1366. +    if (nullfd < 0 || dup2(nullfd, 0) < 0
  1367. +      || dup2(nullfd, 1) < 0 || dup2(nullfd, 2) < 0)
  1368. +      ulog (LOG_FATAL, "open (/dev/null): %s", strerror (errno));
  1369. +  }
  1370. +#else
  1371.    if (open ("/dev/null", O_RDONLY) != 0
  1372.        || open ("/dev/null", O_WRONLY) != 1
  1373.        || open ("/dev/null", O_WRONLY) != 2)
  1374.      ulog (LOG_FATAL, "open (/dev/null): %s", strerror (errno));
  1375. +#endif
  1376.  
  1377. +#ifdef __MINT__ 
  1378. +/* getpgrp() on MiNT has no args but setpgrp has 2...  */
  1379. +#undef HAVE_BSD_PGRP
  1380. +#define HAVE_BSD_PGRP 1
  1381. +#endif
  1382.  #if HAVE_BSD_PGRP
  1383.  
  1384.  #if HAVE_TIOCNOTTY
  1385. @@ -811,7 +886,13 @@
  1386.  {
  1387.  #if HAVE_GETHOSTNAME
  1388.    char ab[256];
  1389. +#ifdef __MINT__
  1390. +  char *p;
  1391.  
  1392. +  /* other uucp stuff has it in $SITENAME */
  1393. +  if (p=getenv("SITENAME"))
  1394. +    return p;
  1395. +#endif
  1396.    if (gethostname (ab, sizeof ab) < 0)
  1397.      {
  1398.        ulog (LOG_ERROR, "gethostname: %s", strerror (errno));
  1399. @@ -871,6 +952,10 @@
  1400.    z = ttyname (0);
  1401.    if (z == NULL)
  1402.      return NULL;
  1403. +#ifdef __MINT__
  1404. +  if (z[1] == ':' && (*z | 0x20) == 'u')
  1405. +    z += 2;
  1406. +#endif
  1407.    if (strncmp (z, "/dev/", 5) == 0)
  1408.      return z + 5;
  1409.    else
  1410. @@ -1093,6 +1178,11 @@
  1411.  
  1412.    if (itick == 0)
  1413.      {
  1414. +/* hmm.  gcc barfs on the #if TIMES_TICK != 0 below when TIMES_TICK
  1415. +   is ((clock_t) 200)  */
  1416. +#ifdef __MINT__
  1417. +      itick = TIMES_TICK;
  1418. +#else
  1419.  #if TIMES_TICK != 0
  1420.        itick = TIMES_TICK;
  1421.  #else /* TIMES_TICK == 0 */
  1422. @@ -1106,6 +1196,7 @@
  1423.        if (itick == 0)
  1424.      itick = 60;
  1425.  #endif /* TIMES_TICK == 0 */
  1426. +#endif
  1427.      }
  1428.  
  1429.    i = (long) times (&s);
  1430. @@ -1187,7 +1278,11 @@
  1431.  
  1432.    if (o < 0)
  1433.      {
  1434. +#ifdef __MINT__
  1435. +      if ((errno == ENOENT || errno == EPATH) && fmkdirs)
  1436. +#else
  1437.        if (errno == ENOENT && fmkdirs)
  1438. +#endif
  1439.      {
  1440.        if (! fsysdep_make_dirs (zfile, fpublic))
  1441.          return NULL;
  1442. @@ -1224,10 +1319,17 @@
  1443.  #endif /* defined (O_APPEND) */
  1444.  #endif /* ! defined (O_CREAT) */
  1445.  
  1446. +#ifdef __MINT__
  1447.    if (fappend)
  1448. +    e = fdopen (o, (char *) "ab");
  1449. +  else
  1450. +    e = fdopen (o, (char *) "wb");
  1451. +#else
  1452. +  if (fappend)
  1453.      e = fdopen (o, (char *) "a");
  1454.    else
  1455.      e = fdopen (o, (char *) "w");
  1456. +#endif
  1457.  
  1458.    if (e == NULL)
  1459.      {
  1460. @@ -1260,7 +1362,15 @@
  1461.  {
  1462.    char *zcopy, *z;
  1463.    int imode;
  1464. +#ifdef __MINT__
  1465. +  char *p, ch;
  1466.  
  1467. +  if (p = (char *) zfile)
  1468. +    for (; ch = *p; ++p)
  1469. +      if (ch == '\\')
  1470. +    *p = '/';
  1471. +#endif
  1472. +
  1473.    zcopy = (char *) alloca (strlen (zfile) + 1);
  1474.    strcpy (zcopy, zfile);
  1475.  
  1476. @@ -1302,6 +1412,14 @@
  1477.    static char *zalc;
  1478.    const char *zdir;
  1479.    int clen;
  1480. +#ifdef __MINT__
  1481. +  char *p, ch;
  1482. +
  1483. +  if (p = (char *) zfile)
  1484. +    for (; ch = *p; ++p)
  1485. +      if (ch == '\\')
  1486. +    *p = '/';
  1487. +#endif
  1488.  
  1489.    if (zfile[0] != '~')
  1490.      return zfile;
  1491. @@ -1349,6 +1467,13 @@
  1492.      }
  1493.      }
  1494.  
  1495. +#ifdef __MINT__
  1496. +  if (p = (char *) zdir)
  1497. +    for (; ch = *p; ++p)
  1498. +      if (ch == '\\')
  1499. +    *p = '/';
  1500. +#endif
  1501. +
  1502.    clen = strlen (zdir) + strlen (zfile) + 2;
  1503.    if (clen > calc)
  1504.      {
  1505. @@ -1532,6 +1657,18 @@
  1506.    int c;
  1507.    char *zcopy, *zslash;
  1508.    struct stat s;
  1509. +#ifdef __MINT__
  1510. +  char *p, ch;
  1511. +
  1512. +  if (p = (char *) zfile)
  1513. +    for (; ch = *p; ++p)
  1514. +      if (ch == '\\')
  1515. +    *p = '/';
  1516. +  if (p = (char *) zdir)
  1517. +    for (; ch = *p; ++p)
  1518. +      if (ch == '\\')
  1519. +    *p = '/';
  1520. +#endif
  1521.  
  1522.    if (*zdir == '~')
  1523.      {
  1524. @@ -1542,9 +1679,43 @@
  1525.    c = strlen (zdir);
  1526.    if (zdir[c - 1] == '/')
  1527.      c--;
  1528. +#ifdef __MINT__
  1529. +  if (strncmp (zfile, zdir, c) != 0) {
  1530. +    char *abs = (char *) zdir, buf[0x101];
  1531. +    int l = c, linkl;
  1532. +
  1533. +    /* on MiNT the `normal' A:, C: etc filesystems are mounted as /a, /c.
  1534. +       the only way to get them into the root as something else (say, /usr)
  1535. +       is via symlinks...  check that also. */
  1536. +    if (!*zdir)
  1537. +      return FALSE;
  1538. +    if (zslash = strchr (zdir+1, '/')) {
  1539. +      l = zslash-zdir;
  1540. +      abs = alloca (l+1);
  1541. +      strncpy (abs, zdir, l);
  1542. +      abs[l] = 0;
  1543. +    }
  1544. +    if ((linkl = readlink (abs, buf, sizeof buf)) <= 0)
  1545. +      return FALSE;
  1546. +    if (buf[1] == ':') {
  1547. +      buf[1] = buf[0] | 0x20;
  1548. +      *buf = '/';
  1549. +    }
  1550. +    if (buf[linkl-1] == '/')
  1551. +      --linkl;
  1552. +    if (strncmp (zfile, buf, linkl) ||
  1553. +        strncmp (zfile+linkl, zslash, c-l))
  1554. +      return FALSE;
  1555. +
  1556. +    c = c - l + linkl;
  1557. +  }
  1558. +  if (zfile[c] != '/' && zfile[c] != '\0')
  1559. +    return FALSE;
  1560. +#else
  1561.    if (strncmp (zfile, zdir, c) != 0
  1562.        || (zfile[c] != '/' && zfile[c] != '\0'))
  1563.      return FALSE;
  1564. +#endif
  1565.    if (strstr (zfile + c, "/../") != NULL)
  1566.      return FALSE;
  1567.  
  1568. @@ -1639,8 +1810,17 @@
  1569.    int aidescs[3];
  1570.    pid_t ipid;
  1571.  
  1572. +#ifdef __MINT__
  1573. +  zlib = (char *) alloca (sizeof LIBDIR + sizeof "/.ttp" + strlen (zprogram));
  1574. +  sprintf (zlib, "%s/%s", LIBDIR, zprogram);
  1575. +
  1576. +  /* if zprogram does not exist then try with .ttp */
  1577. +  if (access (zlib, F_OK))
  1578. +    strcat (zlib, ".ttp");
  1579. +#else
  1580.    zlib = (char *) alloca (sizeof LIBDIR + sizeof "/" + strlen (zprogram));
  1581.    sprintf (zlib, "%s/%s", LIBDIR, zprogram);
  1582. +#endif
  1583.  
  1584.    azargs[0] = zlib;
  1585.    azargs[1] = zarg1;
  1586. @@ -1779,6 +1959,8 @@
  1587.    xmkdir (PRESERVEDIR);
  1588.  }
  1589.  
  1590. +/* MiNT doesn't need this. (we always use vfork) */
  1591. +#ifndef __MINT__
  1592.  /* Retry fork several times before giving up.  */
  1593.  
  1594.  pid_t
  1595. @@ -1797,6 +1979,7 @@
  1596.  
  1597.    return iret;
  1598.  }
  1599. +#endif
  1600.  
  1601.  /* Spawn a child in a fairly secure fashion.  This returns the process
  1602.     ID of the child or -1 on error.  It takes far too many arguments:
  1603. @@ -1840,7 +2023,11 @@
  1604.  {
  1605.    char *zshcmd = NULL;
  1606.    int i;
  1607. +#ifdef __MINT__
  1608. +  char *azenv[25];
  1609. +#else
  1610.    char *azenv[9];
  1611. +#endif
  1612.    char **pazenv;
  1613.    boolean ferr;
  1614.    int ierr = 0;
  1615. @@ -1896,6 +2083,15 @@
  1616.        sprintf (azenv[2], "TERM=%s", zterm);
  1617.  
  1618.        azenv[3] = (char *) "SHELL=/bin/sh";
  1619. +#ifdef __MINT__
  1620. +      /* on MiNT people don't always have a shell in /bin/sh */
  1621. +      ztz = getenv ("SHELL");
  1622. +      if (ztz != NULL)
  1623. +    {
  1624. +      azenv[3] = (char *) alloca (sizeof "SHELL=" + strlen (ztz));
  1625. +      sprintf (azenv[3], "SHELL=%s", ztz);
  1626. +    }
  1627. +#endif
  1628.    
  1629.        azenv[4] = (char *) alloca (sizeof "USER=" + strlen (OWNER));
  1630.        sprintf (azenv[4], "USER=%s", OWNER);
  1631. @@ -1910,6 +2106,81 @@
  1632.        ++ienv;
  1633.      }
  1634.  
  1635. +#ifdef __MINT__
  1636. +      /* the next 10 are used by TOS uucp stuff... */
  1637. +
  1638. +      ztz = getenv ("TEMP");
  1639. +      if (ztz != NULL)
  1640. +    {
  1641. +      azenv[ienv] = (char *) alloca (sizeof "TEMP=" + strlen (ztz));
  1642. +      sprintf (azenv[ienv], "TEMP=%s", ztz);
  1643. +      ++ienv;
  1644. +    }
  1645. +      ztz = getenv ("TMPDIR");
  1646. +      if (ztz != NULL)
  1647. +    {
  1648. +      azenv[ienv] = (char *) alloca (sizeof "TMPDIR=" + strlen (ztz));
  1649. +      sprintf (azenv[ienv], "TMPDIR=%s", ztz);
  1650. +      ++ienv;
  1651. +    }
  1652. +      ztz = getenv ("TMP");
  1653. +      if (ztz != NULL)
  1654. +    {
  1655. +      azenv[ienv] = (char *) alloca (sizeof "TMP=" + strlen (ztz));
  1656. +      sprintf (azenv[ienv], "TMP=%s", ztz);
  1657. +      ++ienv;
  1658. +    }
  1659. +      ztz = getenv ("TEMPDIR");
  1660. +      if (ztz != NULL)
  1661. +    {
  1662. +      azenv[ienv] = (char *) alloca (sizeof "TEMPDIR=" + strlen (ztz));
  1663. +      sprintf (azenv[ienv], "TEMPDIR=%s", ztz);
  1664. +      ++ienv;
  1665. +    }
  1666. +      ztz = getenv ("ETC");
  1667. +      if (ztz != NULL)
  1668. +    {
  1669. +      azenv[ienv] = (char *) alloca (sizeof "ETC=" + strlen (ztz));
  1670. +      sprintf (azenv[ienv], "ETC=%s", ztz);
  1671. +      ++ienv;
  1672. +    }
  1673. +      ztz = getenv ("USR");
  1674. +      if (ztz != NULL)
  1675. +    {
  1676. +      azenv[ienv] = (char *) alloca (sizeof "USR=" + strlen (ztz));
  1677. +      sprintf (azenv[ienv], "USR=%s", ztz);
  1678. +      ++ienv;
  1679. +    }
  1680. +      ztz = getenv ("NEWS");
  1681. +      if (ztz != NULL)
  1682. +    {
  1683. +      azenv[ienv] = (char *) alloca (sizeof "NEWS=" + strlen (ztz));
  1684. +      sprintf (azenv[ienv], "NEWS=%s", ztz);
  1685. +      ++ienv;
  1686. +    }
  1687. +      ztz = getenv ("SITENAME");
  1688. +      if (ztz != NULL)
  1689. +    {
  1690. +      azenv[ienv] = (char *) alloca (sizeof "SITENAME=" + strlen (ztz));
  1691. +      sprintf (azenv[ienv], "SITENAME=%s", ztz);
  1692. +      ++ienv;
  1693. +    }
  1694. +      ztz = getenv ("DOMAIN");
  1695. +      if (ztz != NULL)
  1696. +    {
  1697. +      azenv[ienv] = (char *) alloca (sizeof "DOMAIN=" + strlen (ztz));
  1698. +      sprintf (azenv[ienv], "DOMAIN=%s", ztz);
  1699. +      ++ienv;
  1700. +    }
  1701. +      ztz = getenv ("ORGANIZATION");
  1702. +      if (ztz != NULL)
  1703. +    {
  1704. +      azenv[ienv] = (char *) alloca (sizeof "ORGANIZATION=" + strlen (ztz));
  1705. +      sprintf (azenv[ienv], "ORGANIZATION=%s", ztz);
  1706. +      ++ienv;
  1707. +    }
  1708. +#endif
  1709. +
  1710.        if (zuu_machine != NULL)
  1711.      {
  1712.        azenv[ienv] = (char *) alloca (sizeof "UU_MACHINE="
  1713. @@ -2002,7 +2273,12 @@
  1714.    if (! ferr)
  1715.      {
  1716.        /* This should really be vfork if available.  */
  1717. +#ifdef __MINT__
  1718. +      /* especially on systems without virtual memory... like MiNT :-) */
  1719. +      iret = vfork ();
  1720. +#else
  1721.        iret = isfork ();
  1722. +#endif
  1723.        if (iret < 0)
  1724.      {
  1725.        ferr = TRUE;
  1726. @@ -2084,6 +2360,10 @@
  1727.      {
  1728.        char *zto;
  1729.        const char *azshargs[4];
  1730. +#ifdef __MINT__
  1731. +      /* on MiNT people don't always have a shell in /bin/sh */
  1732. +      char *shell = getenv("SHELL");
  1733. +#endif
  1734.        
  1735.        pazargs[0] = zcmd;
  1736.        zto = zshcmd;
  1737. @@ -2098,7 +2378,12 @@
  1738.           don't know exactly when this happens (I can recreate
  1739.           it on Ultrix 4.0), but in any case it is harmless to
  1740.           not quote a '/'.  */
  1741. +#ifdef __MINT__
  1742. +          /* some (TOS) shells are even worse. :-(  */
  1743. +          if (!strchr("/.-_", *zfrom) && !isalnum(*zfrom))
  1744. +#else
  1745.            if (*zfrom != '/')
  1746. +#endif
  1747.          *zto++ = '\\';
  1748.            *zto++ = *zfrom;
  1749.          }
  1750. @@ -2111,6 +2396,12 @@
  1751.        azshargs[2] = zshcmd;
  1752.        azshargs[3] = NULL;
  1753.  
  1754. +#ifdef __MINT__
  1755. +      if (shell) {
  1756. +        azshargs[0] = shell;
  1757. +        (void) execve ((char *) shell, (char **) azshargs, pazenv);
  1758. +      } else
  1759. +#endif
  1760.        (void) execve ((char *) "/bin/sh", (char **) azshargs, pazenv);
  1761.      }
  1762.  
  1763. diff -ru ./sys2.c /src/t103/uucp-1.03/sys2.c
  1764. --- ./sys2.c    Tue Apr  7 06:05:26 1992
  1765. +++ /src/t103/uucp-1.03/sys2.c    Thu Dec 24 17:36:22 1992
  1766. @@ -428,6 +428,70 @@
  1767.                | ISIG | NOFLSH | TOSTOP)
  1768.  #endif
  1769.  
  1770. +#ifdef __MINT__
  1771. +/* try to use own fast versions of (RAW) read() and write() on serial
  1772. +   ports.  the ones in (current) MiNT are so inefficient they can't keep
  1773. +   up with data coming in at full 19200 even on a 16MHz CPU. :-(  at
  1774. +   least i never got more than ~1750 cps with g(7,2048) on a (raw) 16800
  1775. +   + V.42 link...  (no, data doesn't get lost as long as you have
  1776. +   working handshaking, its just that the link isn't saturated and
  1777. +   german telecom charges are high enough already.  with this stuff i
  1778. +   now get more than 1900 cps on the same link, and nearly 2000 (V.42,
  1779. +   no compression!) on modem2 with 38400 bps...)
  1780. +
  1781. +   note: because this makes subtle assumptions on how the BIOS serial
  1782. +   drivers work there might be problems with serial `patch' programs.
  1783. +   but, to tell you the truth, few of them do it right anyway... (the
  1784. +   only ones i trust are serialfx 1.0 (but only if only have or use
  1785. +   modem1) and ataris serptch2 for the other ports.  (wich still doesn't
  1786. +   fix all bugs on modem1, as well as the `new and improved' TOS 2.06...)
  1787. +   if you know more (that really work!), tell me.)
  1788. +
  1789. +   2nd note:  i don't mind if you use this in other programs, but i do
  1790. +   ask that you always include the source (well you probably have to
  1791. +   anyway, see COPYING :-) because this is such a hack that everyone
  1792. +   should have the possiblity to look at it and maybe debug it (or turn
  1793. +   it off) if it doesn't work on his machine.  and if you do find bugs
  1794. +   or make improvements please mail me at nox@jelal.north.de.  thanx!
  1795. +*/
  1796. +
  1797. +/* make these 0 to turn off */
  1798. +#define MINT_FASTREAD    1
  1799. +#define MINT_FASTWRITE    1
  1800. +
  1801. +/* make this 0 when you have a MiNT version that knows how to send a
  1802. +   break on modem2, or when my version doesn't work because your driver
  1803. +   doesn't keep a copy of the port's SCC register 5 in the iorec (see
  1804. +   scc_or5).  this will only be used when MINT_FASTREAD or WRITE are set. */
  1805. +#define MINT_BREAK    1
  1806. +
  1807. +/* ditto for dropping DTR */
  1808. +#define MINT_DTR    1
  1809. +
  1810. +#include <mintbind.h>
  1811. +#include <ostruct.h>
  1812. +#include <sysvars.h>
  1813. +
  1814. +/* not (yet) in sysvars.h:
  1815. +   (these are really arrays of function pointers, but can't be called
  1816. +   that way because they might clobber too much registers.) */
  1817. +#define xconin    ((long *) 0x53e)
  1818. +#define xconout    ((long *) 0x57e)
  1819. +
  1820. +/* still necessary at least with MiNT 0.95: */
  1821. +#ifndef RTSCTS
  1822. +#define RTSCTS    0x2000
  1823. +#endif
  1824. +
  1825. +#else /* !__MINT__ */
  1826. +
  1827. +#define MINT_FASTREAD    0
  1828. +#define MINT_FASTWRITE    0
  1829. +#define MINT_BREAK    0
  1830. +#define MINT_DTR    0
  1831. +
  1832. +#endif /* __MINT__ */
  1833. +
  1834.  /* External functions.  */
  1835.  extern char *strlwr ();
  1836.  extern int close (), pipe (), dup2 (), read (), write ();
  1837. @@ -539,7 +603,11 @@
  1838.  
  1839.  /* Use the BSD sigblock and sigsetmask calls.  */
  1840.  
  1841. +#ifdef __MINT__
  1842. +extern long sigblock (), sigsetmask ();
  1843. +#else
  1844.  extern int sigblock (), sigsetmask ();
  1845. +#endif
  1846.  
  1847.  #define HELD_SIG_MASK int
  1848.  
  1849. @@ -639,6 +707,546 @@
  1850.  #endif /* ! HAVE_NAPMS && ! HAVE_NAP && ! HAVE_USLEEP */
  1851.  }
  1852.  
  1853. +#ifdef __MINT__
  1854. +
  1855. +/* name of the device currently open (set in fsserial_open) */
  1856. +static const char *S_opendev;
  1857. +
  1858. +/* flag that we set modem2 to 38400 by hand (so we can restore it on close) */
  1859. +static int    S_modem2_38k4;
  1860. +
  1861. +/* points to 2 _IOREC structs that describe the port's read ([0]) and
  1862. +   write ([1]) buffers. (def'd in <ostruct.h>) */
  1863. +static _IOREC    *S_iorec;
  1864. +
  1865. +/* flag that we should watch the CD line (MiNT doesn't yet send SIGHUP...) */
  1866. +static int    S_fwatchcd;
  1867. +
  1868. +/* BIOS device no of the port: (used as index in the pollcd () routine)
  1869. +   6 = modem1, 7 = modem2, 8 = serial1, 9 = serial2. */
  1870. +static int    S_biosdev;
  1871. +
  1872. +/* pointer to driver functions that read/write a character */
  1873. +static long    S_biosread;
  1874. +static long    S_bioswrite;
  1875. +
  1876. +/* beware: never mv these devices if you want this stuff to work...
  1877. +   (there isn't yet a safer way to get the BIOS device no for a dev
  1878. +   name in MiNT.) */
  1879. +static char *names[] = {"midi", "", "", "modem1", "modem2",
  1880. +            "serial1", "serial2", (char *) NULL};
  1881. +
  1882. +/* this gets the BIOS dev no and inits some variables for
  1883. +   fastread() + fastwrite() (if used). */
  1884. +int map_biosdev (devname)
  1885. +/* device name without the "/dev/" */
  1886. +char *devname;
  1887. +{
  1888. +  char **p;
  1889. +  long stack;
  1890. +
  1891. +  S_iorec = 0;
  1892. +
  1893. +  /* find the device */
  1894. +  for (p=names; *p; ++p)
  1895. +    if (!strcmp(devname, *p))
  1896. +      break;
  1897. +  /* if not found get out. */
  1898. +  if (!*p)
  1899. +    return 0;
  1900. +  S_biosdev = p - names + 3;
  1901. +  /* enter supervisor mode */
  1902. +  stack = Super (0L);
  1903. +  /* if the OS version is too old (TOS 1.0 doesn't have the xcon* vectors)
  1904. +     or can't set the device for Iorec(), get out. */
  1905. +  if ((*(OSHEADER **) _sysbase)->os_version < 0x102 ||
  1906. +      (S_biosdev != 3 && Bconmap (0) == 0l && !Bconmap (S_biosdev))) {
  1907. +    (void) Super (stack);
  1908. +    return 0;
  1909. +  }
  1910. +  S_iorec = Iorec (S_biosdev == 3 ? 2 : 0);
  1911. +  S_biosread = xconin[S_biosdev == 3 ? 3 : 1];
  1912. +  S_bioswrite = xconout[S_biosdev == 3 ? 3 : 1];
  1913. +  (void) Super (stack);
  1914. +  if (!S_biosread || !S_bioswrite)
  1915. +    S_iorec = (_IOREC *) NULL;
  1916. +  return S_biosdev;
  1917. +}
  1918. +
  1919. +#if __GNUC__
  1920. +/* macro to turn interrupts off, result is the original sr. */
  1921. +#define intsoff() \
  1922. +({                                    \
  1923. +    short retvalue;                            \
  1924. +                                        \
  1925. +    __asm__ volatile                        \
  1926. +    ("\
  1927. +        movw    sr,%0;                        \
  1928. +        orw     #0x700,sr; "                    \
  1929. +    : "=g"(retvalue)            /* outputs */        \
  1930. +    :                        /* no inputs */        \
  1931. +    );                                \
  1932. +    retvalue;                            \
  1933. +})
  1934. +
  1935. +/* this turns them back on again, arg is the original sr */
  1936. +#define intson(sr_) \
  1937. +(void) ({                                \
  1938. +    short  _sr = (short) (sr_);                    \
  1939. +                                        \
  1940. +    __asm__ volatile                        \
  1941. +    ("\
  1942. +        movw    %0,sr; "                    \
  1943. +    :                    /* no output */        \
  1944. +    : "g"(_sr)                    /* inputs */        \
  1945. +    );                                \
  1946. +})
  1947. +#else /* !__GNUC__ */
  1948. + #error "compiler-specific asm #defines"
  1949. +#endif
  1950. +
  1951. +/* this is used to program the 85c30 SCC... */
  1952. +void sccset (control, tab, size)
  1953. +volatile char *control;
  1954. +char *tab;
  1955. +int size;
  1956. +{
  1957. +  short sr;
  1958. +  long stack = Super(0l);
  1959. +  volatile char dummy;
  1960. +
  1961. +  sr = intsoff();
  1962. +  while (size--) {
  1963. +    dummy = *((volatile char *) 0xfffffa01);
  1964. +    *control = *tab++;
  1965. +  }
  1966. +  intson (sr);
  1967. +  (void) Super (stack);
  1968. +}
  1969. +
  1970. +#if MINT_FASTREAD || MINT_FASTWRITE
  1971. +#if __GNUC__
  1972. +/* macro to call thru a xcon* vector.  we can tell gcc directly that it
  1973. +   clobbers d0-d7 and a0-a5, only the frame pointer in a6 we must take
  1974. +   care of ourselves.
  1975. +   correction: gcc 2.2.2 also wants the reg.s it passes args in unchanged */
  1976. +
  1977. +#define xcon_exec(add, ch) \
  1978. +({                                    \
  1979. +    register long retvalue __asm__("d0");                \
  1980. +    long  _add = (long) (add);                    \
  1981. +    long  _ch  = (long) (ch);                    \
  1982. +                                        \
  1983. +    __asm__ volatile                        \
  1984. +    ("\
  1985. +        movml   a5-a6/d7,sp@-;                    \
  1986. +        movl    %2,sp@-;                    \
  1987. +        jsr    %1@;                        \
  1988. +        addql    #4,sp;                        \
  1989. +        movml   sp@+,a5-a6/d7; "                \
  1990. +    : "=r"(retvalue)            /* outputs */        \
  1991. +    : "a"(_add), "d"(_ch)                /* inputs  */        \
  1992. +    : "d1", "d2", "d3", "d4", "d5", "d6",                \
  1993. +      "a0", "a1", "a2", "a3", "a4"        /* clobbered regs */    \
  1994. +    );                                \
  1995. +    retvalue;                            \
  1996. +})
  1997. +#else /* !__GNUC__ */
  1998. + #error "isn't gcc a wonderful compiler? :-)"
  1999. +#endif
  2000. +
  2001. +#if MINT_DTR || MINT_BREAK
  2002. +/* set bits in scc register 5 */
  2003. +void scc_or5 (control, or)
  2004. +volatile char *control;
  2005. +unsigned char or;
  2006. +{
  2007. +  long stack;
  2008. +  short sr;
  2009. +  volatile char dummy;
  2010. +
  2011. +  /* register 5 is normally WOM (write-only memory :-), but the driver
  2012. +     keeps a copy in the iorec.  so if there is no iorec... */
  2013. +  if (!S_iorec)
  2014. +    return;
  2015. +
  2016. +  /* enter super mode... */
  2017. +  stack = Super (0L);
  2018. +  /* interrupts off */
  2019. +  sr = intsoff();
  2020. +  dummy = *((volatile char *) 0xfffffa01);
  2021. +  *control = 5;
  2022. +  dummy = *((volatile char *) 0xfffffa01);
  2023. +  *control = (((char *) S_iorec)[0x1d] |= or);
  2024. +  intson (sr);
  2025. +  (void) Super (stack);
  2026. +}
  2027. +
  2028. +/* same for clear... */
  2029. +void scc_and5 (control, and)
  2030. +volatile char *control;
  2031. +unsigned char and;
  2032. +{
  2033. +  long stack;
  2034. +  short sr;
  2035. +  volatile char dummy;
  2036. +
  2037. +  /* (see above) */
  2038. +  if (!S_iorec)
  2039. +    return;
  2040. +
  2041. +  /* enter super mode... */
  2042. +  stack = Super (0L);
  2043. +  /* interrupts off */
  2044. +  sr = intsoff();
  2045. +  dummy = *((volatile char *) 0xfffffa01);
  2046. +  *control = 5;
  2047. +  dummy = *((volatile char *) 0xfffffa01);
  2048. +  *control = (((char *) S_iorec)[0x1d] &= and);
  2049. +  intson (sr);
  2050. +  (void) Super (stack);
  2051. +}
  2052. +#endif /* MINT_DTR || MINT_BREAK */
  2053. +
  2054. +/* check the CD status on a serial port */
  2055. +int pollcd (biosdev)
  2056. +int biosdev;
  2057. +{
  2058. +  unsigned char result;
  2059. +  volatile char dummy;
  2060. +  long stack;
  2061. +  short sr;
  2062. +
  2063. +  switch (biosdev) {
  2064. +    case 1:
  2065. +      /* modem1 on STs that don't have Bconmap() */
  2066. +      /* fall thru */
  2067. +    case 6:
  2068. +      /* modem1 */
  2069. +      /* CD is !bit 1 on the 68901 GPIP port */
  2070. +      stack = Super (0L);
  2071. +      result = (1 << 1) & ~*((volatile char *) 0xfffffa01);
  2072. +      (void) Super (stack);
  2073. +      break;
  2074. +    case 7:
  2075. +      /* modem2 */
  2076. +      /* CD is bit 3 of read register 0 on SCC port B */
  2077. +      stack = Super (0L);
  2078. +      /* interrupts off */
  2079. +      sr = intsoff();
  2080. +      dummy = *((volatile char *) 0xfffffa01);
  2081. +      result = (1 << 3) & *((volatile char *) 0xffff8c85L);
  2082. +      intson (sr);
  2083. +      (void) Super (stack);
  2084. +      break;
  2085. +    case 8:
  2086. +      /* serial1 */
  2087. +    case 9:
  2088. +      /* serial2 */
  2089. +      /* MiNT 0.95 has the names of serial1 and 2 reversed on Mega STes
  2090. +     and they aren't real modem ports anyway, so for now we just
  2091. +     fall thru. */
  2092. +    default:
  2093. +      /* unknown port, assume CD always on. */
  2094. +      result = 1;
  2095. +  }
  2096. +  return result;
  2097. +}
  2098. +#endif /* MINT_FASTREAD || MINT_FASTWRITE */
  2099. +
  2100. +#if MINT_FASTREAD
  2101. +/* here is fastread() itself.  called like the OS read(), except that it
  2102. +   also needs the port definition to see if it should block or not.
  2103. +   (always works like in RAW mode, we only don't check that in the port
  2104. +   struct because it will never be called in another mode anyway.
  2105. +   we also don't check the fd for similar reasons.)
  2106. +   addition:  call with buf == NULL and cwant == 0 to flush buffer. */
  2107. +
  2108. +#if MINT_FASTWRITE
  2109. +int fastwrite ();
  2110. +#endif
  2111. +
  2112. +int fastread (fd, buf, cwant, qs)
  2113. +int fd;
  2114. +char *buf;
  2115. +unsigned cwant;
  2116. +struct ssysdep_serial_port *qs;
  2117. +{
  2118. +  char *p;
  2119. +  unsigned short head, bsize, wrap;
  2120. +  long left, stack;
  2121. +
  2122. +  if (!S_iorec)
  2123. +    /* unknown port... */
  2124. +    return read (fd, buf, cwant);
  2125. +
  2126. +  /* if we should watch CD and its not there flush buffers and return 0.
  2127. +     (could use TIOCFLUSH once that works...) */
  2128. +  if (buf && S_fwatchcd && !pollcd (S_biosdev)) {
  2129. +#if MINT_FASTWRITE
  2130. +    (void) fastwrite (fd, (char *) NULL, 0, qs);
  2131. +#endif
  2132. +    buf = (char *) NULL;
  2133. +  }
  2134. +
  2135. +  if (buf && !cwant)
  2136. +    /* nothing to do... */
  2137. +    return 0;
  2138. +
  2139. +  /* if the read should block do a select first. */
  2140. +  if (buf && qs->fread_blocking) {
  2141. +    struct timeval s = {0L, 20000L};
  2142. +    int rfds, result;
  2143. +
  2144. +    /* ...wich actually is not `a' select but a loop of select()s with
  2145. +       timeout, because there is a known bug in MiNT (up to 0.95 at
  2146. +       least) that it doesn't wake up a select when data becomes
  2147. +       available on serial ports.  (works ok on ptys or the console,
  2148. +       just not on serial ports.  oh well...) */
  2149. +    do {
  2150. +      rfds = 1 << fd;
  2151. +      if ((result = select (0, &rfds, (int *) NULL, (int *) NULL, &s)) < 0)
  2152. +    /* if the select gets an error get out */
  2153. +    return result;
  2154. +
  2155. +    /* else loop until we have data. */
  2156. +    } while (!result);
  2157. +  }
  2158. +  /* enter supervisor mode... */
  2159. +  stack = Super (0L);
  2160. +
  2161. +  head = S_iorec->ibufhd;
  2162. +  if (!(left = ((unsigned) S_iorec->ibuftl) - head)) {
  2163. +    /* if the buffer is still empty we're finished. */
  2164. +    (void) Super (stack);
  2165. +    return 0;
  2166. +  }
  2167. +
  2168. +  /* now copy the data out of the buffer */
  2169. +  bsize = S_iorec->ibufsiz;
  2170. +  if (left < 0)
  2171. +    left += bsize;
  2172. +  wrap = bsize - head;
  2173. +
  2174. +  /* if we should flush input pretend we want to read it all */
  2175. +  if (!buf)
  2176. +    cwant = left;
  2177. +
  2178. +  if (left > cwant)
  2179. +    left = cwant;
  2180. +
  2181. +  /* if its just a few then do it here... */
  2182. +  if (buf && left <= 5) {
  2183. +    char *q = S_iorec->ibuf + head;
  2184. +
  2185. +    /* the --left in the while() makes us get one char less because we
  2186. +       want to get the last one thru the driver so that it gets a chance
  2187. +       to do handshaking. (ie turn RTS back on or send XON if necessary) */
  2188. +    p = buf;
  2189. +    while (--left) {
  2190. +      if (!--wrap)
  2191. +    q -= bsize;
  2192. +      *p++ = *++q;
  2193. +    }
  2194. +    S_iorec->ibufhd = q - S_iorec->ibuf;
  2195. +
  2196. +  /* else bcopy is faster. (at least the one in the MiNT libs is :-) */
  2197. +  } else {
  2198. +
  2199. +    /* --wrap and head+1 because head is `inc before access' */
  2200. +    if (--wrap < --left) {
  2201. +      if (buf) {
  2202. +    bcopy (S_iorec->ibuf + head + 1, buf, wrap);
  2203. +    bcopy (S_iorec->ibuf, buf + wrap, left - wrap);
  2204. +      }
  2205. +      S_iorec->ibufhd = left - wrap - 1;
  2206. +    } else {
  2207. +      if (buf)
  2208. +    bcopy (S_iorec->ibuf + head + 1, buf, left);
  2209. +      S_iorec->ibufhd = head + left;
  2210. +    }
  2211. +    /* p points to last char */
  2212. +    p = buf + left;
  2213. +  }
  2214. +
  2215. +  /* this is fun.  did i say i trust serptch2?  the xconin routine on
  2216. +     modem2 doesn't disable interrupts while accessing SCC registers!!
  2217. +     (actually i have fixed that and x other bugs in serptch2 now, but
  2218. +     modem2 still doesn't work reliable. :-(  if you get it to work
  2219. +     please tell me...) */
  2220. +  {
  2221. +    short sr = intsoff();
  2222. +
  2223. +    /* xconin[] are always blocking, and we don't want to hang with ints
  2224. +       off even if something impossible like a magically :-) empty
  2225. +       buffer happens.  so check again. */
  2226. +    if (S_iorec->ibuftl != S_iorec->ibufhd)
  2227. +      if (buf)
  2228. +    *p++ = xcon_exec (S_biosread, 0);
  2229. +      else
  2230. +    (void) xcon_exec (S_biosread, 0);
  2231. +    intson (sr);
  2232. +  }
  2233. +  (void) Super (stack);
  2234. +  if (!buf)
  2235. +    return 0;
  2236. +  return p - buf;
  2237. +}
  2238. +#endif /* MINT_FASTREAD */
  2239. +
  2240. +#if MINT_FASTWRITE
  2241. +/* here is fastwrite()...  comments like on fastread() apply. */
  2242. +int fastwrite (fd, buf, cwrite, qs)
  2243. +int fd;
  2244. +char *buf;
  2245. +unsigned cwrite;
  2246. +struct ssysdep_serial_port *qs;
  2247. +{
  2248. +  char *p = buf;
  2249. +  int slept = 0;
  2250. +
  2251. +  /* /dev/midi doesn't have a write buffer :-( */
  2252. +  if (!S_iorec || S_biosdev == 3)
  2253. +    return write (fd, buf, cwrite);
  2254. +
  2255. +  /* if we should watch CD and its not there flush buffers and return 0. */
  2256. +  if (buf && S_fwatchcd && !pollcd (S_biosdev)) {
  2257. +#if MINT_FASTREAD
  2258. +    (void) fastread (fd, (char *) NULL, 0, qs);
  2259. +#endif
  2260. +    buf = (char *) NULL;
  2261. +  }
  2262. +
  2263. +  if (!buf) {
  2264. +    long stack = Super (0L);
  2265. +
  2266. +    /* flush send buffer...  should be safe to just set the tail pointer. */
  2267. +    S_iorec[1].ibuftl = S_iorec[1].ibufhd;
  2268. +    (void) Super (stack);
  2269. +    return 0;
  2270. +  }
  2271. +
  2272. +  if (!cwrite)
  2273. +    /* nothing to do... */
  2274. +    return 0;
  2275. +
  2276. +  do {
  2277. +    char ch;
  2278. +    unsigned short tail, bsize, wrap, newtail;
  2279. +    long free, stack;
  2280. +
  2281. +    /* enter supervisor mode... */
  2282. +    stack = Super (0L);
  2283. +
  2284. +    tail = S_iorec[1].ibuftl;
  2285. +    bsize = S_iorec[1].ibufsiz;
  2286. +    if ((free = S_iorec[1].ibufhd - tail - 1) < 0)
  2287. +      free += bsize;
  2288. +
  2289. +    /* if buffer is full or we're blocking and can't write enuf */
  2290. +    if (!free || (qs->fread_blocking && free < cwrite && free < bsize/2)) {
  2291. +      long sleepchars;
  2292. +      unsigned isleep;
  2293. +
  2294. +      /* leave super mode. */
  2295. +      (void) Super (stack);
  2296. +
  2297. +      /* if the write should not block thats it. */
  2298. +      if (!qs->fread_blocking)
  2299. +    return p - buf;
  2300. +
  2301. +      /* else sleep the (minimum) time it takes until the buffer is
  2302. +     either half-empty or has space enough for the write, wichever
  2303. +     is smaller. */
  2304. +      if ((sleepchars = bsize/2) > cwrite)
  2305. +    sleepchars = cwrite;
  2306. +      sleepchars -= free;
  2307. +
  2308. +      isleep = (unsigned) ((sleepchars * 10000L) / qs->ibaud);
  2309. +
  2310. +      /* except that if we already slept and the buffer still was full we
  2311. +     sleep for at least 20 milliseconds. (driver must be waiting for
  2312. +     some handshake signal and we don't want to hog the processor.) */
  2313. +      if (slept && isleep < 20)
  2314. +    isleep = 20;
  2315. +
  2316. +      if (isleep < 5)
  2317. +    /* if it still would be less than 5 milliseconds then just
  2318. +       give up this timeslice */
  2319. +    (void) Syield();
  2320. +      else
  2321. +    usleep ((unsigned long) isleep * 1000);
  2322. +
  2323. +      /* loop and try again. */
  2324. +      slept = !free;
  2325. +      continue;
  2326. +    }
  2327. +    slept = 0;
  2328. +
  2329. +    /* save the 1st char, we could need it later. */
  2330. +    ch = *p;
  2331. +    wrap = bsize - tail;
  2332. +    if (free > cwrite)
  2333. +      free = cwrite;
  2334. +    cwrite -= free;
  2335. +
  2336. +    /* now copy to buffer.  if its just a few then do it here... */
  2337. +    if (free < 5) {
  2338. +      char *q = S_iorec[1].ibuf + tail;
  2339. +
  2340. +      while (free--) {
  2341. +    if (!--wrap)
  2342. +      q -= bsize;
  2343. +    *++q = *p++;
  2344. +      }
  2345. +      newtail = q - S_iorec[1].ibuf;
  2346. +
  2347. +    /* ...else use bcopy. */
  2348. +    } else {
  2349. +      /* --wrap and tail+1 because tail is `inc before access' */
  2350. +      if (--wrap < free) {
  2351. +    bcopy (p, S_iorec[1].ibuf + tail + 1, wrap);
  2352. +    bcopy (p + wrap, S_iorec[1].ibuf, free - wrap);
  2353. +    newtail = free - wrap - 1;
  2354. +      } else {
  2355. +    bcopy (p, S_iorec[1].ibuf + tail + 1, free);
  2356. +    newtail = tail + free;
  2357. +      }
  2358. +      p += free;
  2359. +    }
  2360. +
  2361. +    /* the following has to be done with interrupts off to avoid
  2362. +       race conditions. */
  2363. +    {
  2364. +      short sr = intsoff ();
  2365. +
  2366. +      /* if the buffer is empty there might be no interrupt that sends
  2367. +     the next char, so we send it thru the xcon* vector. */
  2368. +      if (S_iorec[1].ibufhd == S_iorec[1].ibuftl) {
  2369. +    (void) xcon_exec (S_bioswrite, (unsigned char) ch);
  2370. +
  2371. +    /* if the buffer now is still empty we must set the head pointer
  2372. +       to skip the 1st char (that we just sent). */
  2373. +    if (S_iorec[1].ibufhd == S_iorec[1].ibuftl) {
  2374. +      if (++tail >= bsize)
  2375. +        tail = 0;
  2376. +      S_iorec[1].ibufhd = tail;
  2377. +    }
  2378. +      }
  2379. +      S_iorec[1].ibuftl = newtail;
  2380. +
  2381. +      intson (sr);
  2382. +    }
  2383. +    (void) Super (stack);
  2384. +
  2385. +  /* if we may block loop until everything is written */
  2386. +  } while (cwrite && qs->fread_blocking);
  2387. +
  2388. +  return p - buf;
  2389. +}
  2390. +#endif /* MINT_FASTWRITE */
  2391. +#endif /* __MINT__ */
  2392. +
  2393.  /* This routine is used for both locking and unlocking.  It is the
  2394.     only routine which knows how to translate a device name into the
  2395.     name of a lock file.  If it can't figure out a name, it does
  2396. @@ -828,7 +1436,13 @@
  2397.    { B50, 50 },
  2398.    { B75, 75 },
  2399.    { B110, 110 },
  2400. +#ifdef B134
  2401.    { B134, 134 },
  2402. +#else
  2403. +#ifdef B135
  2404. +  { B135, 134 },
  2405. +#endif
  2406. +#endif
  2407.    { B150, 150 },
  2408.    { B200, 200 },
  2409.    { B300, 300 },
  2410. @@ -883,13 +1497,23 @@
  2411.        zport = zsysdep_port_name (&fdummy);
  2412.        if (zport != NULL)
  2413.      ulog_device (zport);
  2414. +#ifdef __MINT__
  2415. +      S_opendev = zport;
  2416. +#endif
  2417.      }
  2418.    else
  2419.      {
  2420. +#ifdef __MINT__
  2421. +      if (strncmp (z, "/dev/", sizeof "/dev/" - 1) == 0)
  2422. +    ulog_device (S_opendev = z + sizeof "/dev/" - 1);
  2423. +      else
  2424. +    ulog_device (S_opendev = z);
  2425. +#else
  2426.        if (strncmp (z, "/dev/", sizeof "/dev/" - 1) == 0)
  2427.      ulog_device (z + sizeof "/dev/" - 1);
  2428.        else
  2429.      ulog_device (z);
  2430. +#endif
  2431.      }
  2432.  
  2433.    ib = B0;
  2434. @@ -989,7 +1613,11 @@
  2435.  
  2436.  #if HAVE_BSD_TTY
  2437.  
  2438. +#ifdef __MINT__
  2439. +  q->snew.sg_flags = RAW | ANYP | RTSCTS;
  2440. +#else
  2441.    q->snew.sg_flags = RAW | ANYP;
  2442. +#endif
  2443.    if (ibaud == 0)
  2444.      ib = q->snew.sg_ospeed;
  2445.    else
  2446. @@ -1063,7 +1691,29 @@
  2447.  
  2448.  #endif /* HAVE_POSIX_TERMIOS */
  2449.  
  2450. +#ifdef __MINT__
  2451. +  { long bpsi = ibaud, bpso = ibaud;
  2452. +
  2453. +  /* MiNT 0.95 doesn't know how to set 38400 bps on modem2... */
  2454. +  S_biosdev = map_biosdev (S_opendev);
  2455. +#if MINT_FASTREAD
  2456. +  /* and also TIOCFLUSH is a no-op on serial ports. */
  2457. +  if (S_iorec)
  2458. +    (void) fastread (q->oread, (char *) NULL, 0, q);
  2459. +#endif
  2460. +  if (! fsetterminfo (q->oread, &q->snew) ||
  2461. +      (ibaud && ((errno=-Fcntl(q->oread, &bpso, TIOCOBAUD)) ||
  2462. +         (errno=-Fcntl(q->oread, &bpsi, TIOCIBAUD)))))
  2463. +    if (errno == EBADARG && ibaud == 38400 && S_biosdev == 7) {
  2464. +      char scctab[] = {4, 0xc4, 11, 0x28};
  2465. +
  2466. +      sccset ((volatile char *) 0xffff8c85L, scctab, sizeof scctab);
  2467. +      /* ...and tell the close routine to restore it */
  2468. +      S_modem2_38k4 = 1;
  2469. +    } else
  2470. +#else
  2471.    if (! fsetterminfo (q->oread, &q->snew))
  2472. +#endif
  2473.      {
  2474.        ulog (LOG_ERROR, "Can't set terminal settings: %s", strerror (errno));
  2475.        (void) close (q->oread);
  2476. @@ -1071,6 +1721,9 @@
  2477.      (void) close (q->owrite);
  2478.        return FALSE;
  2479.      }
  2480. +#ifdef __MINT__
  2481. +  }
  2482. +#endif
  2483.  
  2484.    if (ibaud != 0)
  2485.      q->ibaud = ibaud;
  2486. @@ -1184,6 +1837,15 @@
  2487.      {
  2488.        int iset;
  2489.  
  2490. +#if MINT_FASTREAD && MINT_FASTWRITE
  2491. +      if (S_iorec && S_biosdev != 3) {
  2492. +        /* if we're using fastread and fastwrite we can skip the fcntl
  2493. +       because the OS read and write will never be called on this
  2494. +       port anyway. */
  2495. +    qs->fread_blocking = fblock;
  2496. +    return TRUE;
  2497. +      }
  2498. +#endif
  2499.        if (fblock)
  2500.      iset = 0;
  2501.        else
  2502. @@ -1212,6 +1874,21 @@
  2503.       output.  */
  2504.        if (q->fterminal)
  2505.      {
  2506. +#ifdef __MINT__
  2507. +      /* MiNT never hangs up on close... */
  2508. +      fsserial_reset (q);
  2509. +
  2510. +      /* if we had to set modem2 to 38400 by hand then restore the
  2511. +         original settings now. */
  2512. +      if (S_modem2_38k4) {
  2513. +        char scctab[] = {4, 0x44, 11, 0x50};
  2514. +
  2515. +        sccset ((volatile char *) 0xffff8c85L, scctab, sizeof scctab);
  2516. +        S_modem2_38k4 = 0;
  2517. +      }
  2518. +      S_biosdev = 0;
  2519. +      S_iorec = (_IOREC *) NULL;
  2520. +#endif
  2521.        fSalarm = FALSE;
  2522.  
  2523.        if (fsysdep_catch ())
  2524. @@ -1379,6 +2056,27 @@
  2525.    if (! q->fterminal)
  2526.      return TRUE;
  2527.  
  2528. +#if (MINT_FASTREAD || MINT_FASTWRITE) && MINT_DTR
  2529. +  /* MiNT 0.95 doesn't know how to drop DTR on modem2... */
  2530. +  if (S_iorec && S_biosdev == 7) {
  2531. +    volatile char *control = (volatile char *) 0xffff8c85L;
  2532. +
  2533. +    /* DTR is bit 7 in register 5 */
  2534. +    scc_and5 (control, ~(1 << 7));
  2535. +
  2536. +    /* sleep 30 ms... */
  2537. +    usleep (30000L);
  2538. +
  2539. +    /* assert DTR */
  2540. +    scc_or5 (control, (1 << 7));
  2541. +
  2542. +    /* Give the terminal a chance to settle.  */
  2543. +    sleep (1);
  2544. +
  2545. +    return TRUE;
  2546. +  }
  2547. +#endif
  2548. +
  2549.    sbaud = q->snew;
  2550.  
  2551.  #if HAVE_BSD_TTY
  2552. @@ -1538,6 +2236,15 @@
  2553.    if (! qport->u.smodem.s.s.fterminal)
  2554.      return TRUE;
  2555.  
  2556. +#if MINT_FASTREAD || MINT_FASTWRITE
  2557. +  /* MiNT doesn't have TIOCNCAR... (see below.) */
  2558. +
  2559. +  if (S_iorec) {
  2560. +    S_fwatchcd = 0;
  2561. +    return TRUE;
  2562. +  }
  2563. +#endif
  2564. +
  2565.  #ifdef TIOCNCAR
  2566.    /* Tell the modem to ignore carrier.  */ 
  2567.    if (ioctl (qport->u.smodem.s.s.oread, TIOCNCAR, 0) < 0)
  2568. @@ -1576,6 +2283,18 @@
  2569.  
  2570.    if (qport->u.smodem.fcarrier)
  2571.      {
  2572. +#if MINT_FASTREAD || MINT_FASTWRITE
  2573. +      /* MiNT doesn't have TIOCCAR... best thing we can do is make our
  2574. +     fastread/fastwrite flush buffers and return 0 when carrier is
  2575. +     lost.  note this is not exact un*x behaviour (and there also
  2576. +     is no SIGHUP) but its enuf for what we need. */
  2577. +
  2578. +      if (S_iorec) {
  2579. +    S_fwatchcd = 1;
  2580. +    return TRUE;
  2581. +      }
  2582. +#endif
  2583. +
  2584.  #ifdef TIOCCAR
  2585.        /* Tell the modem to pay attention to carrier.  */
  2586.        if (ioctl (qport->u.smodem.s.s.oread, TIOCCAR, 0) < 0)
  2587. @@ -1622,6 +2341,30 @@
  2588.        if (! fsysdep_modem_need_carrier (qport))
  2589.      return FALSE;
  2590.  
  2591. +#if MINT_FASTREAD || MINT_FASTWRITE
  2592. +      /* on MiNT we can only poll the CD line... */
  2593. +      if (S_iorec) {
  2594. +    clock_t timeout = clock () + qdial->ccarrier_wait * CLK_TCK;
  2595. +
  2596. +    while (((long) clock () - (long) timeout) < 0) {
  2597. +      /* If we got a random signal, just return FALSE.  */
  2598. +      if (FGOT_QUIT_SIGNAL ())
  2599. +        return FALSE;
  2600. +
  2601. +      /* if cd is there then we're done. */
  2602. +      if (pollcd (S_biosdev))
  2603. +        return TRUE;
  2604. +
  2605. +      /* else sleep 50 milliseconds before trying again... */
  2606. +      usleep(50000L);
  2607. +    }
  2608. +
  2609. +    /* if we get here, we timed out. */
  2610. +    ulog (LOG_ERROR, "Timed out waiting for carrier");
  2611. +    return FALSE;
  2612. +      }
  2613. +#endif
  2614. +
  2615.  #ifdef TIOCWONLINE
  2616.  
  2617.        /* We know how to wait for carrier, so do so.  */
  2618. @@ -1777,6 +2520,16 @@
  2619.    while (TRUE)
  2620.      {
  2621.        int cgot;
  2622. +#ifdef __MINT__
  2623. +#if !MINT_FASTREAD
  2624. +      /* read() on (current) MiNT can take a while... (does 2 TOS calls
  2625. +     for each character :-( )  measure that so we don't end up
  2626. +     sleeping too long. */
  2627. +      static clock_t read_ticks = 0;
  2628. +      static int read_chars = 32;
  2629. +      clock_t read_start;
  2630. +#endif
  2631. +#endif
  2632.  
  2633.  #if HAVE_SYSV_TERMIO || HAVE_POSIX_TERMIOS
  2634.        /* If we can tell the terminal not to return until we have a
  2635. @@ -1831,7 +2584,27 @@
  2636.        /* Right here is the race condition which we avoid by having the
  2637.       SIGALRM handler schedule another SIGALRM.  */
  2638.  
  2639. +#if MINT_FASTREAD
  2640. +      cgot = fastread (q->oread, zbuf, cwant, q);
  2641. +#else
  2642. +#ifdef __MINT__
  2643. +      /* measure the time a `long' read() takes if it will not block. */
  2644. +
  2645. +      if (q->fterminal && !fpty &&
  2646. +      (cwant >= read_chars || cwant > MAX_INPUT/2) &&
  2647. +      (!q->fread_blocking || Finstat (q->oread))) {
  2648. +    read_start = clock();
  2649. +
  2650. +    cgot = read (q->oread, zbuf, cwant);
  2651. +
  2652. +    if (cgot >= read_chars || cgot > MAX_INPUT/2) {
  2653. +      read_ticks = clock() - read_start;
  2654. +      read_chars = cgot;
  2655. +    }
  2656. +      } else
  2657. +#endif
  2658.        cgot = read (q->oread, zbuf, cwant);
  2659. +#endif
  2660.  
  2661.        /* If the read returned an error, check for signals.  */
  2662.        if (cgot < 0)
  2663. @@ -1940,6 +2713,15 @@
  2664.  
  2665.        isleep = (int) (((long) csleepchars * 10000L) / q->ibaud);
  2666.        isleep -= 10;
  2667. +#ifdef __MINT__
  2668. +#if !MINT_FASTREAD
  2669. +      if (read_ticks > 1)
  2670. +        /* make a guess how long the read itself will take...  sleep
  2671. +           that much less. */
  2672. +        isleep -= (int) ((long) csleepchars * read_ticks * 1000L /
  2673. +                    (read_chars * CLK_TCK));
  2674. +#endif
  2675. +#endif
  2676.  
  2677.        if (isleep > 10)
  2678.          {
  2679. @@ -2044,8 +2826,13 @@
  2680.      return FALSE;
  2681.  
  2682.        /* Loop until we don't get an interrupt.  */
  2683. +#if MINT_FASTWRITE
  2684. +      while ((cdid = fastwrite (q->owrite, zwrite, cwrite, q)) < 0
  2685. +         && errno == EINTR)
  2686. +#else
  2687.        while ((cdid = write (q->owrite, zwrite, cwrite)) < 0
  2688.           && errno == EINTR)
  2689. +#endif
  2690.      {
  2691.        /* Log the signal.  */
  2692.        ulog (LOG_ERROR, (const char *) NULL);
  2693. @@ -2185,8 +2972,13 @@
  2694.  
  2695.        /* Loop until we get something (error or data) other than an
  2696.       acceptable EINTR.  */
  2697. +#if MINT_FASTREAD
  2698. +      while ((cgot = fastread (q->oread, zread, cread, q)) < 0
  2699. +         && errno == EINTR)
  2700. +#else
  2701.        while ((cgot = read (q->oread, zread, cread)) < 0
  2702.           && errno == EINTR)
  2703. +#endif
  2704.      {
  2705.        /* Log the signal.  */
  2706.        ulog (LOG_ERROR, (const char *) NULL);
  2707. @@ -2219,13 +3011,23 @@
  2708.        cdo = cwrite;
  2709.  
  2710.  #if ! HAVE_UNBLOCKED_WRITES
  2711. +#if MINT_FASTWRITE
  2712. +      /* fastwrite() knows how to do an unblocked write... */
  2713. +      if (cdo > SINGLE_WRITE && (!S_iorec || S_biosdev == 3))
  2714. +#else
  2715.        if (cdo > SINGLE_WRITE)
  2716. +#endif
  2717.      cdo = SINGLE_WRITE;
  2718.  #endif
  2719.  
  2720.        /* Loop until we get something besides EINTR.  */
  2721. +#if MINT_FASTWRITE
  2722. +      while ((cdid = fastwrite (q->owrite, zwrite, cdo, q)) < 0
  2723. +         && errno == EINTR)
  2724. +#else
  2725.        while ((cdid = write (q->owrite, zwrite, cdo)) < 0
  2726.           && errno == EINTR)
  2727. +#endif
  2728.      {
  2729.        /* Log the signal.  */
  2730.        ulog (LOG_ERROR, (const char *) NULL);
  2731. @@ -2271,8 +3073,13 @@
  2732.                "fsserial_io: Blocking write of %d", cdo);
  2733.  
  2734.        /* Loop until we get something besides EINTR.  */
  2735. +#if MINT_FASTWRITE
  2736. +      while ((cdid = fastwrite (q->owrite, zwrite, cdo, q)) < 0
  2737. +         && errno == EINTR)
  2738. +#else
  2739.        while ((cdid = write (q->owrite, zwrite, cdo)) < 0
  2740.           && errno == EINTR)
  2741. +#endif
  2742.          {
  2743.            /* Log the signal.  */
  2744.            ulog (LOG_ERROR, (const char *) NULL);
  2745. @@ -2357,6 +3164,19 @@
  2746.  fsserial_break (q)
  2747.       struct ssysdep_serial_port *q;
  2748.  {
  2749. +#if (MINT_FASTREAD || MINT_FASTWRITE) && MINT_BREAK
  2750. +  /* MiNT 0.95 doesn't know how to send a break on modem2... */
  2751. +  if (S_iorec && S_biosdev == 7) {
  2752. +    volatile char *control = (volatile char *) 0xffff8c85L;
  2753. +
  2754. +    /* bit 4 in register 5 is the break condition */
  2755. +    scc_or5 (control, (1 << 4));
  2756. +    sleep (1);
  2757. +    scc_and5 (control, ~(1 << 4));
  2758. +    return TRUE;
  2759. +  }
  2760. +#endif
  2761. +
  2762.  #if HAVE_BSD_TTY
  2763.    ioctl (q->owrite, TIOCSBRK, 0);
  2764.    sleep (1);
  2765. @@ -2413,9 +3233,15 @@
  2766.      {
  2767.      case PORTSETTING_EIGHT:
  2768.  #if HAVE_BSD_TTY
  2769. +#ifdef __MINT__
  2770. +      if (q->snew.sg_flags == (RAW | ANYP | RTSCTS))
  2771. +    return TRUE;
  2772. +      q->snew.sg_flags = RAW | ANYP | RTSCTS;
  2773. +#else
  2774.        if (q->snew.sg_flags == (RAW | ANYP))
  2775.      return TRUE;
  2776.        q->snew.sg_flags = RAW | ANYP;
  2777. +#endif
  2778.  #endif
  2779.  #if HAVE_SYSV_TERMIO || HAVE_POSIX_TERMIOS
  2780.        if ((q->snew.c_iflag & ICLEAR_IFLAG) == 0)
  2781. diff -ru ./sys3.c /src/t103/uucp-1.03/sys3.c
  2782. --- ./sys3.c    Tue Apr  7 06:05:28 1992
  2783. +++ /src/t103/uucp-1.03/sys3.c    Thu Jan  7 20:58:36 1993
  2784. @@ -435,6 +435,12 @@
  2785.     Debugging messages are stored in these when running as a slave.  We
  2786.     use the file AUDIT in the spool directory.  */
  2787.  
  2788. +
  2789. +#ifdef __MINT__
  2790. +/* for Frename() */
  2791. +#include <osbind.h>
  2792. +#endif
  2793. +
  2794.  /* Local functions.  */
  2795.  
  2796.  static char *zsstatic_size P((int c));
  2797. @@ -630,6 +636,29 @@
  2798.        && *zsimple != 'D'
  2799.        && *zsimple != 'X'))
  2800.      {
  2801. +#ifdef __MINT__
  2802. +      char *zcopy, *p, ch;
  2803. +      int clen;
  2804. +
  2805. +      /* see if it already went thru translate_spoolname... */
  2806. +      if ((*zsimple & 0xde) == '@' &&
  2807. +      (clen = strlen (zsimple)) > 7  &&
  2808. +      ((ch = zsimple[clen-1] & 0xdf) == 'C' || ch == 'D' || ch == 'X') &&
  2809. +      strchr (zsimple, '.') == zsimple+clen-2) {
  2810. +    zcopy = p = (char *) alloca (clen + 2);
  2811. +
  2812. +    *p++ = ch;
  2813. +    *p++ = '.';
  2814. +    if (clen > 9)
  2815. +      /* dummy char, will be dropped in translate_spoolname */
  2816. +      ++clen, *p++ = '=';
  2817. +    strncpy (p, zsimple + 1, clen - 3);
  2818. +    zcopy[clen - 1] = 0;
  2819. +
  2820. +    /* this assumes SPOOLDIR_BNU: */
  2821. +    return zsappend (zsystem, zcopy);
  2822. +      }
  2823. +#endif
  2824.        ulog (LOG_ERROR, "Unrecognized file name %s", zsimple);
  2825.        return NULL;
  2826.      }
  2827. @@ -836,7 +865,11 @@
  2828.    e = fopen (zname, "r");
  2829.    if (e == NULL)
  2830.      {
  2831. +#ifdef __MINT__
  2832. +      if (errno != ENOENT && errno != EPATH)
  2833. +#else
  2834.        if (errno != ENOENT)
  2835. +#endif
  2836.      {
  2837.        ulog (LOG_ERROR, "fopen (%s): %s", zname, strerror (errno));
  2838.        return FALSE;
  2839. @@ -939,6 +972,70 @@
  2840.    return TRUE;
  2841.  }
  2842.  
  2843. +#ifdef __MINT__
  2844. +/* translate a spool file name for stupid 8+3 filesystems.  this makes
  2845. +   sense only with SPOOLDIR_BNU or (maybe) SPOOLDIR_TAYLOR because it
  2846. +   drops characters of the system name.  warning: translation done in-place! */
  2847. +char *
  2848. +translate_spoolname(zfile, localfile)
  2849. +     char *zfile;
  2850. +     int localfile;
  2851. +{
  2852. +  char type, *p;
  2853. +
  2854. +  if (!zfile)
  2855. +    return zfile;
  2856. +
  2857. +  if (!(p=strrchr(zfile, '/')))
  2858. +    p=zfile;
  2859. +  else
  2860. +    ++p;
  2861. +
  2862. +  if (((type=*p) == 'C' || type == 'D' || type == 'X') && p[1] == '.') {
  2863. +    char *q, ch, grade = 0;
  2864. +    int l;
  2865. +
  2866. +    /* take the last 7 characters, place a `A' before and a '.' and the
  2867. +       file type (C, X, or D) after.  not 100% safe (especially because
  2868. +       this filesystem is not case sensitive), but thats what the TOS uucico
  2869. +       seems to be doing and at least for now we want to be compatible.
  2870. +       example: D.fooboxN1234 becomes AoxN1234.D (and aoxn1234.d on disk).
  2871. +
  2872. +       (actually files created locally now get the case of the grade coded
  2873. +       in the first char (@ = upper, A = lower) and the sequence number is
  2874. +       in hex with SPOOLDIR_BNU anyway, so this can only be a problem with
  2875. +       incoming files.) */
  2876. +
  2877. +    q=p+2;
  2878. +    /* leave D.0 etc alone */
  2879. +    if (!strcmp (q, "0"))
  2880. +      return zfile;
  2881. +    if ((l = strlen (q) - 7) > 0) {
  2882. +      q+=l;
  2883. +      grade = q[2];
  2884. +    } else {
  2885. +      ++q;
  2886. +      if (l >= -1)
  2887. +    grade = q[l + 1];
  2888. +    }
  2889. +    if (localfile && grade >= 'A' && grade <= 'Z')
  2890. +      *p++='@';
  2891. +    else
  2892. +      *p++='A';
  2893. +    while (ch = *q++) {
  2894. +      /* just to be sure... */
  2895. +      if (ch == '.')
  2896. +    ch='_';
  2897. +      *p++=ch;
  2898. +    }
  2899. +    *p++='.';
  2900. +    *p++=type;
  2901. +    *p++=0;
  2902. +  }
  2903. +  return zfile;
  2904. +}
  2905. +#endif
  2906. +
  2907.  /* Get the real name of a spool file.  */
  2908.  
  2909.  const char *
  2910. @@ -946,7 +1043,12 @@
  2911.       const struct ssysteminfo *qsys;
  2912.       const char *zfile;
  2913.  {
  2914. +#ifdef __MINT__
  2915. +  /* stupid 8+3 filesystem... */
  2916. +  return translate_spoolname((char *) zsfind_file (zfile, qsys->zname), 0);
  2917. +#else
  2918.    return zsfind_file (zfile, qsys->zname);
  2919. +#endif
  2920.  }
  2921.  
  2922.  /* Expand a file name on the local system.  The qsys argument is only
  2923. @@ -960,6 +1062,18 @@
  2924.  {
  2925.    const char *ztry;
  2926.    char *zlook;
  2927. +#ifdef __MINT__
  2928. +  char *p, ch;
  2929. +
  2930. +  if (p = (char *) zfile)
  2931. +    for (; ch = *p; ++p)
  2932. +      if (ch == '\\')
  2933. +    *p = '/';
  2934. +  if (p = (char *) zname)
  2935. +    for (; ch = *p; ++p)
  2936. +      if (ch == '\\')
  2937. +    *p = '/';
  2938. +#endif
  2939.  
  2940.    if (zfile[0] == '/')
  2941.      ztry = zfile;
  2942. @@ -1063,10 +1177,19 @@
  2943.      }
  2944.  #if USE_STDIO
  2945.    e = fopen (zfile, BINREAD);
  2946. +#ifdef __MINT__
  2947. +  /* give GEMDOS a kick. */
  2948. +  if (e == NULL || setvbuf(e, NULL, _IOFBF, 0x2000))
  2949. +#else
  2950.    if (e == NULL)
  2951. +#endif
  2952.      {
  2953.        ulog (LOG_ERROR, "fopen (%s): %s", zfile, strerror (errno));
  2954. +#ifdef __MINT__
  2955. +      if (pfgone != NULL && (errno == ENOENT || errno == EPATH))
  2956. +#else
  2957.        if (pfgone != NULL && errno == ENOENT)
  2958. +#endif
  2959.      *pfgone = TRUE;
  2960.        return NULL;
  2961.      }
  2962. @@ -1147,7 +1270,11 @@
  2963.      z = (char *) xmalloc (cneed);
  2964.      calc = cneed;
  2965.        }
  2966. +#ifdef __MINT__
  2967. +    sprintf (z, "%s/TM_%05d.%03d", qsys->zname, getpid (), icount);
  2968. +#else
  2969.      sprintf (z, "%s/TM.%05d.%03d", qsys->zname, getpid (), icount);
  2970. +#endif
  2971.      zret = z;
  2972.    }
  2973.  #endif
  2974. @@ -1175,6 +1302,14 @@
  2975.    openfile_t e;
  2976.    long c1, c2;
  2977.    char *zcopy, *zslash;
  2978. +#ifdef __MINT__
  2979. +  char *p, ch;
  2980. +
  2981. +  if (p = (char *) zto)
  2982. +    for (; ch = *p; ++p)
  2983. +      if (ch == '\\')
  2984. +    *p = '/';
  2985. +#endif
  2986.  
  2987.    z = zstemp_file (qsys);
  2988.  
  2989. @@ -1182,7 +1317,11 @@
  2990.  
  2991.    if (o == -1)
  2992.      {
  2993. +#ifdef __MINT__
  2994. +      if (errno == ENOENT || errno == EPATH)
  2995. +#else
  2996.        if (errno == ENOENT)
  2997. +#endif
  2998.      {
  2999.        if (! fsysdep_make_dirs (z, FALSE))
  3000.          return EFILECLOSED;
  3001. @@ -1198,7 +1337,12 @@
  3002.  #if USE_STDIO
  3003.    e = fdopen (o, (char *) BINWRITE);
  3004.  
  3005. +#ifdef __MINT__
  3006. +  /* give GEMDOS another kick... */
  3007. +  if (e == NULL || setvbuf(e, NULL, _IOFBF, 0x2000))
  3008. +#else
  3009.    if (e == NULL)
  3010. +#endif
  3011.      {
  3012.        ulog (LOG_ERROR, "fdopen (%s): %s", z, strerror (errno));
  3013.        (void) close (o);
  3014. @@ -1313,6 +1457,18 @@
  3015.       boolean fcheck;
  3016.       const char *zuser;
  3017.  {
  3018. +#ifdef __MINT__
  3019. +  char *p, ch;
  3020. +
  3021. +  if (p = (char *) zorig)
  3022. +    for (; ch = *p; ++p)
  3023. +      if (ch == '\\')
  3024. +    *p = '/';
  3025. +  if (p = (char *) zto)
  3026. +    for (; ch = *p; ++p)
  3027. +      if (ch == '\\')
  3028. +    *p = '/';
  3029. +#endif
  3030.    DEBUG_MESSAGE2 (DEBUG_SPOOLDIR,
  3031.            "fsysdep_move_file: Moving %s to %s", zorig, zto);
  3032.  
  3033. @@ -1390,7 +1546,11 @@
  3034.  
  3035.    /* If this file is in the spool directory, make sure all directories
  3036.       exist.  */
  3037. +#ifdef __MINT__
  3038. +  if (*zto != '/' && (errno == ENOENT || errno == EPATH))
  3039. +#else
  3040.    if (*zto != '/' && errno == ENOENT)
  3041. +#endif
  3042.      {
  3043.        if (! fsysdep_make_dirs (zto, FALSE))
  3044.      {
  3045. @@ -1535,7 +1695,11 @@
  3046.  #if USE_STDIO
  3047.    e = fdopen (o, (char *) BINWRITE);
  3048.  
  3049. +#ifdef __MINT__
  3050. +  if (e == NULL || setvbuf(e, NULL, _IOFBF, 0x2000))
  3051. +#else
  3052.    if (e == NULL)
  3053. +#endif
  3054.      {
  3055.        ulog (LOG_ERROR, "fdopen (%s): %s", zname, strerror (errno));
  3056.        (void) close (o);
  3057. @@ -1550,6 +1714,50 @@
  3058.  #endif /* ! HAVE_FTRUNCATE */
  3059.  }
  3060.  
  3061. +
  3062. +#ifdef __MINT__
  3063. +/* change lock file names LCK.something into something.LCK and
  3064. +   (spooldir/)L.something into (spooldir/)something.L
  3065. +   (stupid 8+3 filesystem...)
  3066. +   do the 1st one in a static because zlock can be in the text segment
  3067. +   the 2nd case should be safe to do in-place.
  3068. +   (this probably only works with SPOOLDIR_BNU) */
  3069. +
  3070. +char *
  3071. +translate_lock (zlock)
  3072. +     char *zlock;
  3073. +{
  3074. +  static char s[15];
  3075. +  char *p, *q, *ret=zlock, ch, lck[5];
  3076. +
  3077. +  if (!(p=strrchr(zlock, '/')))
  3078. +    p=zlock;
  3079. +  else
  3080. +    ++p;
  3081. +  if (*p == 'L' && p[1] == '.') {
  3082. +    *lck='.';
  3083. +    lck[1]='L';
  3084. +    lck[2]=0;
  3085. +    q=p+2;
  3086. +  } else {
  3087. +    if (*zlock != 'L' || strlen (zlock) <=3 || zlock[3] != '.')
  3088. +      return zlock;
  3089. +    ret=p=s;
  3090. +    q=zlock+sizeof "LCK."-1;
  3091. +    *lck='.';
  3092. +    strncpy(lck+1, zlock, 3);
  3093. +    lck[4]=0;
  3094. +  }
  3095. +  while (ch = *q++) {
  3096. +    if (ch == '.')
  3097. +      ch='_';
  3098. +    *p++=ch;
  3099. +  }
  3100. +  strcpy(p, lck);
  3101. +  return ret;
  3102. +}
  3103. +#endif
  3104. +
  3105.  /* Lock something.  If the fspooldir argument is TRUE, the argument is
  3106.     a file name relative to the spool directory; otherwise the argument
  3107.     is a simple file name which should be created in the system lock
  3108. @@ -1576,6 +1784,11 @@
  3109.    const char *zerr;
  3110.    boolean fret;
  3111.  
  3112. +#ifdef __MINT__
  3113. +  char utmpf[FILENAME_MAX], upath[FILENAME_MAX];
  3114. +
  3115. +  zlock = translate_lock(zlock);
  3116. +#endif
  3117.  #ifdef LOCKDIR
  3118.    if (fspooldir)
  3119.      zpath = zlock;
  3120. @@ -1609,14 +1822,25 @@
  3121.  
  3122.    ztempfile = (char *) alloca (cslash + sizeof "TMP1234567890");
  3123.    strncpy (ztempfile, zpath, cslash);
  3124. +#ifdef __MINT__
  3125. +  sprintf (abtempfile, "%08d.TMP", (int) ime);
  3126. +#else
  3127.    sprintf (abtempfile, "TMP%010d", (int) ime);
  3128. +#endif
  3129.    ztempfile[cslash] = '\0';
  3130.    strcat (ztempfile, abtempfile);
  3131.  
  3132. +#ifdef __MINT__
  3133. +newtempf:
  3134. +#endif
  3135.    o = creat (ztempfile, IPUBLIC_FILE_MODE);
  3136.    if (o < 0)
  3137.      {
  3138. +#ifdef __MINT__
  3139. +      if (errno == ENOENT || errno == EPATH)
  3140. +#else
  3141.        if (errno == ENOENT)
  3142. +#endif
  3143.      {
  3144.        if (! fsysdep_make_dirs (ztempfile, FALSE))
  3145.          return FALSE;
  3146. @@ -1659,14 +1883,38 @@
  3147.    o = -1;
  3148.    zerr = NULL;
  3149.  
  3150. +#ifdef __MINT__
  3151. +  /* translate filenames for Frename (see below) */
  3152. +  _unx2dos (ztempfile, utmpf);
  3153. +  _unx2dos (zpath, upath);
  3154. +#endif
  3155. +
  3156.    while (link (ztempfile, zpath) != 0)
  3157.      {
  3158.        int cgot;
  3159.        int ipid;
  3160.  
  3161. +#ifdef __MINT__
  3162. +      /* on MiNT link only works on some filesystems... on all others
  3163. +     the closest approximation we have is Frename. :-( */
  3164. +      int frenamed = 0;
  3165. +
  3166. +      if (errno == EINVAL) {
  3167. +    if (!(errno = -Frename (0, utmpf, upath)))
  3168. +      break;
  3169. +
  3170. +    frenamed = 1;
  3171. +      }
  3172. +
  3173. +      fret = FALSE;
  3174. +
  3175. +      /* Frename returns EACCESS when it really means EEXIST. */
  3176. +      if (errno != EEXIST && errno != EACCESS)
  3177. +#else
  3178.        fret = FALSE;
  3179.  
  3180.        if (errno != EEXIST)
  3181. +#endif
  3182.      {
  3183.        ulog (LOG_ERROR, "link (%s, %s): %s", ztempfile, zpath,
  3184.          strerror (errno));
  3185. @@ -1848,8 +2096,14 @@
  3186.            break;
  3187.          }
  3188.  
  3189. +#ifdef __MINT__
  3190. +          /* if link didn't work the filesystem won't have inodes anyway. */
  3191. +          if ((frenamed || sfile.st_ino == sdescriptor.st_ino)
  3192. +           && sfile.st_dev == sdescriptor.st_dev)
  3193. +#else
  3194.            if (sfile.st_ino == sdescriptor.st_ino
  3195.            && sfile.st_dev == sdescriptor.st_dev)
  3196. +#endif
  3197.          {
  3198.            /* Close the file before assuming we've succeeded to
  3199.               pick up any trailing errors.  */
  3200. @@ -1874,6 +2128,11 @@
  3201.        (void) close (o);
  3202.        o = -1;
  3203.        fret = TRUE;
  3204. +#ifdef __MINT__
  3205. +      /* if we had to use Frename we must make a new tempfile first */
  3206. +      if (frenamed)
  3207. +    goto newtempf;
  3208. +#endif
  3209.      }
  3210.  
  3211.    if (zerr != NULL)
  3212. @@ -1886,7 +2145,13 @@
  3213.       future calls, but considering that we create lock files in
  3214.       various different directories it's probably more trouble than
  3215.       it's worth.  */
  3216. +#ifdef __MINT__
  3217. +  /* if we had to use Frename the tempfile will no longer be there
  3218. +     so we ignore the error. */
  3219. +  if (remove (ztempfile) != 0 && errno != ENOENT)
  3220. +#else
  3221.    if (remove (ztempfile) != 0)
  3222. +#endif
  3223.      ulog (LOG_ERROR, "remove (%s): %s", ztempfile, strerror (errno));
  3224.  
  3225.    return fret;
  3226. @@ -1901,6 +2166,9 @@
  3227.  {
  3228.    const char *zpath;
  3229.  
  3230. +#ifdef __MINT__
  3231. +  zlock = translate_lock(zlock);
  3232. +#endif
  3233.  #ifdef LOCKDIR
  3234.    if (fspooldir)
  3235.      zpath = zlock;
  3236. @@ -2039,7 +2307,11 @@
  3237.  
  3238.    if (o < 0)
  3239.      {
  3240. +#ifdef __MINT__
  3241. +      if (errno == ENOENT || errno == EPATH)
  3242. +#else
  3243.        if (errno == ENOENT)
  3244. +#endif
  3245.      {
  3246.        if (! fsysdep_make_dirs (zfile, FALSE))
  3247.          {
  3248. @@ -2184,6 +2456,16 @@
  3249.  #endif
  3250.  
  3251.        zname = zsfind_file (absimple, zsystem);
  3252. +#ifdef __MINT__
  3253. +      /* munge the name for 8+3 filesystems...
  3254. +     if the grade is upper case make the first char of the
  3255. +     *.C file name @ instead of A to keep the information on this
  3256. +     case-ignoring filesystem.  (the sequence number is in hex at
  3257. +     least with SPOOLDIR_BNU and the system name isn't used so the
  3258. +     grade is the only part where case matters.) */
  3259. +
  3260. +      translate_spoolname (zname, btype == 'C');
  3261. +#endif
  3262.        if (zname == NULL)
  3263.      return NULL;
  3264.      }
  3265. @@ -2234,12 +2516,40 @@
  3266.  
  3267.    for (i = 0, q = pascmds; i < ccmds; i++, q++)
  3268.      {
  3269. +#ifdef __MINT__
  3270. +      char *p, ch;
  3271. +
  3272. +      if (p = (char *) q->zfrom)
  3273. +    for (; ch = *p; ++p)
  3274. +      if (ch == '\\')
  3275. +        *p = '/';
  3276. +
  3277. +      if (p = (char *) q->zto)
  3278. +    for (; ch = *p; ++p)
  3279. +      if (ch == '\\')
  3280. +        *p = '/';
  3281. +#endif
  3282.        switch (q->bcmd)
  3283.      {
  3284.      case 'S':
  3285. +#ifdef __MINT__
  3286. +      /* stupid 8+3 filesystem...
  3287. +         put the translated temp file name in the command file */
  3288. +
  3289. +      { char *ztempf = alloca (strlen (q->ztemp) + 1);
  3290. +
  3291. +      strcpy (ztempf, q->ztemp);
  3292. +      translate_spoolname(ztempf, 0);
  3293. +
  3294. +      fprintf (e, "S %s %s %s -%s %s 0%o %s\n", q->zfrom, q->zto,
  3295. +           q->zuser, q->zoptions, ztempf, q->imode,
  3296. +           q->znotify);
  3297. +      }
  3298. +#else
  3299.        fprintf (e, "S %s %s %s -%s %s 0%o %s\n", q->zfrom, q->zto,
  3300.             q->zuser, q->zoptions, q->ztemp, q->imode,
  3301.             q->znotify);
  3302. +#endif
  3303.        break;
  3304.      case 'R':
  3305.        fprintf (e, "R %s %s %s -%s\n", q->zfrom, q->zto, q->zuser,
  3306. @@ -2311,6 +2621,9 @@
  3307.        sprintf (absx, "X.%.7sX%s", zLocalname, abseq);
  3308.  
  3309.        zname = zsfind_file (absx, zLocalname);
  3310. +#ifdef __MINT__
  3311. +      translate_spoolname (zname, 0);
  3312. +#endif
  3313.        if (zname == NULL)
  3314.      return NULL;
  3315.        if (stat (zname, &s) != 0)
  3316. @@ -2336,6 +2649,15 @@
  3317.    FILE *e;
  3318.    pid_t ipid;
  3319.  
  3320. +#ifdef __MINT__
  3321. +  char *p, ch;
  3322. +
  3323. +  if (p = (char *) zfile)
  3324. +    for (; ch = *p; ++p)
  3325. +      if (ch == '\\')
  3326. +    *p = '/';
  3327. +#endif
  3328. +
  3329.    zSwildcard_alloc = NULL;
  3330.    zSwildcard = NULL;
  3331.  
  3332. @@ -2355,6 +2677,10 @@
  3333.    zcmd = (char *) alloca (sizeof ECHO_PROGRAM + sizeof " " + strlen (zfile));
  3334.    sprintf (zcmd, "%s %s", ECHO_PROGRAM, zfile);
  3335.  
  3336. +#ifdef __MINT__
  3337. +  /* on MiNT people don't always have a shell in /bin/sh */
  3338. +  if (!(azargs[0] = getenv("SHELL")))
  3339. +#endif
  3340.    azargs[0] = "/bin/sh";
  3341.    azargs[1] = "-c";
  3342.    azargs[2] = zcmd;
  3343. @@ -2557,10 +2883,38 @@
  3344.       const char *zfile;
  3345.  {
  3346.    char *zid;
  3347. +#ifdef __MINT__
  3348. +  /* handle [@a]oxn1234.c as well as the `normal' C.fooboxN1234 format */
  3349. +  int clen, slen = strlen (qsys->zname);
  3350. +  char ch;
  3351. +
  3352. +  zid = (char *) alloca (slen + CSEQLEN + 2);
  3353. +  if ((clen = strlen (zfile)) > 7 && (zfile[clen - 1] & 0xdf) == 'C' &&
  3354. +    strchr (zfile, '.') == zfile + clen - 2) {
  3355. +    strcpy (zid, qsys->zname);
  3356. +    strncpy (zid + slen, zfile + clen - CSEQLEN - 3, CSEQLEN + 1);
  3357. +    zid[slen + CSEQLEN + 1] = 0;
  3358. +
  3359. +    /* restore the case of the grade */
  3360. +    if ((ch = zid[slen] & 0xdf) >= 'A' && ch <= 'Z') {
  3361. +      const char *p = strrchr (zfile, '/');
  3362.  
  3363. +      if (!p)
  3364. +    p = zfile;
  3365. +      else
  3366. +    ++p;
  3367. +      if (*p != '@')
  3368. +    ch |= 0x20;
  3369. +      zid[slen] = ch;
  3370. +    }
  3371. +  } else
  3372. +    sprintf (zid, "%s%s", qsys->zname,
  3373. +         zfile + strlen (zfile) - CSEQLEN - 1);
  3374. +#else
  3375.    zid = (char *) alloca (strlen (qsys->zname) + CSEQLEN + 2);
  3376.    sprintf (zid, "%s%s", qsys->zname,
  3377.         zfile + strlen (zfile) - CSEQLEN - 1);
  3378. +#endif
  3379.  
  3380.    return zscopy (zid);
  3381.  }
  3382. @@ -2599,7 +2953,11 @@
  3383.    sprintf (abname, "C.%s", abend);
  3384.  #endif
  3385.  
  3386. +#ifdef __MINT__
  3387. +  return translate_spoolname (zsfind_file (abname, zsys), 1);
  3388. +#else
  3389.    return zsfind_file (abname, zsys);
  3390. +#endif
  3391.  }
  3392.  
  3393.  #if ! HAVE_RENAME
  3394. diff -ru ./sys4.c /src/t103/uucp-1.03/sys4.c
  3395. --- ./sys4.c    Tue Apr  7 06:05:28 1992
  3396. +++ /src/t103/uucp-1.03/sys4.c    Wed Jan  6 20:20:54 1993
  3397. @@ -236,7 +236,30 @@
  3398.       we are looking in and AIX uucp sets it to the local system rather
  3399.       than the remote one.  */
  3400.    if (zfile[0] != 'C' || zfile[1] != '.')
  3401. +#ifdef __MINT__
  3402. +  {
  3403. +    char ch;
  3404. +
  3405. +    /* stupid 8+3 filesystem...  look for *.[cC] too */
  3406. +    clen = strlen (zfile);
  3407. +    if (clen < 7 || strchr(zfile, '.') != zfile+clen-2 ||
  3408. +    (zfile[clen-1] & 0xdf) != 'C')
  3409. +      return FALSE;
  3410. +
  3411. +    *pbgrade = ch = zfile[clen - 7];
  3412. +
  3413. +    /* we saved the case of the grade into the first char: A means lower,
  3414. +       @ upper */
  3415. +    if ((ch & 0xdf) >= 'A' && ch <= 'Z') {
  3416. +      if (*zfile != '@')
  3417. +    ch |= 0x20;
  3418. +      *pbgrade = ch;
  3419. +    }
  3420. +    return TRUE;
  3421. +  }
  3422. +#else
  3423.      return FALSE;
  3424. +#endif
  3425.    clen = strlen (zfile);
  3426.    if (clen < 7)
  3427.      return FALSE;
  3428. @@ -359,7 +382,11 @@
  3429.    qdir = opendir ((char *) zdir);
  3430.    if (qdir == NULL)
  3431.      {
  3432. +#ifdef __MINT__
  3433. +      if (errno != ENOENT && errno != EPATH)
  3434. +#else
  3435.        if (errno != ENOENT)
  3436. +#endif
  3437.      ulog (LOG_ERROR, "opendir (%s): %s", zdir, strerror (errno));
  3438.        return FALSE;
  3439.      }
  3440. @@ -384,7 +411,13 @@
  3441.  
  3442.        zname = qentry->d_name;
  3443.        if (fswork_file (qsys->zname, qentry->d_name, &bfilegrade)
  3444. +#if 1
  3445. +      /* hmmm. is my bsearch() the only one that doesn't like
  3446. +         getting called with zero count? :-)  -nox */
  3447. +      && (azSwork_files == NULL || !chad
  3448. +#else
  3449.        && (azSwork_files == NULL
  3450. +#endif
  3451.            || bsearch ((pointer) &zname,
  3452.                (pointer) azSwork_files,
  3453.                chad, sizeof (char *),
  3454. @@ -586,6 +619,35 @@
  3455.            qSwork_file->aslines[iline].zline = NULL;
  3456.            return FALSE;
  3457.          }
  3458. +#ifdef __MINT__
  3459. +          /* kludge to make requests written by the `old' uux work:
  3460. +         if zfrom and ztemp are equal and look like afoobar.[dx]
  3461. +         and the options are empty then use -C and munge zfrom back. */
  3462. +          { int clen; char ch;
  3463. +
  3464. +        if (!*qcmd->zoptions && (*qcmd->zfrom & 0xdf) == 'A' &&
  3465. +            (clen = strlen (qcmd->zfrom)) > 7 && clen <= 10 &&
  3466. +            ((ch = qcmd->zfrom[clen - 1] & 0xdf) == 'D' || ch == 'X') &&
  3467. +            !strcmp (qcmd->zfrom, qcmd->ztemp) &&
  3468. +            strchr (qcmd->zfrom, '.') == qcmd->zfrom + clen - 2 &&
  3469. +            !strchr (qcmd->zfrom, '\\') &&
  3470. +            !strchr (qcmd->zfrom, '/')) {
  3471. +          char *p, *ztmp = alloca (clen + 1);
  3472. +
  3473. +          p = ztmp;
  3474. +          *p++ = ch;
  3475. +          *p++ = '.';
  3476. +          if (clen > 9)
  3477. +            /* dummy char, will be dropped in translate_spoolname */
  3478. +            ++clen, *p++ = '_';
  3479. +          strncpy (p, qcmd->zfrom + 1, clen - 3);
  3480. +          ztmp[clen - 1] = 0;
  3481. +          strcpy ((char *) qcmd->zfrom, ztmp);
  3482. +
  3483. +          qcmd->zoptions = "C";
  3484. +        }
  3485. +          }
  3486. +#endif
  3487.  
  3488.            qSwork_file->aslines[iline].ztemp = xstrdup (zreal);
  3489.          }
  3490. @@ -708,6 +770,14 @@
  3491.    int cwant;
  3492.    static char *zbuf;
  3493.    static int cbuf;
  3494. +#ifdef __MINT__
  3495. +  char *p, ch;
  3496. +
  3497. +  if (p = (char *) qline->ztemp)
  3498. +    for (; ch = *p; ++p)
  3499. +      if (ch == '\\')
  3500. +    *p = '/';
  3501. +#endif
  3502.  
  3503.    if (! fsysdep_file_exists (qline->ztemp))
  3504.      return NULL;
  3505. diff -ru ./sys5.c /src/t103/uucp-1.03/sys5.c
  3506. --- ./sys5.c    Tue Apr  7 06:05:28 1992
  3507. +++ /src/t103/uucp-1.03/sys5.c    Wed Jan  6 20:23:30 1993
  3508. @@ -257,7 +257,11 @@
  3509.    qSxqt_topdir = opendir ((char *) ZDIR);
  3510.    if (qSxqt_topdir == NULL)
  3511.      {
  3512. +#ifdef __MINT__
  3513. +      if (errno == ENOENT || errno == EPATH)
  3514. +#else
  3515.        if (errno == ENOENT)
  3516. +#endif
  3517.      return TRUE;
  3518.        ulog (LOG_ERROR, "opendir (%s): %s", ZDIR, strerror (errno));
  3519.        return FALSE;
  3520. @@ -337,7 +341,11 @@
  3521.        qSxqt_dir = opendir (zSdir);
  3522.  
  3523.        if (qSxqt_dir == NULL
  3524. +#ifdef __MINT__
  3525. +          && errno != EPATH
  3526. +#else
  3527.            && errno != ENOTDIR
  3528. +#endif
  3529.            && errno != ENOENT)
  3530.          ulog (LOG_ERROR, "opendir (%s): %s", zSdir, strerror (errno));
  3531.      }
  3532. @@ -401,6 +409,36 @@
  3533.  
  3534.        return zret;
  3535.      }
  3536. +#ifdef __MINT__
  3537. +    else {
  3538. +      int clen;
  3539. +
  3540. +      /* stupid 8+3 filesystem...  look for *.x too */
  3541. +      if (q != NULL &&
  3542. +         (clen = strlen (q->d_name)) >= 7 &&
  3543. +         strchr(q->d_name, '.') == q->d_name+clen-2 &&
  3544. +         (q->d_name[clen-1] & 0xdf) == 'X') {
  3545. +        const char *zret;
  3546. +
  3547. +        /* this assumes SPOOLDIR_BNU */
  3548. +        *pzsystem = zSsystem;
  3549. +
  3550. +        /* Set *pferr to TRUE in case zsappend returns NULL.  */
  3551. +        *pferr = TRUE;
  3552. +
  3553. +        zret = zsappend (zSdir, q->d_name);
  3554. +
  3555. +  #if DEBUG > 1
  3556. +        if (zret != NULL)
  3557. +          DEBUG_MESSAGE2 (DEBUG_SPOOLDIR,
  3558. +                  "zsysdep_get_xqt: Returning %s (system %s)",
  3559. +                  zret, *pzsystem);
  3560. +  #endif
  3561. +
  3562. +        return zret;
  3563. +      }
  3564. +    }
  3565. +#endif
  3566.          
  3567.        /* If we've reached the end of the directory, then if we are
  3568.       using subdirectories loop around to read the next one,
  3569. @@ -456,6 +494,10 @@
  3570.       boolean *pferr;
  3571.  {
  3572.    char *zcopy, *ztok;
  3573. +#ifdef __MINT__
  3574. +  char *ztmp;
  3575. +  int clen;
  3576. +#endif
  3577.  
  3578.    *pferr = TRUE;
  3579.  
  3580. @@ -499,6 +541,20 @@
  3581.       the path.  */
  3582.    zcopy = (char *) alloca (strlen (zpath) + 1);
  3583.    strcpy (zcopy, zpath);
  3584. +#ifdef __MINT__
  3585. +  /* and on MiNT that includes looking for file `types' *.ttp etc
  3586. +     if the command doesn't come with one. */
  3587. +  if (strchr (zcmd, '.')) {
  3588. +    /* if there is a . assume it does */
  3589. +    ztmp = (char *) zcmd;
  3590. +    clen = 0;
  3591. +  } else {
  3592. +    ztmp = alloca ((clen = strlen (zcmd)) + sizeof ".ttp");
  3593. +    strcpy (ztmp, zcmd);
  3594. +    /* make zsappend allocate enough... */
  3595. +    strcpy (ztmp + clen, ".xxx");
  3596. +  }
  3597. +#endif
  3598.    for (ztok = strtok (zcopy, " ");
  3599.         ztok != NULL;
  3600.         ztok = strtok ((char *) NULL, " "))
  3601. @@ -505,9 +561,37 @@
  3602.      {
  3603.        const char *zname;
  3604.  
  3605. +#ifdef __MINT__
  3606. +      zname = zsappend (ztok, ztmp);
  3607. +      if (zname == NULL)
  3608. +    return NULL;
  3609. +
  3610. +      if (clen) {
  3611. +        char *p = (char *) zname + clen + strlen (ztok) + 1;
  3612. +
  3613. +    /* try the unchanged command first */
  3614. +    *p = 0;
  3615. +    if (access (zname, F_OK) == 0)
  3616. +      return zname;
  3617. +
  3618. +    /* and now command.ttp */
  3619. +    strcpy (p++, ".ttp");
  3620. +    if (access (zname, F_OK) == 0)
  3621. +      return zname;
  3622. +
  3623. +    /* command.prg */
  3624. +    strcpy (p, "prg");
  3625. +    if (access (zname, F_OK) == 0)
  3626. +      return zname;
  3627. +
  3628. +    /* command.tos */
  3629. +    strcpy (p, "tos");
  3630. +      }
  3631. +#else
  3632.        zname = zsappend (ztok, zcmd);
  3633.        if (zname == NULL)
  3634.      return NULL;
  3635. +#endif
  3636.        if (access (zname, F_OK) == 0)
  3637.      return zname;
  3638.      }
  3639. @@ -529,6 +613,15 @@
  3640.       const struct ssysteminfo *qsys;
  3641.       const char *zfile;
  3642.  {
  3643. +#ifdef __MINT__
  3644. +  char *p, ch;
  3645. +
  3646. +  if (p = (char *) zfile)
  3647. +    for (; ch = *p; ++p)
  3648. +      if (ch == '\\')
  3649. +    *p = '/';
  3650. +#endif
  3651. +
  3652.    if (strncmp (zfile, "../", sizeof "../" - 1) == 0
  3653.        || strstr (zfile, "/../") != NULL
  3654.        || (*zfile == '/'
  3655. @@ -617,7 +710,11 @@
  3656.        aidescs[2] = creat (*pzerror, IPRIVATE_FILE_MODE);
  3657.        if (aidescs[2] < 0)
  3658.      {
  3659. +#ifdef __MINT__
  3660. +      if (errno == ENOENT || errno == EPATH)
  3661. +#else
  3662.        if (errno == ENOENT)
  3663. +#endif
  3664.          {
  3665.            if (! fsysdep_make_dirs (*pzerror, FALSE))
  3666.          {
  3667. @@ -786,7 +883,11 @@
  3668.    char ab[14];
  3669.  
  3670.    sprintf (ab, "LXQ.%.9s", zcmd);
  3671. +#ifdef __MINT__
  3672. +  return access (translate_lock(ab), F_OK) == 0;
  3673. +#else
  3674.    return access (ab, F_OK) == 0;
  3675. +#endif
  3676.  }
  3677.  
  3678.  /* Lock a particular execute file.  */
  3679. @@ -796,15 +897,30 @@
  3680.       const char *zfile;
  3681.  {
  3682.    char *zcopy, *z;
  3683. +#ifdef __MINT__
  3684. +  int clen;
  3685. +#endif
  3686.  
  3687.    zcopy = (char *) alloca (strlen (zfile) + 1);
  3688.    strcpy (zcopy, zfile);
  3689.  
  3690.    z = strrchr (zcopy, '/');
  3691. +#ifdef __MINT__
  3692. +  if (!z)
  3693. +    z = zcopy;
  3694. +  else
  3695. +    ++z;
  3696. +  /* if zfile matches *.X replace the last char */
  3697. +  if ((clen = strlen (z)) > 3 && (z[clen - 1] & 0xdf) == 'X' &&
  3698. +      strchr (z, '.') == z + clen - 2)
  3699. +    z += clen - 1;
  3700. +  *z = 'L';
  3701. +#else
  3702.    if (z == NULL)
  3703.      *zcopy = 'L';
  3704.    else
  3705.      *(z + 1) = 'L';
  3706. +#endif
  3707.  
  3708.    return fsdo_lock (zcopy, TRUE);
  3709.  }
  3710. @@ -816,15 +932,30 @@
  3711.       const char *zfile;
  3712.  {
  3713.    char *zcopy, *z;
  3714. +#ifdef __MINT__
  3715. +  int clen;
  3716. +#endif
  3717.  
  3718.    zcopy = (char *) alloca (strlen (zfile) + 1);
  3719.    strcpy (zcopy, zfile);
  3720.  
  3721.    z = strrchr (zcopy, '/');
  3722. +#ifdef __MINT__
  3723. +  if (!z)
  3724. +    z = zcopy;
  3725. +  else
  3726. +    ++z;
  3727. +  /* if zfile matches *.X replace the last char */
  3728. +  if ((clen = strlen (z)) > 3 && (z[clen - 1] & 0xdf) == 'X' &&
  3729. +      strchr (z, '.') == z + clen - 2)
  3730. +    z += clen - 1;
  3731. +  *z = 'L';
  3732. +#else
  3733.    if (z == NULL)
  3734.      *zcopy = 'L';
  3735.    else
  3736.      *(z + 1) = 'L';
  3737. +#endif
  3738.  
  3739.    return fsdo_unlock (zcopy, TRUE);
  3740.  }
  3741. diff -ru ./sys6.c /src/t103/uucp-1.03/sys6.c
  3742. --- ./sys6.c    Tue Apr  7 06:05:28 1992
  3743. +++ /src/t103/uucp-1.03/sys6.c    Mon Sep 21 03:47:52 1992
  3744. @@ -91,6 +91,14 @@
  3745.  fsysdep_needs_cwd (zfile)
  3746.       const char *zfile;
  3747.  {
  3748. +#ifdef __MINT__
  3749. +  char *p, ch;
  3750. +
  3751. +  if (p = (char *) zfile)
  3752. +    for (; ch = *p; ++p)
  3753. +      if (ch == '\\')
  3754. +    *p = '/';
  3755. +#endif
  3756.    return *zfile != '/' && *zfile != '~';
  3757.  }
  3758.  
  3759. @@ -102,6 +110,14 @@
  3760.       const char *zfile;
  3761.       boolean flocal;
  3762.  {
  3763. +#ifdef __MINT__
  3764. +  char *p, ch;
  3765. +
  3766. +  if (p = (char *) zfile)
  3767. +    for (; ch = *p; ++p)
  3768. +      if (ch == '\\')
  3769. +    *p = '/';
  3770. +#endif
  3771.    if (*zfile == '/')
  3772.      return zfile;
  3773.    if (*zfile == '~')
  3774. @@ -127,7 +143,14 @@
  3775.       const char *zfile;
  3776.  {
  3777.    const char *z;
  3778. +#ifdef __MINT__
  3779. +  char *p, ch;
  3780.  
  3781. +  if (p = (char *) zfile)
  3782. +    for (; ch = *p; ++p)
  3783. +      if (ch == '\\')
  3784. +    *p = '/';
  3785. +#endif
  3786.    z = strrchr (zfile, '/');
  3787.    if (z != NULL)
  3788.      return z + 1;
  3789. @@ -221,7 +244,12 @@
  3790.        return TRUE;
  3791.      }
  3792.    *pfworked = FALSE;
  3793. +#ifdef __MINT__
  3794. +  /* link() works only on some filesystems, on the default one it gets EINVAL */
  3795. +  return errno == EXDEV || errno == EINVAL;
  3796. +#else
  3797.    return errno == EXDEV;
  3798. +#endif
  3799.  }
  3800.  
  3801.  /*
  3802. diff -ru ./sys7.c /src/t103/uucp-1.03/sys7.c
  3803. --- ./sys7.c    Tue Apr  7 06:05:30 1992
  3804. +++ /src/t103/uucp-1.03/sys7.c    Wed Jan  6 20:39:54 1993
  3805. @@ -210,7 +210,11 @@
  3806.    e = fopen (zfile, "r");
  3807.    if (e == NULL)
  3808.      {
  3809. +#ifdef __MINT__
  3810. +      if (errno == ENOENT || errno == EPATH)
  3811. +#else
  3812.        if (errno == ENOENT)
  3813. +#endif
  3814.      ulog (LOG_ERROR, "%s: Job not found", zid);
  3815.        else
  3816.      ulog (LOG_ERROR, "fopen (%s): %s", zfile, strerror (errno));
  3817. @@ -262,7 +266,11 @@
  3818.            else
  3819.          isys = ussettime (ztemp);
  3820.  
  3821. +#ifdef __MINT__
  3822. +          if (isys != 0 && errno != ENOENT && errno != EPATH)
  3823. +#else
  3824.            if (isys != 0 && errno != ENOENT)
  3825. +#endif
  3826.          {
  3827.            ulog (LOG_ERROR, "%s (%s): %s",
  3828.              fkill ? "remove" : "utime", ztemp,
  3829. @@ -282,7 +290,11 @@
  3830.    else
  3831.      isys = ussettime (zfile);
  3832.  
  3833. +#ifdef __MINT__
  3834. +  if (isys != 0 && errno != ENOENT && errno != EPATH)
  3835. +#else
  3836.    if (isys != 0 && errno != ENOENT)
  3837. +#endif
  3838.      {
  3839.        ulog (LOG_ERROR, "%s (%s): %s", fkill ? "remove" : "utime",
  3840.          zfile, strerror (errno));
  3841. @@ -314,7 +326,11 @@
  3842.  
  3843.    if (stat (zfile, &s) < 0)
  3844.      {
  3845. +#ifdef __MINT__
  3846. +      if (errno != ENOENT && errno != EPATH)
  3847. +#else
  3848.        if (errno != ENOENT)
  3849. +#endif
  3850.      ulog (LOG_ERROR, "stat (%s): %s", zfile, strerror (errno));
  3851.        return isysdep_time ((long *) NULL);
  3852.      }
  3853. @@ -332,7 +348,11 @@
  3854.  
  3855.    if (stat (zfile, &s) < 0)
  3856.      {
  3857. +#ifdef __MINT__
  3858. +      if (errno != ENOENT && errno != EPATH)
  3859. +#else
  3860.        if (errno != ENOENT)
  3861. +#endif
  3862.      ulog (LOG_ERROR, "stat (%s): %s", zfile, strerror (errno));
  3863.        return 0;
  3864.      }
  3865. @@ -466,8 +486,17 @@
  3866.        int ierr;
  3867.        int ipid;
  3868.  
  3869. +#ifdef __MINT__
  3870. +      /* look for _*.lck too... */
  3871. +      if ((qentry->d_name[0] == '_' &&
  3872. +      strncasecmp (qentry->d_name + strlen(qentry->d_name) - sizeof ".lck",
  3873. +           ".lck", sizeof ".lck" - 1) != 0) ||
  3874. +      strncmp (qentry->d_name, "LCK..", sizeof "LCK.." - 1) != 0)
  3875. +    continue;
  3876. +#else
  3877.        if (strncmp (qentry->d_name, "LCK..", sizeof "LCK.." - 1) != 0)
  3878.      continue;
  3879. +#endif
  3880.  
  3881.        zname = zsappend (zdir, qentry->d_name);
  3882.        o = open (zname, O_RDONLY, 0);
  3883. diff -ru ./sysdep.h /src/t103/uucp-1.03/sysdep.h
  3884. --- ./sysdep.h    Tue Apr  7 06:05:30 1992
  3885. +++ /src/t103/uucp-1.03/sysdep.h    Thu Sep 17 00:57:24 1992
  3886. @@ -217,8 +217,13 @@
  3887.  #endif
  3888.  
  3889.  /* On Unix, binary files are the same as text files.  */
  3890. +#ifdef __MINT__
  3891. +#define BINREAD "rb"
  3892. +#define BINWRITE "wb"
  3893. +#else
  3894.  #define BINREAD "r"
  3895.  #define BINWRITE "w"
  3896. +#endif
  3897.  
  3898.  /* If we have sigaction, we can force system calls to not be
  3899.     restarted.  */
  3900. @@ -388,22 +393,27 @@
  3901.  
  3902.  #ifndef S_IRUSR
  3903.  
  3904. -#define S_IRWXU 0700
  3905.  #define S_IRUSR 0400
  3906.  #define S_IWUSR 0200
  3907.  #define S_IXUSR 0100
  3908.  
  3909. -#define S_IRWXG 0070
  3910.  #define S_IRGRP 0040
  3911.  #define S_IWGRP 0020
  3912.  #define S_IXGRP 0010
  3913.  
  3914. -#define S_IRWXO 0007
  3915.  #define S_IROTH 0004
  3916.  #define S_IWOTH 0002
  3917.  #define S_IXOTH 0001
  3918.  
  3919.  #endif /* ! defined (S_IRUSR) */
  3920. +
  3921. +#ifndef S_IRWXU
  3922. +
  3923. +#define S_IRWXU 0700
  3924. +#define S_IRWXG 0070
  3925. +#define S_IRWXO 0007
  3926. +
  3927. +#endif
  3928.  
  3929.  #ifndef S_ISDIR
  3930.  #ifdef S_IFDIR
  3931. diff -ru ./sysinf.c /src/t103/uucp-1.03/sysinf.c
  3932. --- ./sysinf.c    Tue Apr  7 06:05:30 1992
  3933. +++ /src/t103/uucp-1.03/sysinf.c    Mon Oct 12 17:06:20 1992
  3934. @@ -1566,7 +1566,9 @@
  3935.  
  3936.  #endif /* HAVE_TAYLOR_CONFIG */
  3937.  
  3938. -#if HAVE_TAYLOR_CONFIG
  3939. +/* accept g parameters in brackets in bnu.c  -nox */
  3940. +/* #if HAVE_TAYLOR_CONFIG */
  3941. +#if HAVE_TAYLOR_CONFIG || HAVE_BNU_CONFIG
  3942.  
  3943.  /* Add a protocol parameter entry.  The pc parameter points to the
  3944.     number of protocol parameter entries, and the pq parameter points
  3945. diff -ru ./tstuu.c /src/t103/uucp-1.03/tstuu.c
  3946. --- ./tstuu.c    Tue Apr  7 06:05:32 1992
  3947. +++ /src/t103/uucp-1.03/tstuu.c    Wed Jan  6 20:42:10 1993
  3948. @@ -242,6 +242,12 @@
  3949.  
  3950.  #include "getopt.h"
  3951.  
  3952. +#ifdef __MINT__
  3953. +long    _stksize = 0x8000;
  3954. +#include <process.h>
  3955. +#include <osbind.h>
  3956. +#endif
  3957. +
  3958.  /* Get definitions for both O_NONBLOCK and O_NDELAY.  */
  3959.  
  3960.  #ifndef O_NDELAY
  3961. @@ -373,8 +379,13 @@
  3962.    const char *zcmd1, *zcmd2;
  3963.    const char *zpty;
  3964.    const char *zsys;
  3965. +#ifdef __MINT__
  3966. +  char abpty1[sizeof "/pipe/ptyp0"];
  3967. +  char abpty2[sizeof "/pipe/ptyp0"];
  3968. +#else
  3969.    char abpty1[sizeof "/dev/ptyp0"];
  3970.    char abpty2[sizeof "/dev/ptyp0"];
  3971. +#endif
  3972.    char *zptyname;
  3973.    int omaster1, oslave1, omaster2, oslave2;
  3974.  
  3975. @@ -443,6 +454,16 @@
  3976.        int om, os;
  3977.        FILE *e;
  3978.    
  3979. +#ifdef __MINT__
  3980. +      /* MiNT has a special dir for pipes + ptys... */
  3981. +      sprintf (zptyname, "\\pipe\\pty%c%c", *zpty,
  3982. +           "0123456789abcdef"[ipty]);
  3983. +      om = Fcreate (zptyname, 4 | 2);
  3984. +      if (om < 0)
  3985. +        continue;
  3986. +      *zptyname = '/';
  3987. +      zptyname[sizeof "/pipe" - 1] = '/';
  3988. +#else
  3989.        sprintf (zptyname, "/dev/pty%c%c", *zpty,
  3990.             "0123456789abcdef"[ipty]);
  3991.        om = open (zptyname, O_RDWR);
  3992. @@ -449,6 +470,7 @@
  3993.        if (om < 0)
  3994.          continue;
  3995.        zptyname[5] = 't';
  3996. +#endif
  3997.        os = open (zptyname, O_RDWR);
  3998.        if (os < 0)
  3999.          {
  4000. @@ -467,7 +489,11 @@
  4001.            perror ("fopen");
  4002.            exit (EXIT_FAILURE);
  4003.          }
  4004. +#ifdef __MINT__
  4005. +          fprintf (e, "%s", zptyname + 6);
  4006. +#else
  4007.            fprintf (e, "%s", zptyname + 5);
  4008. +#endif
  4009.            if (fclose (e) != 0)
  4010.          {
  4011.            perror ("fclose");
  4012. @@ -487,7 +513,11 @@
  4013.            perror ("fopen");
  4014.            exit (EXIT_FAILURE);
  4015.          }
  4016. +#ifdef __MINT__
  4017. +          fprintf (e, "%s", zptyname + 6);
  4018. +#else
  4019.            fprintf (e, "%s", zptyname + 5);
  4020. +#endif
  4021.            if (fclose (e) != 0)
  4022.          {
  4023.            perror ("fclose");
  4024. @@ -560,8 +590,13 @@
  4025.      exit (system ((char *) zcmd1));
  4026.        else
  4027.      {
  4028. +#ifdef __MINT__
  4029. +      (void) execl ("uucico.ttp", "uucico", "-I", "/usr/tmp/tstuu/Config1",
  4030. +            "-q", "-S", zsys, "-pstdin", (const char *) NULL);
  4031. +#else
  4032.        (void) execl ("uucico", "uucico", "-I", "/usr/tmp/tstuu/Config1",
  4033.              "-q", "-S", zsys, "-pstdin", (const char *) NULL);
  4034. +#endif
  4035.        fprintf (stderr, "execl failed\n");
  4036.        exit (EXIT_FAILURE);
  4037.      }
  4038. @@ -603,8 +638,13 @@
  4039.      exit (system ((char *) zcmd2));
  4040.        else
  4041.      {
  4042. +#ifdef __MINT__
  4043. +      (void) execl ("uucico.ttp", "uucico", "-I", "/usr/tmp/tstuu/Config2",
  4044. +            "-lq", (const char *)NULL);
  4045. +#else
  4046.        (void) execl ("uucico", "uucico", "-I", "/usr/tmp/tstuu/Config2",
  4047.              "-lq", (const char *)NULL);
  4048. +#endif
  4049.        fprintf (stderr, "execl failed\n");
  4050.        exit (EXIT_FAILURE);
  4051.      }
  4052. @@ -764,7 +804,11 @@
  4053.    int i;
  4054.    FILE *e;
  4055.  
  4056. +#ifdef __MINT__
  4057. +  e = xfopen (z, "wb");
  4058. +#else
  4059.    e = xfopen (z, "w");
  4060. +#endif
  4061.      
  4062.    for (i = 0; i < 256; i++)
  4063.      {
  4064. @@ -791,7 +835,11 @@
  4065.    int i;
  4066.    FILE *e;
  4067.  
  4068. +#ifdef __MINT__
  4069. +  e = xfopen (z, "rb");
  4070. +#else
  4071.    e = xfopen (z, "r");
  4072. +#endif
  4073.  
  4074.    for (i = 0; i < 256; i++)
  4075.      {
  4076. @@ -932,20 +980,35 @@
  4077.      {
  4078.        FILE *eprog;
  4079.  
  4080. +#ifdef __MINT__
  4081. +      eprog = xfopen ("/usr/tmp/tstuu/Chat1.sh", "w");
  4082. +#else
  4083.        eprog = xfopen ("/usr/tmp/tstuu/Chat1", "w");
  4084. +#endif
  4085.  
  4086.        /* Wait for the other side to open the port and flush input.  */
  4087.        fprintf (eprog, "sleep 1\n");
  4088.        fprintf (eprog,
  4089.             "echo password $1 speed $2 1>&2\n");
  4090. +#ifdef __MINT__
  4091. +      /* workaround for shells that always do crlf expansion... */
  4092. +      fprintf (eprog, "echo -n test1\\\\015\n");
  4093. +#else
  4094.        fprintf (eprog, "echo test1\n");
  4095. +#endif
  4096.        fprintf (eprog, "exit 0\n");
  4097.  
  4098.        xfclose (eprog);
  4099.  
  4100. +#ifdef __MINT__
  4101. +      (void) chmod ("/usr/tmp/tstuu/Chat1.sh", S_IRWXU);
  4102. +
  4103. +      fprintf (e, "chat-program /usr/tmp/tstuu/Chat1.sh \\P \\S\n");
  4104. +#else
  4105.        (void) chmod ("/usr/tmp/tstuu/Chat1", S_IRWXU);
  4106.  
  4107.        fprintf (e, "chat-program /usr/tmp/tstuu/Chat1 \\P \\S\n");
  4108. +#endif
  4109.  
  4110.        fprintf (e, "chat word: \\P\n");
  4111.        fprintf (e, "chat-fail login;\n");
  4112. @@ -1021,7 +1084,11 @@
  4113.        if (zProtocols != NULL)
  4114.      fprintf (e, "protocol %s\n", zProtocols);
  4115.  
  4116. +#ifdef __MINT__
  4117. +      eprog = xfopen ("/usr/tmp/tstuu/Chat2.sh", "w");
  4118. +#else
  4119.        eprog = xfopen ("/usr/tmp/tstuu/Chat2", "w");
  4120. +#endif
  4121.  
  4122.        fprintf (eprog,
  4123.             "echo port $1 1>&2\n");
  4124. @@ -1029,7 +1096,11 @@
  4125.  
  4126.        xfclose (eprog);
  4127.  
  4128. +#ifdef __MINT__
  4129. +      fprintf (e, "called-chat-program /bin/sh /usr/tmp/tstuu/Chat2.sh \\Y\n");
  4130. +#else
  4131.        fprintf (e, "called-chat-program /bin/sh /usr/tmp/tstuu/Chat2 \\Y\n");
  4132. +#endif
  4133.        fprintf (e, "time any\n");
  4134.  
  4135.        xfclose (e);
  4136. @@ -1103,7 +1174,12 @@
  4137.        (void) remove (zto);
  4138.        umake_file (zfrom, 5);
  4139.  
  4140. +#ifdef __MINT__
  4141. +      /* avoid problems with some shells... */
  4142. +      sprintf (ab, "%s -c '~/from3' test1!~/to3", zuucp2);
  4143. +#else
  4144.        sprintf (ab, "%s -c \\~/from3 test1!~/to3", zuucp2);
  4145. +#endif
  4146.        xsystem (ab);
  4147.      }
  4148.  
  4149. @@ -1149,13 +1225,22 @@
  4150.  
  4151.        if (fcall_uucico)
  4152.      {
  4153. +#ifdef __MINT__
  4154. +      /* avoid problems with some shells... */
  4155. +      zfrom = "'/usr/spool/uucppublic/to6*'";
  4156. +#else
  4157.        zfrom = "/usr/spool/uucppublic/to6\\*";
  4158. +#endif
  4159.        zfrom1 = "/usr/spool/uucppublic/to6.1";
  4160.        zfrom2 = "/usr/spool/uucppublic/to6.2";
  4161.      }
  4162.        else
  4163.      {
  4164. +#ifdef __MINT__
  4165. +      zfrom = "'/usr/tmp/tstuu/spool2/to6*'";
  4166. +#else
  4167.        zfrom = "/usr/tmp/tstuu/spool2/to6\\*";
  4168. +#endif
  4169.        zfrom1 = "/usr/tmp/tstuu/spool2/to6.1";
  4170.        zfrom2 = "/usr/tmp/tstuu/spool2/to6.2";
  4171.      }
  4172. @@ -1193,8 +1278,13 @@
  4173.        (void) remove (zto1);
  4174.        (void) remove (zto2);
  4175.  
  4176. +#ifdef __MINT__
  4177. +      sprintf (ab, "%s 'test1!/usr/tmp/tstuu/spool1/to7.*' %s", zuucp2,
  4178. +           zto);
  4179. +#else
  4180.        sprintf (ab, "%s test1!/usr/tmp/tstuu/spool1/to7.\\* %s", zuucp2,
  4181.             zto);
  4182. +#endif
  4183.        xsystem (ab);
  4184.      }
  4185.  }
  4186. @@ -1399,8 +1489,16 @@
  4187.       const char *zcmd;
  4188.  {
  4189.    int istat;
  4190. +#ifdef __MINT__
  4191. +  char *p = (char *) zcmd, *sh = getenv("SHELL");
  4192. +
  4193. +  if (!sh)
  4194. +    sh = "/bin/sh";
  4195.  
  4196. +  istat = spawnl (P_WAIT, sh, sh, "-c", p, (char *) NULL);
  4197. +#else
  4198.    istat = system ((char *) zcmd);
  4199. +#endif
  4200.    if (istat != 0)
  4201.      {
  4202.        fprintf (stderr, "Command failed with status %d\n", istat);
  4203.