diff options
Diffstat (limited to 'gnu/libexec/uucp/cu')
| -rw-r--r-- | gnu/libexec/uucp/cu/Makefile | 4 | ||||
| -rw-r--r-- | gnu/libexec/uucp/cu/cu.1 | 65 | ||||
| -rw-r--r-- | gnu/libexec/uucp/cu/cu.c | 157 |
3 files changed, 163 insertions, 63 deletions
diff --git a/gnu/libexec/uucp/cu/Makefile b/gnu/libexec/uucp/cu/Makefile index c2171a690a83..ada7ab2b64a7 100644 --- a/gnu/libexec/uucp/cu/Makefile +++ b/gnu/libexec/uucp/cu/Makefile @@ -1,9 +1,9 @@ # Makefile for cu -# $Id: Makefile,v 1.1 1993/08/05 18:23:27 conklin Exp $ +# $Id: Makefile,v 1.3 1994/05/31 07:47:39 ache Exp $ BINDIR= $(bindir) BINOWN= $(owner) -BINMODE= 4555 +BINMODE= 4555 PROG= cu SRCS= cu.c prot.c log.c chat.c conn.c tcp.c tli.c copy.c diff --git a/gnu/libexec/uucp/cu/cu.1 b/gnu/libexec/uucp/cu/cu.1 index c08fe8020f25..630e11ca6e96 100644 --- a/gnu/libexec/uucp/cu/cu.1 +++ b/gnu/libexec/uucp/cu/cu.1 @@ -1,5 +1,5 @@ -''' $Id: cu.1,v 1.1 1993/08/05 18:23:28 conklin Exp $ -.TH cu 1 "Taylor UUCP 1.04" +''' $Id: cu.1,v 1.2 1994/05/07 18:09:51 ache Exp $ +.TH cu 1 "Taylor UUCP 1.05" .SH NAME cu \- Call up another system .SH SYNOPSIS @@ -22,8 +22,12 @@ Otherwise, if the argument begins with a digit, it is taken to be a phone number to call. Otherwise, it is taken to be the name of a system to call. The .B \-z +or +.B \-\-system option may be used to name a system beginning with a digit, and the .B \-c +or +.B \-\-phone option may be used to name a phone number that does not begin with a digit. @@ -31,9 +35,9 @@ digit. locates a port to use in the UUCP configuration files. If a simple system name is given, it will select a port appropriate for that system. The -.B \-p, \-l +.B \-p, \-\-port, \-l, \-\-line, \-s and -.B \-s +.B \-\-speed options may be used to control the port selection. When a connection is made to the remote system, @@ -208,53 +212,55 @@ default is true. The following options may be given to .I cu. .TP 5 -.B \-e +.B \-e, \-\-parity=even Use even parity. .TP 5 -.B \-o -Use odd parity. If both +.B \-o, \-\-parity=odd +Use odd parity. +.TP 5 +.B \-\-parity=none +Use no parity. No parity is also used if both .B \-e and .B \-o -are used, no parity is used. Otherwise the default parity of the line -is used. +are given. .TP 5 -.B \-h +.B \-h, \-\-halfduplex Echo characters locally (half-duplex mode). .TP 5 -.B \-z system +.B \-z system, \-\-system system The system to call. .TP 5 -.B \-c phone-number +.B \-c phone-number, \-\-phone phone-number The phone number to call. .TP 5 -.B \-p port +.B \-p port, \-\-port port Name the port to use. .TP 5 .B \-a port Equivalent to -.B \-p port. +.B \-\-port port. .TP 5 -.B \-l line +.B \-l line, \-\-line line Name the line to use by giving a device name. This may be used to dial out on ports that are not listed in the UUCP configuration files. Write access to the device is required. .TP 5 -.B \-s speed +.B \-s speed, \-\-speed speed The speed (baud rate) to use. .TP 5 .B \-# Where # is a number, equivalent to -.B \-s #. +.B \-\-speed #. .TP 5 -.B \-n +.B \-n, \-\-prompt Prompt for the phone number to use. .TP 5 .B \-d Enter debugging mode. Equivalent to -.B \-x all. +.B \-debug all. .TP 5 -.B \-x type +.B \-x type, \-\-debug type Turn on particular debugging types. The following types are recognized: abnormal, chat, handshake, uucp-proto, proto, port, config, spooldir, execute, incoming, outgoing. Only abnormal, chat, @@ -262,20 +268,26 @@ handshake, port, config, incoming and outgoing are meaningful for .I cu. Multiple types may be given, separated by commas, and the -.B \-x +.B \-\-debug option may appear multiple times. A number may also be given, which will turn on that many types from the foregoing list; for example, -.B \-x 2 +.B \-\-debug 2 is equivalent to -.B \-x abnormal,chat. -.B \-x all +.B \-\-debug abnormal,chat. +.B \-\-debug all may be used to turn on all debugging options. .TP 5 -.B \-I file +.B \-I file, \-\-config file Set configuration file to use. This option may not be available, depending upon how .I cu was compiled. +.TP 5 +.B \-v, \-\-version +Report version information and exit. +.TP 5 +.B \-\-help +Print a help message and exit. .SH BUGS This program does not work very well. .SH FILES @@ -284,3 +296,6 @@ approximation. .br /usr/lib/uucp/config - Configuration file. +.SH AUTHOR +Ian Lance Taylor +<ian@airs.com> diff --git a/gnu/libexec/uucp/cu/cu.c b/gnu/libexec/uucp/cu/cu.c index 5e34601de3b9..3939f6a02ece 100644 --- a/gnu/libexec/uucp/cu/cu.c +++ b/gnu/libexec/uucp/cu/cu.c @@ -1,7 +1,7 @@ /* cu.c Call up a remote system. - Copyright (C) 1992 Ian Lance Taylor + Copyright (C) 1992, 1993, 1994 Ian Lance Taylor This file is part of the Taylor UUCP package. @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucp.h" #if USE_RCS_ID -const char cu_rcsid[] = "$Id: cu.c,v 1.1 1993/08/05 18:23:29 conklin Exp $"; +const char cu_rcsid[] = "$Id: cu.c,v 1.2 1994/05/07 18:09:54 ache Exp $"; #endif #include "cu.h" @@ -66,7 +66,7 @@ boolean fCuvar_binary = FALSE; /* A prefix string to use before sending a binary character from a file; this is only used if fCuvar_binary is TRUE. The default is - ^Z. */ + ^V. */ const char *zCuvar_binary_prefix = "\026"; /* Whether to check for echoes of characters sent when sending a file. @@ -126,9 +126,6 @@ static const struct uuconf_cmdtab asCuvars[] = { NULL, 0, NULL, NULL} }; -/* The program name. */ -char abProgram[] = "cu"; - /* The string printed at the initial connect. */ #if ANSI_C #define ZCONNMSG "\aConnected." @@ -175,6 +172,9 @@ static boolean fCulocalecho; /* Whether we need to call fsysdep_cu_finish. */ static boolean fCustarted; +/* Whether ZCONNMSG has been printed yet. */ +static boolean fCuconnprinted = FALSE; + /* A structure used to pass information to icuport_lock. */ struct sconninfo { @@ -187,6 +187,7 @@ struct sconninfo /* Local functions. */ static void ucuusage P((void)); +static void ucuhelp P((void)); static void ucuabort P((void)); static void uculog_start P((void)); static void uculog_end P((void)); @@ -209,7 +210,24 @@ static boolean fcusend_buf P((struct sconnection *qconn, const char *zbuf, do { if (! fsysdep_terminal_puts (zline)) ucuabort (); } while (0) /* Long getopt options. */ -static const struct option asCulongopts[] = { { NULL, 0, NULL, 0 } }; +static const struct option asCulongopts[] = +{ + { "phone", required_argument, NULL, 'c' }, + { "parity", required_argument, NULL, 2 }, + { "halfduplex", no_argument, NULL, 'h' }, + { "prompt", no_argument, NULL, 'n' }, + { "line", required_argument, NULL, 'l' }, + { "port", required_argument, NULL, 'p' }, + { "speed", required_argument, NULL, 's' }, + { "baud", required_argument, NULL, 's' }, + { "mapcr", no_argument, NULL, 't' }, + { "system", required_argument, NULL, 'z' }, + { "config", required_argument, NULL, 'I' }, + { "debug", required_argument, NULL, 'x' }, + { "version", no_argument, NULL, 'v' }, + { "help", no_argument, NULL, 1 }, + { NULL, 0, NULL, 0 } +}; int main (argc, argv) @@ -252,6 +270,8 @@ main (argc, argv) struct uuconf_dialer *qdialer; char bcmd; + zProgram = argv[0]; + /* We want to accept -# as a speed. It's easiest to look through the arguments, replace -# with -s#, and let getopt handle it. */ for (i = 1; i < argc; i++) @@ -271,7 +291,7 @@ main (argc, argv) } } - while ((iopt = getopt_long (argc, argv, "a:c:dehnI:l:op:s:tx:z:", + while ((iopt = getopt_long (argc, argv, "a:c:dehnI:l:op:s:tvx:z:", asCulongopts, (int *) NULL)) != EOF) { switch (iopt) @@ -347,13 +367,47 @@ main (argc, argv) #endif break; + case 'v': + /* Print version and exit. */ + fprintf + (stderr, + "%s: Taylor UUCP %s, copyright (C) 1991, 1992, 1993, 1994 Ian Lance Taylor\n", + zProgram, VERSION); + exit (EXIT_SUCCESS); + /*NOTREACHED*/ + + case 2: + /* --parity. */ + if (strncmp (optarg, "even", strlen (optarg)) == 0) + feven = TRUE; + else if (strncmp (optarg, "odd", strlen (optarg)) == 0) + fodd = TRUE; + else if (strncmp (optarg, "none", strlen (optarg)) == 0) + { + feven = TRUE; + fodd = TRUE; + } + else + { + fprintf (stderr, "%s: --parity requires even, odd or none\n", + zProgram); + ucuusage (); + } + break; + + case 1: + /* --help. */ + ucuhelp (); + exit (EXIT_SUCCESS); + /*NOTREACHED*/ + case 0: /* Long option found and flag set. */ break; default: ucuusage (); - break; + /*NOTREACHED*/ } } @@ -366,7 +420,10 @@ main (argc, argv) if (optind != argc - 1 || zsystem != NULL || zphone != NULL) - ucuusage (); + { + fprintf (stderr, "%s: too many arguments\n", zProgram); + ucuusage (); + } if (strcmp (argv[optind], "dir") != 0) { if (isdigit (BUCHAR (argv[optind][0]))) @@ -382,7 +439,11 @@ main (argc, argv) && zport == NULL && zline == NULL && ibaud == 0L) - ucuusage (); + { + fprintf (stderr, "%s: must specify system, line, port or speed\n", + zProgram); + ucuusage (); + } if (fprompt) { @@ -395,7 +456,7 @@ main (argc, argv) if (getline (&zphone, &cphone, stdin) <= 0 || *zphone == '\0') { - fprintf (stderr, "%s: No phone number entered\n", abProgram); + fprintf (stderr, "%s: no phone number entered\n", zProgram); exit (EXIT_FAILURE); } } @@ -523,16 +584,20 @@ main (argc, argv) sport.uuconf_u.uuconf_sdirect.uuconf_zdevice = NULL; sport.uuconf_u.uuconf_sdirect.uuconf_ibaud = ibaud; - if (! fsysdep_port_access (&sport)) - ulog (LOG_FATAL, "%s: Permission denied", zline); - - if (! fconn_init (&sport, &sconn)) + if (! fconn_init (&sport, &sconn, UUCONF_PORTTYPE_UNKNOWN)) ucuabort (); if (! fconn_lock (&sconn, FALSE)) ulog (LOG_FATAL, "%s: Line in use", zline); qCuconn = &sconn; + + /* Check user access after locking the port, because on + some systems shared lines affect the ownership and + permissions. In such a case ``Line in use'' is more + clear than ``Permission denied.'' */ + if (! fsysdep_port_access (&sport)) + ulog (LOG_FATAL, "%s: Permission denied", zline); } ihighbaud = 0L; } @@ -544,7 +609,8 @@ main (argc, argv) continue; if (qsys->uuconf_qport != NULL) { - if (fconn_init (qsys->uuconf_qport, &sconn)) + if (fconn_init (qsys->uuconf_qport, &sconn, + UUCONF_PORTTYPE_UNKNOWN)) { if (fconn_lock (&sconn, FALSE)) { @@ -648,7 +714,8 @@ main (argc, argv) || qsys == NULL) ucuabort (); - if (qsys->uuconf_qalternate == NULL) + qsys = qsys->uuconf_qalternate; + if (qsys == NULL) ulog (LOG_FATAL, "%s: No remaining alternates", zsystem); fCuclose_conn = FALSE; @@ -693,6 +760,7 @@ main (argc, argv) only comes out when a special command is received from the terminal. */ printf ("%s\n", ZCONNMSG); + fCuconnprinted = TRUE; if (! fsysdep_terminal_raw (fCulocalecho)) ucuabort (); @@ -719,7 +787,8 @@ main (argc, argv) (void) fconn_unlock (&sconn); uconn_free (&sconn); - printf ("\n%s\n", ZDISMSG); + if (fCuconnprinted) + printf ("\n%s\n", ZDISMSG); ulog_close (); @@ -734,41 +803,56 @@ main (argc, argv) static void ucuusage () { + fprintf (stderr, "Usage: %s [options] [system or phone-number]\n", + zProgram); + fprintf (stderr, "Use %s --help for help\n", zProgram); + exit (EXIT_FAILURE); +} + +/* Print a help message. */ + +static void +ucuhelp () +{ fprintf (stderr, - "Taylor UUCP version %s, copyright (C) 1991, 1992 Ian Lance Taylor\n", + "Taylor UUCP %s, copyright (C) 1991, 1992, 1993, 1994 Ian Lance Taylor\n", VERSION); fprintf (stderr, - "Usage: cu [options] [system or phone-number]\n"); + "Usage: %s [options] [system or phone-number]\n", zProgram); fprintf (stderr, - " -a port, -p port: Use named port\n"); + " -a,-p,--port port: Use named port\n"); fprintf (stderr, - " -l line: Use named device (e.g. tty0)\n"); + " -l,--line line: Use named device (e.g. tty0)\n"); fprintf (stderr, - " -s speed, -#: Use given speed\n"); + " -s,--speed,--baud speed, -#: Use given speed\n"); fprintf (stderr, - " -c phone: Phone number to call\n"); + " -c,--phone phone: Phone number to call\n"); fprintf (stderr, - " -z system: System to call\n"); + " -z,--system system: System to call\n"); fprintf (stderr, " -e: Set even parity\n"); fprintf (stderr, " -o: Set odd parity\n"); fprintf (stderr, - " -h: Echo locally\n"); + " --parity={odd,even}: Set parity\n"); + fprintf (stderr, + " -h,--halfduplex: Echo locally\n"); fprintf (stderr, - " -t: Map carriage return to carriage return/linefeed\n"); + " -t,--mapcr: Map carriage return to carriage return/linefeed\n"); fprintf (stderr, - " -n: Prompt for phone number\n"); + " -n,--prompt: Prompt for phone number\n"); fprintf (stderr, " -d: Set maximum debugging level\n"); fprintf (stderr, - " -x debug: Set debugging type\n"); + " -x,--debug debug: Set debugging type\n"); #if HAVE_TAYLOR_CONFIG fprintf (stderr, - " -I file: Set configuration file to use\n"); + " -I,--config file: Set configuration file to use\n"); #endif /* HAVE_TAYLOR_CONFIG */ - - exit (EXIT_FAILURE); + fprintf (stderr, + " -v,--version: Print version and exit\n"); + fprintf (stderr, + " --help: Print help and exit\n"); } /* This function is called when a fatal error occurs. */ @@ -805,7 +889,8 @@ ucuabort () ulog_close (); - printf ("\n%s\n", ZDISMSG); + if (fCuconnprinted) + printf ("\n%s\n", ZDISMSG); usysdep_exit (FALSE); } @@ -866,7 +951,7 @@ icuport_lock (qport, pinfo) q->fmatched = TRUE; - if (! fconn_init (qport, q->qconn)) + if (! fconn_init (qport, q->qconn, UUCONF_PORTTYPE_UNKNOWN)) return UUCONF_NOT_FOUND; else if (! fconn_lock (q->qconn, FALSE)) { |
