Display what we think the permissions of systems are.
Copyright (C) 1991, 1992 Ian Lance Taylor
This file is part of the Taylor UUCP package.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
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.
const char uuchk_rcsid
[] = "$Id: uuchk.c,v 1.1 1993/08/04 19:36:14 jtc Exp $";
static void ukusage
P((void));
static void ukshow
P((const struct uuconf_system
*qsys
,
static int ikshow_port
P((struct uuconf_port
*qport
, pointer pinfo
));
static void ukshow_dialer
P((struct uuconf_dialer
*qdial
));
static void ukshow_chat
P((const struct uuconf_chat
*qchat
,
static void ukshow_size
P((struct uuconf_timespan
*q
, boolean fcall
,
static void ukshow_proto_params
P((struct uuconf_proto_param
*pas
,
static void ukshow_time
P((const struct uuconf_timespan
*));
static struct uuconf_timespan
*qcompress_span
P((struct uuconf_timespan
*));
static void ukuuconf_error
P((pointer puuconf
, int iret
));
/* Structure used to pass uuconf pointer into ikshow_port and also let
it record whether any ports were found. */
/* The uuconf global pointer. */
const struct uuconf_system
*qsys
;
/* Whether any ports were seen. */
/* Long getopt options. */
static const struct option asKlongopts
[] = { { NULL
, 0, NULL
, 0 } };
/* The configuration file name. */
const char *zconfig
= NULL
;
while ((iopt
= getopt_long (argc
, argv
, "I:x:", asKlongopts
,
/* Set the configuration file name. */
/* Set the debugging level. There is actually no debugging
information for this program. */
/* Long option found and flag set. */
iret
= uuconf_init (&puuconf
, (const char *) NULL
, zconfig
);
if (iret
!= UUCONF_SUCCESS
)
ukuuconf_error (puuconf
, iret
);
iret
= uuconf_system_names (puuconf
, &pzsystems
, FALSE
);
if (iret
!= UUCONF_SUCCESS
)
ukuuconf_error (puuconf
, iret
);
while (*pzsystems
!= NULL
)
struct uuconf_system ssys
;
iret
= uuconf_system_info (puuconf
, *pzsystems
, &ssys
);
if (iret
!= UUCONF_SUCCESS
)
ukuuconf_error (puuconf
, iret
);
(void) uuconf_system_free (puuconf
, &ssys
);
/* Avoid errors about not returning a value. */
/* Print a usage message and die. */
"Taylor UUCP version %s, copyright (C) 1991, 1992 Ian Lance Taylor\n",
"Usage: uuchk [-I file]\n");
" -I file: Set configuration file to use\n");
/* Dump out the information for a system. */
const struct uuconf_system
*qsys
;
printf ("System: %s", qsys
->uuconf_zname
);
if (qsys
->uuconf_pzalias
!= NULL
)
for (pz
= qsys
->uuconf_pzalias
; *pz
!= NULL
; pz
++)
for (i
= 0; qsys
!= NULL
; qsys
= qsys
->uuconf_qalternate
, i
++)
struct uuconf_timespan
*qtime
, *qspan
;
if (i
!= 0 || qsys
->uuconf_qalternate
!= NULL
)
printf ("Alternate %d", i
);
if (qsys
->uuconf_zalternate
!= NULL
)
printf (" (%s)", qsys
->uuconf_zalternate
);
/* See if this alternate could be used when calling out. */
fcall
= qsys
->uuconf_fcall
;
if (qsys
->uuconf_qtimegrade
== NULL
)
/* See if this alternate could be used when calling in. */
fcalled
= qsys
->uuconf_fcalled
;
if (! fcall
&& ! fcalled
)
printf (" This alternate is never used\n");
if (qsys
->uuconf_zcalled_login
!= NULL
&& strcmp (qsys
->uuconf_zcalled_login
, "ANY") != 0)
if (i
== 0 && qsys
->uuconf_qalternate
== NULL
)
printf (" Caller must log in as %s\n",
qsys
->uuconf_zcalled_login
);
printf (" When called using login name %s\n",
qsys
->uuconf_zcalled_login
);
printf (" When called using any login name\n");
if (qsys
->uuconf_zlocalname
!= NULL
)
printf (" Will use %s as name of local system\n",
qsys
->uuconf_zlocalname
);
if (fcalled
&& qsys
->uuconf_fcallback
)
printf (" If called, will call back\n");
if (i
== 0 && qsys
->uuconf_qalternate
== NULL
)
printf (" This alternate applies when calling");
if (qsys
->uuconf_zport
!= NULL
|| qsys
->uuconf_qport
!= NULL
)
if (qsys
->uuconf_zport
!= NULL
)
printf ("port %s", qsys
->uuconf_zport
);
printf ("a specially defined port");
if (qsys
->uuconf_ibaud
!= 0)
printf (" at speed %ld", qsys
->uuconf_ibaud
);
if (qsys
->uuconf_ihighbaud
!= 0)
printf (" to %ld", qsys
->uuconf_ihighbaud
);
else if (qsys
->uuconf_ibaud
!= 0)
printf (" at speed %ld", qsys
->uuconf_ibaud
);
if (qsys
->uuconf_ihighbaud
!= 0)
printf (" to %ld", qsys
->uuconf_ihighbaud
);
printf (" using any port\n");
if (qsys
->uuconf_qport
!= NULL
)
printf (" The port is defined as:\n");
(void) ikshow_port (qsys
->uuconf_qport
, (pointer
) &si
);
struct uuconf_port sdummy
;
printf (" The possible ports are:\n");
iret
= uuconf_find_port (puuconf
, qsys
->uuconf_zport
,
ikshow_port
, (pointer
) &si
,
if (iret
!= UUCONF_NOT_FOUND
)
ukuuconf_error (puuconf
, iret
);
printf (" *** There are no matching ports\n");
if (qsys
->uuconf_zphone
!= NULL
)
if ((qsys
->uuconf_zport
!= NULL
&& strcmp (qsys
->uuconf_zport
, "TCP") == 0)
|| (qsys
->uuconf_qport
!= NULL
&& (qsys
->uuconf_qport
->uuconf_ttype
|| qsys
->uuconf_qport
->uuconf_ttype
== UUCONF_PORTTYPE_TLI
)))
printf (" Remote address %s\n", qsys
->uuconf_zphone
);
printf (" Phone number %s\n", qsys
->uuconf_zphone
);
ukshow_chat (&qsys
->uuconf_schat
, " Chat");
if (qsys
->uuconf_zcall_login
!= NULL
|| qsys
->uuconf_zcall_password
!= NULL
)
iret
= uuconf_callout (puuconf
, qsys
, &zlogin
, &zpass
);
if (iret
== UUCONF_NOT_FOUND
)
printf (" Can not determine login name or password\n");
else if (iret
!= UUCONF_SUCCESS
)
ukuuconf_error (puuconf
, iret
);
printf (" Login name %s\n", zlogin
);
printf (" Password %s\n", zpass
);
qtime
= qcompress_span (qsys
->uuconf_qtimegrade
);
for (qspan
= qtime
; qspan
!= NULL
; qspan
= qspan
->uuconf_qnext
)
printf (" may call if ");
if ((char) qspan
->uuconf_ival
== UUCONF_GRADE_LOW
)
printf ("work grade %c or higher", (char) qspan
->uuconf_ival
);
if (qspan
->uuconf_cretry
!= 0)
printf (" (retry %d)", qspan
->uuconf_cretry
);
if (qsys
->uuconf_qcalltimegrade
!= NULL
)
qtime
= qcompress_span (qsys
->uuconf_qcalltimegrade
);
if (qtime
->uuconf_istart
!= 0)
for (qspan
= qtime
; qspan
!= NULL
; qspan
= qspan
->uuconf_qnext
)
if ((char) qspan
->uuconf_ival
== UUCONF_GRADE_LOW
)
printf (" may accept work grade %c or higher\n",
(char) qspan
->uuconf_ival
);
if (qspan
->uuconf_qnext
== NULL
)
if (qspan
->uuconf_iend
!= 7 * 24 * 60)
!= qspan
->uuconf_qnext
->uuconf_istart
)
printf (" (At other times may accept any work)\n");
if (qsys
->uuconf_fsequence
)
printf (" Sequence numbers are used\n");
ukshow_chat (&qsys
->uuconf_scalled_chat
, " When called, chat");
if (qsys
->uuconf_zdebug
!= NULL
)
printf (" Debugging level %s\n", qsys
->uuconf_zdebug
);
if (qsys
->uuconf_zmax_remote_debug
!= NULL
)
printf (" Max remote debugging level %s\n",
qsys
->uuconf_zmax_remote_debug
);
ukshow_size (qsys
->uuconf_qcall_local_size
, TRUE
, TRUE
);
ukshow_size (qsys
->uuconf_qcall_remote_size
, TRUE
, FALSE
);
ukshow_size (qsys
->uuconf_qcalled_local_size
, FALSE
, TRUE
);
ukshow_size (qsys
->uuconf_qcalled_remote_size
, FALSE
, TRUE
);
printf (" May %smake local requests when calling\n",
qsys
->uuconf_fcall_transfer
? "" : "not ");
printf (" May %smake local requests when called\n",
qsys
->uuconf_fcalled_transfer
? "" : "not ");
if (qsys
->uuconf_fcall_transfer
|| qsys
->uuconf_fcalled_transfer
)
printf (" May send by local request:");
for (pz
= qsys
->uuconf_pzlocal_send
; *pz
!= NULL
; pz
++)
if (! qsys
->uuconf_fsend_request
)
printf (" May not send files by remote request\n");
printf (" May send by remote request:");
for (pz
= qsys
->uuconf_pzremote_send
; *pz
!= NULL
; pz
++)
if (qsys
->uuconf_fcall_transfer
|| qsys
->uuconf_fcalled_transfer
)
printf (" May accept by local request:");
for (pz
= qsys
->uuconf_pzlocal_receive
; *pz
!= NULL
; pz
++)
if (! qsys
->uuconf_frec_request
)
printf (" May not receive files by remote request\n");
printf (" May receive by remote request:");
for (pz
= qsys
->uuconf_pzremote_receive
; *pz
!= NULL
; pz
++)
for (pz
= qsys
->uuconf_pzcmds
; *pz
!= NULL
; pz
++)
printf (" Execution path");
for (pz
= qsys
->uuconf_pzpath
; *pz
!= NULL
; pz
++)
if (qsys
->uuconf_cfree_space
!= 0)
printf (" Will leave %ld bytes available\n", qsys
->uuconf_cfree_space
);
if (qsys
->uuconf_zpubdir
!= NULL
)
printf (" Public directory is %s\n", qsys
->uuconf_zpubdir
);
if (qsys
->uuconf_pzforward_from
!= NULL
)
printf (" May forward from");
for (pz
= qsys
->uuconf_pzforward_from
; *pz
!= NULL
; pz
++)
if (qsys
->uuconf_pzforward_to
!= NULL
)
printf (" May forward to");
for (pz
= qsys
->uuconf_pzforward_to
; *pz
!= NULL
; pz
++)
if (qsys
->uuconf_zprotocols
!= NULL
)
printf (" Will use protocols %s\n", qsys
->uuconf_zprotocols
);
printf (" Will use any known protocol\n");
if (qsys
->uuconf_qproto_params
!= NULL
)
ukshow_proto_params (qsys
->uuconf_qproto_params
, 1);
/* Show information about a port. */
ikshow_port (qport
, pinfo
)
struct uuconf_port
*qport
;
struct sinfo
*qi
= (struct sinfo
*) pinfo
;
struct uuconf_modem_port
*qmodem
;
struct uuconf_tli_port
*qtli
;
printf (" Port name %s\n", qport
->uuconf_zname
);
switch (qport
->uuconf_ttype
)
case UUCONF_PORTTYPE_STDIN
:
printf (" Port type stdin\n");
case UUCONF_PORTTYPE_DIRECT
:
printf (" Port type direct\n");
if (qport
->uuconf_u
.uuconf_sdirect
.uuconf_zdevice
!= NULL
)
qport
->uuconf_u
.uuconf_sdirect
.uuconf_zdevice
);
printf (" Speed %ld\n", qport
->uuconf_u
.uuconf_sdirect
.uuconf_ibaud
);
case UUCONF_PORTTYPE_MODEM
:
qmodem
= &qport
->uuconf_u
.uuconf_smodem
;
printf (" Port type modem\n");
if (qmodem
->uuconf_zdevice
!= NULL
)
printf (" Device %s\n", qmodem
->uuconf_zdevice
);
if (qmodem
->uuconf_zdial_device
!= NULL
)
printf (" Dial device %s\n", qmodem
->uuconf_zdial_device
);
printf (" Speed %ld\n", qmodem
->uuconf_ibaud
);
if (qmodem
->uuconf_ilowbaud
!= qmodem
->uuconf_ihighbaud
)
printf (" Speed range %ld to %ld\n", qmodem
->uuconf_ilowbaud
,
qmodem
->uuconf_ihighbaud
);
printf (" Carrier %savailable\n",
qmodem
->uuconf_fcarrier
? "" : "not ");
if (qmodem
->uuconf_qdialer
!= NULL
)
printf (" Specially defined dialer\n");
ukshow_dialer (qmodem
->uuconf_qdialer
);
else if (qmodem
->uuconf_pzdialer
!= NULL
&& qmodem
->uuconf_pzdialer
[0] != NULL
)
struct uuconf_dialer sdial
;
/* This might be a single dialer name, or it might be a
sequence of dialer/token pairs. */
if (qmodem
->uuconf_pzdialer
[1] == NULL
|| qmodem
->uuconf_pzdialer
[2] == NULL
)
iret
= uuconf_dialer_info (qi
->puuconf
,
qmodem
->uuconf_pzdialer
[0],
if (iret
== UUCONF_NOT_FOUND
)
printf (" *** No dialer %s\n", qmodem
->uuconf_pzdialer
[0]);
else if (iret
!= UUCONF_SUCCESS
)
ukuuconf_error (qi
->puuconf
, iret
);
printf (" Dialer %s\n", qmodem
->uuconf_pzdialer
[0]);
if (qmodem
->uuconf_pzdialer
[1] != NULL
)
printf (" Token %s\n", qmodem
->uuconf_pzdialer
[1]);
pz
= qmodem
->uuconf_pzdialer
;
iret
= uuconf_dialer_info (qi
->puuconf
, *pz
, &sdial
);
if (iret
== UUCONF_NOT_FOUND
)
printf (" *** No dialer %s\n", *pz
);
else if (iret
!= UUCONF_SUCCESS
)
ukuuconf_error (qi
->puuconf
, iret
);
printf (" Dialer %s\n", *pz
);
printf (" Token %s\n", *pz
);
printf (" *** No dialer information\n");
case UUCONF_PORTTYPE_TCP
:
printf (" Port type tcp\n");
printf (" TCP service %s\n",
qport
->uuconf_u
.uuconf_stcp
.uuconf_zport
);
case UUCONF_PORTTYPE_TLI
:
qtli
= &qport
->uuconf_u
.uuconf_stli
;
printf (" Port type TLI%s\n",
qtli
->uuconf_fstream
? "S" : "");
if (qtli
->uuconf_zdevice
!= NULL
)
printf (" Device %s\n", qtli
->uuconf_zdevice
);
if (qtli
->uuconf_pzpush
!= NULL
)
for (pz
= qtli
->uuconf_pzpush
; *pz
!= NULL
; pz
++)
if (qtli
->uuconf_pzdialer
!= NULL
&& qtli
->uuconf_pzdialer
[0] != NULL
)
printf (" Dialer sequence");
for (pz
= qtli
->uuconf_pzdialer
; *pz
!= NULL
; pz
++)
if (qtli
->uuconf_zservaddr
!= NULL
)
printf (" Server address %s\n", qtli
->uuconf_zservaddr
);
fprintf (stderr
, " CAN'T HAPPEN\n");
if (qport
->uuconf_zprotocols
!= NULL
)
printf (" Will use protocols %s\n", qport
->uuconf_zprotocols
);
if (qport
->uuconf_zlockname
!= NULL
)
printf (" Will use lockname %s\n", qport
->uuconf_zlockname
);
if (qport
->uuconf_qproto_params
!= NULL
)
ukshow_proto_params (qport
->uuconf_qproto_params
, 3);
/* Return NOT_FOUND to force find_port to continue searching. */
/* Show information about a dialer. */
ukshow_chat (&q
->uuconf_schat
, " Chat");
printf (" Wait for dialtone %s\n", q
->uuconf_zdialtone
);
printf (" Pause while dialing %s\n", q
->uuconf_zpause
);
printf (" Carrier %savailable\n", q
->uuconf_fcarrier
? "" : "not ");
printf (" Wait %d seconds for carrier\n", q
->uuconf_ccarrier_wait
);
if (q
->uuconf_fdtr_toggle
)
if (q
->uuconf_fdtr_toggle_wait
)
ukshow_chat (&q
->uuconf_scomplete
, " When complete chat");
ukshow_chat (&q
->uuconf_sabort
, " When aborting chat");
if (q
->uuconf_qproto_params
!= NULL
)
ukshow_proto_params (q
->uuconf_qproto_params
, 4);
/* Show a chat script. */
ukshow_chat (qchat
, zhdr
)
const struct uuconf_chat
*qchat
;
if (qchat
->uuconf_pzprogram
!= NULL
)
printf ("%s program", zhdr
);
for (pz
= qchat
->uuconf_pzprogram
; *pz
!= NULL
; pz
++)
if (qchat
->uuconf_pzchat
!= NULL
)
printf ("%s script", zhdr
);
for (pz
= qchat
->uuconf_pzchat
; *pz
!= NULL
; pz
++)
if ((*pz
)[0] != '-' || pz
== qchat
->uuconf_pzchat
)
printf ("%s script timeout %d\n", zhdr
, qchat
->uuconf_ctimeout
);
if (qchat
->uuconf_pzfail
!= NULL
)
printf ("%s failure strings", zhdr
);
for (pz
= qchat
->uuconf_pzfail
; *pz
!= NULL
; pz
++)
if (qchat
->uuconf_fstrip
)
printf ("%s script incoming bytes stripped to seven bits\n", zhdr
);
/* Show a size/time restriction. */
ukshow_size (qspan
, fcall
, flocal
)
struct uuconf_timespan
*qspan
;
struct uuconf_timespan
*q
;
qspan
= qcompress_span (qspan
);
printf (" If call%s the following applies to a %s request:\n",
fcall
? "ing" : "ed", flocal
? "local" : "remote");
if (qspan
->uuconf_istart
>= 60)
for (q
= qspan
; q
!= NULL
; q
= q
->uuconf_qnext
)
printf (" may transfer files %ld bytes or smaller\n", q
->uuconf_ival
);
if (q
->uuconf_qnext
== NULL
)
if (q
->uuconf_iend
<= 6 * 24 * 60 + 23 * 60)
if (q
->uuconf_iend
+ 60 <= q
->uuconf_qnext
->uuconf_istart
)
printf (" (At other times may send files of any size)\n");
/* Show protocol parameters. */
ukshow_proto_params (pas
, cindent
)
struct uuconf_proto_param
*pas
;
struct uuconf_proto_param
*q
;
for (q
= pas
; q
->uuconf_bproto
!= '\0'; q
++)
struct uuconf_proto_param_entry
*qe
;
for (i
= 0; i
< cindent
; i
++)
printf ("For protocol %c will use the following parameters\n",
for (qe
= q
->uuconf_qentries
; qe
->uuconf_cargs
> 0; qe
++)
for (i
= 0; i
< cindent
; i
++)
for (ia
= 0; ia
< qe
->uuconf_cargs
; ia
++)
printf (" %s", qe
->uuconf_pzargs
[ia
]);
/* Display a time span. */
const struct uuconf_timespan
*q
;
int ihourstart
, ihourend
;
int iminutestart
, iminuteend
;
const char * const zdays
= "Sun\0Mon\0Tue\0Wed\0Thu\0Fri\0Sat\0Sun";
if (q
->uuconf_istart
== 0 && q
->uuconf_iend
== 7 * 24 * 60)
idaystart
= q
->uuconf_istart
/ (24 * 60);
ihourstart
= (q
->uuconf_istart
% (24 * 60)) / 60;
iminutestart
= q
->uuconf_istart
% 60;
idayend
= q
->uuconf_iend
/ (24 * 60);
ihourend
= (q
->uuconf_iend
% (24 * 60)) / 60;
iminuteend
= q
->uuconf_iend
% 60;
if (idaystart
== idayend
)
printf ("%s from %02d:%02d to %02d:%02d", zdays
+ idaystart
* 4,
ihourstart
, iminutestart
, ihourend
, iminuteend
);
printf ("From %s %02d:%02d to %s %02d:%02d",
zdays
+ idaystart
* 4, ihourstart
, iminutestart
,
zdays
+ idayend
* 4, ihourend
, iminuteend
);
/* Compress a time span by merging any two adjacent spans with
identical values. This isn't necessary for uucico, but it looks
nicer when printed out. */
static struct uuconf_timespan
*
struct uuconf_timespan
*qlist
;
struct uuconf_timespan
**pq
;
if ((*pq
)->uuconf_qnext
!= NULL
&& (*pq
)->uuconf_iend
== (*pq
)->uuconf_qnext
->uuconf_istart
&& (*pq
)->uuconf_ival
== (*pq
)->uuconf_qnext
->uuconf_ival
)
struct uuconf_timespan
*qnext
;
qnext
= (*pq
)->uuconf_qnext
;
(*pq
)->uuconf_qnext
= qnext
->uuconf_qnext
;
(*pq
)->uuconf_iend
= qnext
->uuconf_iend
;
pq
= &(*pq
)->uuconf_qnext
;
/* Display a uuconf error and exit. */
ukuuconf_error (puuconf
, iret
)
(void) uuconf_error_string (puuconf
, iret
, ab
, sizeof ab
);
if ((iret
& UUCONF_ERROR_FILENAME
) == 0)
fprintf (stderr
, "uuchk: %s\n", ab
);
fprintf (stderr
, "uuchk:%s\n", ab
);