summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormuffin <none@none>2005-09-16 01:11:41 -0700
committermuffin <none@none>2005-09-16 01:11:41 -0700
commit8d489c7a815fcac696803219572e95aa01532b0f (patch)
tree753716ff18fa2fc969db18f1a27045889203c779
parent8ba1bcfcc383cbdad998864b5dff1133decd99a6 (diff)
downloadillumos-gate-8d489c7a815fcac696803219572e95aa01532b0f.tar.gz
6269036 cmd/xstr and gcc don't get along
6272021 gcc and cmd/mt don't get along 6273910 gcc and cmd/tabs don't get along 6273935 gcc and cmd/tip don't get along 6273951 gcc and cmd/users don't get along --HG-- rename : usr/src/cmd/users/pkginfo => deleted_files/usr/src/cmd/users/pkginfo
-rw-r--r--deleted_files/usr/src/cmd/users/pkginfo (renamed from usr/src/cmd/users/pkginfo)0
-rw-r--r--usr/src/Makefile.lint4
-rw-r--r--usr/src/cmd/mt/mt.c28
-rw-r--r--usr/src/cmd/tabs/tabs.c91
-rw-r--r--usr/src/cmd/tip/Makefile7
-rw-r--r--usr/src/cmd/tip/acu.c50
-rw-r--r--usr/src/cmd/tip/aculib/Makefile4
-rw-r--r--usr/src/cmd/tip/aculib/biz22.c94
-rw-r--r--usr/src/cmd/tip/aculib/biz31.c112
-rw-r--r--usr/src/cmd/tip/aculib/df.c92
-rw-r--r--usr/src/cmd/tip/aculib/dn11.c94
-rw-r--r--usr/src/cmd/tip/aculib/hayes.c105
-rw-r--r--usr/src/cmd/tip/aculib/v3451.c98
-rw-r--r--usr/src/cmd/tip/aculib/v831.c145
-rw-r--r--usr/src/cmd/tip/aculib/ventel.c117
-rw-r--r--usr/src/cmd/tip/acutab.c34
-rw-r--r--usr/src/cmd/tip/cmds.c474
-rw-r--r--usr/src/cmd/tip/cmdtab.c12
-rw-r--r--usr/src/cmd/tip/cu.c45
-rw-r--r--usr/src/cmd/tip/hunt.c38
-rw-r--r--usr/src/cmd/tip/log.c27
-rw-r--r--usr/src/cmd/tip/partab.c4
-rw-r--r--usr/src/cmd/tip/remcap.c117
-rw-r--r--usr/src/cmd/tip/remote.c37
-rw-r--r--usr/src/cmd/tip/tip.c251
-rw-r--r--usr/src/cmd/tip/tip.h58
-rw-r--r--usr/src/cmd/tip/tipout.c80
-rw-r--r--usr/src/cmd/tip/uucplock.c135
-rw-r--r--usr/src/cmd/tip/value.c127
-rw-r--r--usr/src/cmd/tip/vars.c4
-rw-r--r--usr/src/cmd/users/Makefile6
-rw-r--r--usr/src/cmd/users/users.c704
-rw-r--r--usr/src/cmd/xstr/xstr.c226
33 files changed, 1792 insertions, 1628 deletions
diff --git a/usr/src/cmd/users/pkginfo b/deleted_files/usr/src/cmd/users/pkginfo
index 23330d949b..23330d949b 100644
--- a/usr/src/cmd/users/pkginfo
+++ b/deleted_files/usr/src/cmd/users/pkginfo
diff --git a/usr/src/Makefile.lint b/usr/src/Makefile.lint
index 64b5f838b0..7d5119a649 100644
--- a/usr/src/Makefile.lint
+++ b/usr/src/Makefile.lint
@@ -245,14 +245,17 @@ COMMON_SUBDIRS = \
cmd/sync \
cmd/syseventadm \
cmd/syseventd \
+ cmd/tabs \
cmd/tail \
cmd/tee \
cmd/th_tools \
+ cmd/tip \
cmd/touch \
cmd/tr \
cmd/truss \
cmd/tty \
cmd/uadmin \
+ cmd/users \
cmd/utmp_update \
cmd/utmpd \
cmd/valtools \
@@ -263,6 +266,7 @@ COMMON_SUBDIRS = \
cmd/whodo \
cmd/wracct \
cmd/xargs \
+ cmd/xstr \
cmd/yes \
cmd/yppasswd \
cmd/zdump \
diff --git a/usr/src/cmd/mt/mt.c b/usr/src/cmd/mt/mt.c
index 49c51ba142..e4f876fda0 100644
--- a/usr/src/cmd/mt/mt.c
+++ b/usr/src/cmd/mt/mt.c
@@ -87,10 +87,11 @@ static struct commands {
static struct mt_tape_info tapes[] = MT_TAPE_INFO;
#endif /* sun */
+int
main(int argc, char **argv)
{
- register char *cp;
- register struct commands *comp;
+ char *cp;
+ struct commands *comp;
if (argc > 2 && (equal(argv[1], "-t") || equal(argv[1], "-f"))) {
argc -= 2;
@@ -122,10 +123,10 @@ main(int argc, char **argv)
if (errno == EIO) {
(void) fprintf(stderr,
"%s: no tape loaded or drive offline\n",
- tape);
+ tape);
} else if (errno == EACCES) {
(void) fprintf(stderr,
- "%s: write protected or reserved.\n", tape);
+ "%s: write protected or reserved.\n", tape);
} else {
perror(tape);
}
@@ -133,8 +134,8 @@ main(int argc, char **argv)
}
if (comp->c_code == MTIOCFORCERESERVE ||
- comp->c_code == MTIOCRESERVE ||
- comp->c_code == MTIOCRELEASE) {
+ comp->c_code == MTIOCRESERVE ||
+ comp->c_code == MTIOCRELEASE) {
/*
* Handle all MTIOC ioctls used in
* reservation/release/takeownership.
@@ -177,7 +178,7 @@ main(int argc, char **argv)
mt_com.mt_op = MTREW;
if (ioctl(mtfd, MTIOCTOP, &mt_com) < 0) {
(void) fprintf(stderr, "%s %s %d ",
- tape, comp->c_name, mt_fileno);
+ tape, comp->c_name, mt_fileno);
perror("mt");
exit(2);
}
@@ -193,7 +194,7 @@ main(int argc, char **argv)
}
if (ioctl(mtfd, MTIOCTOP, &mt_com) < 0) {
(void) fprintf(stderr, "%s %s %d ", tape, comp->c_name,
- mt_fileno);
+ mt_fileno);
perror("failed");
exit(2);
}
@@ -213,7 +214,7 @@ main(int argc, char **argv)
}
if (ioctl(mtfd, MTIOCTOP, &mt_com) < 0) {
(void) fprintf(stderr, "%s %s %ld ", tape, comp->c_name,
- mt_com.mt_count);
+ mt_com.mt_count);
perror("failed");
exit(2);
}
@@ -311,10 +312,9 @@ print_config(void)
* Interpret the status buffer returned
*/
static void
-status(bp)
- register struct mtget *bp;
+status(struct mtget *bp)
{
- register struct mt_tape_info *mt = NULL;
+ struct mt_tape_info *mt = NULL;
struct mtdrivetype mdt;
struct mtdrivetype_request mdt_req;
char *name = (char *)NULL;
@@ -353,10 +353,10 @@ status(bp)
(void) printf("%s tape drive:\n", name);
(void) printf(" sense key(0x%x)= %s residual= %ld ",
- bp->mt_erreg, print_key(bp->mt_erreg), bp->mt_resid);
+ bp->mt_erreg, print_key(bp->mt_erreg), bp->mt_resid);
(void) printf("retries= %d\n", bp->mt_dsreg);
(void) printf(" file no= %ld block no= %ld\n",
- bp->mt_fileno, bp->mt_blkno);
+ bp->mt_fileno, bp->mt_blkno);
} else {
/* Handle non-SCSI drives here. */
if (mt->t_type == 0) {
diff --git a/usr/src/cmd/tabs/tabs.c b/usr/src/cmd/tabs/tabs.c
index d32826bd1f..4423b23cc3 100644
--- a/usr/src/cmd/tabs/tabs.c
+++ b/usr/src/cmd/tabs/tabs.c
@@ -48,6 +48,7 @@
#include <string.h>
#include <ctype.h>
#include <limits.h>
+#include <signal.h>
#define EQ(a, b) (strcmp(a, b) == 0)
/* max # columns used (needed for GSI) */
@@ -134,7 +135,7 @@ static int stdtab(char option[], int tabvect[]);
static void usage();
static int chk_codes(char *codes);
-void
+int
main(int argc, char **argv)
{
int tabvect[NTABS]; /* build tab list here */
@@ -149,7 +150,7 @@ main(int argc, char **argv)
#endif
(void) textdomain(TEXT_DOMAIN);
- signal(SIGINT, endup);
+ (void) signal(SIGINT, endup);
if (ioctl(1, TCGETA, &ttyold) == 0) {
ttyisave = ttyold.c_iflag;
ttyosave = ttyold.c_oflag;
@@ -199,10 +200,11 @@ main(int argc, char **argv)
option_end = 1;
else
tabspec = scan; /* --file */
- else if (strcmp(scan+1, "code") == 0);
+ else if (strcmp(scan+1, "code") == 0) {
+ /* EMPTY */
/* skip to next argument */
- else if (chk_codes(scan+1) ||
- (isdigit(*(scan+1)) && *(scan+2) == '\0')) {
+ } else if (chk_codes(scan+1) ||
+ (isdigit(*(scan+1)) && *(scan+2) == '\0')) {
/*
* valid code or single digit decimal
* number
@@ -240,7 +242,7 @@ main(int argc, char **argv)
} else {
(void) fprintf(stderr, gettext(
"tabs: %s: tab stop values must be positive integers\n"),
- *argv);
+ *argv);
usage();
}
}
@@ -249,7 +251,7 @@ main(int argc, char **argv)
}
if (*terminal == '\0') {
if ((terminal = getenv("TERM")) == (char *)NULL ||
- *terminal == '\0') {
+ *terminal == '\0') {
/*
* Use tab setting and clearing sequences specified
* by the ANSI standard.
@@ -284,7 +286,7 @@ main(int argc, char **argv)
repetab("8", tabvect);
settabs(tabvect);
endup();
- exit(0);
+ return (0);
}
/*
@@ -294,10 +296,10 @@ int
chk_codes(char *code)
{
if (*(code+1) == '\0' && (*code == 'a' || *code == 'c' ||
- *code == 'f' || *code == 'p' || *code == 's' || *code == 'u'))
+ *code == 'f' || *code == 'p' || *code == 's' || *code == 'u'))
return (1);
else if (*(code+1) == '2' && *(code+2) == '\0' &&
- (*code == 'a' || *code == 'c'))
+ (*code == 'a' || *code == 'c'))
return (1);
else if (*code == 'c' && *(code+1) == '3' && *(code+2) == '\0')
return (1);
@@ -308,8 +310,8 @@ chk_codes(char *code)
void
scantab(char *scan, int tabvect[NTABS], int level)
{
- register char c;
- if (*scan == '-')
+ char c;
+ if (*scan == '-') {
if ((c = *++scan) == '-')
filetab(++scan, tabvect, level);
else if (c >= '0' && c <= '9')
@@ -319,9 +321,10 @@ scantab(char *scan, int tabvect[NTABS], int level)
(void) fprintf(stderr, gettext(
"tabs: %s: unknown tab code\n"), scan);
usage();
- } else;
- else
+ }
+ } else {
arbitab(scan, tabvect);
+ }
}
/* repetab: scan and set repetitve tabs, 1+n, 1+2*n, etc */
@@ -329,7 +332,7 @@ scantab(char *scan, int tabvect[NTABS], int level)
void
repetab(char *scan, int tabvect[NTABS])
{
- register incr, i, tabn;
+ int incr, i, tabn;
int limit;
incr = getnum(&scan);
tabn = 1;
@@ -347,7 +350,7 @@ void
arbitab(char *scan, int tabvect[NTABS])
{
char *scan_save;
- register i, t, last;
+ int i, t, last;
scan_save = scan;
last = 0;
@@ -378,7 +381,7 @@ arbitab(char *scan, int tabvect[NTABS])
endup();
(void) fprintf(stderr, gettext(
"tabs: %s: last tab stop would be set at a column greater than %d\n"),
- scan_save, NCOLS);
+ scan_save, NCOLS);
usage();
}
tabvect[i] = 0;
@@ -390,8 +393,8 @@ arbitab(char *scan, int tabvect[NTABS])
void
filetab(char *scan, int tabvect[NTABS], int level)
{
- register length, i;
- register char c;
+ int length, i;
+ char c;
int fildes;
char card[CARDSIZ]; /* buffer area for 1st card in file */
char state, found;
@@ -400,7 +403,7 @@ filetab(char *scan, int tabvect[NTABS], int level)
endup();
(void) fprintf(stderr, gettext(
"tabs: %s points to another file: invalid file indirection\n"),
- scan);
+ scan);
exit(1);
}
if ((fildes = open(scan, O_RDONLY)) < 0) {
@@ -462,7 +465,8 @@ done:
if (found && scan != 0) {
scantab(scan, tabvect, 1);
temp = scan;
- while (*++temp);
+ while (*++temp)
+ ;
*temp = '\n';
}
else
@@ -473,7 +477,7 @@ int
getmarg(char *term)
{
if (strncmp(term, "1620", 4) == 0 ||
- strncmp(term, "1700", 4) == 0 || strncmp(term, "450", 3) == 0)
+ strncmp(term, "1700", 4) == 0 || strncmp(term, "450", 3) == 0)
return (DMG);
else if (strncmp(term, "300s", 4) == 0)
return (GMG);
@@ -490,15 +494,15 @@ getmarg(char *term)
struct ttab *
-termadj()
+termadj(void)
{
- register struct ttab *t;
+ struct ttab *t;
if (strncmp(terminal, "40-2", 4) == 0 || strncmp(terminal,
- "40/2", 4) == 0 || strncmp(terminal, "4420", 4) == 0)
+ "40/2", 4) == 0 || strncmp(terminal, "4420", 4) == 0)
(void) strcpy(terminal, "4424");
else if (strncmp(terminal, "ibm", 3) == 0 || strcmp(terminal,
- "3101") == 0 || strcmp(terminal, "system1") == 0)
+ "3101") == 0 || strcmp(terminal, "system1") == 0)
(void) strcpy(terminal, "ibm");
for (t = termtab; t->ttype; t++) {
@@ -520,8 +524,8 @@ void
settabs(int tabvect[NTABS])
{
char setbuf[512]; /* 2+3*NTABS+2+NCOLS+NTABS (+ some extra) */
- register char *p; /* ptr for assembly in setbuf */
- register *curtab; /* ptr to tabvect item */
+ char *p; /* ptr for assembly in setbuf */
+ int *curtab; /* ptr to tabvect item */
int i, previous, nblanks;
if (istty) {
ttyold.c_iflag &= ~ICRNL;
@@ -599,7 +603,7 @@ settabs(int tabvect[NTABS])
*/
previous = 1; curtab = tabvect;
while ((nblanks = *curtab-previous) >= 0 &&
- previous + nblanks <= maxtab) {
+ previous + nblanks <= maxtab) {
for (i = 1; i <= nblanks; i++) *p++ = ' ';
previous = *curtab++;
(void) strcpy(p, settab);
@@ -622,8 +626,8 @@ settabs(int tabvect[NTABS])
char *
cleartabs(register char *p, char *qq)
{
- register i;
- register char *q;
+ int i;
+ char *q;
q = qq;
if (clear_tabs == 0) { /* if repetitive sequence */
*p++ = CR;
@@ -634,7 +638,8 @@ cleartabs(register char *p, char *qq)
}
*p++ = CR;
} else {
- while (*p++ = *q++); /* copy table sequence */
+ while (*p++ = *q++) /* copy table sequence */
+ ;
p--; /* adjust for null */
if (EQ(terminal, "4424")) { /* TTY40 extra delays needed */
*p++ = '\0';
@@ -650,8 +655,8 @@ cleartabs(register char *p, char *qq)
int
getnum(char **scan1)
{
- register n;
- register char c, *scan;
+ int n;
+ char c, *scan;
n = 0;
scan = *scan1;
while ((c = *scan++) >= '0' && c <= '9') n = n * 10 + c -'0';
@@ -661,7 +666,7 @@ getnum(char **scan1)
/* usage: terminate processing with usage message */
void
-usage()
+usage(void)
{
(void) fprintf(stderr, gettext(
"usage: tabs [ -n| --file| [[-code] -a| -a2| -c| -c2| -c3| -f| -p| -s| -u]] \
@@ -676,7 +681,7 @@ usage()
/* endup: make sure tty mode reset & exit */
void
-endup()
+endup(void)
{
if (istty) {
@@ -719,17 +724,21 @@ static char stdtabs[] = {
int
stdtab(char option[], int tabvect[])
{
- register char *sp;
+ char *sp;
tabvect[0] = 0;
sp = stdtabs;
while (*sp) {
if (EQ(option, sp)) {
- while (*sp++); /* skip to 1st tab value */
- while (*tabvect++ = *sp++); /* copy, make int */
+ while (*sp++) /* skip to 1st tab value */
+ ;
+ while (*tabvect++ = *sp++) /* copy, make int */
+ ;
return (0);
}
- while (*sp++); /* skip to 1st tab value */
- while (*sp++); /* skip over tab list */
+ while (*sp++) /* skip to 1st tab value */
+ ;
+ while (*sp++) /* skip over tab list */
+ ;
}
return (-1);
}
diff --git a/usr/src/cmd/tip/Makefile b/usr/src/cmd/tip/Makefile
index af3e06e7e6..32ce22a653 100644
--- a/usr/src/cmd/tip/Makefile
+++ b/usr/src/cmd/tip/Makefile
@@ -1,5 +1,5 @@
#
-# Copyright 1998-2002 Sun Microsystems, Inc. All rights reserved.
+# Copyright 2002 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "%Z%%M% %I% %E% SMI"
@@ -62,6 +62,7 @@ $(ROOTETCREMOTE) := FILEMODE = 644
$(ROOTACULOG) := FILEMODE = 600
$(ROOTACULOG) := OWNER = uucp
+LINTFLAGS += -u
CPPFLAGS += -DDEFBR=300 -DDEFFS=BUFSIZ -DACULOG -DUSG
CONFIG= -DV831 -DVENTEL -DV3451 -DDF02 -DDF03 -DBIZ1031 -DBIZ1022 -DHAYES
ACULIB= aculib/aculib.a
@@ -110,7 +111,9 @@ clean: FRC
$(RM) $(OBJS)
lint:
- -lint -hbacvx $(CFLAGS) $(SOURCES)
+ cd aculib; $(MAKE) lint
+ $(LINT.c) $(SRCS) $(LDLIBS.cmd)
+
include ../Makefile.targ
diff --git a/usr/src/cmd/tip/acu.c b/usr/src/cmd/tip/acu.c
index 76de8d1f58..d2797f7452 100644
--- a/usr/src/cmd/tip/acu.c
+++ b/usr/src/cmd/tip/acu.c
@@ -2,21 +2,25 @@
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
+
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
-#ident "%Z%%M% %I% %E% SMI" /* from UCB 5.3 4/3/86 */
+#pragma ident "%Z%%M% %I% %E% SMI"
#include "tip.h"
+extern acu_t acutable[];
+
static acu_t *acu = NOACU;
static int conflag;
-static void acuabort();
-static acu_t *acutype();
+static void acuabort(int);
+static acu_t *acutype(char *);
static sigjmp_buf jmpbuf;
+
/*
* Establish connection for tip
*
@@ -34,9 +38,9 @@ static sigjmp_buf jmpbuf;
* found in the file).
*/
char *
-connect()
+connect(void)
{
- register char *cp = PN;
+ char *cp = PN;
char *phnum, string[256];
int tried = 0;
@@ -47,9 +51,9 @@ connect()
* otherwise, use /etc/phones
*/
if (sigsetjmp(jmpbuf, 1)) {
- signal(SIGINT, SIG_IGN);
- signal(SIGQUIT, SIG_IGN);
- printf("\ncall aborted\n");
+ (void) signal(SIGINT, SIG_IGN);
+ (void) signal(SIGQUIT, SIG_IGN);
+ (void) printf("\ncall aborted\n");
logent(value(HOST), "", "", "call aborted");
if (acu != NOACU) {
boolean(value(VERBOSE)) = FALSE;
@@ -62,8 +66,8 @@ connect()
delock(uucplock);
exit(1);
}
- signal(SIGINT, acuabort);
- signal(SIGQUIT, acuabort);
+ (void) signal(SIGINT, acuabort);
+ (void) signal(SIGQUIT, acuabort);
if ((acu = acutype(AT)) == NOACU)
return ("unknown ACU type");
if (*cp != '@') {
@@ -75,16 +79,16 @@ connect()
if (conflag = (*acu->acu_dialer)(phnum, CU)) {
logent(value(HOST), phnum, acu->acu_name,
- "call completed");
+ "call completed");
return (NOSTR);
} else
logent(value(HOST), phnum, acu->acu_name,
- "call failed");
+ "call failed");
tried++;
}
} else {
if (phfd == NOFILE) {
- printf("%s: ", PH);
+ (void) printf("%s: ", PH);
return ("can't open phone number file");
}
rewind(phfd);
@@ -108,11 +112,11 @@ connect()
if (conflag = (*acu->acu_dialer)(phnum, CU)) {
logent(value(HOST), phnum, acu->acu_name,
- "call completed");
+ "call completed");
return (NOSTR);
} else
logent(value(HOST), phnum, acu->acu_name,
- "call failed");
+ "call failed");
tried++;
}
}
@@ -123,33 +127,31 @@ connect()
return (tried ? "call failed" : "missing phone number");
}
-disconnect(reason)
- char *reason;
+void
+disconnect(char *reason)
{
if (!conflag)
return;
if (reason == NOSTR) {
logent(value(HOST), "", acu->acu_name, "call terminated");
if (boolean(value(VERBOSE)))
- printf("\r\ndisconnecting...");
+ (void) printf("\r\ndisconnecting...");
} else
logent(value(HOST), "", acu->acu_name, reason);
(*acu->acu_disconnect)();
}
static void
-acuabort(s)
+acuabort(int s)
{
- signal(s, SIG_IGN);
+ (void) signal(s, SIG_IGN);
siglongjmp(jmpbuf, 1);
}
static acu_t *
-acutype(s)
- register char *s;
+acutype(char *s)
{
- register acu_t *p;
- extern acu_t acutable[];
+ acu_t *p;
if (s != NOSTR)
for (p = acutable; p->acu_name != '\0'; p++)
diff --git a/usr/src/cmd/tip/aculib/Makefile b/usr/src/cmd/tip/aculib/Makefile
index 4df6c48095..7e90f0bebd 100644
--- a/usr/src/cmd/tip/aculib/Makefile
+++ b/usr/src/cmd/tip/aculib/Makefile
@@ -26,6 +26,7 @@ OBJS= biz22.o biz31.o df.o dn11.o hayes.o ventel.o v831.o v3451.o
include ../../Makefile.cmd
+LINTFLAGS += -u
CPPFLAGS= -I../ -DUSG $(CPPFLAGS.master)
.KEEP_STATE:
@@ -39,3 +40,6 @@ $(ACULIB): $(OBJS)
clean:
$(RM) $(ACULIB) $(OBJS) core errs
+
+lint:
+ $(LINT.c) $(OBJS:%.o=%.c)
diff --git a/usr/src/cmd/tip/aculib/biz22.c b/usr/src/cmd/tip/aculib/biz22.c
index c570e4a5ac..2141b0e906 100644
--- a/usr/src/cmd/tip/aculib/biz22.c
+++ b/usr/src/cmd/tip/aculib/biz22.c
@@ -1,62 +1,66 @@
/*
- * Copyright (c) 2000 by Sun Microsystems, Inc.
- * All rights reserved.
+ * Copyright 2000 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
*/
-/* from UCB 4.4 6/25/83 */
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
+
#pragma ident "%Z%%M% %I% %E% SMI"
#include "tip.h"
#define DISCONNECT_CMD "\20\04" /* disconnection string */
-static void sigALRM();
+static void sigALRM(void);
+static int cmd(char *);
+static int detect(char *);
+
static int timeout = 0;
static sigjmp_buf timeoutbuf;
+void biz22_disconnect(void);
+
/*
* Dial up on a BIZCOMP Model 1022 with either
* tone dialing (mod = "V")
* pulse dialing (mod = "W")
*/
static int
-biz_dialer(num, mod)
- char *num, *mod;
+biz_dialer(char *num, char *mod)
{
- register int connected = 0;
+ int connected = 0;
char cbuf[40];
if (boolean(value(VERBOSE)))
- printf("\nstarting call...");
+ (void) printf("\nstarting call...");
/*
* Disable auto-answer and configure for tone/pulse
* dialing
*/
if (cmd("\02K\r")) {
- printf("can't initialize bizcomp...");
+ (void) printf("can't initialize bizcomp...");
return (0);
}
- strcpy(cbuf, "\02.\r");
+ (void) strcpy(cbuf, "\02.\r");
cbuf[1] = *mod;
if (cmd(cbuf)) {
- printf("can't set dialing mode...");
+ (void) printf("can't set dialing mode...");
return (0);
}
- strcpy(cbuf, "\02D");
- strlcat(cbuf, num, sizeof (cbuf));
- strlcat(cbuf, "\r", sizeof (cbuf));
- write(FD, cbuf, strlen(cbuf));
+ (void) strcpy(cbuf, "\02D");
+ (void) strlcat(cbuf, num, sizeof (cbuf));
+ (void) strlcat(cbuf, "\r", sizeof (cbuf));
+ (void) write(FD, cbuf, strlen(cbuf));
if (!detect("7\r")) {
- printf("can't get dial tone...");
+ (void) printf("can't get dial tone...");
return (0);
}
if (boolean(value(VERBOSE)))
- printf("ringing...");
+ (void) printf("ringing...");
/*
* The reply from the BIZCOMP should be:
* 2 \r or 7 \r failure
@@ -67,8 +71,8 @@ biz_dialer(num, mod)
if (timeout) {
char line[80];
- sprintf(line, "%d second dial timeout",
- number(value(DIALTIMEOUT)));
+ (void) sprintf(line, "%d second dial timeout",
+ number(value(DIALTIMEOUT)));
logent(value(HOST), num, "biz1022", line);
}
#endif
@@ -77,36 +81,40 @@ biz_dialer(num, mod)
return (connected);
}
-biz22w_dialer(num, acu)
- char *num, *acu;
+/* ARGSUSED */
+int
+biz22w_dialer(char *num, char *acu)
{
return (biz_dialer(num, "W"));
}
-biz22f_dialer(num, acu)
- char *num, *acu;
+/* ARGSUSED */
+int
+biz22f_dialer(char *num, char *acu)
{
return (biz_dialer(num, "V"));
}
-biz22_disconnect()
+void
+biz22_disconnect(void)
{
- write(FD, DISCONNECT_CMD, 4);
- sleep(2);
- ioctl(FD, TCFLSH, TCOFLUSH);
+ (void) write(FD, DISCONNECT_CMD, 4);
+ (void) sleep(2);
+ (void) ioctl(FD, TCFLSH, TCOFLUSH);
}
-biz22_abort()
+void
+biz22_abort(void)
{
- write(FD, "\02", 1);
+ (void) write(FD, "\02", 1);
}
static void
-sigALRM()
+sigALRM(void)
{
timeout = 1;
@@ -114,30 +122,28 @@ sigALRM()
}
static int
-cmd(s)
- register char *s;
+cmd(char *s)
{
char c;
sig_handler_t f;
- write(FD, s, strlen(s));
+ (void) write(FD, s, strlen(s));
f = signal(SIGALRM, (sig_handler_t)sigALRM);
if (sigsetjmp(timeoutbuf, 1)) {
biz22_abort();
- signal(SIGALRM, f);
+ (void) signal(SIGALRM, f);
return (1);
}
- alarm(number(value(DIALTIMEOUT)));
- read(FD, &c, 1);
- alarm(0);
- signal(SIGALRM, f);
+ (void) alarm(number(value(DIALTIMEOUT)));
+ (void) read(FD, &c, 1);
+ (void) alarm(0);
+ (void) signal(SIGALRM, f);
c &= 0177;
return (c != '\r');
}
static int
-detect(s)
- register char *s;
+detect(char *s)
{
char c;
sig_handler_t f;
@@ -149,13 +155,13 @@ detect(s)
biz22_abort();
break;
}
- alarm(number(value(DIALTIMEOUT)));
- read(FD, &c, 1);
- alarm(0);
+ (void) alarm(number(value(DIALTIMEOUT)));
+ (void) read(FD, &c, 1);
+ (void) alarm(0);
c &= 0177;
if (c != *s++)
return (0);
}
- signal(SIGALRM, f);
+ (void) signal(SIGALRM, f);
return (timeout == 0);
}
diff --git a/usr/src/cmd/tip/aculib/biz31.c b/usr/src/cmd/tip/aculib/biz31.c
index fe0fbac5dc..5dba92d65e 100644
--- a/usr/src/cmd/tip/aculib/biz31.c
+++ b/usr/src/cmd/tip/aculib/biz31.c
@@ -2,21 +2,29 @@
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
+
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
-#ident "%Z%%M% %I% %E% SMI" /* from UCB 4.7 6/25/83 */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
#include "tip.h"
#define MAXRETRY 3 /* sync up retry count */
#define DISCONNECT_CMD "\21\25\11\24" /* disconnection string */
-static void sigALRM();
-static int timeout = 0;
-static sigjmp_buf timeoutbuf;
+static int detect(char *);
+static int bizsync(int);
+static void echo(char *);
+static void flush(char *);
+static void sigALRM(void);
+static int timeout = 0;
+static sigjmp_buf timeoutbuf;
+
+void biz31_disconnect(void);
/*
* Dial up on a BIZCOMP Model 1031 with either
@@ -24,19 +32,18 @@ static sigjmp_buf timeoutbuf;
* pulse dialing (mod = "w")
*/
static int
-biz_dialer(num, mod)
- char *num, *mod;
+biz_dialer(char *num, char *mod)
{
- register int connected = 0;
+ int connected = 0;
if (!bizsync(FD)) {
logent(value(HOST), "", "biz", "out of sync");
- printf("bizcomp out of sync\n");
+ (void) printf("bizcomp out of sync\n");
delock(uucplock);
exit(0);
}
if (boolean(value(VERBOSE)))
- printf("\nstarting call...");
+ (void) printf("\nstarting call...");
echo("#\rk$\r$\n"); /* disable auto-answer */
echo("$>$.$ #\r"); /* tone/pulse dialing */
echo(mod);
@@ -48,7 +55,7 @@ biz_dialer(num, mod)
echo(num);
echo("\r$\n");
if (boolean(value(VERBOSE)))
- printf("ringing...");
+ (void) printf("ringing...");
/*
* The reply from the BIZCOMP should be:
* `^G NO CONNECTION\r\n^G\r\n' failure
@@ -59,8 +66,8 @@ biz_dialer(num, mod)
if (timeout) {
char line[80];
- sprintf(line, "%d second dial timeout",
- number(value(DIALTIMEOUT)));
+ (void) sprintf(line, "%d second dial timeout",
+ number(value(DIALTIMEOUT)));
logent(value(HOST), num, "biz", line);
}
#endif
@@ -73,61 +80,64 @@ biz_dialer(num, mod)
return (connected);
}
-biz31w_dialer(num, acu)
- char *num, *acu;
+/* ARGSUSED */
+int
+biz31w_dialer(char *num, char *acu)
{
return (biz_dialer(num, "w"));
}
-biz31f_dialer(num, acu)
- char *num, *acu;
+/* ARGSUSED */
+int
+biz31f_dialer(char *num, char *acu)
{
return (biz_dialer(num, "f"));
}
-biz31_disconnect()
+void
+biz31_disconnect(void)
{
- write(FD, DISCONNECT_CMD, 4);
- sleep(2);
- ioctl(FD, TCFLSH, TCOFLUSH);
+ (void) write(FD, DISCONNECT_CMD, 4);
+ (void) sleep(2);
+ (void) ioctl(FD, TCFLSH, TCOFLUSH);
}
-biz31_abort()
+void
+biz31_abort(void)
{
- write(FD, "\33", 1);
+ (void) write(FD, "\33", 1);
}
-static int
-echo(s)
- register char *s;
+static void
+echo(char *s)
{
char c;
while (c = *s++) {
switch (c) {
case '$':
- read(FD, &c, 1);
+ (void) read(FD, &c, 1);
s++;
break;
case '#':
c = *s++;
- write(FD, &c, 1);
+ (void) write(FD, &c, 1);
break;
default:
- write(FD, &c, 1);
- read(FD, &c, 1);
+ (void) write(FD, &c, 1);
+ (void) read(FD, &c, 1);
}
}
}
static void
-sigALRM()
+sigALRM(void)
{
timeout = 1;
@@ -135,8 +145,7 @@ sigALRM()
}
static int
-detect(s)
- register char *s;
+detect(char *s)
{
char c;
sig_handler_t f;
@@ -145,23 +154,22 @@ detect(s)
timeout = 0;
while (*s) {
if (sigsetjmp(timeoutbuf, 1)) {
- printf("\07timeout waiting for reply\n");
+ (void) printf("\07timeout waiting for reply\n");
biz31_abort();
break;
}
- alarm(number(value(DIALTIMEOUT)));
- read(FD, &c, 1);
- alarm(0);
+ (void) alarm(number(value(DIALTIMEOUT)));
+ (void) read(FD, &c, 1);
+ (void) alarm(0);
if (c != *s++)
break;
}
- signal(SIGALRM, f);
+ (void) signal(SIGALRM, f);
return (timeout == 0);
}
-static int
-flush(s)
- register char *s;
+static void
+flush(char *s)
{
char c;
sig_handler_t f;
@@ -170,11 +178,11 @@ flush(s)
while (*s++) {
if (sigsetjmp(timeoutbuf, 1))
break;
- alarm(10);
- read(FD, &c, 1);
- alarm(0);
+ (void) alarm(10);
+ (void) read(FD, &c, 1);
+ (void) alarm(0);
}
- signal(SIGALRM, f);
+ (void) signal(SIGALRM, f);
timeout = 0; /* guard against disconnection */
}
@@ -184,7 +192,7 @@ flush(s)
* call there are gory ways to simulate this.
*/
static int
-bizsync(fd)
+bizsync(int fd)
{
#ifdef FIOCAPACITY
struct capacity b;
@@ -196,25 +204,25 @@ bizsync(fd)
#define chars(b) (b)
#define IOCTL FIONREAD
#endif
- register int already = 0;
+ int already = 0;
char buf[10];
retry:
if (ioctl(fd, IOCTL, (caddr_t)&b) >= 0 && chars(b) > 0)
- ioctl(fd, TCFLSH, TCIOFLUSH);
- write(fd, "\rp>\r", 4);
- sleep(1);
+ (void) ioctl(fd, TCFLSH, TCIOFLUSH);
+ (void) write(fd, "\rp>\r", 4);
+ (void) sleep(1);
if (ioctl(fd, IOCTL, (caddr_t)&b) >= 0) {
if (chars(b) != 10) {
nono:
if (already > MAXRETRY)
return (0);
- write(fd, DISCONNECT_CMD, 4);
- sleep(2);
+ (void) write(fd, DISCONNECT_CMD, 4);
+ (void) sleep(2);
already++;
goto retry;
} else {
- read(fd, buf, 10);
+ (void) read(fd, buf, 10);
if (strncmp(buf, "p >\r\n\r\n>", 8))
goto nono;
}
diff --git a/usr/src/cmd/tip/aculib/df.c b/usr/src/cmd/tip/aculib/df.c
index 22f00d9345..f7cfad2bbe 100644
--- a/usr/src/cmd/tip/aculib/df.c
+++ b/usr/src/cmd/tip/aculib/df.c
@@ -2,12 +2,14 @@
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
+
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
-#ident "%Z%%M% %I% %E% SMI" /* from UCB 4.8 6/25/83 */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Dial the DF02-AC or DF03-AC
@@ -15,88 +17,94 @@
#include "tip.h"
-static sigjmp_buf Sjbuf;
-static void timeout();
+static sigjmp_buf Sjbuf;
+static void timeout(void);
-df02_dialer(num, acu)
- char *num, *acu;
+void df_disconnect(void);
+int df_dialer(char *, char *, int);
+
+int
+df02_dialer(char *num, char *acu)
{
return (df_dialer(num, acu, 0));
}
-df03_dialer(num, acu)
- char *num, *acu;
+int
+df03_dialer(char *num, char *acu)
{
return (df_dialer(num, acu, 1));
}
-df_dialer(num, acu, df03)
- char *num, *acu;
- int df03;
+/* ARGSUSED */
+int
+df_dialer(char *num, char *acu, int df03)
{
- register int f = FD;
+ int f = FD;
struct termios buf;
int speed = 0;
char c = '\0';
- ioctl(f, TCGETS, &buf);
+ (void) ioctl(f, TCGETS, &buf);
buf.c_cflag |= HUPCL;
- ioctl(f, TCSETS, &buf);
+ (void) ioctl(f, TCSETS, &buf);
if (sigsetjmp(Sjbuf, 1)) {
- printf("connection timed out\r\n");
+ (void) printf("connection timed out\r\n");
df_disconnect();
return (0);
}
if (boolean(value(VERBOSE)))
- printf("\ndialing...");
- fflush(stdout);
+ (void) printf("\ndialing...");
+ (void) fflush(stdout);
#ifdef TIOCMSET
if (df03) {
int st = TIOCM_ST; /* secondary Transmit flag */
- ioctl(f, TCGETS, &buf);
+ (void) ioctl(f, TCGETS, &buf);
if (cfgetospeed(&buf) != B1200) { /* must dial at 1200 baud */
speed = cfgetospeed(&buf);
- cfsetospeed(&buf, B0);
- cfsetispeed(&buf, B0);
- cfsetospeed(&buf, B1200);
- ioctl(f, TCSETSW, &buf);
- ioctl(f, TIOCMBIC, &st); /* clear ST for 300 baud */
+ (void) cfsetospeed(&buf, B0);
+ (void) cfsetispeed(&buf, B0);
+ (void) cfsetospeed(&buf, B1200);
+ (void) ioctl(f, TCSETSW, &buf);
+ /* clear ST for 300 baud */
+ (void) ioctl(f, TIOCMBIC, &st);
} else
- ioctl(f, TIOCMBIS, &st); /* set ST for 1200 baud */
+ /* set ST for 1200 baud */
+ (void) ioctl(f, TIOCMBIS, &st);
}
#endif
- signal(SIGALRM, timeout);
- alarm(5 * strlen(num) + 10);
- ioctl(f, TCFLSH, TCOFLUSH);
- write(f, "\001", 1);
- sleep(1);
- write(f, "\002", 1);
- write(f, num, strlen(num));
- read(f, &c, 1);
+ (void) signal(SIGALRM, (sig_handler_t)timeout);
+ (void) alarm(5 * strlen(num) + 10);
+ (void) ioctl(f, TCFLSH, TCOFLUSH);
+ (void) write(f, "\001", 1);
+ (void) sleep(1);
+ (void) write(f, "\002", 1);
+ (void) write(f, num, strlen(num));
+ (void) read(f, &c, 1);
#ifdef TIOCMSET
if (df03 && speed) {
- cfsetospeed(&buf, B0);
- cfsetispeed(&buf, B0);
- cfsetospeed(&buf, speed);
- ioctl(f, TCSETSW, &buf);
+ (void) cfsetospeed(&buf, B0);
+ (void) cfsetispeed(&buf, B0);
+ (void) cfsetospeed(&buf, speed);
+ (void) ioctl(f, TCSETSW, &buf);
}
#endif
return (c == 'A');
}
-df_disconnect()
+void
+df_disconnect(void)
{
- write(FD, "\001", 1);
- sleep(1);
- ioctl(FD, TCFLSH, TCOFLUSH);
+ (void) write(FD, "\001", 1);
+ (void) sleep(1);
+ (void) ioctl(FD, TCFLSH, TCOFLUSH);
}
-
-df_abort()
+void
+df_abort(void)
{
df_disconnect();
@@ -104,7 +112,7 @@ df_abort()
static void
-timeout()
+timeout(void)
{
siglongjmp(Sjbuf, 1);
diff --git a/usr/src/cmd/tip/aculib/dn11.c b/usr/src/cmd/tip/aculib/dn11.c
index 24bac51d5f..d383fd53fb 100644
--- a/usr/src/cmd/tip/aculib/dn11.c
+++ b/usr/src/cmd/tip/aculib/dn11.c
@@ -2,57 +2,57 @@
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
+
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
-#ident "%Z%%M% %I% %E% SMI" /* from UCB 4.14 6/25/83 */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Routines for dialing up on DN-11
*/
#include "tip.h"
-int dn_abort();
-void alarmtr();
-static sigjmp_buf jmpbuf;
-static int child = -1, dn;
+void alarmtr(void);
+
+static sigjmp_buf jmpbuf;
+static int child = -1, dn;
-dn_dialer(num, acu)
- char *num, *acu;
+int
+dn_dialer(char *num, char *acu)
{
- extern errno;
- char *p, *q, phone[40];
- int lt, nw, connected = 1;
- register int timelim;
+ int lt, nw;
+ int timelim;
struct termios buf;
if (boolean(value(VERBOSE)))
- printf("\nstarting call...");
+ (void) printf("\nstarting call...");
if ((dn = open(acu, 1)) < 0) {
if (errno == EBUSY)
- printf("line busy...");
+ (void) printf("line busy...");
else
- printf("acu open error...");
+ (void) printf("acu open error...");
return (0);
}
if (sigsetjmp(jmpbuf, 1)) {
- kill(child, SIGKILL);
- close(dn);
+ (void) kill(child, SIGKILL);
+ (void) close(dn);
return (0);
}
- signal(SIGALRM, alarmtr);
+ (void) signal(SIGALRM, (sig_handler_t)alarmtr);
timelim = 5 * strlen(num);
- alarm(timelim < 30 ? 30 : timelim);
+ (void) alarm(timelim < 30 ? 30 : timelim);
if ((child = fork()) == 0) {
/*
* ignore this stuff for aborts
*/
- signal(SIGALRM, SIG_IGN);
- signal(SIGINT, SIG_IGN);
- signal(SIGQUIT, SIG_IGN);
- sleep(2);
+ (void) signal(SIGALRM, SIG_IGN);
+ (void) signal(SIGINT, SIG_IGN);
+ (void) signal(SIGQUIT, SIG_IGN);
+ (void) sleep(2);
nw = write(dn, num, lt = strlen(num));
exit(nw != lt);
}
@@ -61,35 +61,35 @@ dn_dialer(num, acu)
*/
if ((FD = open(DV, 2)) < 0) {
if (errno == EIO)
- printf("lost carrier...");
+ (void) printf("lost carrier...");
else
- printf("dialup line open failed...");
- alarm(0);
- kill(child, SIGKILL);
- close(dn);
+ (void) printf("dialup line open failed...");
+ (void) alarm(0);
+ (void) kill(child, SIGKILL);
+ (void) close(dn);
return (0);
}
- alarm(0);
- ioctl(dn, TCGETS, &buf);
+ (void) alarm(0);
+ (void) ioctl(dn, TCGETS, &buf);
buf.c_cflag |= HUPCL;
- ioctl(dn, TCSETSF, &buf);
- signal(SIGALRM, SIG_DFL);
+ (void) ioctl(dn, TCSETSF, &buf);
+ (void) signal(SIGALRM, SIG_DFL);
while ((nw = wait(&lt)) != child && nw != -1)
;
- fflush(stdout);
- close(dn);
+ (void) fflush(stdout);
+ (void) close(dn);
if (lt != 0) {
- close(FD);
+ (void) close(FD);
return (0);
}
return (1);
}
void
-alarmtr()
+alarmtr(void)
{
- alarm(0);
+ (void) alarm(0);
siglongjmp(jmpbuf, 1);
}
@@ -97,26 +97,28 @@ alarmtr()
* Insurance, for some reason we don't seem to be
* hanging up...
*/
-dn_disconnect()
+void
+dn_disconnect(void)
{
int dtr = TIOCM_DTR;
- sleep(2);
+ (void) sleep(2);
if (FD > 0)
- ioctl(FD, TIOCMBIC, &dtr);
- close(FD);
+ (void) ioctl(FD, TIOCMBIC, &dtr);
+ (void) close(FD);
}
-dn_abort()
+void
+dn_abort(void)
{
int dtr = TIOCM_DTR;
- sleep(2);
+ (void) sleep(2);
if (child > 0)
- kill(child, SIGKILL);
+ (void) kill(child, SIGKILL);
if (dn > 0)
- close(dn);
+ (void) close(dn);
if (FD > 0)
- ioctl(FD, TIOCMBIC, &dtr);
- close(FD);
+ (void) ioctl(FD, TIOCMBIC, &dtr);
+ (void) close(FD);
}
diff --git a/usr/src/cmd/tip/aculib/hayes.c b/usr/src/cmd/tip/aculib/hayes.c
index 85a26a8dc1..977be33c02 100644
--- a/usr/src/cmd/tip/aculib/hayes.c
+++ b/usr/src/cmd/tip/aculib/hayes.c
@@ -2,96 +2,103 @@
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
+
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
-#ident "%Z%%M% %I% %E% SMI"
+
+#pragma ident "%Z%%M% %I% %E% SMI"
#include "tip.h"
-static void sigALRM();
-static sigjmp_buf timeoutbuf;
+static int hayes_sync(int);
+static void sigALRM(void);
+static sigjmp_buf timeoutbuf;
+
+void hayes_disconnect(void);
/*
* Dial up on a Hayes Smart Modem 1200 or 2400
*/
+/* ARGSUSED */
int
-hayes_dialer(num, acu)
- char *num, *acu;
+hayes_dialer(char *num, char *acu)
{
char code = 0, cr = 0;
- void (*f)();
+ sig_handler_t f;
struct termios buf;
- f = signal(SIGALRM, sigALRM);
+ f = signal(SIGALRM, (sig_handler_t)sigALRM);
if (!hayes_sync(FD)) {
- printf("can't synchronize with hayes\n");
+ (void) printf("can't synchronize with hayes\n");
#ifdef ACULOG
logent(value(HOST), num, "hayes", "can't synch up");
#endif
- signal(SIGALRM, f);
+ (void) signal(SIGALRM, f);
return (0);
}
if (boolean(value(VERBOSE)))
- printf("\ndialing...");
- fflush(stdout);
- ioctl(FD, TCGETS, &buf);
+ (void) printf("\ndialing...");
+ (void) fflush(stdout);
+ (void) ioctl(FD, TCGETS, &buf);
buf.c_cflag |= HUPCL;
- ioctl(FD, TCSETS, &buf);
- ioctl(FD, TCFLSH, TCIOFLUSH);
+ (void) ioctl(FD, TCSETS, &buf);
+ (void) ioctl(FD, TCFLSH, TCIOFLUSH);
if (sigsetjmp(timeoutbuf, 1)) {
#ifdef ACULOG
char line[80];
- sprintf(line, "%d second dial timeout",
- number(value(DIALTIMEOUT)));
+ (void) sprintf(line, "%d second dial timeout",
+ number(value(DIALTIMEOUT)));
logent(value(HOST), num, "hayes", line);
#endif
hayes_disconnect();
- signal(SIGALRM, f);
+ (void) signal(SIGALRM, f);
return (0);
}
- alarm(number(value(DIALTIMEOUT)));
- ioctl(FD, TCFLSH, TCIOFLUSH);
+ (void) alarm(number(value(DIALTIMEOUT)));
+ (void) ioctl(FD, TCFLSH, TCIOFLUSH);
if (*num == 'S')
- write(FD, "AT", 2);
+ (void) write(FD, "AT", 2);
else
- write(FD, "ATDT", 4); /* use tone dialing */
- write(FD, num, strlen(num));
- write(FD, "\r", 1);
- read(FD, &code, 1);
- read(FD, &cr, 1);
+ (void) write(FD, "ATDT", 4); /* use tone dialing */
+ (void) write(FD, num, strlen(num));
+ (void) write(FD, "\r", 1);
+ (void) read(FD, &code, 1);
+ (void) read(FD, &cr, 1);
if (code == '1' && cr == '0')
- read(FD, &cr, 1);
- alarm(0);
- signal(SIGALRM, f);
+ (void) read(FD, &cr, 1);
+ (void) alarm(0);
+ (void) signal(SIGALRM, f);
if ((code == '1' || code == '5') && cr == '\r')
return (1);
return (0);
}
-hayes_disconnect()
+void
+hayes_disconnect(void)
{
- close(FD);
+ (void) close(FD);
}
-hayes_abort()
+void
+hayes_abort(void)
{
int dtr = TIOCM_DTR;
- alarm(0);
- ioctl(FD, TIOCMBIC, &dtr);
- sleep(2);
- ioctl(FD, TCFLSH, TCIOFLUSH);
- close(FD);
+ (void) alarm(0);
+ (void) ioctl(FD, TIOCMBIC, &dtr);
+ (void) sleep(2);
+ (void) ioctl(FD, TCFLSH, TCIOFLUSH);
+ (void) close(FD);
}
static void
-sigALRM()
+sigALRM(void)
{
siglongjmp(timeoutbuf, 1);
}
@@ -100,9 +107,9 @@ sigALRM()
* This piece of code attempts to get the hayes in sync.
*/
static int
-hayes_sync(fd)
+hayes_sync(int fd)
{
- register int tries;
+ int tries;
char code = 0, cr = 0;
int dtr = TIOCM_DTR;
@@ -111,9 +118,9 @@ hayes_sync(fd)
* the modem connected, and insure a consistent state
* to start from.
*/
- ioctl(fd, TIOCMBIC, &dtr);
- sleep(1);
- ioctl(fd, TIOCMBIS, &dtr);
+ (void) ioctl(fd, TIOCMBIC, &dtr);
+ (void) sleep(1);
+ (void) ioctl(fd, TIOCMBIS, &dtr);
for (tries = 0; tries < 3; tries++) {
/*
* After reseting the modem, initialize all
@@ -126,16 +133,16 @@ hayes_sync(fd)
* S2=255 - disable escape character
* S12=255 - longest possible escape guard time
*/
- write(fd, "ATV0Q0E0S0=1S2=255S12=255\r", 26);
- sleep(1);
+ (void) write(fd, "ATV0Q0E0S0=1S2=255S12=255\r", 26);
+ (void) sleep(1);
/* flush any echoes or return codes */
- ioctl(fd, TCFLSH, TCIOFLUSH);
+ (void) ioctl(fd, TCFLSH, TCIOFLUSH);
/* now see if the modem is talking to us properly */
- write(fd, "AT\r", 3);
+ (void) write(fd, "AT\r", 3);
if (sigsetjmp(timeoutbuf, 1) == 0) {
- alarm(2);
- read(FD, &code, 1);
- read(FD, &cr, 1);
+ (void) alarm(2);
+ (void) read(FD, &code, 1);
+ (void) read(FD, &cr, 1);
if (code == '0' && cr == '\r')
return (1);
}
diff --git a/usr/src/cmd/tip/aculib/v3451.c b/usr/src/cmd/tip/aculib/v3451.c
index 221e67c85a..c9799ae185 100644
--- a/usr/src/cmd/tip/aculib/v3451.c
+++ b/usr/src/cmd/tip/aculib/v3451.c
@@ -1,14 +1,14 @@
/*
- * Copyright (c) 2000 by Sun Microsystems, Inc.
- * All rights reserved.
+ * Copyright 2000 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
*/
-/* from UCB 4.4 6/25/83 */
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
+
#pragma ident "%Z%%M% %I% %E% SMI"
/*
@@ -16,14 +16,20 @@
*/
#include "tip.h"
-static sigjmp_buf Sjbuf;
+static int expect(char *);
+static int notin(char *, char *);
+static int prefix(char *, char *);
+static void vawrite(char *, int);
+static void alarmtr(void);
+
+static sigjmp_buf Sjbuf;
-v3451_dialer(num, acu)
- register char *num;
- char *acu;
+/* ARGSUSED */
+int
+v3451_dialer(char *num, char *acu)
{
int ok;
- void (*func)();
+ sig_handler_t func;
struct termios buf;
int slow = number(value(BAUDRATE)) < 1200;
char phone[50];
@@ -39,29 +45,29 @@ v3451_dialer(num, acu)
vawrite("I\r", 1 + slow);
vawrite("\005\r", 2 + slow);
if (!expect("READY")) {
- printf("can't synchronize with vadic 3451\n");
+ (void) printf("can't synchronize with vadic 3451\n");
#ifdef ACULOG
logent(value(HOST), num, "vadic", "can't synch up");
#endif
return (0);
}
- ioctl(FD, TCGETS, &buf);
+ (void) ioctl(FD, TCGETS, &buf);
buf.c_cflag |= HUPCL;
- ioctl(FD, TCSETSF, &buf);
- sleep(1);
+ (void) ioctl(FD, TCSETSF, &buf);
+ (void) sleep(1);
vawrite("D\r", 2 + slow);
if (!expect("NUMBER?")) {
- printf("Vadic will not accept dial command\n");
+ (void) printf("Vadic will not accept dial command\n");
#ifdef ACULOG
logent(value(HOST), num, "vadic", "will not accept dial");
#endif
return (0);
}
- strlcpy(phone, num, sizeof (phone));
- strlcat(phone, "\r", sizeof (phone));
+ (void) strlcpy(phone, num, sizeof (phone));
+ (void) strlcat(phone, "\r", sizeof (phone));
vawrite(phone, 1 + slow);
if (!expect(phone)) {
- printf("Vadic will not accept phone number\n");
+ (void) printf("Vadic will not accept phone number\n");
#ifdef ACULOG
logent(value(HOST), num, "vadic", "will not accept number");
#endif
@@ -76,56 +82,54 @@ v3451_dialer(num, acu)
vawrite("\r", 1 + slow);
vawrite("\r", 1 + slow);
if (!expect("DIALING:")) {
- printf("Vadic failed to dial\n");
+ (void) printf("Vadic failed to dial\n");
#ifdef ACULOG
logent(value(HOST), num, "vadic", "failed to dial");
#endif
return (0);
}
if (boolean(value(VERBOSE)))
- printf("\ndialing...");
+ (void) printf("\ndialing...");
ok = expect("ON LINE");
- signal(SIGINT, func);
+ (void) signal(SIGINT, func);
if (!ok) {
- printf("call failed\n");
+ (void) printf("call failed\n");
#ifdef ACULOG
logent(value(HOST), num, "vadic", "call failed");
#endif
return (0);
}
- ioctl(FD, TCFLSH, TCOFLUSH);
+ (void) ioctl(FD, TCFLSH, TCOFLUSH);
return (1);
}
-v3451_disconnect()
+void
+v3451_disconnect(void)
{
- close(FD);
+ (void) close(FD);
}
-v3451_abort()
+void
+v3451_abort(void)
{
- close(FD);
+ (void) close(FD);
}
-static
-vawrite(cp, delay)
- register char *cp;
- int delay;
+static void
+vawrite(char *cp, int delay)
{
- for (; *cp; sleep(delay), cp++)
- write(FD, cp, 1);
+ for (; *cp; (void) sleep(delay), cp++)
+ (void) write(FD, cp, 1);
}
-static
-expect(cp)
- register char *cp;
+static int
+expect(char *cp)
{
char buf[300];
- register char *rp = buf;
- static void alarmtr();
+ char *rp = buf;
int timeout = 30, online = 0;
if (strcmp(cp, "\"\"") == 0)
@@ -140,35 +144,34 @@ expect(cp)
online = strcmp(cp, "ON LINE") == 0;
if (online)
timeout = number(value(DIALTIMEOUT));
- signal(SIGALRM, alarmtr);
+ (void) signal(SIGALRM, (sig_handler_t)alarmtr);
if (sigsetjmp(Sjbuf, 1))
return (0);
- alarm(timeout);
+ (void) alarm(timeout);
while (notin(cp, buf) && rp < buf + sizeof (buf) - 1) {
if (online && notin("FAILED CALL", buf) == 0)
return (0);
if (read(FD, rp, 1) < 0) {
- alarm(0);
+ (void) alarm(0);
return (0);
}
if (*rp &= 0177)
rp++;
*rp = '\0';
}
- alarm(0);
+ (void) alarm(0);
return (1);
}
static void
-alarmtr()
+alarmtr(void)
{
siglongjmp(Sjbuf, 1);
}
-static
-notin(sh, lg)
- char *sh, *lg;
+static int
+notin(char *sh, char *lg)
{
for (; *lg; lg++)
@@ -177,11 +180,10 @@ notin(sh, lg)
return (1);
}
-static
-prefix(s1, s2)
- register char *s1, *s2;
+static int
+prefix(char *s1, char *s2)
{
- register char c;
+ char c;
while ((c = *s1++) == *s2++)
if (c == '\0')
diff --git a/usr/src/cmd/tip/aculib/v831.c b/usr/src/cmd/tip/aculib/v831.c
index d117bb4bf1..eee2763cce 100644
--- a/usr/src/cmd/tip/aculib/v831.c
+++ b/usr/src/cmd/tip/aculib/v831.c
@@ -2,12 +2,14 @@
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
+
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
-#ident "%Z%%M% %I% %E% SMI" /* from UCB 4.5 6/25/83 */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Routines for dialing up on Vadic 831
@@ -16,47 +18,47 @@
#include "tip.h"
-int v831_abort();
-static void alarmtr();
-extern errno;
+static char dialit(char *, char *);
+static char *sanitize(char *);
+static void alarmtr(void);
-static sigjmp_buf jmpbuf;
-static int child = -1;
+static sigjmp_buf jmpbuf;
+static int child = -1;
-v831_dialer(num, acu)
- char *num, *acu;
+int
+v831_dialer(char *num, char *acu)
{
- int status, pid, connected = 1;
- register int timelim;
+ int status, pid;
+ int timelim;
if (boolean(value(VERBOSE)))
- printf("\nstarting call...");
+ (void) printf("\nstarting call...");
#ifdef DEBUG
- printf("(acu=%s)\n", acu);
+ (void) printf("(acu=%s)\n", acu);
#endif
if ((AC = open(acu, O_RDWR)) < 0) {
if (errno == EBUSY)
- printf("line busy...");
+ (void) printf("line busy...");
else
- printf("acu open error...");
+ (void) printf("acu open error...");
return (0);
}
if (sigsetjmp(jmpbuf, 1)) {
- kill(child, SIGKILL);
- close(AC);
+ (void) kill(child, SIGKILL);
+ (void) close(AC);
return (0);
}
- signal(SIGALRM, alarmtr);
+ (void) signal(SIGALRM, (sig_handler_t)alarmtr);
timelim = 5 * strlen(num);
- alarm(timelim < 30 ? 30 : timelim);
+ (void) alarm(timelim < 30 ? 30 : timelim);
if ((child = fork()) == 0) {
/*
* ignore this stuff for aborts
*/
- signal(SIGALRM, SIG_IGN);
- signal(SIGINT, SIG_IGN);
- signal(SIGQUIT, SIG_IGN);
- sleep(2);
+ (void) signal(SIGALRM, SIG_IGN);
+ (void) signal(SIGINT, SIG_IGN);
+ (void) signal(SIGQUIT, SIG_IGN);
+ (void) sleep(2);
exit(dialit(num, acu) != 'A');
}
/*
@@ -64,33 +66,33 @@ v831_dialer(num, acu)
*/
if ((FD = open(DV, O_RDWR)) < 0) {
#ifdef DEBUG
- printf("(after open, errno=%d)\n", errno);
+ (void) printf("(after open, errno=%d)\n", errno);
#endif
if (errno == EIO)
- printf("lost carrier...");
+ (void) printf("lost carrier...");
else
- printf("dialup line open failed...");
- alarm(0);
- kill(child, SIGKILL);
- close(AC);
+ (void) printf("dialup line open failed...");
+ (void) alarm(0);
+ (void) kill(child, SIGKILL);
+ (void) close(AC);
return (0);
}
- alarm(0);
- signal(SIGALRM, SIG_DFL);
+ (void) alarm(0);
+ (void) signal(SIGALRM, SIG_DFL);
while ((pid = wait(&status)) != child && pid != -1)
;
if (status) {
- close(AC);
+ (void) close(AC);
return (0);
}
return (1);
}
static void
-alarmtr()
+alarmtr(void)
{
- alarm(0);
+ (void) alarm(0);
siglongjmp(jmpbuf, 1);
}
@@ -98,45 +100,47 @@ alarmtr()
* Insurance, for some reason we don't seem to be
* hanging up...
*/
-v831_disconnect()
+void
+v831_disconnect(void)
{
struct termios cntrl;
int dtr = TIOCM_DTR;
- sleep(2);
+ (void) sleep(2);
#ifdef DEBUG
printf("[disconnect: FD=%d]\n", FD);
#endif
if (FD > 0) {
- ioctl(FD, TIOCMBIC, &dtr);
- ioctl(FD, TCGETS, &cntrl);
- cfsetospeed(&cntrl, B0);
+ (void) ioctl(FD, TIOCMBIC, &dtr);
+ (void) ioctl(FD, TCGETS, &cntrl);
+ (void) cfsetospeed(&cntrl, B0);
cntrl.c_cflag &= ~XCLUDE;
- ioctl(FD, TCSETSF, &cntrl);
+ (void) ioctl(FD, TCSETSF, &cntrl);
}
- close(FD);
+ (void) close(FD);
}
-v831_abort()
+void
+v831_abort(void)
{
int dtr = TIOCM_DTR;
struct termios buf;
#ifdef DEBUG
- printf("[abort: AC=%d]\n", AC);
+ (void) printf("[abort: AC=%d]\n", AC);
#endif
- sleep(2);
+ (void) sleep(2);
if (child > 0)
- kill(child, SIGKILL);
+ (void) kill(child, SIGKILL);
if (AC > 0) {
- ioctl(FD, TCGETS, &buf);
+ (void) ioctl(FD, TCGETS, &buf);
buf.c_cflag &= ~XCLUDE;
- ioctl(FD, TCSETSF, &buf);
- close(AC);
+ (void) ioctl(FD, TCSETSF, &buf);
+ (void) close(AC);
}
if (FD > 0)
- ioctl(FD, TIOCMBIC, &dtr);
- close(FD);
+ (void) ioctl(FD, TIOCMBIC, &dtr);
+ (void) close(FD);
}
/*
@@ -152,25 +156,23 @@ struct vaconfig {
{ 0 }
};
-#define pc(x) (c = x, write(AC, &c, 1))
+#define pc(x) (c = x, (void) write(AC, &c, 1))
#define ABORT 01
#define SI 017
#define STX 02
#define ETX 03
-static
-dialit(phonenum, acu)
- register char *phonenum;
- char *acu;
+static char
+dialit(char *phonenum, char *acu)
{
- register struct vaconfig *vp;
+ struct vaconfig *vp;
struct termios cntrl;
- char c, *sanitize();
+ char c;
int i;
phonenum = sanitize(phonenum);
#ifdef DEBUG
- printf("(dial phonenum=%s)\n", phonenum);
+ (void) printf("(dial phonenum=%s)\n", phonenum);
#endif
if (*phonenum == '<' && phonenum[1] == 0)
return ('Z');
@@ -178,21 +180,21 @@ dialit(phonenum, acu)
if (strcmp(vp->vc_name, acu) == 0)
break;
if (vp->vc_name == 0) {
- printf("Unable to locate dialer (%s)\n", acu);
+ (void) printf("Unable to locate dialer (%s)\n", acu);
return ('K');
}
- ioctl(AC, TCGETS, &cntrl);
- cfsetospeed(&cntrl, B0);
- cfsetispeed(&cntrl, B0);
+ (void) ioctl(AC, TCGETS, &cntrl);
+ (void) cfsetospeed(&cntrl, B0);
+ (void) cfsetispeed(&cntrl, B0);
cntrl.c_cflag &= ~(CSIZE|PARENB|PARODD);
- cfsetospeed(&cntrl, B2400);
+ (void) cfsetospeed(&cntrl, B2400);
cntrl.c_cflag |= CS8;
cntrl.c_iflag &= IXOFF|IXANY;
cntrl.c_lflag &= ~(ICANON|ISIG);
cntrl.c_oflag = 0;
cntrl.c_cc[VMIN] = cntrl.c_cc[VTIME] = 0;
- ioctl(AC, TCSETSF, &cntrl);
- ioctl(AC, TCFLSH, TCOFLUSH);
+ (void) ioctl(AC, TCSETSF, &cntrl);
+ (void) ioctl(AC, TCFLSH, TCOFLUSH);
pc(STX);
pc(vp->vc_rack);
pc(vp->vc_modem);
@@ -200,7 +202,7 @@ dialit(phonenum, acu)
pc(*phonenum++);
pc(SI);
pc(ETX);
- sleep(1);
+ (void) sleep(1);
i = read(AC, &c, 1);
#ifdef DEBUG
printf("read %d chars, char=%c, errno %d\n", i, c, errno);
@@ -211,26 +213,25 @@ dialit(phonenum, acu)
char cc, oc = c;
pc(ABORT);
- read(AC, &cc, 1);
+ (void) read(AC, &cc, 1);
#ifdef DEBUG
- printf("abort response=%c\n", cc);
+ (void) printf("abort response=%c\n", cc);
#endif
c = oc;
v831_disconnect();
}
- close(AC);
+ (void) close(AC);
#ifdef DEBUG
- printf("dialit: returns %c\n", c);
+ (void) printf("dialit: returns %c\n", c);
#endif
return (c);
}
static char *
-sanitize(s)
- register char *s;
+sanitize(char *s)
{
static char buf[128];
- register char *cp;
+ char *cp;
for (cp = buf; *s; s++) {
if (!isdigit(*s) && *s == '<' && *s != '_')
diff --git a/usr/src/cmd/tip/aculib/ventel.c b/usr/src/cmd/tip/aculib/ventel.c
index 635a879c5c..85fc2c8b85 100644
--- a/usr/src/cmd/tip/aculib/ventel.c
+++ b/usr/src/cmd/tip/aculib/ventel.c
@@ -2,12 +2,14 @@
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
+
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
-#ident "%Z%%M% %I% %E% SMI" /* from UCB 1.5 6/25/83 */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Routines for calling up on a Ventel Modem
@@ -17,16 +19,21 @@
#define MAXRETRY 5
-static void sigALRM();
-static int timeout = 0;
-static sigjmp_buf timeoutbuf;
+static int vensync(int);
+static int gobble(char);
+static void echo(char *);
+static void sigALRM(void);
+static int timeout = 0;
+static sigjmp_buf timeoutbuf;
+
+void ven_disconnect(void);
-ven_dialer(num, acu)
- register char *num;
- char *acu;
+/* ARGSUSED */
+int
+ven_dialer(char *num, char *acu)
{
- register char *cp;
- register int connected = 0;
+ char *cp;
+ int connected = 0;
struct termios buf;
#ifdef ACULOG
char line[80];
@@ -35,23 +42,23 @@ ven_dialer(num, acu)
* Get in synch with a couple of carriage returns
*/
if (!vensync(FD)) {
- printf("can't synchronize with ventel\n");
+ (void) printf("can't synchronize with ventel\n");
#ifdef ACULOG
logent(value(HOST), num, "ventel", "can't synch up");
#endif
return (0);
}
if (boolean(value(VERBOSE)))
- printf("\ndialing...");
- fflush(stdout);
- ioctl(FD, TCGETS, &buf);
+ (void) printf("\ndialing...");
+ (void) fflush(stdout);
+ (void) ioctl(FD, TCGETS, &buf);
buf.c_cflag |= HUPCL;
- ioctl(FD, TCSETSF, &buf);
+ (void) ioctl(FD, TCSETSF, &buf);
#ifdef VENNOECHO
echo("#k$\r$\n$D$I$A$L$:$ ");
for (cp = num; *cp; cp++) {
- sleep(1);
- write(FD, cp, 1);
+ (void) sleep(1);
+ (void) write(FD, cp, 1);
}
echo("\r$\n");
#else
@@ -59,19 +66,19 @@ ven_dialer(num, acu)
for (cp = num; *cp; cp++) {
char c;
- sleep(1);
- write(FD, cp, 1);
- read(FD, &c, 1);
+ (void) sleep(1);
+ (void) write(FD, cp, 1);
+ (void) read(FD, &c, 1);
}
echo(">\r$\n");
#endif
if (gobble('\n'))
connected = gobble('!');
- ioctl(FD, TCFLSH, TCIOFLUSH);
+ (void) ioctl(FD, TCFLSH, TCIOFLUSH);
#ifdef ACULOG
if (timeout) {
- sprintf(line, "%d second dial timeout",
- number(value(DIALTIMEOUT)));
+ (void) sprintf(line, "%d second dial timeout",
+ number(value(DIALTIMEOUT)));
logent(value(HOST), num, "ventel", line);
}
#endif
@@ -80,56 +87,56 @@ ven_dialer(num, acu)
return (connected);
}
-ven_disconnect()
+void
+ven_disconnect(void)
{
- close(FD);
+ (void) close(FD);
}
-ven_abort()
+void
+ven_abort(void)
{
- write(FD, "\03", 1);
- close(FD);
+ (void) write(FD, "\03", 1);
+ (void) close(FD);
}
-static int
-echo(s)
- register char *s;
+static void
+echo(char *s)
{
char c;
while (c = *s++) {
switch (c) {
case '$':
- read(FD, &c, 1);
+ (void) read(FD, &c, 1);
s++;
break;
case '#':
c = *s++;
- write(FD, &c, 1);
+ (void) write(FD, &c, 1);
break;
default:
- write(FD, &c, 1);
- read(FD, &c, 1);
+ (void) write(FD, &c, 1);
+ (void) read(FD, &c, 1);
}
}
}
static void
-sigALRM()
+sigALRM(void)
{
- printf("\07timeout waiting for reply\n");
+ (void) printf("\07timeout waiting for reply\n");
timeout = 1;
siglongjmp(timeoutbuf, 1);
}
static int
-gobble(match)
- register char match;
+gobble(char match)
{
char c;
sig_handler_t f;
@@ -138,19 +145,19 @@ gobble(match)
timeout = 0;
do {
if (sigsetjmp(timeoutbuf, 1)) {
- signal(SIGALRM, f);
+ (void) signal(SIGALRM, f);
return (0);
}
- alarm(number(value(DIALTIMEOUT)));
- read(FD, &c, 1);
- alarm(0);
+ (void) alarm(number(value(DIALTIMEOUT)));
+ (void) read(FD, &c, 1);
+ (void) alarm(0);
c &= 0177;
#ifdef notdef
if (boolean(value(VERBOSE)))
- putchar(c);
+ (void) putchar(c);
#endif
} while (c != '\n' && c != match);
- signal(SIGALRM, SIG_DFL);
+ (void) signal(SIGALRM, SIG_DFL);
return (c == match);
}
@@ -161,7 +168,7 @@ gobble(match)
* there are gory ways to simulate this.
*/
static int
-vensync(fd)
+vensync(int fd)
{
int already = 0, nread;
char buf[60];
@@ -175,39 +182,39 @@ vensync(fd)
* If you don't have the ioctl calls to diddle directly
* with DTR, you can always try setting the baud rate to 0.
*/
- ioctl(FD, TIOCMBIC, &dtr);
- sleep(2);
- ioctl(FD, TIOCMBIS, &dtr);
+ (void) ioctl(FD, TIOCMBIC, &dtr);
+ (void) sleep(2);
+ (void) ioctl(FD, TIOCMBIS, &dtr);
while (already < MAXRETRY) {
/*
* After reseting the modem, send it two \r's to
* autobaud on. Make sure to delay between them
* so the modem can frame the incoming characters.
*/
- write(fd, "\r", 1);
+ (void) write(fd, "\r", 1);
#ifdef VMUNIX
{
#include <sys/time.h>
struct timeval tv = {0, 500000};
- select(0, 0, 0, 0, &tv);
+ (void) select(0, 0, 0, 0, &tv);
}
#else
- sleep(1);
+ (void) sleep(1);
#endif
- write(fd, "\r", 1);
- sleep(3);
+ (void) write(fd, "\r", 1);
+ (void) sleep(3);
if (ioctl(fd, FIONREAD, (caddr_t)&nread) < 0) {
perror("tip: ioctl");
continue;
}
while (nread > 0) {
- read(fd, buf, min(nread, 60));
+ (void) read(fd, buf, min(nread, 60));
if ((buf[nread - 1] & 0177) == '$')
return (1);
nread -= min(nread, 60);
}
- sleep(1);
+ (void) sleep(1);
already++;
}
return (0);
diff --git a/usr/src/cmd/tip/acutab.c b/usr/src/cmd/tip/acutab.c
index b7711869b2..db1cdb5022 100644
--- a/usr/src/cmd/tip/acutab.c
+++ b/usr/src/cmd/tip/acutab.c
@@ -1,22 +1,34 @@
/*
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
-#ident "%Z%%M% %I% %E% SMI" /* from UCB 4.7 6/25/83 */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
#include "tip.h"
-extern int df02_dialer(), df03_dialer(), df_disconnect(), df_abort(),
- biz31f_dialer(), biz31_disconnect(), biz31_abort(),
- biz31w_dialer(),
- biz22f_dialer(), biz22_disconnect(), biz22_abort(),
- biz22w_dialer(),
- hayes_dialer(), hayes_disconnect(), hayes_abort(),
- ven_dialer(), ven_disconnect(), ven_abort(),
- v3451_dialer(), v3451_disconnect(), v3451_abort(),
- v831_dialer(), v831_disconnect(), v831_abort(),
- dn_dialer(), dn_disconnect(), dn_abort();
+extern int df02_dialer(char *, char *), df03_dialer(char *, char *);
+extern int biz31f_dialer(char *, char *), biz31w_dialer(char *, char *);
+extern int biz22f_dialer(char *, char *), biz22w_dialer(char *, char *);
+extern int hayes_dialer(char *, char *);
+extern int ven_dialer(char *, char *);
+extern int v3451_dialer(char *, char *);
+extern int v831_dialer(char *, char *);
+extern int dn_dialer(char *, char *);
+extern void df_disconnect(void), df_abort(void);
+extern void biz31_disconnect(void), biz31_abort(void);
+extern void biz22_disconnect(void), biz22_abort(void);
+extern void hayes_disconnect(void), hayes_abort(void);
+extern void ven_disconnect(void), ven_abort(void);
+extern void v3451_disconnect(void), v3451_abort(void);
+extern void v831_disconnect(void), v831_abort(void);
+extern void dn_disconnect(void), dn_abort(void);
acu_t acutable[] = {
#if BIZ1031
diff --git a/usr/src/cmd/tip/cmds.c b/usr/src/cmd/tip/cmds.c
index 79fc0d58a3..d4ae2d66e4 100644
--- a/usr/src/cmd/tip/cmds.c
+++ b/usr/src/cmd/tip/cmds.c
@@ -2,13 +2,14 @@
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
+
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
-#ident "%Z%%M% %I% %E% SMI" /* from UCB 5.4 5/5/86 */
+#pragma ident "%Z%%M% %I% %E% SMI"
#include "tip.h"
#ifdef USG
@@ -31,19 +32,28 @@ static char *argv[10]; /* argument vector for take and put */
sigjmp_buf intbuf; /* for interrupts and timeouts */
-void timeout(); /* timeout function called on alarm */
-void intcopy(); /* interrupt routine for file transfers */
+void timeout(void); /* timeout function called on alarm */
+void intcopy(void); /* interrupt routine for file transfers */
+void transfer(char *, int, char *);
+void transmit(FILE *, char *, char *);
+void send(char);
+void execute(char *);
+void prtime(char *, time_t);
+void hardwareflow(char *);
+void intr(char *);
+int args(char *, char *[], size_t);
+int anyof(char *, char *);
/*
* FTP - remote ==> local
* get a file from the remote host
*/
-getfl(c)
- char c;
+void
+getfl(int c)
{
- char buf[256], *cp, *expand();
+ char buf[256], *cp;
- putchar(c);
+ (void) putchar(c);
/*
* get the UNIX receiving file's name
*/
@@ -53,7 +63,7 @@ getfl(c)
if (cp == NOSTR)
return;
if ((sfd = creat(cp, 0666)) < 0) {
- printf("\r\n%s: cannot creat\r\n", copyname);
+ (void) printf("\r\n%s: cannot creat\r\n", copyname);
return;
}
@@ -61,7 +71,7 @@ getfl(c)
* collect parameters
*/
if (prompt("List command for remote system? ", buf, sizeof (buf))) {
- unlink(copyname);
+ (void) unlink(copyname);
return;
}
transfer(buf, sfd, value(EOFREAD));
@@ -70,17 +80,18 @@ getfl(c)
/*
* Cu-like take command
*/
-cu_take(cc)
- char cc;
+/* ARGSUSED */
+void
+cu_take(int cc)
{
int fd, argc;
- char line[BUFSIZ], *expand(), *cp;
+ char line[BUFSIZ], *cp;
if (prompt("[take] ", copyname, sizeof (copyname)))
return;
argc = args(copyname, argv, sizeof (argv)/sizeof (char *));
if (argc < 1 || argc > 2) {
- printf("usage: <take> from [to]\r\n");
+ (void) printf("usage: <take> from [to]\r\n");
return;
}
if (argc == 1)
@@ -89,10 +100,10 @@ cu_take(cc)
if (cp == NOSTR)
return;
if ((fd = creat(cp, 0666)) < 0) {
- printf("\r\n%s: cannot create\r\n", argv[1]);
+ (void) printf("\r\n%s: cannot create\r\n", argv[1]);
return;
}
- sprintf(line, "cat %s; echo \01", argv[0]);
+ (void) snprintf(line, sizeof (line), "cat %s; echo \01", argv[0]);
transfer(line, fd, "\01");
}
@@ -100,31 +111,33 @@ cu_take(cc)
* Bulk transfer routine --
* used by getfl(), cu_take(), and pipefile()
*/
-transfer(buf, fd, eofchars)
- char *buf, *eofchars;
+void
+transfer(char *buf, int fd, char *eofchars)
{
- register int ct;
+ int ct;
char c, buffer[BUFSIZ];
char *p = buffer; /* can't be register because of longjmp */
- register int cnt, eof, bol;
+ int cnt, eof, bol;
time_t start;
- void (*f)();
+ sig_handler_t f;
- parwrite(FD, buf, strlen(buf));
- kill(pid, SIGIOT);
- read(repdes[0], (char *)&ccc, 1); /* Wait until read process stops */
+ parwrite(FD, (unsigned char *)buf, strlen(buf));
+ (void) kill(pid, SIGIOT);
+ /* Wait until read process stops */
+ (void) read(repdes[0], (char *)&ccc, 1);
/*
* finish command
*/
- parwrite(FD, "\r", 1);
+ parwrite(FD, (unsigned char *)"\r", 1);
do
- read(FD, &c, 1);
- while ((c&0177) != '\n');
+ (void) read(FD, &c, 1);
+ while ((c&0177) != '\n')
+ ;
if (sigsetjmp(intbuf, 1))
goto out;
- f = signal(SIGINT, intcopy);
+ f = signal(SIGINT, (sig_handler_t)intcopy);
intr("on");
start = time(0);
@@ -147,75 +160,76 @@ transfer(buf, fd, eofchars)
if (c == '\n') {
bol = 1;
if (boolean(value(VERBOSE)))
- printf("\r%d", ++ct);
+ (void) printf("\r%d", ++ct);
} else
bol = 0;
if ((cnt = (p-buffer)) == number(value(FRAMESIZE))) {
if (write(fd, buffer, cnt) != cnt) {
- printf("\r\nwrite error\r\n");
+ (void) printf("\r\nwrite error\r\n");
goto out;
}
p = buffer;
}
}
out:
- if (cnt = (p-buffer))
+ if ((cnt = (p-buffer)) != 0)
if (write(fd, buffer, cnt) != cnt)
- printf("\r\nwrite error\r\n");
+ (void) printf("\r\nwrite error\r\n");
if (boolean(value(VERBOSE)))
prtime(" lines transferred in ", time(0)-start);
intr("off");
- write(fildes[1], (char *)&ccc, 1);
- signal(SIGINT, f);
- close(fd);
+ (void) write(fildes[1], (char *)&ccc, 1);
+ (void) signal(SIGINT, f);
+ (void) close(fd);
}
/*
* FTP - remote ==> local process
* send remote input to local process via pipe
*/
-pipefile()
+/* ARGSUSED */
+void
+pipefile(int cc)
{
int cpid, pdes[2];
char buf[256];
int status, p;
- extern int errno;
if (prompt("Local command? ", buf, sizeof (buf)))
return;
if (pipe(pdes)) {
- printf("can't establish pipe\r\n");
+ (void) printf("can't establish pipe\r\n");
return;
}
if ((cpid = fork()) < 0) {
- printf("can't fork!\r\n");
+ (void) printf("can't fork!\r\n");
return;
} else if (cpid) {
if (prompt("List command for remote system? ", buf,
- sizeof (buf))) {
- close(pdes[0]), close(pdes[1]);
- kill(cpid, SIGKILL);
+ sizeof (buf))) {
+ (void) close(pdes[0]), (void) close(pdes[1]);
+ (void) kill(cpid, SIGKILL);
} else {
- close(pdes[0]);
- signal(SIGPIPE, intcopy);
+ (void) close(pdes[0]);
+ (void) signal(SIGPIPE, (sig_handler_t)intcopy);
transfer(buf, pdes[1], value(EOFREAD));
- signal(SIGPIPE, SIG_DFL);
+ (void) signal(SIGPIPE, SIG_DFL);
while ((p = wait(&status)) > 0 && p != cpid)
;
}
} else {
- register int f;
+ int f;
userperm();
- dup2(pdes[0], 0);
- close(pdes[0]);
+ (void) dup2(pdes[0], 0);
+ (void) close(pdes[0]);
for (f = 3; f < 20; f++)
- close(f);
+ (void) close(f);
execute(buf);
- printf("can't execl!\r\n");
+ (void) printf("can't execl!\r\n");
exit(0);
}
}
@@ -225,14 +239,13 @@ pipefile()
* send local file to remote host
* terminate transmission with pseudo EOF sequence
*/
-sendfile(cc)
- char cc;
+void
+tip_sendfile(int cc)
{
FILE *fd;
char *fnamex;
- char *expand();
- putchar(cc);
+ (void) putchar(cc);
/*
* get file name
*/
@@ -246,53 +259,54 @@ sendfile(cc)
if (fnamex == NOSTR)
return;
if ((fd = fopen(fnamex, "r")) == NULL) {
- printf("%s: cannot open\r\n", fname);
+ (void) printf("%s: cannot open\r\n", fname);
return;
}
transmit(fd, value(EOFWRITE), NULL);
if (!boolean(value(ECHOCHECK))) {
struct termios buf;
- ioctl(FD, TCGETS, (char *)&buf); /* this does a */
- ioctl(FD, TCSETSF, (char *)&buf); /* wflushtty */
+ (void) ioctl(FD, TCGETS, (char *)&buf); /* this does a */
+ (void) ioctl(FD, TCSETSF, (char *)&buf); /* wflushtty */
}
}
/*
* Bulk transfer routine to remote host --
- * used by sendfile() and cu_put()
+ * used by tip_sendfile() and cu_put()
*/
-transmit(fd, eofchars, command)
- FILE *fd;
- char *eofchars, *command;
+void
+transmit(FILE *fd, char *eofchars, char *command)
{
- void (*ointr)();
+ sig_handler_t ointr;
char *pc, lastc, rc;
int c, ccount, lcount;
time_t start_t, stop_t;
- kill(pid, SIGIOT); /* put TIPOUT into a wait state */
+ (void) kill(pid, SIGIOT); /* put TIPOUT into a wait state */
timedout = 0;
if (sigsetjmp(intbuf, 1)) {
if (timedout)
- printf("\r\ntimed out at eol\r\n");
- alarm(0);
+ (void) printf("\r\ntimed out at eol\r\n");
+ (void) alarm(0);
goto out;
}
- ointr = signal(SIGINT, intcopy);
+ ointr = signal(SIGINT, (sig_handler_t)intcopy);
intr("on");
- read(repdes[0], (char *)&ccc, 1);
+ (void) read(repdes[0], (char *)&ccc, 1);
if (command != NULL) {
for (pc = command; *pc; pc++)
send(*pc);
if (boolean(value(ECHOCHECK)))
- read(FD, (char *)&c, 1); /* trailing \n */
+ (void) read(FD, (char *)&c, 1); /* trailing \n */
else {
struct termios buf;
-
- sleep(5); /* wait for remote stty to take effect */
- ioctl(FD, TCGETS, (char *)&buf); /* this does a */
- ioctl(FD, TCSETSF, (char *)&buf); /* wflushtty */
+ /* wait for remote stty to take effect */
+ (void) sleep(5);
+ /* this does a */
+ (void) ioctl(FD, TCGETS, (char *)&buf);
+ /* wflushtty */
+ (void) ioctl(FD, TCSETSF, (char *)&buf);
}
}
lcount = 0;
@@ -303,10 +317,10 @@ transmit(fd, eofchars, command)
lcount++;
send(c);
if (boolean(value(VERBOSE)) && lcount%100 == 0)
- printf("\r%d", lcount);
+ (void) printf("\r%d", lcount);
}
if (boolean(value(VERBOSE)))
- printf("\r%d", lcount);
+ (void) printf("\r%d", lcount);
goto out;
}
for (;;) {
@@ -334,13 +348,13 @@ transmit(fd, eofchars, command)
send(c);
} while (c != '\r');
if (boolean(value(VERBOSE)))
- printf("\r%d", ++lcount);
+ (void) printf("\r%d", ++lcount);
if (boolean(value(ECHOCHECK))) {
- alarm(number(value(ETIMEOUT)));
+ (void) alarm(number(value(ETIMEOUT)));
do { /* wait for prompt */
- read(FD, &rc, 1);
+ (void) read(FD, &rc, 1);
} while ((rc&0177) != character(value(PROMPT)));
- alarm(0);
+ (void) alarm(0);
}
}
out:
@@ -350,34 +364,34 @@ out:
for (pc = eofchars; *pc; pc++)
send(*pc);
stop_t = time(0);
- fclose(fd);
+ (void) fclose(fd);
if (boolean(value(VERBOSE)))
if (boolean(value(RAWFTP)))
prtime(" chars transferred in ", stop_t-start_t);
else
prtime(" lines transferred in ", stop_t-start_t);
- write(fildes[1], (char *)&ccc, 1);
+ (void) write(fildes[1], (char *)&ccc, 1);
intr("off");
- signal(SIGINT, ointr);
+ (void) signal(SIGINT, ointr);
}
/*
* Cu-like put command
*/
-cu_put(cc)
- char cc;
+/* ARGSUSED */
+void
+cu_put(int cc)
{
FILE *fd;
char line[BUFSIZ];
int argc;
- char *expand();
char *copynamex;
if (prompt("[put] ", copyname, sizeof (copyname)))
return;
argc = args(copyname, argv, sizeof (argv)/sizeof (char *));
if (argc < 1 || argc > 2) {
- printf("usage: <put> from [to]\r\n");
+ (void) printf("usage: <put> from [to]\r\n");
return;
}
if (argc == 1)
@@ -386,13 +400,14 @@ cu_put(cc)
if (copynamex == NOSTR)
return;
if ((fd = fopen(copynamex, "r")) == NULL) {
- printf("%s: cannot open\r\n", copynamex);
+ (void) printf("%s: cannot open\r\n", copynamex);
return;
}
if (boolean(value(ECHOCHECK)))
- sprintf(line, "cat>%s\r", argv[1]);
+ (void) snprintf(line, sizeof (line), "cat>%s\r", argv[1]);
else
- sprintf(line, "stty -echo; cat>%s; stty echo\r", argv[1]);
+ (void) snprintf(line, sizeof (line),
+ "stty -echo; cat>%s; stty echo\r", argv[1]);
transmit(fd, "\04", line);
}
@@ -400,14 +415,14 @@ cu_put(cc)
* FTP - send single character
* wait for echo & handle timeout
*/
-send(c)
- char c;
+void
+send(char c)
{
char cc;
int retry = 0;
cc = c;
- parwrite(FD, &cc, 1);
+ parwrite(FD, (unsigned char *)&cc, 1);
#ifdef notdef
if (number(value(CDELAY)) > 0 && c != '\r')
nap(number(value(CDELAY)));
@@ -422,21 +437,21 @@ send(c)
tryagain:
timedout = 0;
if (sigsetjmp(intbuf, 1) && timedout) {
- printf("\r\ntimeout error (%s)\r\n", ctrl(c));
+ (void) printf("\r\ntimeout error (%s)\r\n", ctrl(c));
if (retry++ > 3)
return;
- parwrite(FD, &null, 1); /* poke it */
+ parwrite(FD, (unsigned char *)&null, 1); /* poke it */
goto tryagain;
}
- alarm(number(value(ETIMEOUT)));
- read(FD, &cc, 1);
- alarm(0);
+ (void) alarm(number(value(ETIMEOUT)));
+ (void) read(FD, &cc, 1);
+ (void) alarm(0);
}
void
-timeout()
+timeout(void)
{
- signal(SIGALRM, (sig_handler_t)timeout);
+ (void) signal(SIGALRM, (sig_handler_t)timeout);
timedout = 1;
siglongjmp(intbuf, 1);
}
@@ -445,49 +460,50 @@ timeout()
* Stolen from consh() -- puts a remote file on the output of a local command.
* Identical to consh() except for where stdout goes.
*/
-pipeout(c)
+void
+pipeout(int c)
{
char buf[256];
int cpid, status, p;
time_t start;
- putchar(c);
+ (void) putchar(c);
if (prompt("Local command? ", buf, sizeof (buf)))
return;
- kill(pid, SIGIOT); /* put TIPOUT into a wait state */
- signal(SIGINT, SIG_IGN);
- signal(SIGQUIT, SIG_IGN);
+ (void) kill(pid, SIGIOT); /* put TIPOUT into a wait state */
+ (void) signal(SIGINT, SIG_IGN);
+ (void) signal(SIGQUIT, SIG_IGN);
intr("on");
- read(repdes[0], (char *)&ccc, 1);
+ (void) read(repdes[0], (char *)&ccc, 1);
/*
* Set up file descriptors in the child and
* let it go...
*/
if ((cpid = fork()) < 0)
- printf("can't fork!\r\n");
+ (void) printf("can't fork!\r\n");
else if (cpid) {
start = time(0);
while ((p = wait(&status)) > 0 && p != cpid)
;
} else {
- register int i;
+ int i;
userperm();
- dup2(FD, 1);
+ (void) dup2(FD, 1);
for (i = 3; i < 20; i++)
- close(i);
- signal(SIGINT, SIG_DFL);
- signal(SIGQUIT, SIG_DFL);
+ (void) close(i);
+ (void) signal(SIGINT, SIG_DFL);
+ (void) signal(SIGQUIT, SIG_DFL);
execute(buf);
- printf("can't find `%s'\r\n", buf);
+ (void) printf("can't find `%s'\r\n", buf);
exit(0);
}
if (boolean(value(VERBOSE)))
prtime("away for ", time(0)-start);
- write(fildes[1], (char *)&ccc, 1);
+ (void) write(fildes[1], (char *)&ccc, 1);
intr("off");
- signal(SIGINT, SIG_DFL);
- signal(SIGQUIT, SIG_DFL);
+ (void) signal(SIGINT, SIG_DFL);
+ (void) signal(SIGQUIT, SIG_DFL);
}
/*
@@ -496,18 +512,19 @@ pipeout(c)
* 1 <-> remote tty out
* 2 <-> local tty stderr out
*/
-consh(c)
+void
+consh(int c)
{
char buf[256];
int cpid, status, p;
- void (*ointr)(), (*oquit)();
+ sig_handler_t ointr, oquit;
time_t start;
- putchar(c);
+ (void) putchar(c);
if (prompt("Local command? ", buf, sizeof (buf)))
return;
- kill(pid, SIGIOT); /* put TIPOUT into a wait state */
- read(repdes[0], (char *)&ccc, 1);
+ (void) kill(pid, SIGIOT); /* put TIPOUT into a wait state */
+ (void) read(repdes[0], (char *)&ccc, 1);
ointr = signal(SIGINT, SIG_IGN);
oquit = signal(SIGQUIT, SIG_IGN);
unraw();
@@ -516,43 +533,45 @@ consh(c)
* let it go...
*/
if ((cpid = fork()) < 0)
- printf("can't fork!\r\n");
+ (void) printf("can't fork!\r\n");
else if (cpid) {
start = time(0);
while ((p = wait(&status)) > 0 && p != cpid)
;
raw();
- signal(SIGINT, ointr);
- signal(SIGQUIT, oquit);
+ (void) signal(SIGINT, ointr);
+ (void) signal(SIGQUIT, oquit);
} else {
- register int i;
+ int i;
userperm();
- dup2(FD, 0);
- dup2(0, 1);
+ (void) dup2(FD, 0);
+ (void) dup2(0, 1);
for (i = 3; i < 20; i++)
- close(i);
- signal(SIGINT, SIG_DFL);
- signal(SIGQUIT, SIG_DFL);
+ (void) close(i);
+ (void) signal(SIGINT, SIG_DFL);
+ (void) signal(SIGQUIT, SIG_DFL);
execute(buf);
- printf("can't find `%s'\r\n", buf);
+ (void) printf("can't find `%s'\r\n", buf);
exit(0);
}
if (boolean(value(VERBOSE)))
prtime("\r\naway for ", time(0)-start);
- write(fildes[1], (char *)&ccc, 1);
+ (void) write(fildes[1], (char *)&ccc, 1);
}
/*
* Escape to local shell
*/
-shell()
+/* ARGSUSED */
+void
+shell(int cc)
{
int shpid, status;
- void (*ointr)(), (*oquit)();
+ sig_handler_t ointr, oquit;
char *cp;
- printf("[sh]\r\n");
+ (void) printf("[sh]\r\n");
ointr = signal(SIGINT, SIG_IGN);
oquit = signal(SIGQUIT, SIG_IGN);
unraw();
@@ -560,19 +579,19 @@ shell()
while (shpid != wait(&status))
;
raw();
- printf("\r\n!\r\n");
- signal(SIGINT, ointr);
- signal(SIGQUIT, oquit);
+ (void) printf("\r\n!\r\n");
+ (void) signal(SIGINT, ointr);
+ (void) signal(SIGQUIT, oquit);
} else {
userperm();
- signal(SIGQUIT, SIG_DFL);
- signal(SIGINT, SIG_DFL);
+ (void) signal(SIGQUIT, SIG_DFL);
+ (void) signal(SIGINT, SIG_DFL);
if ((cp = strrchr(value(SHELL), '/')) == NULL)
cp = value(SHELL);
else
cp++;
- execl(value(SHELL), cp, 0);
- printf("\r\ncan't execl!\r\n");
+ (void) execl(value(SHELL), cp, 0);
+ (void) printf("\r\ncan't execl!\r\n");
exit(1);
}
}
@@ -581,22 +600,23 @@ shell()
* TIPIN portion of scripting
* initiate the conversation with TIPOUT
*/
-setscript()
+void
+setscript(void)
{
char c;
/*
* enable TIPOUT side for dialogue
*/
- kill(pid, SIGEMT);
+ (void) kill(pid, SIGEMT);
if (boolean(value(SCRIPT)))
- write(fildes[1], value(RECORD), strlen(value(RECORD)));
- write(fildes[1], "\n", 1);
+ (void) write(fildes[1], value(RECORD), strlen(value(RECORD)));
+ (void) write(fildes[1], "\n", 1);
/*
* wait for TIPOUT to finish
*/
- read(repdes[0], &c, 1);
+ (void) read(repdes[0], &c, 1);
if (c == 'n')
- fprintf(stderr, "tip: can't create record file %s\r\n",
+ (void) fprintf(stderr, "tip: can't create record file %s\r\n",
value(RECORD));
}
@@ -604,10 +624,12 @@ setscript()
* Change current working directory of
* local portion of tip
*/
-chdirectory()
+/* ARGSUSED */
+void
+chdirectory(int cc)
{
char dirname[80];
- register char *cp = dirname;
+ char *cp = dirname;
if (prompt("[cd] ", dirname, sizeof (dirname))) {
if (stoprompt)
@@ -615,65 +637,65 @@ chdirectory()
cp = value(HOME);
}
if (chdir(cp) < 0)
- printf("%s: bad directory\r\n", cp);
- printf("!\r\n");
+ (void) printf("%s: bad directory\r\n", cp);
+ (void) printf("!\r\n");
}
-/* XXX - really should rename this routine to avoid conflict with libc */
-abort(msg)
- char *msg;
+void
+tip_abort(char *msg)
{
-
- signal(SIGCHLD, SIG_DFL); /* don't want to hear about our child */
- kill(pid, SIGTERM);
+ /* don't want to hear about our child */
+ (void) signal(SIGCHLD, SIG_DFL);
+ (void) kill(pid, SIGTERM);
myperm();
disconnect(msg);
if (msg != NOSTR)
- printf("\r\n%s", msg);
- printf("\r\n[EOT]\r\n");
+ (void) printf("\r\n%s", msg);
+ (void) printf("\r\n[EOT]\r\n");
delock(uucplock);
unraw();
exit(0);
}
-finish()
+/* ARGSUSED */
+void
+finish(int cc)
{
char *dismsg;
if ((dismsg = value(DISCONNECT)) != NOSTR) {
- write(FD, dismsg, strlen(dismsg));
- sleep(5);
+ (void) write(FD, dismsg, strlen(dismsg));
+ (void) sleep(5);
}
- abort(NOSTR);
+ tip_abort(NOSTR);
}
void
-intcopy()
+intcopy(void)
{
- signal(SIGINT, SIG_IGN);
+ (void) signal(SIGINT, SIG_IGN);
siglongjmp(intbuf, 1);
}
-execute(s)
- char *s;
+void
+execute(char *s)
{
- register char *cp;
+ char *cp;
if ((cp = strrchr(value(SHELL), '/')) == NULL)
cp = value(SHELL);
else
cp++;
- execl(value(SHELL), cp, "-c", s, 0);
+ (void) execl(value(SHELL), cp, "-c", s, 0);
}
-args(buf, a, na)
- char *buf, *a[];
- size_t na;
+int
+args(char *buf, char *a[], size_t na)
{
- register char *p = buf, *start;
- register char **parg = a;
- register int n = 0;
+ char *p = buf, *start;
+ char **parg = a;
+ int n = 0;
do {
while (*p && (*p == ' ' || *p == '\t'))
@@ -692,26 +714,27 @@ args(buf, a, na)
return (n);
}
-prtime(s, a)
- char *s;
- time_t a;
+void
+prtime(char *s, time_t a)
{
- register i;
+ int i;
int nums[3];
for (i = 0; i < 3; i++) {
nums[i] = (int)(a % quant[i]);
a /= quant[i];
}
- printf("%s", s);
+ (void) printf("%s", s);
while (--i >= 0)
if (nums[i] || i == 0 && nums[1] == 0 && nums[2] == 0)
- printf("%d %s%c ", nums[i], sep[i],
- nums[i] == 1 ? '\0' : 's');
- printf("\r\n!\r\n");
+ (void) printf("%d %s%c ", nums[i], sep[i],
+ nums[i] == 1 ? '\0' : 's');
+ (void) printf("\r\n!\r\n");
}
-variable()
+/* ARGSUSED */
+void
+variable(int cc)
{
char buf[256];
@@ -720,7 +743,7 @@ variable()
vlex(buf);
if (vtable[BEAUTIFY].v_access&CHANGED) {
vtable[BEAUTIFY].v_access &= ~CHANGED;
- kill(pid, SIGSYS);
+ (void) kill(pid, SIGSYS);
}
if (vtable[SCRIPT].v_access&CHANGED) {
vtable[SCRIPT].v_access &= ~CHANGED;
@@ -768,12 +791,12 @@ variable()
/*
* Turn tandem mode on or off for remote tty.
*/
-tandem(option)
- char *option;
+void
+tandem(char *option)
{
struct termios rmtty;
- ioctl(FD, TCGETS, (char *)&rmtty);
+ (void) ioctl(FD, TCGETS, (char *)&rmtty);
if (equal(option, "on")) {
rmtty.c_iflag |= IXOFF|IXON;
arg.c_iflag |= IXOFF|IXON;
@@ -783,59 +806,61 @@ tandem(option)
rmtty.c_iflag &= ~(IXOFF|IXON);
arg.c_iflag &= ~(IXOFF|IXON);
}
- ioctl(FD, TCSETSF, (char *)&rmtty);
- ioctl(0, TCSETSF, (char *)&arg);
+ (void) ioctl(FD, TCSETSF, (char *)&rmtty);
+ (void) ioctl(0, TCSETSF, (char *)&arg);
}
/*
* Turn hardwareflow mode on or off for remote tty.
*/
-hardwareflow(option)
- char *option;
+void
+hardwareflow(char *option)
{
struct termios rmtty;
- ioctl(FD, TCGETS, (char *)&rmtty);
+ (void) ioctl(FD, TCGETS, (char *)&rmtty);
if (equal(option, "on")) {
rmtty.c_cflag |= (CRTSCTS|CRTSXOFF);
} else {
rmtty.c_cflag &= ~(CRTSCTS|CRTSXOFF);
}
- ioctl(FD, TCSETSF, (char *)&rmtty);
+ (void) ioctl(FD, TCSETSF, (char *)&rmtty);
}
/*
* Turn interrupts from local tty on or off.
*/
-intr(option)
- char *option;
+void
+intr(char *option)
{
if (equal(option, "on"))
arg.c_lflag |= ISIG;
else
arg.c_lflag &= ~ISIG;
- ioctl(0, TCSETSF, (char *)&arg);
+ (void) ioctl(0, TCSETSF, (char *)&arg);
}
/*
* Send a break.
*/
-genbrk()
+/* ARGSUSED */
+void
+genbrk(int cc)
{
- ioctl(FD, TCSBRK, 0);
+ (void) ioctl(FD, TCSBRK, 0);
}
/*
* Suspend tip
*/
-suspend(c)
- char c;
+void
+suspend(int c)
{
unraw();
- kill(c == _CTRL('y') ? getpid() : 0, SIGTSTP);
+ (void) kill(c == _CTRL('y') ? getpid() : 0, SIGTSTP);
raw();
}
@@ -844,52 +869,48 @@ suspend(c)
*/
char *
-expand(name)
- char name[];
+expand(char name[])
{
static char xname[BUFSIZ];
char cmdbuf[BUFSIZ];
- register int pid, l, rc;
- register char *cp, *Shell;
+ int pid, l;
+ char *cp, *Shell;
int s, pivec[2];
- void (*sigint)();
if (!anyof(name, "~{[*?$`'\"\\"))
return (name);
- /* sigint = signal(SIGINT, SIG_IGN); */
if (pipe(pivec) < 0) {
perror("pipe");
- /* signal(SIGINT, sigint) */
return (name);
}
- sprintf(cmdbuf, "echo %s", name);
+ (void) snprintf(cmdbuf, sizeof (cmdbuf), "echo %s", name);
if ((pid = vfork()) == 0) {
userperm();
Shell = value(SHELL);
if (Shell == NOSTR)
Shell = "/bin/sh";
- close(pivec[0]);
- close(1);
- dup(pivec[1]);
- close(pivec[1]);
- close(2);
- execl(Shell, Shell, "-c", cmdbuf, 0);
+ (void) close(pivec[0]);
+ (void) close(1);
+ (void) dup(pivec[1]);
+ (void) close(pivec[1]);
+ (void) close(2);
+ (void) execl(Shell, Shell, "-c", cmdbuf, 0);
_exit(1);
}
if (pid == -1) {
perror("fork");
- close(pivec[0]);
- close(pivec[1]);
+ (void) close(pivec[0]);
+ (void) close(pivec[1]);
return (NOSTR);
}
- close(pivec[1]);
+ (void) close(pivec[1]);
l = read(pivec[0], xname, BUFSIZ);
- close(pivec[0]);
- while (wait(&s) != pid);
+ (void) close(pivec[0]);
+ while (wait(&s) != pid)
;
s &= 0377;
if (s != 0 && s != SIGPIPE) {
- fprintf(stderr, "\"Echo\" failed\n");
+ (void) fprintf(stderr, "\"Echo\" failed\n");
return (NOSTR);
}
if (l < 0) {
@@ -897,11 +918,12 @@ expand(name)
return (NOSTR);
}
if (l == 0) {
- fprintf(stderr, "\"%s\": No match\n", name);
+ (void) fprintf(stderr, "\"%s\": No match\n", name);
return (NOSTR);
}
if (l == BUFSIZ) {
- fprintf(stderr, "Buffer overflow expanding \"%s\"\n", name);
+ (void) fprintf(stderr, "Buffer overflow expanding \"%s\"\n",
+ name);
return (NOSTR);
}
xname[l] = 0;
@@ -915,12 +937,12 @@ expand(name)
* Are any of the characters in the two strings the same?
*/
-anyof(s1, s2)
- register char *s1, *s2;
+int
+anyof(char *s1, char *s2)
{
- register int c;
+ int c;
- while (c = *s1++)
+ while ((c = *s1++) != 0)
if (any(c, s2))
return (1);
return (0);
diff --git a/usr/src/cmd/tip/cmdtab.c b/usr/src/cmd/tip/cmdtab.c
index 52857f5685..0ed17854a8 100644
--- a/usr/src/cmd/tip/cmdtab.c
+++ b/usr/src/cmd/tip/cmdtab.c
@@ -2,24 +2,26 @@
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
+
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
-#ident "%Z%%M% %I% %E% SMI" /* from UCB 5.3 5/5/86 */
+#pragma ident "%Z%%M% %I% %E% SMI"
#include "tip.h"
-extern int shell(), getfl(), sendfile(), chdirectory();
-extern int finish(), help(), pipefile(), pipeout(), consh(), variable();
-extern int cu_take(), cu_put(), dollar(), genbrk(), suspend();
+extern void shell(int), getfl(int), tip_sendfile(int), chdirectory(int);
+extern void finish(int), help(int), pipefile(int), pipeout(int);
+extern void consh(int), variable(int), cu_take(int), cu_put(int);
+extern void genbrk(int), suspend(int);
esctable_t etable[] = {
{ '!', NORM, "shell", shell },
{ '<', NORM, "receive file from remote host", getfl },
- { '>', NORM, "send file to remote host", sendfile },
+ { '>', NORM, "send file to remote host", tip_sendfile },
{ 't', NORM, "take file from remote UNIX", cu_take },
{ 'p', NORM, "put file to remote UNIX", cu_put },
{ '|', NORM, "pipe remote file", pipefile },
diff --git a/usr/src/cmd/tip/cu.c b/usr/src/cmd/tip/cu.c
index e67101f8bc..3f4cee8add 100644
--- a/usr/src/cmd/tip/cu.c
+++ b/usr/src/cmd/tip/cu.c
@@ -2,32 +2,33 @@
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
+
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
-#ident "%Z%%M% %I% %E% SMI" /* from UCB 5.2 1/13/86 */
+#pragma ident "%Z%%M% %I% %E% SMI"
#include "tip.h"
-void cleanup();
-void timeout();
+void cleanup(void);
+void timeout(void);
/*
* Botch the interface to look like cu's
*/
-cumain(argc, argv)
- char *argv[];
+void
+cumain(int argc, char *argv[])
{
- register int i;
+ int i;
static char sbuf[12];
if (argc < 2) {
usage:
- fprintf(stderr,
- "usage: cu telno [-t] [-s speed] [-a acu] [-l line] [-#]\n");
+ (void) fprintf(stderr,
+ "usage: cu telno [-t] [-s speed] [-a acu] [-l line] [-#]\n");
exit(8);
}
CU = DV = NOSTR;
@@ -35,8 +36,9 @@ usage:
if (argv[1][0] != '-')
PN = argv[1];
else if (argv[1][1] != '\0' && argv[1][2] != '\0') {
- fprintf(stderr, "cu: extra characters after flag: %s\n",
- argv[1]);
+ (void) fprintf(stderr,
+ "cu: extra characters after flag: %s\n",
+ argv[1]);
goto usage;
} else switch (argv[1][1]) {
@@ -53,8 +55,9 @@ usage:
if (argc < 3)
goto usage;
if (speed(atoi(argv[2])) == 0) {
- fprintf(stderr, "cu: unsupported speed %s\n",
- argv[2]);
+ (void) fprintf(stderr,
+ "cu: unsupported speed %s\n",
+ argv[2]);
exit(3);
}
BR = atoi(argv[2]); ++argv; --argc;
@@ -73,26 +76,26 @@ usage:
break;
default:
- fprintf(stderr, "cu: bad flag %s\n", argv[1]);
+ (void) fprintf(stderr, "cu: bad flag %s\n", argv[1]);
goto usage;
}
}
- signal(SIGINT, cleanup);
- signal(SIGQUIT, cleanup);
- signal(SIGHUP, cleanup);
- signal(SIGTERM, cleanup);
+ (void) signal(SIGINT, (sig_handler_t)cleanup);
+ (void) signal(SIGQUIT, (sig_handler_t)cleanup);
+ (void) signal(SIGHUP, (sig_handler_t)cleanup);
+ (void) signal(SIGTERM, (sig_handler_t)cleanup);
/*
* The "cu" host name is used to define the
* attributes of the generic dialer.
*/
- sprintf(sbuf, "cu%d", BR);
+ (void) sprintf(sbuf, "cu%d", BR);
if ((i = hunt(sbuf)) == 0) {
- printf("all ports busy\n");
+ (void) printf("all ports busy\n");
exit(3);
}
if (i == -1) {
- printf("link down\n");
+ (void) printf("link down\n");
delock(uucplock);
exit(3);
}
@@ -109,7 +112,7 @@ usage:
if (HW)
ttysetup(speed(BR));
if (connect()) {
- printf("Connect failed\n");
+ (void) printf("Connect failed\n");
myperm();
delock(uucplock);
exit(1);
diff --git a/usr/src/cmd/tip/hunt.c b/usr/src/cmd/tip/hunt.c
index 77795255c4..f6280c2834 100644
--- a/usr/src/cmd/tip/hunt.c
+++ b/usr/src/cmd/tip/hunt.c
@@ -2,40 +2,39 @@
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
+
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
-#ident "%Z%%M% %I% %E% SMI" /* from UCB 4.7 6/25/83 */
-#include "tip.h"
+#pragma ident "%Z%%M% %I% %E% SMI"
-extern char *getremote();
-extern int errno;
+#include "tip.h"
static sigjmp_buf deadline;
static int deadfl;
void
-dead()
+dead(void)
{
deadfl = 1;
siglongjmp(deadline, 1);
}
-hunt(name)
- char *name;
+int
+hunt(char *name)
{
- register char *cp;
- void (*f)();
+ char *cp;
+ sig_handler_t f;
f = signal(SIGALRM, (sig_handler_t)dead);
while (cp = getremote(name)) {
deadfl = 0;
uucplock = cp;
- if (mlock(uucplock) < 0) {
+ if (tip_mlock(uucplock) < 0) {
delock(uucplock);
continue;
}
@@ -49,34 +48,35 @@ hunt(name)
if (!HW)
break;
if (sigsetjmp(deadline, 1) == 0) {
- alarm(10);
+ (void) alarm(10);
if (!trusted_device)
userperm();
errno = 0;
if ((FD = open(cp, O_RDWR)) < 0 && errno != EBUSY) {
- fprintf(stderr, "tip: ");
+ (void) fprintf(stderr, "tip: ");
perror(cp);
}
if (!trusted_device)
myperm();
if (FD >= 0 && !isatty(FD)) {
- fprintf(stderr, "tip: %s: not a tty\n", cp);
- close(FD);
+ (void) fprintf(stderr, "tip: %s: not a tty\n",
+ cp);
+ (void) close(FD);
FD = -1;
}
}
- alarm(0);
+ (void) alarm(0);
if (!deadfl && FD >= 0) {
struct termios t;
- ioctl(FD, TCGETS, &t);
+ (void) ioctl(FD, TCGETS, &t);
t.c_cflag |= XCLUDE|HUPCL;
- ioctl(FD, TCSETSF, &t);
- signal(SIGALRM, f);
+ (void) ioctl(FD, TCSETSF, &t);
+ (void) signal(SIGALRM, f);
return ((int)cp);
}
delock(uucplock);
}
- signal(SIGALRM, f);
+ (void) signal(SIGALRM, f);
return (deadfl ? -1 : (int)cp);
}
diff --git a/usr/src/cmd/tip/log.c b/usr/src/cmd/tip/log.c
index 6350746d24..b9d26ebf94 100644
--- a/usr/src/cmd/tip/log.c
+++ b/usr/src/cmd/tip/log.c
@@ -2,12 +2,14 @@
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
+
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
-#ident "%Z%%M% %I% %E% SMI" /* from UCB 4.6 6/25/83 */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
#include "tip.h"
@@ -16,9 +18,8 @@ static FILE *flog = NULL;
/*
* Log file maintenance routines
*/
-
-logent(group, num, acu, message)
- char *group, *num, *acu, *message;
+void
+logent(char *group, char *num, char *acu, char *message)
{
char *user, *timestamp;
struct passwd *pwd;
@@ -40,26 +41,28 @@ logent(group, num, acu, message)
t = time(0);
timestamp = ctime(&t);
timestamp[24] = '\0';
- fprintf(flog, "%s (%s) <%s, %s, %s> %s\n",
- user, timestamp, group,
+ (void) fprintf(flog, "%s (%s) <%s, %s, %s> %s\n",
+ user, timestamp, group,
#ifdef PRISTINE
- "",
+ "",
#else
- num,
+ num,
#endif
- acu, message);
- fflush(flog);
+ acu, message);
+ (void) fflush(flog);
#ifndef USG
(void) flock(fileno(flog), LOCK_UN);
#endif
}
-loginit()
+void
+loginit(void)
{
#ifdef ACULOG
flog = fopen(value(LOG), "a");
if (flog == NULL)
- fprintf(stderr, "tip: can't open log file %s\r\n", value(LOG));
+ (void) fprintf(stderr, "tip: can't open log file %s\r\n",
+ value(LOG));
#endif
}
diff --git a/usr/src/cmd/tip/partab.c b/usr/src/cmd/tip/partab.c
index 818269641d..682f292407 100644
--- a/usr/src/cmd/tip/partab.c
+++ b/usr/src/cmd/tip/partab.c
@@ -2,12 +2,14 @@
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
+
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
-#ident "%Z%%M% %I% %E% SMI" /* from UCB 4.2 6/25/83 */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Even parity table for 0-0177
diff --git a/usr/src/cmd/tip/remcap.c b/usr/src/cmd/tip/remcap.c
index ee515cf077..5159d8b4e2 100644
--- a/usr/src/cmd/tip/remcap.c
+++ b/usr/src/cmd/tip/remcap.c
@@ -1,14 +1,14 @@
/*
- * Copyright (c) 2000,2001 by Sun Microsystems, Inc.
- * All rights reserved.
+ * Copyright 2001 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
*/
-/* from UCB 4.8 6/25/83 */
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
+
#pragma ident "%Z%%M% %I% %E% SMI"
/*
@@ -24,6 +24,11 @@
#include <ctype.h>
#endif
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <ctype.h>
+
#ifndef BUFSIZ
#define BUFSIZ 1024
#endif
@@ -56,13 +61,20 @@ char *RM;
* doesn't, and because living w/o it is not hard.
*/
-static char *tbuf;
-static int hopcount; /* detect infinite loops in termcap, init 0 */
-char *tskip();
-char *tgetstr();
-char *tdecode();
-char *getenv();
-static char *remotefile;
+static char *tbuf;
+static int hopcount; /* detect infinite loops in termcap, init 0 */
+static char *remotefile;
+
+static char *tskip(char *);
+static char *tdecode(char *, char **);
+
+char *tgetstr(char *, char **);
+int getent(char *, char *, char *, int);
+int tnchktc(void);
+int tnamatch(char *);
+
+extern void myperm(void);
+extern void userperm(void);
/*
* If we use a user specified entry to get the device name,
@@ -75,9 +87,8 @@ int trusted_device = 0;
* from the termcap file. Parse is very rudimentary;
* we just notice escaped newlines.
*/
-tgetent(bp, name, len)
- char *bp, *name;
- int len;
+int
+tgetent(char *bp, char *name, int len)
{
char lbuf[BUFSIZ], *cp, *p;
int rc1, rc2;
@@ -101,22 +112,21 @@ tgetent(bp, name, len)
while (*p++ != ':')
;
if (strlen(bp) + strlen(p) >= len) {
- write(2, "Remcap entry too long\n", 23);
+ (void) write(2, "Remcap entry too long\n", 23);
return (-1);
}
- strcat(bp, p);
+ (void) strcat(bp, p);
}
tbuf = bp;
return (1);
}
}
-getent(bp, name, cp, len)
- char *bp, *name, *cp;
- int len;
+int
+getent(char *bp, char *name, char *cp, int len)
{
- register int c;
- register int i = 0, cnt = 0;
+ int c;
+ int i = 0, cnt = 0;
char ibuf[BUFSIZ], *cp2;
int tf;
int safe = 1; /* reset only when we open the user's $REMOTE */
@@ -136,7 +146,7 @@ getent(bp, name, cp, len)
if (cp2 == (char *)0 || strcmp(name, cp2) == 0) {
if (strstr(cp, "dv=") != 0)
trusted_device = 0;
- strncpy(bp, cp, len-1);
+ (void) strncpy(bp, cp, len-1);
bp[len-1] = '\0';
return (tnchktc());
} else
@@ -161,7 +171,7 @@ getent(bp, name, cp, len)
if (i == cnt) {
cnt = read(tf, ibuf, BUFSIZ);
if (cnt <= 0) {
- close(tf);
+ (void) close(tf);
return (0);
}
i = 0;
@@ -175,7 +185,7 @@ getent(bp, name, cp, len)
break;
}
if (cp >= bp+len) {
- write(2, "Remcap entry too long\n", 23);
+ (void) write(2, "Remcap entry too long\n", 23);
break;
} else
*cp++ = c;
@@ -192,7 +202,7 @@ getent(bp, name, cp, len)
*/
if (!safe && strstr(bp, "dv=") != 0)
trusted_device = 0;
- close(tf);
+ (void) close(tf);
return (tnchktc());
}
}
@@ -205,32 +215,32 @@ getent(bp, name, cp, len)
* entries to say "like an HP2621 but doesn't turn on the labels".
* Note that this works because of the left to right scan.
*/
-tnchktc()
+int
+tnchktc(void)
{
- register char *p, *q;
+ char *p, *q;
char tcname[64]; /* name of similar terminal */
char tcbuf[BUFSIZ];
char *holdtbuf = tbuf;
int l;
- char *cp;
p = tbuf + strlen(tbuf) - 2; /* before the last colon */
while (*--p != ':')
if (p < tbuf) {
- write(2, "Bad remcap entry\n", 18);
+ (void) write(2, "Bad remcap entry\n", 18);
return (0);
}
p++;
/* p now points to beginning of last field */
if (p[0] != 't' || p[1] != 'c')
return (1);
- strlcpy(tcname, p+3, sizeof (tcname));
+ (void) strlcpy(tcname, p+3, sizeof (tcname));
q = tcname;
while (*q && *q != ':')
q++;
*q = 0;
if (++hopcount > MAXHOP) {
- write(2, "Infinite tc= loop\n", 18);
+ (void) write(2, "Infinite tc= loop\n", 18);
return (0);
}
if (getent(tcbuf, tcname, remotefile, sizeof (tcbuf)) != 1) {
@@ -243,10 +253,10 @@ tnchktc()
;
l = p - holdtbuf + strlen(q);
if (l > BUFSIZ) {
- write(2, "Remcap entry too long\n", 23);
+ (void) write(2, "Remcap entry too long\n", 23);
q[BUFSIZ - (p-holdtbuf)] = 0;
}
- strcpy(p, q);
+ (void) strcpy(p, q);
tbuf = holdtbuf;
return (1);
}
@@ -257,10 +267,10 @@ tnchktc()
* against each such name. The normal : terminator after the last
* name (before the first field) stops us.
*/
-tnamatch(np)
- char *np;
+int
+tnamatch(char *np)
{
- register char *Np, *Bp;
+ char *Np, *Bp;
Bp = tbuf;
if (*Bp == '#')
@@ -284,8 +294,7 @@ tnamatch(np)
* into the termcap file in octal.
*/
static char *
-tskip(bp)
- register char *bp;
+tskip(char *bp)
{
while (*bp && *bp != ':')
@@ -308,11 +317,11 @@ tskip(bp)
* a # character. If the option is not found we return -1.
* Note that we handle octal numbers beginning with 0.
*/
-tgetnum(id)
- char *id;
+int
+tgetnum(char *id)
{
- register int i, base;
- register char *bp = tbuf;
+ int i, base;
+ char *bp = tbuf;
for (;;) {
bp = tskip(bp);
@@ -341,10 +350,10 @@ tgetnum(id)
* of the buffer. Return 1 if we find the option, or 0 if it is
* not given.
*/
-tgetflag(id)
- char *id;
+int
+tgetflag(char *id)
{
- register char *bp = tbuf;
+ char *bp = tbuf;
for (;;) {
bp = tskip(bp);
@@ -368,10 +377,9 @@ tgetflag(id)
* No checking on area overflow.
*/
char *
-tgetstr(id, area)
- char *id, **area;
+tgetstr(char *id, char **area)
{
- register char *bp = tbuf;
+ char *bp = tbuf;
for (;;) {
bp = tskip(bp);
@@ -393,17 +401,15 @@ tgetstr(id, area)
* string capability escapes.
*/
static char *
-tdecode(str, area)
- register char *str;
- char **area;
+tdecode(char *str, char **area)
{
- register char *cp;
- register int c;
- register char *dp;
+ char *cp;
+ int c;
+ char *dp;
int i;
cp = *area;
- while ((c = *str++) && c != ':') {
+ while ((c = *str++) != 0 && c != ':') {
switch (c) {
case '^':
@@ -425,7 +431,8 @@ nextc:
c -= '0', i = 2;
do
c <<= 3, c |= *str++ - '0';
- while (--i && isdigit(*str));
+ while (--i && isdigit(*str))
+ ;
}
break;
}
diff --git a/usr/src/cmd/tip/remote.c b/usr/src/cmd/tip/remote.c
index 57848eec8f..3dbe742ed4 100644
--- a/usr/src/cmd/tip/remote.c
+++ b/usr/src/cmd/tip/remote.c
@@ -2,13 +2,14 @@
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
+
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
-#ident "%Z%%M% %I% %E% SMI" /* from UCB 5.3 4/30/86 */
+#pragma ident "%Z%%M% %I% %E% SMI"
#include "tip.h"
@@ -26,17 +27,16 @@ static char *capstrings[] = {
"di", "es", "ex", "fo", "rc", "re", "pa", 0
};
-char *rgetstr();
+extern char *rgetstr(char *, char **);
-static
-getremcap(host)
- register char *host;
+static void
+getremcap(char *host)
{
int stat;
char tbuf[BUFSIZ];
static char buf[BUFSIZ/2];
char *bp = buf;
- register char **p, ***q;
+ char **p, ***q;
if ((stat = rgetent(tbuf, host, sizeof (tbuf))) <= 0) {
if (DV ||
@@ -61,9 +61,9 @@ getremcap(host)
ET = 10;
return;
}
- fprintf(stderr, stat == 0 ?
- "tip: unknown host %s\n" :
- "tip: can't open host description file\n", host);
+ (void) fprintf(stderr, stat == 0 ?
+ "tip: unknown host %s\n" :
+ "tip: can't open host description file\n", host);
exit(3);
}
@@ -79,13 +79,13 @@ getremcap(host)
else
DU = rgetflag("du");
if (DV == NOSTR) {
- fprintf(stderr, "%s: missing device spec\n", host);
+ (void) fprintf(stderr, "%s: missing device spec\n", host);
exit(3);
}
if (DU && CU == NOSTR)
CU = DV;
if (DU && PN == NOSTR) {
- fprintf(stderr, "%s: missing phone number\n", host);
+ (void) fprintf(stderr, "%s: missing phone number\n", host);
exit(3);
}
DB = rgetflag("db");
@@ -131,13 +131,13 @@ getremcap(host)
if (EX == NULL)
EX = (char *)"\t\n\b\f";
if (ES != NOSTR)
- vstring("es", ES);
+ (void) vstring("es", ES);
if (FO != NOSTR)
- vstring("fo", FO);
+ (void) vstring("fo", FO);
if (PR != NOSTR)
- vstring("pr", PR);
+ (void) vstring("pr", PR);
if (RC != NOSTR)
- vstring("rc", RC);
+ (void) vstring("rc", RC);
if ((DL = rgetnum("dl")) < 0)
DL = 0;
if ((CL = rgetnum("cl")) < 0)
@@ -147,16 +147,15 @@ getremcap(host)
}
char *
-getremote(host)
- char *host;
+getremote(char *host)
{
- register char *cp;
+ char *cp;
static char *next;
static int lookedup = 0;
if (!lookedup) {
if (host == NOSTR && (host = getenv("HOST")) == NOSTR) {
- fprintf(stderr, "tip: no host specified\n");
+ (void) fprintf(stderr, "tip: no host specified\n");
exit(3);
}
getremcap(host);
diff --git a/usr/src/cmd/tip/tip.c b/usr/src/cmd/tip/tip.c
index 87eee957a8..c7306e3d5b 100644
--- a/usr/src/cmd/tip/tip.c
+++ b/usr/src/cmd/tip/tip.c
@@ -2,13 +2,14 @@
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
+
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
-#ident "%Z%%M% %I% %E% SMI" /* from UCB 5.4 4/3/86 */
+#pragma ident "%Z%%M% %I% %E% SMI"
/*
* tip - UNIX link to other systems
@@ -29,21 +30,26 @@ int bauds[] = {
57600, 76800, 115200, 153600, 230400, 307200, 460800, -1
};
-void intprompt();
-void timeout();
-void deadkid();
-void cleanup();
-char *sname();
-char PNbuf[256]; /* This limits the size of a number */
+extern void tipout(void) __NORETURN;
+extern void timeout(void);
+extern esctable_t etable[];
+extern unsigned char evenpartab[];
+
+void intprompt(void);
+void deadkid(void);
+void cleanup(void);
+void tipin(void) __NORETURN;
+unsigned char escape(void);
+char *sname(char *);
+char PNbuf[256]; /* This limits the size of a number */
int noparity = 0;
-
-main(argc, argv)
- char *argv[];
+int
+main(int argc, char *argv[])
{
char *system = NOSTR;
- register int i;
- register char *p;
+ int i;
+ char *p;
char sbuf[12];
gid = getgid();
@@ -57,12 +63,13 @@ main(argc, argv)
}
if (argc > 4) {
- fprintf(stderr, "usage: tip [-v] [-speed] [system-name]\n");
- exit(1);
+ (void) fprintf(stderr,
+ "usage: tip [-v] [-speed] [system-name]\n");
+ return (1);
}
if (!isatty(0)) {
- fprintf(stderr, "tip: must be interactive\n");
- exit(1);
+ (void) fprintf(stderr, "tip: must be interactive\n");
+ return (1);
}
for (; argc > 1; argv++, argc--) {
@@ -80,7 +87,8 @@ main(argc, argv)
break;
default:
- fprintf(stderr, "tip: %s, unknown option\n", argv[1]);
+ (void) fprintf(stderr, "tip: %s, unknown option\n",
+ argv[1]);
break;
}
}
@@ -98,31 +106,32 @@ main(argc, argv)
* is private, we don't want 'ps' or 'w' to find it).
*/
if (strlen(system) > sizeof (PNbuf) - 1) {
- fprintf(stderr, "tip: phone number too long (max = %d bytes)\n",
+ (void) fprintf(stderr,
+ "tip: phone number too long (max = %d bytes)\n",
sizeof (PNbuf) - 1);
- exit(1);
+ return (1);
}
- strncpy(PNbuf, system, sizeof (PNbuf) - 1);
+ (void) strncpy(PNbuf, system, sizeof (PNbuf) - 1);
for (p = system; *p; p++)
*p = '\0';
PN = PNbuf;
- sprintf(sbuf, "tip%d", BR);
+ (void) sprintf(sbuf, "tip%d", BR);
system = sbuf;
notnumber:
- signal(SIGINT, cleanup);
- signal(SIGQUIT, cleanup);
- signal(SIGHUP, cleanup);
- signal(SIGTERM, cleanup);
+ (void) signal(SIGINT, (sig_handler_t)cleanup);
+ (void) signal(SIGQUIT, (sig_handler_t)cleanup);
+ (void) signal(SIGHUP, (sig_handler_t)cleanup);
+ (void) signal(SIGTERM, (sig_handler_t)cleanup);
if ((i = hunt(system)) == 0) {
- printf("all ports busy\n");
- exit(3);
+ (void) printf("all ports busy\n");
+ return (3);
}
if (i == -1) {
- printf("link down\n");
+ (void) printf("link down\n");
delock(uucplock);
- exit(3);
+ return (3);
}
setbuf(stdout, NULL);
loginit();
@@ -154,10 +163,11 @@ notnumber:
vinit(); /* init variables */
setparity("none"); /* set the parity table */
if ((i = speed(number(value(BAUDRATE)))) == NULL) {
- printf("tip: bad baud rate %d\n", number(value(BAUDRATE)));
+ (void) printf("tip: bad baud rate %d\n",
+ number(value(BAUDRATE)));
myperm();
delock(uucplock);
- exit(3);
+ return (3);
}
@@ -169,10 +179,10 @@ notnumber:
if (HW)
ttysetup(i);
if (p = connect()) {
- printf("\07%s\n[EOT]\n", p);
+ (void) printf("\07%s\n[EOT]\n", p);
myperm();
delock(uucplock);
- exit(1);
+ return (1);
}
/*
@@ -189,7 +199,7 @@ cucommon:
* the "cu" version of tip.
*/
- ioctl(0, TCGETS, (char *)&defarg);
+ (void) ioctl(0, TCGETS, (char *)&defarg);
arg = defarg;
/* turn off input processing */
arg.c_lflag &= ~(ICANON|ISIG|ECHO|IEXTEN);
@@ -204,8 +214,8 @@ cucommon:
tandem("off");
raw();
- pipe(fildes); pipe(repdes);
- signal(SIGALRM, timeout);
+ (void) pipe(fildes); (void) pipe(repdes);
+ (void) signal(SIGALRM, (sig_handler_t)timeout);
/*
* Everything's set up now:
@@ -215,11 +225,11 @@ cucommon:
* so, fork one process for local side and one for remote.
*/
if (CM != NOSTR) {
- sleep(2); /* let line settle */
- parwrite(FD, CM, strlen(CM));
+ (void) sleep(2); /* let line settle */
+ parwrite(FD, (unsigned char *)CM, strlen(CM));
}
- printf(cumode ? "Connected\r\n" : "\07connected\r\n");
- signal(SIGCHLD, deadkid);
+ (void) printf(cumode ? "Connected\r\n" : "\07connected\r\n");
+ (void) signal(SIGCHLD, (sig_handler_t)deadkid);
if (pid = fork())
tipin();
else
@@ -228,15 +238,15 @@ cucommon:
}
void
-deadkid()
+deadkid(void)
{
if (pid >= 0 && waitpid(pid, NULL, WNOHANG) == pid)
- abort("Connection Closed");
+ tip_abort("Connection Closed");
}
void
-cleanup()
+cleanup(void)
{
if (uid != getuid()) {
@@ -249,40 +259,44 @@ cleanup()
/*
* put the controlling keyboard into raw mode
*/
-raw()
+void
+raw(void)
{
- ioctl(0, TCSETSF, (char *)&arg);
+ (void) ioctl(0, TCSETSF, (char *)&arg);
}
/*
* return keyboard to normal mode
*/
-unraw()
+void
+unraw(void)
{
- ioctl(0, TCSETSF, (char *)&defarg);
+ (void) ioctl(0, TCSETSF, (char *)&defarg);
}
/*
* switch to using invoking user's permissions
*/
-userperm()
+void
+userperm(void)
{
- setegid(gid);
- seteuid(uid);
+ (void) setegid(gid);
+ (void) seteuid(uid);
}
/*
* switch to using my special (setuid) permissions
*/
-myperm()
+void
+myperm(void)
{
- setegid(egid);
- seteuid(euid);
+ (void) setegid(egid);
+ (void) seteuid(euid);
}
static sigjmp_buf promptbuf;
@@ -292,20 +306,18 @@ static sigjmp_buf promptbuf;
* in from the terminal. Handles signals & allows use of
* normal erase and kill characters.
*/
-prompt(s, p, len)
- char *s;
- register char *p;
- size_t len;
+int
+prompt(char *s, char *p, size_t len)
{
- register char *b = p;
- register int c;
- void (*ointr)(), (*oquit)();
+ char *b = p;
+ int c;
+ sig_handler_t ointr, oquit;
stoprompt = 0;
- ointr = signal(SIGINT, intprompt);
+ ointr = signal(SIGINT, (sig_handler_t)intprompt);
oquit = signal(SIGQUIT, SIG_IGN);
unraw();
- printf("%s", s);
+ (void) printf("%s", s);
if (sigsetjmp(promptbuf, 1) == 0)
while (p < b + len - 1 &&
((c = getchar()) != EOF) && (c != '\n'))
@@ -313,8 +325,8 @@ prompt(s, p, len)
*p = '\0';
raw();
- signal(SIGINT, ointr);
- signal(SIGQUIT, oquit);
+ (void) signal(SIGINT, ointr);
+ (void) signal(SIGQUIT, oquit);
return (stoprompt || p == b);
}
@@ -322,20 +334,21 @@ prompt(s, p, len)
* Interrupt service routine during prompting
*/
void
-intprompt()
+intprompt(void)
{
- signal(SIGINT, SIG_IGN);
- signal(SIGQUIT, SIG_IGN);
+ (void) signal(SIGINT, SIG_IGN);
+ (void) signal(SIGQUIT, SIG_IGN);
stoprompt = 1;
- printf("\r\n");
+ (void) printf("\r\n");
siglongjmp(promptbuf, 1);
}
/*
* ****TIPIN TIPIN****
*/
-tipin()
+void
+tipin(void)
{
unsigned char gch, c;
int bol = 1;
@@ -348,7 +361,7 @@ tipin()
* it; so wait a second, then setscript()
*/
if (boolean(value(SCRIPT))) {
- sleep(1);
+ (void) sleep(1);
setscript();
}
@@ -364,7 +377,7 @@ tipin()
bol = 1;
parwrite(FD, &gch, 1);
if (boolean(value(HALFDUPLEX)))
- printf("\r\n");
+ (void) printf("\r\n");
continue;
} else if (!cumode && gch == character(value(FORCE)))
gch = getchar()&0377;
@@ -374,7 +387,7 @@ tipin()
c = gch;
parwrite(FD, &gch, 1);
if (boolean(value(HALFDUPLEX)))
- putchar(c);
+ (void) putchar(c);
}
}
@@ -382,41 +395,41 @@ tipin()
* Escape handler --
* called on recognition of ``escapec'' at the beginning of a line
*/
-escape()
+unsigned char
+escape(void)
{
- register unsigned char gch;
- register esctable_t *p;
+ unsigned char gch;
+ esctable_t *p;
char c = character(value(ESCAPE));
- extern esctable_t etable[];
gch = (getchar()&0377);
for (p = etable; p->e_char; p++)
if (p->e_char == gch) {
if ((p->e_flags&PRIV) && uid)
continue;
- printf("%s", ctrl(c));
+ (void) printf("%s", ctrl(c));
(*p->e_func)(gch);
return (0);
}
/* ESCAPE ESCAPE forces ESCAPE */
if (c != gch)
- parwrite(FD, &c, 1);
+ parwrite(FD, (unsigned char *)&c, 1);
return (gch);
}
-speed(n)
- int n;
+int
+speed(int n)
{
- register int *p;
+ int *p;
for (p = bauds; *p != -1; p++)
if (*p == n)
return (p - bauds);
- return (NULL);
+ return (0);
}
-any(c, p)
- register char c, *p;
+int
+any(char c, char *p)
{
while (p && *p)
if (*p++ == c)
@@ -425,11 +438,10 @@ any(c, p)
}
char *
-interp(s)
- register char *s;
+interp(char *s)
{
static char buf[256];
- register char *p = buf, c, *q;
+ char *p = buf, c, *q;
while (c = *s++) {
for (q = "\nn\rr\tt\ff\033E\bb"; *q; q++)
@@ -451,8 +463,7 @@ interp(s)
}
char *
-ctrl(c)
- char c;
+ctrl(char c)
{
static char s[3];
@@ -470,35 +481,34 @@ ctrl(c)
/*
* Help command
*/
-help(c)
- char c;
+void
+help(int c)
{
- register esctable_t *p;
- extern esctable_t etable[];
+ esctable_t *p;
- printf("%c\r\n", c);
+ (void) printf("%c\r\n", c);
for (p = etable; p->e_char; p++) {
if ((p->e_flags&PRIV) && uid)
continue;
- printf("%2s", ctrl(character(value(ESCAPE))));
- printf("%-2s %c %s\r\n", ctrl(p->e_char),
- p->e_flags&EXP ? '*': ' ', p->e_help);
+ (void) printf("%2s", ctrl(character(value(ESCAPE))));
+ (void) printf("%-2s %c %s\r\n", ctrl(p->e_char),
+ p->e_flags&EXP ? '*': ' ', p->e_help);
}
}
/*
* Set up the "remote" tty's state
*/
-ttysetup(speed)
- int speed;
+void
+ttysetup(int speed)
{
struct termios buf;
char *loc;
- ioctl(FD, TCGETS, (char *)&buf);
+ (void) ioctl(FD, TCGETS, (char *)&buf);
buf.c_cflag &= (CREAD|HUPCL|CLOCAL|CRTSCTS|CRTSXOFF);
buf.c_cflag |= CS8;
- cfsetospeed(&buf, speed);
+ (void) cfsetospeed(&buf, speed);
if (boolean(value(HARDWAREFLOW))) {
int i = TIOCM_CAR;
@@ -507,7 +517,7 @@ ttysetup(speed)
* because some devices require both CD and RTS to
* be up before sending.
*/
- ioctl(FD, TIOCMGET, &i);
+ (void) ioctl(FD, TIOCMGET, &i);
if (i & TIOCM_CAR)
buf.c_cflag |= (CRTSCTS|CRTSXOFF);
}
@@ -528,7 +538,7 @@ ttysetup(speed)
buf.c_lflag = 0;
buf.c_cc[VMIN] = 1;
buf.c_cc[VTIME] = 0;
- ioctl(FD, TCSETSF, (char *)&buf);
+ (void) ioctl(FD, TCSETSF, (char *)&buf);
}
/*
@@ -536,10 +546,9 @@ ttysetup(speed)
* strip leading directories.
*/
char *
-sname(s)
- register char *s;
+sname(char *s)
{
- register char *p = s;
+ char *p = s;
while (*s)
if (*s++ == '/')
@@ -554,14 +563,11 @@ static char partab[0400];
* We are doing 8 bit wide output, so we just generate a character
* with the right parity and output it.
*/
-parwrite(fd, buf, n)
- int fd;
- unsigned char *buf;
- register int n;
+void
+parwrite(int fd, unsigned char *buf, int n)
{
- register int i;
- register unsigned char *bp;
- extern int errno;
+ int i;
+ unsigned char *bp;
bp = buf;
for (i = 0; i < n; i++) {
@@ -570,7 +576,7 @@ parwrite(fd, buf, n)
}
if (write(fd, buf, n) < 0) {
if (errno == EIO || errno == ENXIO)
- abort("Lost carrier.");
+ tip_abort("Lost carrier.");
/* this is questionable */
perror("write");
}
@@ -579,21 +585,20 @@ parwrite(fd, buf, n)
/*
* Build a parity table with appropriate high-order bit.
*/
-setparity(defparity)
- char *defparity;
+void
+setparity(char *defparity)
{
- register int i;
+ int i;
char *parity;
- extern char evenpartab[];
if (value(PARITY) == NOSTR)
value(PARITY) = defparity;
parity = value(PARITY);
for (i = 0; i < 0400; i++)
partab[i] = evenpartab[i];
- if (equal(parity, "even"))
- ;
- else if (equal(parity, "odd")) {
+ if (equal(parity, "even")) {
+ /* EMPTY */
+ } else if (equal(parity, "odd")) {
for (i = 0; i < 0400; i++)
partab[i] ^= 0200; /* reverse bit 7 */
} else if (equal(parity, "none")) {
@@ -608,7 +613,7 @@ setparity(defparity)
for (i = 0; i < 0400; i++)
partab[i] |= 0200; /* turn on bit 7 */
} else {
- fprintf(stderr, "%s: unknown parity value\n", PA);
- fflush(stderr);
+ (void) fprintf(stderr, "%s: unknown parity value\n", PA);
+ (void) fflush(stderr);
}
}
diff --git a/usr/src/cmd/tip/tip.h b/usr/src/cmd/tip/tip.h
index 2fe34824c0..4f90edaeb1 100644
--- a/usr/src/cmd/tip/tip.h
+++ b/usr/src/cmd/tip/tip.h
@@ -8,6 +8,9 @@
* specifies the terms and conditions for redistribution.
*/
+#ifndef _TIP_H
+#define _TIP_H
+
#pragma ident "%Z%%M% %I% %E% SMI"
/*
@@ -33,13 +36,15 @@
#include <string.h>
#include <time.h>
#include <sys/isa_defs.h> /* for ENDIAN defines */
+#include <stdlib.h>
+#include <sys/wait.h>
#define _CTRL(c) (c&037)
#ifdef USG
#define signal(_sig_, _hdlr_) sigset((_sig_), (_hdlr_))
#endif
-typedef void (*sig_handler_t)(); /* works on BSD and SV */
+typedef void (*sig_handler_t)(int); /* works on BSD and SV */
/*
* Remote host attributes
@@ -115,9 +120,9 @@ typedef
typedef
struct {
char *acu_name;
- int (*acu_dialer)();
- int (*acu_disconnect)();
- int (*acu_abort)();
+ int (*acu_dialer)(char *, char *);
+ void (*acu_disconnect)(void);
+ void (*acu_abort)(void);
}
acu_t;
@@ -162,7 +167,7 @@ typedef
char e_char; /* char to match on */
char e_flags; /* experimental, priviledged */
char *e_help; /* help string */
- int (*e_func)(); /* command */
+ void (*e_func)(int); /* command */
}
esctable_t;
@@ -178,6 +183,9 @@ extern int noparity;
#ifndef ACULOG
#define logent(a, b, c, d)
#define loginit()
+#else
+extern void logent(char *, char *, char *, char *);
+extern void loginit(void);
#endif
/*
@@ -252,11 +260,35 @@ char ch; /* for tipout */
char *uucplock; /* name of lock file for uucp's */
extern int trusted_device;
-extern char *ctrl();
-extern char *ctime();
-extern struct passwd *getpwuid();
-extern char *getlogin();
-extern char *vinterp();
-extern char *getenv();
-extern char *malloc();
-extern char *connect();
+
+extern char *connect(void);
+extern char *ctrl(char);
+extern char *getremote(char *);
+extern char *expand(char []);
+extern char *vinterp(char *, char);
+extern void cumain(int, char *[]);
+extern void delock(char *);
+extern void disconnect(char *);
+extern void myperm(void);
+extern void parwrite(int, unsigned char *, int);
+extern void raw(void);
+extern void setparity(char *);
+extern void setscript(void);
+extern void tandem(char *);
+extern void tip_abort(char *);
+extern void ttysetup(int);
+extern void unraw(void);
+extern void userperm(void);
+extern void vinit(void);
+extern void vlex(char *);
+extern int any(char, char *);
+extern int hunt(char *);
+extern int prompt(char *, char *, size_t);
+extern int rgetent(char *, char *, int);
+extern int rgetflag(char *);
+extern int rgetnum(char *);
+extern int speed(int);
+extern int tip_mlock(char *);
+extern int vstring(char *, char *);
+
+#endif /* _TIP_H */
diff --git a/usr/src/cmd/tip/tipout.c b/usr/src/cmd/tip/tipout.c
index fbfb9212e0..94b9ff6f9b 100644
--- a/usr/src/cmd/tip/tipout.c
+++ b/usr/src/cmd/tip/tipout.c
@@ -2,15 +2,17 @@
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
+
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
-#ident "%Z%%M% %I% %E% SMI" /* from UCB 5.1 4/30/85 */
+#pragma ident "%Z%%M% %I% %E% SMI"
#include "tip.h"
+
/*
* tip
*
@@ -25,11 +27,11 @@ static sigjmp_buf sigbuf;
* sent by TIPIN when it wants to posses the remote host
*/
void
-intIOT()
+intIOT(void)
{
- write(repdes[1], &ccc, 1);
- read(fildes[0], &ccc, 1);
+ (void) write(repdes[1], &ccc, 1);
+ (void) read(fildes[0], &ccc, 1);
siglongjmp(sigbuf, 1);
}
@@ -38,20 +40,20 @@ intIOT()
* accepts script file name over the pipe and acts accordingly
*/
void
-intEMT()
+intEMT(void)
{
char c, line[256];
- register char *pline = line;
+ char *pline = line;
char reply;
- read(fildes[0], &c, 1);
+ (void) read(fildes[0], &c, 1);
while (c != '\n') {
*pline++ = c;
- read(fildes[0], &c, 1);
+ (void) read(fildes[0], &c, 1);
}
*pline = '\0';
if (boolean(value(SCRIPT)) && fscript != NULL)
- fclose(fscript);
+ (void) fclose(fscript);
if (pline == line) {
boolean(value(SCRIPT)) = FALSE;
reply = 'y';
@@ -63,21 +65,21 @@ intEMT()
boolean(value(SCRIPT)) = TRUE;
}
}
- write(repdes[1], &reply, 1);
+ (void) write(repdes[1], &reply, 1);
siglongjmp(sigbuf, 1);
}
void
-intTERM()
+intTERM(void)
{
if (boolean(value(SCRIPT)) && fscript != NULL)
- fclose(fscript);
+ (void) fclose(fscript);
exit(0);
}
void
-intSYS()
+intSYS(void)
{
boolean(value(BEAUTIFY)) = !boolean(value(BEAUTIFY));
@@ -87,31 +89,36 @@ intSYS()
/*
* ****TIPOUT TIPOUT****
*/
-tipout()
+void
+tipout(void)
{
char buf[BUFSIZ];
- register char *cp;
- register int cnt;
- extern int errno;
+ char *cp;
+ int cnt;
sigset_t omask, bmask, tmask;
- signal(SIGINT, SIG_IGN);
- signal(SIGQUIT, SIG_IGN);
- signal(SIGEMT, (sig_handler_t)intEMT); /* attention from TIPIN */
- signal(SIGTERM, (sig_handler_t)intTERM); /* time to go signal */
- signal(SIGIOT, (sig_handler_t)intIOT); /* scripting going on signal */
- signal(SIGHUP, (sig_handler_t)intTERM); /* for dial-ups */
- signal(SIGSYS, (sig_handler_t)intSYS); /* beautify toggle */
+ (void) signal(SIGINT, SIG_IGN);
+ (void) signal(SIGQUIT, SIG_IGN);
+ /* attention from TIPIN */
+ (void) signal(SIGEMT, (sig_handler_t)intEMT);
+ /* time to go signal */
+ (void) signal(SIGTERM, (sig_handler_t)intTERM);
+ /* scripting going on signal */
+ (void) signal(SIGIOT, (sig_handler_t)intIOT);
+ /* for dial-ups */
+ (void) signal(SIGHUP, (sig_handler_t)intTERM);
+ /* beautify toggle */
+ (void) signal(SIGSYS, (sig_handler_t)intSYS);
(void) sigsetjmp(sigbuf, 1);
- sigemptyset(&omask);
- sigemptyset(&bmask);
- sigaddset(&bmask, SIGEMT);
- sigaddset(&bmask, SIGTERM);
- sigaddset(&bmask, SIGIOT);
- sigaddset(&bmask, SIGSYS);
- sigemptyset(&tmask);
- sigaddset(&tmask, SIGTERM);
+ (void) sigemptyset(&omask);
+ (void) sigemptyset(&bmask);
+ (void) sigaddset(&bmask, SIGEMT);
+ (void) sigaddset(&bmask, SIGTERM);
+ (void) sigaddset(&bmask, SIGIOT);
+ (void) sigaddset(&bmask, SIGSYS);
+ (void) sigemptyset(&tmask);
+ (void) sigaddset(&tmask, SIGTERM);
for (;;) {
cnt = read(FD, buf, BUFSIZ);
if (cnt <= 0) {
@@ -125,7 +132,7 @@ tipout()
DB = 0;
if ((fd = open(DV, O_RDWR)) >= 0) {
if (fd != FD)
- close(fd);
+ (void) close(fd);
}
continue;
}
@@ -142,15 +149,16 @@ tipout()
for (cp = buf; cp < buf + cnt; cp++)
*cp &= 0177;
- write(1, buf, cnt);
+ (void) write(1, buf, cnt);
if (boolean(value(SCRIPT)) && fscript != NULL) {
if (!boolean(value(BEAUTIFY))) {
- fwrite(buf, 1, cnt, fscript);
+ (void) fwrite(buf, 1, cnt, fscript);
} else {
for (cp = buf; cp < buf + cnt; cp++)
if ((*cp >= ' ' && *cp <= '~')||
any(*cp, value(EXCEPTIONS)))
- putc(*cp, fscript);
+ (void) putc(*cp,
+ fscript);
}
}
}
diff --git a/usr/src/cmd/tip/uucplock.c b/usr/src/cmd/tip/uucplock.c
index a9b5b5285c..8eaf2d16d0 100644
--- a/usr/src/cmd/tip/uucplock.c
+++ b/usr/src/cmd/tip/uucplock.c
@@ -2,12 +2,15 @@
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
+
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
-#ident "%Z%%M% %I% %E% SMI" /* from UCB 4.6 6/25/83 */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
/*
* defs that come from uucp.h
*/
@@ -17,14 +20,14 @@
#define SLCKTIME (8*60*60) /* device timeout (LCK.. files) in seconds */
#ifdef __STDC__
#define ASSERT(e, f, v) if (!(e)) {\
- fprintf(stderr, "AERROR - (%s) ", #e); \
- fprintf(stderr, f, v); \
+ (void) fprintf(stderr, "AERROR - (%s) ", #e); \
+ (void) fprintf(stderr, f, v); \
finish(FAIL); \
}
#else
#define ASSERT(e, f, v) if (!(e)) {\
- fprintf(stderr, "AERROR - (%s) ", "e"); \
- fprintf(stderr, f, v); \
+ (void) fprintf(stderr, "AERROR - (%s) ", "e"); \
+ (void) fprintf(stderr, f, v); \
finish(FAIL); \
}
#endif
@@ -45,11 +48,18 @@
#include <stdio.h>
#include <errno.h>
#include <string.h>
+#include <stdlib.h>
+#include <time.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <utime.h>
-static void stlock();
-static int onelock();
-static int checkLock();
+static void stlock(char *);
+static int onelock(char *, char *, char *);
+static int checkLock(char *);
+extern void finish(int);
/*
* ulockf(file, atime)
@@ -67,18 +77,17 @@ static int checkLock();
*
* return codes: 0 | FAIL
*/
-
-static
-ulockf(file, atime)
- char *file;
- time_t atime;
+/* ARGSUSED */
+static int
+ulockf(char *file, time_t atime)
{
static char pid[SIZEOFPID+2] = { '\0' }; /* +2 for '\n' and NULL */
static char tempfile[NAMESIZE];
if (pid[0] == '\0') {
- (void) sprintf(pid, "%*d\n", SIZEOFPID, getpid());
- (void) sprintf(tempfile, "%s/LTMP.%d", LOCKDIR, getpid());
+ (void) sprintf(pid, "%*d\n", SIZEOFPID, (int)getpid());
+ (void) snprintf(tempfile, sizeof (tempfile),
+ "%s/LTMP.%d", LOCKDIR, getpid());
}
if (onelock(pid, tempfile, file) == -1) {
/* lock file exists */
@@ -105,14 +114,12 @@ ulockf(file, atime)
* FAIL -> lock file still active
*/
static int
-checkLock(file)
-register char *file;
+checkLock(char *file)
{
- register int ret;
+ int ret;
int lpid = -1;
char alpid[SIZEOFPID+2]; /* +2 for '\n' and NULL */
int fd;
- extern int errno;
fd = open(file, 0);
if (fd == -1) {
@@ -146,11 +153,9 @@ int Nlocks = 0;
*/
static void
-stlock(name)
- char *name;
+stlock(char *name)
{
char *p;
- extern char *calloc();
int i;
for (i = 0; i < Nlocks; i++) {
@@ -162,7 +167,7 @@ stlock(name)
i = Nlocks++;
p = calloc(strlen(name) + 1, sizeof (char));
ASSERT(p != NULL, "CAN NOT ALLOCATE FOR %s", name);
- strcpy(p, name);
+ (void) strcpy(p, name);
Lockfile[i] = p;
}
@@ -173,9 +178,8 @@ stlock(name)
* return codes: none
*/
-static
-rmlock(name)
- char *name;
+static void
+rmlock(char *name)
{
int i;
@@ -183,30 +187,29 @@ rmlock(name)
if (Lockfile[i] == NULL)
continue;
if (name == NULL || strcmp(name, Lockfile[i]) == SAME) {
- unlink(Lockfile[i]);
+ (void) unlink(Lockfile[i]);
free(Lockfile[i]);
Lockfile[i] = NULL;
}
}
}
-static
-onelock(pid, tempfile, name)
- char *pid, *tempfile, *name;
+static int
+onelock(char *pid, char *tempfile, char *name)
{
int fd;
static int first = 1;
- extern int errno;
fd = creat(tempfile, 0444);
if (fd < 0) {
if (first) {
if (errno == EACCES) {
- fprintf(stderr,
+ (void) fprintf(stderr,
"tip: can't create files in lock file directory %s\n",
LOCKDIR);
} else if (access(LOCKDIR, 0) < 0) {
- fprintf(stderr, "tip: lock file directory %s: ",
+ (void) fprintf(stderr,
+ "tip: lock file directory %s: ",
LOCKDIR);
perror("");
}
@@ -218,86 +221,62 @@ onelock(pid, tempfile, name)
}
/* +1 for '\n' */
if (write(fd, pid, SIZEOFPID+1) != (SIZEOFPID+1)) {
- fprintf(stderr,
+ (void) fprintf(stderr,
"tip: can't write to files in lock file directory %s: %s\n",
LOCKDIR, strerror(errno));
(void) unlink(tempfile);
return (-1);
}
- fchmod(fd, 0444);
- close(fd);
+ (void) fchmod(fd, 0444);
+ (void) close(fd);
if (link(tempfile, name) < 0) {
- unlink(tempfile);
+ (void) unlink(tempfile);
return (-1);
}
- unlink(tempfile);
+ (void) unlink(tempfile);
return (0);
}
/*
* delock(sys) remove a lock file
* char *sys;
- *
- * return codes: 0 | FAIL
*/
-delock(sys)
- char *sys;
+void
+delock(char *sys)
{
struct stat sb;
char lname[NAMESIZE];
if (stat(sys, &sb) < 0)
- return (FAIL);
- sprintf(lname, "%s/%s.%3.3lu.%3.3lu.%3.3lu", LOCKDIR, LOCKPRE,
- (unsigned long)major(sb.st_dev),
- (unsigned long)major(sb.st_rdev),
- (unsigned long)minor(sb.st_rdev));
+ return;
+ (void) snprintf(lname, sizeof (lname), "%s/%s.%3.3lu.%3.3lu.%3.3lu",
+ LOCKDIR, LOCKPRE,
+ (unsigned long)major(sb.st_dev),
+ (unsigned long)major(sb.st_rdev),
+ (unsigned long)minor(sb.st_rdev));
rmlock(lname);
}
/*
- * mlock(sys) create system lock
+ * tip_mlock(sys) create system lock
* char *sys;
*
* return codes: 0 | FAIL
*/
-mlock(sys)
- char *sys;
+int
+tip_mlock(char *sys)
{
struct stat sb;
char lname[NAMESIZE];
if (stat(sys, &sb) < 0)
return (FAIL);
- sprintf(lname, "%s/%s.%3.3lu.%3.3lu.%3.3lu", LOCKDIR, LOCKPRE,
- (unsigned long)major(sb.st_dev),
- (unsigned long)major(sb.st_rdev),
- (unsigned long)minor(sb.st_rdev));
+ (void) snprintf(lname, sizeof (lname), "%s/%s.%3.3lu.%3.3lu.%3.3lu",
+ LOCKDIR, LOCKPRE,
+ (unsigned long)major(sb.st_dev),
+ (unsigned long)major(sb.st_rdev),
+ (unsigned long)minor(sb.st_rdev));
return (ulockf(lname, (time_t)SLCKTIME) < 0 ? FAIL : 0);
}
-
-/*
- * update access and modify times for lock files
- * return:
- * none
- */
-void
-ultouch()
-{
- register int i;
- time_t time();
-
- struct ut {
- time_t actime;
- time_t modtime;
- } ut;
-
- ut.actime = time(&ut.modtime);
- for (i = 0; i < Nlocks; i++) {
- if (Lockfile[i] == NULL)
- continue;
- utime(Lockfile[i], &ut);
- }
-}
diff --git a/usr/src/cmd/tip/value.c b/usr/src/cmd/tip/value.c
index a48e0fa764..aabe0f49ab 100644
--- a/usr/src/cmd/tip/value.c
+++ b/usr/src/cmd/tip/value.c
@@ -1,30 +1,37 @@
/*
- * Copyright (c) 2000 by Sun Microsystems, Inc.
- * All rights reserved.
+ * Copyright 2000 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
*/
-/* from UCB 4.5 6/25/83 */
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
+
#pragma ident "%Z%%M% %I% %E% SMI"
#include "tip.h"
#define MIDDLE 35
-static value_t *vlookup();
+static value_t *vlookup(char *);
static int col = 0;
+extern char *interp(char *);
+
+static void vtoken(char *);
+static void vprint(value_t *);
+static int vaccess(unsigned, unsigned);
+
/*
* Variable manipulation
*/
-vinit()
+void
+vinit(void)
{
- register value_t *p;
- register char *cp;
+ value_t *p;
+ char *cp;
FILE *f;
char file[1024];
@@ -41,21 +48,21 @@ vinit()
*/
if ((cp = value(HOME)) == NULL)
cp = "";
- strlcpy(file, cp, sizeof (file));
- strlcat(file, "/.tiprc", sizeof (file));
+ (void) strlcpy(file, cp, sizeof (file));
+ (void) strlcat(file, "/.tiprc", sizeof (file));
if ((f = fopen(file, "r")) != NULL) {
- register char *tp;
+ char *tp;
while (fgets(file, sizeof (file)-1, f) != NULL) {
if (file[0] == '#')
continue;
if (vflag)
- printf("set %s", file);
+ (void) printf("set %s", file);
if (tp = strrchr(file, '\n'))
*tp = '\0';
vlex(file);
}
- fclose(f);
+ (void) fclose(f);
}
/*
* To allow definition of exception prior to fork
@@ -64,13 +71,12 @@ vinit()
}
/*VARARGS1*/
-vassign(p, v)
- register value_t *p;
- char *v;
+void
+vassign(value_t *p, char *v)
{
if (!vaccess(p->v_access, WRITE)) {
- printf("access denied\r\n");
+ (void) printf("access denied\r\n");
return;
}
switch (p->v_type&TMASK) {
@@ -83,11 +89,11 @@ vassign(p, v)
free(p->v_value);
}
if ((p->v_value = malloc(strlen(v)+1)) == NOSTR) {
- printf("out of core\r\n");
+ (void) printf("out of core\r\n");
return;
}
p->v_type &= ~(ENVIRON|INIT);
- strcpy(p->v_value, v);
+ (void) strcpy(p->v_value, v);
break;
case NUMBER:
@@ -110,17 +116,17 @@ vassign(p, v)
p->v_access |= CHANGED;
}
-vlex(s)
- register char *s;
+void
+vlex(char *s)
{
- register value_t *p;
+ value_t *p;
if (equal(s, "all")) {
for (p = vtable; p->v_name; p++)
if (vaccess(p->v_access, READ))
vprint(p);
} else {
- register char *cp;
+ char *cp;
do {
if (cp = vinterp(s, ' '))
@@ -130,25 +136,23 @@ vlex(s)
} while (s);
}
if (col > 0) {
- printf("\r\n");
+ (void) printf("\r\n");
col = 0;
}
}
-static int
-vtoken(s)
- register char *s;
+static void
+vtoken(char *s)
{
- register value_t *p;
- register char *cp, *cp2;
- char *expand();
+ value_t *p;
+ char *cp, *cp2;
if (cp = strchr(s, '=')) {
*cp = '\0';
if (p = vlookup(s)) {
cp++;
if (p->v_type&NUMBER)
- vassign(p, atoi(cp));
+ vassign(p, (char *)atoi(cp));
else {
if (strcmp(s, "record") == 0)
if ((cp2 = expand(cp)) != NOSTR)
@@ -159,7 +163,7 @@ vtoken(s)
}
} else if (cp = strchr(s, '?')) {
*cp = '\0';
- if ((p = vlookup(s)) && vaccess(p->v_access, READ)) {
+ if ((p = vlookup(s)) != NULL && vaccess(p->v_access, READ)) {
vprint(p);
return;
}
@@ -172,70 +176,67 @@ vtoken(s)
if (p->v_type&BOOL)
vassign(p, s);
else
- printf("%s: no value specified\r\n", s);
+ (void) printf("%s: no value specified\r\n", s);
return;
}
}
- printf("%s: unknown variable\r\n", s);
+ (void) printf("%s: unknown variable\r\n", s);
}
-static int
-vprint(p)
- register value_t *p;
+static void
+vprint(value_t *p)
{
- register char *cp;
- extern char *interp(), *ctrl();
+ char *cp;
if (col > 0 && col < MIDDLE)
while (col++ < MIDDLE)
- putchar(' ');
+ (void) putchar(' ');
col += strlen(p->v_name);
switch (p->v_type&TMASK) {
case BOOL:
if (boolean(p->v_value) == FALSE) {
col++;
- putchar('!');
+ (void) putchar('!');
}
- printf("%s", p->v_name);
+ (void) printf("%s", p->v_name);
break;
case STRING:
- printf("%s=", p->v_name);
+ (void) printf("%s=", p->v_name);
col++;
if (p->v_value) {
- cp = interp(p->v_value, NULL);
+ cp = interp(p->v_value);
col += strlen(cp);
- printf("%s", cp);
+ (void) printf("%s", cp);
}
break;
case NUMBER:
col += 6;
- printf("%s=%-5d", p->v_name, number(p->v_value));
+ (void) printf("%s=%-5d", p->v_name, number(p->v_value));
break;
case CHAR:
- printf("%s=", p->v_name);
+ (void) printf("%s=", p->v_name);
col++;
if (p->v_value) {
cp = ctrl(character(p->v_value));
col += strlen(cp);
- printf("%s", cp);
+ (void) printf("%s", cp);
}
break;
}
if (col >= MIDDLE) {
col = 0;
- printf("\r\n");
+ (void) printf("\r\n");
return;
}
}
static int
-vaccess(mode, rw)
- register unsigned mode, rw;
+vaccess(unsigned mode, unsigned rw)
{
if (mode & (rw<<PUBLIC))
return (1);
@@ -245,10 +246,9 @@ vaccess(mode, rw)
}
static value_t *
-vlookup(s)
- register char *s;
+vlookup(char *s)
{
- register value_t *p;
+ value_t *p;
for (p = vtable; p->v_name; p++)
if (equal(p->v_name, s) || (p->v_abrev && equal(p->v_abrev, s)))
@@ -257,14 +257,12 @@ vlookup(s)
}
char *
-vinterp(s, stop)
- register char *s;
- char stop;
+vinterp(char *s, char stop)
{
- register char *p = s, c;
+ char *p = s, c;
int num;
- while ((c = *s++) && c != stop)
+ while ((c = *s++) != 0 && c != stop)
switch (c) {
case '^':
@@ -280,7 +278,7 @@ vinterp(s, stop)
if (c >= '0' && c <= '7')
num = (num<<3)+(c-'0');
else {
- register char *q = "n\nr\rt\tb\bf\f";
+ char *q = "n\nr\rt\tb\bf\f";
for (; *q; q++)
if (c == *q++) {
@@ -312,20 +310,17 @@ vinterp(s, stop)
/*
* assign variable s with value v (for NUMBER or STRING or CHAR types)
*/
-
-vstring(s, v)
- register char *s;
- register char *v;
+int
+vstring(char *s, char *v)
{
- register value_t *p;
+ value_t *p;
char *v2;
- char *expand();
p = vlookup(s);
if (p == 0)
return (1);
if (p->v_type&NUMBER)
- vassign(p, atoi(v));
+ vassign(p, (char *)atoi(v));
else {
if (strcmp(s, "record") == 0)
if ((v2 = expand(v)) != NOSTR)
diff --git a/usr/src/cmd/tip/vars.c b/usr/src/cmd/tip/vars.c
index 4367e28ba5..3c33923fbe 100644
--- a/usr/src/cmd/tip/vars.c
+++ b/usr/src/cmd/tip/vars.c
@@ -2,12 +2,14 @@
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
+
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
-#ident "%Z%%M% %I% %E% SMI" /* from UCB 4.6 6/25/83 */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
#include "tip.h"
diff --git a/usr/src/cmd/users/Makefile b/usr/src/cmd/users/Makefile
index 83d94497cc..9713429781 100644
--- a/usr/src/cmd/users/Makefile
+++ b/usr/src/cmd/users/Makefile
@@ -22,7 +22,9 @@
#
#ident "%Z%%M% %I% %E% SMI"
#
-# Copyright (c) 1989 by Sun Microsystems, Inc.
+#
+# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
#
PROG= listusers
@@ -33,7 +35,7 @@ include ../Makefile.cmd
.KEEP_STATE:
-all: $(PROG) pkginfo
+all: $(PROG)
$(PROG): $(OBJS)
$(LINK.c) $(OBJS) -o $@ $(LDLIBS)
diff --git a/usr/src/cmd/users/users.c b/usr/src/cmd/users/users.c
index 263fb3dfa3..672a1af58a 100644
--- a/usr/src/cmd/users/users.c
+++ b/usr/src/cmd/users/users.c
@@ -19,15 +19,15 @@
*
* CDDL HEADER END
*/
-/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
-/* All Rights Reserved */
-
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
+/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
+/* All Rights Reserved */
+
#pragma ident "%Z%%M% %I% %E% SMI"
/*
@@ -51,14 +51,14 @@
* facility
*/
-#include <sys/types.h>
-#include <stdio.h>
-#include <string.h>
-#include <string.h>
-#include <grp.h>
-#include <pwd.h>
-#include <stdarg.h>
-#include <fmtmsg.h>
+#include <sys/types.h>
+#include <stdio.h>
+#include <string.h>
+#include <grp.h>
+#include <pwd.h>
+#include <stdarg.h>
+#include <fmtmsg.h>
+#include <stdlib.h>
/*
@@ -78,17 +78,6 @@
* exit Exit the program
*/
-extern void *malloc();
-extern int getopt();
-extern char *optarg;
-extern int optind;
-extern int opterr;
-extern struct passwd *getpwent();
-extern struct group *getgrent();
-extern int fmtmsg();
-extern int putenv();
-extern void exit();
-
/*
* Local constant definitions
*/
@@ -106,10 +95,10 @@ extern void exit();
#define LOGINFIELDSZ MAXLOGINSIZE+2
#define isauserlogin(uid) (uid >= 100)
-#define isasystemlogin(uid) (uid < 100)
+#define isasystemlogin(uid) (uid < 100)
#define isausergroup(gid) (gid >= 100)
#define isasystemgroup(gid) (gid < 100)
-
+
/*
* Local datatype definitions
*/
@@ -120,8 +109,8 @@ extern void exit();
*/
struct reqgrp {
- char *groupname;
- struct reqgrp *next;
+ char *groupname;
+ struct reqgrp *next;
int found;
gid_t groupID;
};
@@ -132,11 +121,11 @@ struct reqgrp {
*/
struct reqlogin {
- char *loginname;
- struct reqlogin *next;
- int found;
+ char *loginname;
+ struct reqlogin *next;
+ int found;
};
-
+
/*
* These functions handle error and warning message writing.
* (This deals with UNIX(r) standard message generation, so
@@ -154,7 +143,7 @@ struct reqlogin {
static char fcnlbl[MM_MXLABELLN+1]; /* Buffer for message label */
static char msgbuf[MM_MXTXTLN+1]; /* Buffer for message text */
-
+
/*
* void initmsg(p)
*
@@ -171,15 +160,16 @@ static char msgbuf[MM_MXTXTLN+1]; /* Buffer for message text */
*/
static void
-initmsg(p)
- char *p; /* Ptr to command name */
+initmsg(char *p) /* Ptr to command name */
{
/* Automatic data */
char *q; /* Local multi-use pointer */
/* Use only the simple filename if there is a slash in the name */
- if ((q = strrchr(p, '/')) == (char *) NULL) q = p;
- else q++;
+ if ((q = strrchr(p, '/')) == NULL)
+ q = p;
+ else
+ q++;
/* Build the label for messages */
(void) snprintf(fcnlbl, sizeof (fcnlbl), "UX:%s", q);
@@ -191,7 +181,7 @@ initmsg(p)
*/
(void) putenv("MSGVERB=text");
}
-
+
/*
* void wrtmsg(severity, action, tag, text[, txtarg1[, txtarg2[, ...]]])
*
@@ -224,14 +214,14 @@ wrtmsg(int severity, char *action, char *tag, char *text, ...)
/* Generate the error message */
va_start(argp, text);
- if (text != MM_NULLTXT)
- {
+ if (text != MM_NULLTXT) {
+ /* LINTED */
errorflg = vsnprintf(msgbuf, sizeof (msgbuf), text, argp) >
- MM_MXTXTLN;
+ MM_MXTXTLN;
}
(void) fmtmsg(MM_PRINT, fcnlbl, severity,
- (text == MM_NULLTXT) ? MM_NULLTXT : msgbuf,
- action, tag);
+ (text == MM_NULLTXT) ? MM_NULLTXT : msgbuf,
+ action, tag);
va_end(argp);
/*
@@ -240,14 +230,13 @@ wrtmsg(int severity, char *action, char *tag, char *text, ...)
*/
if (errorflg) {
- (void) fmtmsg(MM_PRINT, fcnlbl, MM_WARNING,
- "Internal message buffer overflow",
- MM_NULLACT, MM_NULLTAG);
- exit(100);
+ (void) fmtmsg(MM_PRINT, fcnlbl, MM_WARNING,
+ "Internal message buffer overflow",
+ MM_NULLACT, MM_NULLTAG);
+ exit(100);
}
}
-/* ARGSUSED */
-
+
/*
* These functions allocate space for the information we gather.
* It works by having a memory heap with strings allocated from
@@ -280,11 +269,13 @@ wrtmsg(int severity, char *action, char *tag, char *text, ...)
#define ALLOCBLKSZ 4096
-static char *nextblkaddr = (char *) NULL;
-static char *laststraddr = (char *) NULL;
-static char *memallocdif = "Memory allocation difficulty. Command terminates";
-static char *toomuchspace = "Internal space allocation error. Command terminates";
-
+static char *nextblkaddr = NULL;
+static char *laststraddr = NULL;
+static char *memallocdif =
+ "Memory allocation difficulty. Command terminates";
+static char *toomuchspace =
+ "Internal space allocation error. Command terminates";
+
/*
* void *allocblk(size)
* unsigned int size
@@ -302,8 +293,7 @@ static char *toomuchspace = "Internal space allocation error. Command termina
*/
static void *
-allocblk(size)
- unsigned int size;
+allocblk(unsigned int size)
{
/* Automatic data */
char *rtnval;
@@ -311,8 +301,8 @@ allocblk(size)
/* Make sure the sizes are aligned correctly */
if ((size = size + (4 - (size % 4))) > ALLOCBLKSZ) {
- wrtmsg(MM_ERROR, MM_NULLACT, MM_NULLTAG, toomuchspace);
- exit(101);
+ wrtmsg(MM_ERROR, MM_NULLACT, MM_NULLTAG, toomuchspace);
+ exit(101);
}
/* Set up the value we're going to return */
@@ -320,18 +310,18 @@ allocblk(size)
/* Get the space we need off of the heap */
if ((nextblkaddr += size) >= laststraddr) {
- if ((rtnval = (char *) malloc(ALLOCBLKSZ)) == (char *) NULL) {
- wrtmsg(MM_ERROR, MM_NULLACT, MM_NULLTAG, memallocdif);
- exit(101);
- }
- laststraddr = rtnval + ALLOCBLKSZ;
- nextblkaddr = rtnval + size;
+ if ((rtnval = malloc(ALLOCBLKSZ)) == NULL) {
+ wrtmsg(MM_ERROR, MM_NULLACT, MM_NULLTAG, memallocdif);
+ exit(101);
+ }
+ laststraddr = rtnval + ALLOCBLKSZ;
+ nextblkaddr = rtnval + size;
}
/* We're through */
- return((void *) rtnval);
+ return ((void *)rtnval);
}
-
+
/*
* char *allocstr(nbytes)
* unsigned int nbytes
@@ -348,23 +338,22 @@ allocblk(size)
*/
static char *
-allocstr(nchars)
- unsigned int nchars;
+allocstr(unsigned int nchars)
{
if (nchars > ALLOCBLKSZ) {
- wrtmsg(MM_ERROR, MM_NULLACT, MM_NULLTAG, toomuchspace);
- exit(101);
+ wrtmsg(MM_ERROR, MM_NULLACT, MM_NULLTAG, toomuchspace);
+ exit(101);
}
if ((laststraddr -= nchars) < nextblkaddr) {
- if ((nextblkaddr = (char *) malloc(ALLOCBLKSZ)) == (char *) NULL) {
- wrtmsg(MM_ERROR, MM_NULLACT, MM_NULLTAG, memallocdif);
- exit(101);
- }
- laststraddr = nextblkaddr + ALLOCBLKSZ - nchars;
+ if ((nextblkaddr = malloc(ALLOCBLKSZ)) == NULL) {
+ wrtmsg(MM_ERROR, MM_NULLACT, MM_NULLTAG, memallocdif);
+ exit(101);
+ }
+ laststraddr = nextblkaddr + ALLOCBLKSZ - nchars;
}
- return(laststraddr);
+ return (laststraddr);
}
-
+
/*
* These functions control the group membership list, as found in the
* /etc/group file.
@@ -383,12 +372,12 @@ allocstr(nchars)
*/
struct grpmember {
- char *membername;
- struct grpmember *next;
+ char *membername;
+ struct grpmember *next;
};
-static struct grpmember *membershead;
-
+static struct grpmember *membershead;
+
/*
* void initmembers()
*
@@ -400,12 +389,12 @@ static struct grpmember *membershead;
*/
static void
-initmembers()
+initmembers(void)
{
/* Set up the members list to be a null member's list */
- membershead = (struct grpmember *) NULL;
+ membershead = NULL;
}
-
+
/*
* void addmember(p)
* char *p
@@ -422,18 +411,17 @@ initmembers()
*/
static void
-addmember(p)
- char *p;
+addmember(char *p)
{
/* Automatic data */
- struct grpmember *new; /* Member being added */
+ struct grpmember *new; /* Member being added */
- new = (struct grpmember *) allocblk(sizeof(struct grpmember));
- new->membername = strcpy(allocstr((unsigned int) strlen(p)+1), p);
+ new = (struct grpmember *)allocblk(sizeof (struct grpmember));
+ new->membername = strcpy(allocstr((unsigned int)strlen(p)+1), p);
new->next = membershead;
membershead = new;
}
-
+
/*
* init isamember(p)
* char *p
@@ -451,23 +439,22 @@ addmember(p)
*/
static int
-isamember(p)
- char *p;
+isamember(char *p)
{
/* Automatic Data */
int found; /* FLAG: TRUE if login found */
- struct grpmember *pmem; /* Pointer to group member */
+ struct grpmember *pmem; /* Pointer to group member */
/* Search the membership list for the 'p' */
found = FALSE;
- for (pmem = membershead ; !found && pmem ; pmem = pmem->next) {
- if (strcmp(p, pmem->membername) == 0) found = TRUE;
+ for (pmem = membershead; !found && pmem; pmem = pmem->next) {
+ if (strcmp(p, pmem->membername) == 0) found = TRUE;
}
return (found);
}
-
+
/*
* These functions handle the display list. The display list contains
* all of the information we're to display. The list contains a pointer
@@ -494,13 +481,13 @@ isamember(p)
*/
struct display {
- char *loginID;
- char *freefield;
- struct display *next;
+ char *loginID;
+ char *freefield;
+ struct display *next;
};
static struct display *displayhead;
-
+
/*
* void initdisp()
*
@@ -513,14 +500,14 @@ static struct display *displayhead;
*/
static void
-initdisp()
+initdisp(void)
{
- displayhead = (struct display *) allocblk(sizeof(struct display));
- displayhead->next = (struct display *) NULL;
+ displayhead = (struct display *)allocblk(sizeof (struct display));
+ displayhead->next = NULL;
displayhead->loginID = "";
displayhead->freefield = "";
}
-
+
/*
* void adddisp(pwent)
* struct passwd *pwent
@@ -544,15 +531,14 @@ initdisp()
*/
static void
-adddisp(pwent)
- struct passwd *pwent;
+adddisp(struct passwd *pwent)
{
/* Automatic data */
- struct display *new; /* Display item being added */
- struct display *prev; /* Previous display item */
- struct display *current; /* Next display item */
- int found; /* FLAG, insertion point found */
- int compare = 1; /* strcmp() compare value */
+ struct display *new; /* Display item being added */
+ struct display *prev; /* Previous display item */
+ struct display *current; /* Next display item */
+ int found; /* FLAG, insertion point found */
+ int compare = 1; /* strcmp() compare value */
/* Find where this value belongs in the list */
@@ -560,34 +546,39 @@ adddisp(pwent)
current = displayhead->next;
found = FALSE;
while (!found && current) {
- if ((compare = strcmp(current->loginID, pwent->pw_name)) >= 0)
- found = TRUE;
- else {
- prev = current;
- current = current->next;
- }
+ if ((compare = strcmp(current->loginID, pwent->pw_name)) >= 0)
+ found = TRUE;
+ else {
+ prev = current;
+ current = current->next;
+ }
}
/* Insert this value in the list, only if it is unique though */
if (compare != 0) {
- /* Build a display structure containing the value to add to the list, and add to the list */
- new = (struct display *) allocblk(sizeof(struct display));
- new->loginID = strcpy(allocstr((unsigned int) strlen(pwent->pw_name)+1), pwent->pw_name);
- if (pwent->pw_comment && pwent->pw_comment[0] != '\0')
- new->freefield =
- strcpy(allocstr((unsigned int)
- strlen(pwent->pw_comment)+1),
- pwent->pw_comment);
- else
- new->freefield =
- strcpy(allocstr((unsigned int)
- strlen(pwent->pw_gecos)+1),
- pwent->pw_gecos);
- new->next = current;
- prev->next = new;
+ /*
+ * Build a display structure containing the value to add to
+ * the list, and add to the list
+ */
+ new = (struct display *)allocblk(sizeof (struct display));
+ new->loginID =
+ strcpy(allocstr((unsigned int)strlen(pwent->pw_name)+1),
+ pwent->pw_name);
+ if (pwent->pw_comment && pwent->pw_comment[0] != '\0')
+ new->freefield =
+ strcpy(allocstr(
+ (unsigned int)strlen(pwent->pw_comment)+1),
+ pwent->pw_comment);
+ else
+ new->freefield =
+ strcpy(allocstr(
+ (unsigned int)strlen(pwent->pw_gecos)+1),
+ pwent->pw_gecos);
+ new->next = current;
+ prev->next = new;
}
}
-
+
/*
* void genreport()
*
@@ -601,11 +592,11 @@ adddisp(pwent)
*/
static void
-genreport()
+genreport(void)
{
/* Automatic data */
- struct display *current; /* Value to display */
+ struct display *current; /* Value to display */
int i; /* Counter of characters */
/*
@@ -618,14 +609,16 @@ genreport()
/*
* Display elements in the list
*/
- for (current = displayhead->next ; current ; current = current->next) {
- (void) fputs(current->loginID, stdout);
- for (i = LOGINFIELDSZ - strlen(current->loginID) ; --i >= 0 ; (void) putc(' ', stdout)) ;
- (void) fputs(current->freefield, stdout);
- (void) putc('\n', stdout);
+ for (current = displayhead->next; current; current = current->next) {
+ (void) fputs(current->loginID, stdout);
+ for (i = LOGINFIELDSZ - strlen(current->loginID); --i >= 0;
+ (void) putc(' ', stdout))
+ ;
+ (void) fputs(current->freefield, stdout);
+ (void) putc('\n', stdout);
}
}
-
+
/*
* listusers [-l logins] [-g groups]
*
@@ -642,34 +635,33 @@ genreport()
* 1 Usage error
*/
-main(argc, argv)
- int argc;
- char *argv[];
+int
+main(int argc, char **argv)
{
/* Automatic data */
- struct reqgrp *reqgrphead; /* Head of the req'd group list */
- struct reqgrp *pgrp; /* Current item in the req'd group list */
- struct reqgrp *qgrp; /* Prev item in the req'd group list */
- struct reqgrp *rgrp; /* Running ptr for scanning group list */
- struct reqlogin *reqloginhead; /* Head of req'd login list */
- struct reqlogin *plogin; /* Current item in the req'd login list */
- struct reqlogin *qlogin; /* Previous item in the req'd login list */
- struct reqlogin *rlogin; /* Running ptr for scanning login list */
- struct passwd *pwent; /* Ptr to an /etc/passwd entry */
- struct group *grent; /* Ptr to an /etc/group entry */
- char *token; /* Ptr to a token extracted by strtok() */
- char **pp; /* Ptr to a member of a group */
- char *g_arg; /* Ptr to the -g option's argument */
- char *l_arg; /* Ptr to the -l option's argument */
- int g_seen; /* FLAG, true if -g on cmd */
- int l_seen; /* FLAG, TRUE if -l is on the command line */
- int errflg; /* FLAG, TRUE if there is a command-line problem */
- int done; /* FLAG, TRUE if the process (?) is complete */
- int groupcount; /* Number of groups specified by the user */
- int rc; /* Return code from strcmp() */
- int c; /* Character returned from getopt() */
+ struct reqgrp *reqgrphead; /* Head of the req'd group list */
+ struct reqgrp *pgrp; /* Current item in the req'd group list */
+ struct reqgrp *qgrp; /* Prev item in the req'd group list */
+ struct reqgrp *rgrp; /* Running ptr for scanning group list */
+ struct reqlogin *reqloginhead; /* Head of req'd login list */
+ struct reqlogin *plogin; /* Current item in the req'd login list */
+ struct reqlogin *qlogin; /* Previous item in the req'd login list */
+ struct reqlogin *rlogin; /* Running ptr for scanning login list */
+ struct passwd *pwent; /* Ptr to an /etc/passwd entry */
+ struct group *grent; /* Ptr to an /etc/group entry */
+ char *token; /* Ptr to a token extracted by strtok() */
+ char **pp; /* Ptr to a member of a group */
+ char *g_arg; /* Ptr to the -g option's argument */
+ char *l_arg; /* Ptr to the -l option's argument */
+ int g_seen; /* FLAG, true if -g on cmd */
+ int l_seen; /* FLAG, TRUE if -l is on the command line */
+ int errflg; /* FLAG, TRUE if there is a command-line problem */
+ int done; /* FLAG, TRUE if the process (?) is complete */
+ int groupcount; /* Number of groups specified by the user */
+ int rc; /* Return code from strcmp() */
+ int c; /* Character returned from getopt() */
/* Initializations */
@@ -682,34 +674,36 @@ main(argc, argv)
opterr = 0;
while (!errflg && ((c = getopt(argc, argv, "g:l:")) != EOF)) {
- /* Case on the option character */
- switch(c) {
+ /* Case on the option character */
+ switch (c) {
- case 'g':
- if (g_seen) errflg = TRUE;
- else {
- g_seen = TRUE;
- g_arg = optarg;
- }
- break;
+ case 'g':
+ if (g_seen)
+ errflg = TRUE;
+ else {
+ g_seen = TRUE;
+ g_arg = optarg;
+ }
+ break;
+
+ case 'l':
+ if (l_seen)
+ errflg = TRUE;
+ else {
+ l_seen = TRUE;
+ l_arg = optarg;
+ }
+ break;
- case 'l':
- if (l_seen) errflg = TRUE;
- else {
- l_seen = TRUE;
- l_arg = optarg;
+ default:
+ errflg = TRUE;
}
- break;
-
- default:
- errflg = TRUE;
- }
}
/* Write out a usage message if necessary and quit */
if (errflg || (optind != argc)) {
- wrtmsg(MM_ERROR, MM_NULLACT, MM_NULLTAG, USAGE_MSG);
- exit(1);
+ wrtmsg(MM_ERROR, MM_NULLACT, MM_NULLTAG, USAGE_MSG);
+ exit(1);
}
@@ -719,42 +713,46 @@ main(argc, argv)
*/
if (g_seen) {
- /* Begin with an empty list */
- groupcount = 0;
- reqgrphead = (struct reqgrp *) NULL;
-
- /* Extract the first token putting an element on the list */
- if ((token = strtok(g_arg, ",")) != (char *) NULL) {
- pgrp = (struct reqgrp *) allocblk(sizeof(struct reqgrp));
- pgrp->groupname = token;
- pgrp->found = FALSE;
- pgrp->next = (struct reqgrp *) NULL;
- groupcount++;
- reqgrphead = pgrp;
- qgrp = pgrp;
-
- /*
- * Extract subsequent tokens (group names), avoiding duplicate
- * names (note, list is NOT empty)
- */
- while (token = strtok((char *) NULL, ",")) {
-
- /* Check for duplication */
- rgrp = reqgrphead;
- while (rgrp && (rc = strcmp(token, rgrp->groupname))) rgrp = rgrp->next;
- if (rc != 0) {
+ /* Begin with an empty list */
+ groupcount = 0;
+ reqgrphead = NULL;
- /* Not a duplicate. Add on the list */
- pgrp = (struct reqgrp *) allocblk(sizeof(struct reqgrp));
+ /* Extract the first token putting an element on the list */
+ if ((token = strtok(g_arg, ",")) != NULL) {
+ pgrp = (struct reqgrp *)
+ allocblk(sizeof (struct reqgrp));
pgrp->groupname = token;
pgrp->found = FALSE;
- pgrp->next = (struct reqgrp *) NULL;
+ pgrp->next = NULL;
groupcount++;
- qgrp->next = pgrp;
+ reqgrphead = pgrp;
qgrp = pgrp;
- }
+
+ /*
+ * Extract subsequent tokens (group names), avoiding
+ * duplicate names (note, list is NOT empty)
+ */
+ while (token = strtok(NULL, ",")) {
+
+ /* Check for duplication */
+ rgrp = reqgrphead;
+ while (rgrp &&
+ (rc = strcmp(token, rgrp->groupname)))
+ rgrp = rgrp->next;
+ if (rc != 0) {
+
+ /* Not a duplicate. Add on the list */
+ pgrp = (struct reqgrp *)
+ allocblk(sizeof (struct reqgrp));
+ pgrp->groupname = token;
+ pgrp->found = FALSE;
+ pgrp->next = NULL;
+ groupcount++;
+ qgrp->next = pgrp;
+ qgrp = pgrp;
+ }
+ }
}
- }
}
/*
@@ -763,43 +761,49 @@ main(argc, argv)
*/
if (l_seen) {
- /* Begin with a null list */
- reqloginhead = (struct reqlogin *) NULL;
-
- /* Extract the first token from the argument to the -l option */
- if (token = strtok(l_arg, ",")) {
-
- /* Put the first element in the list */
- plogin = (struct reqlogin *) allocblk(sizeof(struct reqlogin));
- plogin->loginname = token;
- plogin->found = FALSE;
- plogin->next = (struct reqlogin *) NULL;
- reqloginhead = plogin;
- qlogin = plogin;
-
- /*
- * For each subsequent token in the -l argument's
- * comma list ...
- */
-
- while (token = strtok((char *) NULL, ",")) {
+ /* Begin with a null list */
+ reqloginhead = NULL;
- /* Check for duplication (list is not empty) */
- rlogin = reqloginhead;
- while (rlogin && (rc = strcmp(token, rlogin->loginname)))
- rlogin = rlogin->next;
+ /* Extract the first token from the argument to the -l option */
+ if (token = strtok(l_arg, ",")) {
- /* If it's not a duplicate, add it to the list */
- if (rc != 0) {
- plogin = (struct reqlogin *) allocblk(sizeof(struct reqlogin));
+ /* Put the first element in the list */
+ plogin = (struct reqlogin *)
+ allocblk(sizeof (struct reqlogin));
plogin->loginname = token;
plogin->found = FALSE;
- plogin->next = (struct reqlogin *) NULL;
- qlogin->next = plogin;
+ plogin->next = NULL;
+ reqloginhead = plogin;
qlogin = plogin;
- }
+
+ /*
+ * For each subsequent token in the -l argument's
+ * comma list ...
+ */
+
+ while (token = strtok(NULL, ",")) {
+
+ /* Check for duplication (list is not empty) */
+ rlogin = reqloginhead;
+ while (rlogin &&
+ (rc = strcmp(token, rlogin->loginname)))
+ rlogin = rlogin->next;
+
+ /*
+ * If it's not a duplicate,
+ * add it to the list
+ */
+ if (rc != 0) {
+ plogin = (struct reqlogin *)
+ allocblk(sizeof (struct reqlogin));
+ plogin->loginname = token;
+ plogin->found = FALSE;
+ plogin->next = NULL;
+ qlogin->next = plogin;
+ qlogin = plogin;
+ }
+ }
}
- }
}
@@ -814,48 +818,62 @@ main(argc, argv)
initmembers();
if (g_seen) {
- /* For each group in the /etc/group file ... */
- while (grent = getgrent()) {
-
- /* For each group mentioned with the -g option ... */
- for (pgrp = reqgrphead ; (groupcount > 0) && pgrp ; pgrp = pgrp->next) {
-
- if (pgrp->found == FALSE) {
-
- /*
- * If the mentioned group is found in the
- * /etc/group file ...
- */
- if (strcmp(grent->gr_name, pgrp->groupname) == 0) {
-
- /* Mark the entry is found, remembering the
- * group-ID for later */
- pgrp->found = TRUE;
- groupcount--;
- pgrp->groupID = grent->gr_gid;
- if (isausergroup(pgrp->groupID))
- for (pp = grent->gr_mem ; *pp ; pp++) addmember(*pp);
+ /* For each group in the /etc/group file ... */
+ while (grent = getgrent()) {
+
+ /* For each group mentioned with the -g option ... */
+ for (pgrp = reqgrphead; (groupcount > 0) && pgrp;
+ pgrp = pgrp->next) {
+
+ if (pgrp->found == FALSE) {
+
+ /*
+ * If the mentioned group is found in
+ * the /etc/group file ...
+ */
+ if (strcmp(grent->gr_name,
+ pgrp->groupname) == 0) {
+
+ /*
+ * Mark the entry is found,
+ * remembering the group-ID
+ * for later
+ */
+ pgrp->found = TRUE;
+ groupcount--;
+ pgrp->groupID = grent->gr_gid;
+ if (isausergroup(pgrp->groupID))
+ for (pp = grent->gr_mem;
+ *pp; pp++)
+ addmember(*pp);
+ }
+ }
}
- }
- }
- }
-
- /* If any groups weren't found, write a message
- * indicating such, then continue */
- qgrp = (struct reqgrp *) NULL;
- for (pgrp = reqgrphead ; pgrp ; pgrp = pgrp->next) {
- if (!pgrp->found) {
- wrtmsg(MM_WARNING, MM_NULLACT, MM_NULLTAG, "%s was not found", pgrp->groupname);
- if (!qgrp) reqgrphead = pgrp->next;
- else qgrp->next = pgrp->next;
}
- else if (isasystemgroup(pgrp->groupID)) {
- wrtmsg(MM_WARNING, MM_NULLACT, MM_NULLTAG, "%s is not a user group", pgrp->groupname);
- if (!qgrp) reqgrphead = pgrp->next;
- else qgrp->next = pgrp->next;
+
+ /*
+ * If any groups weren't found, write a message
+ * indicating such, then continue
+ */
+ qgrp = NULL;
+ for (pgrp = reqgrphead; pgrp; pgrp = pgrp->next) {
+ if (!pgrp->found) {
+ wrtmsg(MM_WARNING, MM_NULLACT, MM_NULLTAG,
+ "%s was not found", pgrp->groupname);
+ if (!qgrp)
+ reqgrphead = pgrp->next;
+ else
+ qgrp->next = pgrp->next;
+ } else if (isasystemgroup(pgrp->groupID)) {
+ wrtmsg(MM_WARNING, MM_NULLACT, MM_NULLTAG,
+ "%s is not a user group", pgrp->groupname);
+ if (!qgrp)
+ reqgrphead = pgrp->next;
+ else
+ qgrp->next = pgrp->next;
+ } else
+ qgrp = pgrp;
}
- else qgrp = pgrp;
- }
}
@@ -869,65 +887,77 @@ main(argc, argv)
*/
while (pwent = getpwent()) {
- /* The login from /etc/passwd hasn't been included in
- * the display yet */
- done = FALSE;
-
-
- /*
- * If the login was explicitly requested, include it in
- * the display if it is a user login
- */
-
- if (l_seen) {
- for (plogin = reqloginhead ; !done && plogin ; plogin = plogin->next) {
- if (strcmp(pwent->pw_name, plogin->loginname) == 0) {
- plogin->found = TRUE;
- if (isauserlogin(pwent->pw_uid)) adddisp(pwent);
- else
- wrtmsg(MM_WARNING, MM_NULLACT, MM_NULLTAG,
- "%s is not a user login", plogin->loginname);
- done = TRUE;
- }
- }
- }
-
-
- /*
- * If the login-ID isn't already on the list, if its primary
- * group-ID is one of those groups requested, or it is a member
- * of the groups requested, include it in the display if it is
- * a user login (uid >= 100).
- */
-
- if (isauserlogin(pwent->pw_uid)) {
-
- if (!done && g_seen) {
- for (pgrp = reqgrphead ; !done && pgrp ; pgrp = pgrp->next)
- if (pwent->pw_gid == pgrp->groupID) {
- adddisp(pwent);
- done = TRUE;
- }
- if (!done && isamember(pwent->pw_name)) {
- adddisp(pwent);
- done = TRUE;
- }
+ /*
+ * The login from /etc/passwd hasn't been included in
+ * the display yet
+ */
+ done = FALSE;
+
+
+ /*
+ * If the login was explicitly requested, include it in
+ * the display if it is a user login
+ */
+
+ if (l_seen) {
+ for (plogin = reqloginhead; !done && plogin;
+ plogin = plogin->next) {
+ if (strcmp(pwent->pw_name,
+ plogin->loginname) == 0) {
+ plogin->found = TRUE;
+ if (isauserlogin(pwent->pw_uid))
+ adddisp(pwent);
+ else
+ wrtmsg(MM_WARNING, MM_NULLACT,
+ MM_NULLTAG,
+ "%s is not a user login",
+ plogin->loginname);
+ done = TRUE;
+ }
+ }
}
/*
- * If neither -l nor -g is on the command-line and the login-ID
- * is a user login, include it in the display.
+ * If the login-ID isn't already on the list, if its primary
+ * group-ID is one of those groups requested, or it is a member
+ * of the groups requested, include it in the display if it is
+ * a user login (uid >= 100).
*/
- if (!l_seen && !g_seen) adddisp(pwent);
- }
+ if (isauserlogin(pwent->pw_uid)) {
+
+ if (!done && g_seen) {
+ for (pgrp = reqgrphead; !done && pgrp;
+ pgrp = pgrp->next)
+ if (pwent->pw_gid == pgrp->groupID) {
+ adddisp(pwent);
+ done = TRUE;
+ }
+ if (!done && isamember(pwent->pw_name)) {
+ adddisp(pwent);
+ done = TRUE;
+ }
+ }
+
+
+ /*
+ * If neither -l nor -g is on the command-line and
+ * the login-ID is a user login, include it in
+ * the display.
+ */
+
+ if (!l_seen && !g_seen)
+ adddisp(pwent);
+ }
}
/* Let the user know about logins they requested that don't exist */
- if (l_seen) for (plogin = reqloginhead ; plogin ; plogin = plogin->next)
- if (!plogin->found)
- wrtmsg(MM_WARNING, MM_NULLACT, MM_NULLTAG, "%s was not found", plogin->loginname);
+ if (l_seen)
+ for (plogin = reqloginhead; plogin; plogin = plogin->next)
+ if (!plogin->found)
+ wrtmsg(MM_WARNING, MM_NULLACT, MM_NULLTAG,
+ "%s was not found", plogin->loginname);
/*
@@ -938,9 +968,5 @@ main(argc, argv)
/*
* We're through!
*/
- exit(0);
-
-#ifdef lint
- return(0);
-#endif
+ return (0);
}
diff --git a/usr/src/cmd/xstr/xstr.c b/usr/src/cmd/xstr/xstr.c
index 0e673f0770..7378337aa2 100644
--- a/usr/src/cmd/xstr/xstr.c
+++ b/usr/src/cmd/xstr/xstr.c
@@ -12,13 +12,15 @@
* specifies the terms and conditions for redistribution.
*/
-#ident "%Z%%M% %I% %E% SMI"
+#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <ctype.h>
#include <sys/types.h>
#include <signal.h>
#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
/*
* xstr - extract and hash strings in a C program
@@ -27,16 +29,23 @@
* November, 1978
*/
-#define ignore(a) ((void) a)
-
off_t tellpt;
-off_t hashit();
-void onintr();
-char *savestr();
-char *strcat();
-char *strcpy();
-off_t yankstr();
-void cleanup();
+off_t hashit(char *, int);
+void onintr(void);
+char *savestr(char *);
+off_t yankstr(char **);
+void cleanup(void);
+void process(char *);
+int octdigit(char);
+void inithash(void);
+void flushsh(void);
+void found(int, off_t, char *);
+void prstr(char *);
+void xsdotc(void);
+int fgetNUL(char *, int, FILE *);
+int xgetc(FILE *);
+int lastchr(char *);
+int istail(char *, char *);
off_t mesgpt;
char *strings = "strings";
@@ -47,15 +56,12 @@ char *xname = "xstr";
int readstd;
int tmpfd;
-main(argc, argv)
- int argc;
- char *argv[];
+int
+main(int argc, char **argv)
{
-
-
argc--, argv++;
while (argc > 0 && argv[0][0] == '-') {
- register char *cp = &(*argv++)[1];
+ char *cp = &(*argv++)[1];
argc--;
if (*cp == 0) {
@@ -78,12 +84,12 @@ main(argc, argv)
continue;
default:
- fprintf(stderr,
+ (void) fprintf(stderr,
"usage: xstr [ -v ] [ -c ] [ -l label ] [ - ] [ name ... ]\n");
} while (*cp);
}
if (signal(SIGINT, SIG_IGN) == SIG_DFL)
- signal(SIGINT, onintr);
+ (void) signal(SIGINT, (void (*)(int))onintr);
if (cflg || argc == 0 && !readstd)
inithash();
else {
@@ -106,26 +112,25 @@ main(argc, argv)
argc--, argv++;
else
readstd = 0;
- };
+ }
flushsh();
if (cflg == 0)
xsdotc();
(void) cleanup();
- exit(0);
- /* NOTREACHED */
+ return (0);
}
char linebuf[BUFSIZ];
-process(name)
- char *name;
+void
+process(char *name)
{
char *cp;
- register int c;
- register int incomm = 0;
+ int c;
+ int incomm = 0;
int ret;
- printf("extern char\t%s[];\n", xname);
+ (void) printf("extern char\t%s[];\n", xname);
for (;;) {
if (fgets(linebuf, sizeof (linebuf), stdin) == NULL) {
if (ferror(stdin)) {
@@ -137,27 +142,27 @@ process(name)
}
if (linebuf[0] == '#') {
if (linebuf[1] == ' ' && isdigit(linebuf[2]))
- printf("#line%s", &linebuf[1]);
+ (void) printf("#line%s", &linebuf[1]);
else
- printf("%s", linebuf);
+ (void) printf("%s", linebuf);
continue;
}
- for (cp = linebuf; c = *cp++; ) {
+ for (cp = linebuf; (c = *cp++) != 0; ) {
switch (c) {
case '"':
if (incomm)
goto def;
- if ((ret = (int) yankstr(&cp)) == -1)
+ if ((ret = (int)yankstr(&cp)) == -1)
goto out;
- printf("(&%s[%d])", xname, ret);
+ (void) printf("(&%s[%d])", xname, ret);
break;
case '\'':
if (incomm)
goto def;
- putchar(c);
+ (void) putchar(c);
if (*cp)
- putchar(*cp++);
+ (void) putchar(*cp++);
break;
case '/':
@@ -165,20 +170,20 @@ process(name)
goto def;
incomm = 1;
cp++;
- printf("/*");
+ (void) printf("/*");
continue;
case '*':
if (incomm && *cp == '/') {
incomm = 0;
cp++;
- printf("*/");
+ (void) printf("*/");
continue;
}
goto def;
def:
default:
- putchar(c);
+ (void) putchar(c);
break;
}
}
@@ -189,16 +194,15 @@ out:
}
off_t
-yankstr(cpp)
- register char **cpp;
+yankstr(char **cpp)
{
- register char *cp = *cpp;
- register int c, ch;
+ char *cp = *cpp;
+ int c, ch;
char dbuf[BUFSIZ];
- register char *dp = dbuf;
- register char *tp;
+ char *dp = dbuf;
+ char *tp;
- while (c = *cp++) {
+ while ((c = *cp++) != 0) {
switch (c) {
case '"':
@@ -223,7 +227,8 @@ yankstr(cpp)
cp = linebuf;
continue;
}
- for (tp = "b\bt\tr\rn\nf\f\\\\\"\""; ch = *tp++; tp++)
+ for (tp = "b\bt\tr\rn\nf\f\\\\\"\""; (ch = *tp++) != 0;
+ tp++)
if (c == ch) {
c = *tp;
goto gotc;
@@ -250,17 +255,18 @@ out:
return (hashit(dbuf, 1));
}
-octdigit(c)
- char c;
+int
+octdigit(char c)
{
return (isdigit(c) && c != '8' && c != '9');
}
-inithash()
+void
+inithash(void)
{
char buf[BUFSIZ];
- register FILE *mesgread = fopen(strings, "r");
+ FILE *mesgread = fopen(strings, "r");
if (mesgread == NULL)
return;
@@ -268,18 +274,16 @@ inithash()
mesgpt = tellpt;
if (fgetNUL(buf, sizeof (buf), mesgread) == NULL)
break;
- ignore(hashit(buf, 0));
+ (void) hashit(buf, 0);
}
- ignore(fclose(mesgread));
+ (void) fclose(mesgread);
}
-fgetNUL(obuf, rmdr, file)
- char *obuf;
- register int rmdr;
- FILE *file;
+int
+fgetNUL(char *obuf, int rmdr, FILE *file)
{
- register c;
- register char *buf = obuf;
+ int c;
+ char *buf = obuf;
while (--rmdr > 0 && (c = xgetc(file)) != 0 && c != EOF)
*buf++ = c;
@@ -287,8 +291,8 @@ fgetNUL(obuf, rmdr, file)
return ((feof(file) || ferror(file)) ? NULL : 1);
}
-xgetc(file)
- FILE *file;
+int
+xgetc(FILE *file)
{
tellpt++;
@@ -305,12 +309,10 @@ struct hash {
} bucket[BUCKETS];
off_t
-hashit(str, new)
- char *str;
- int new;
+hashit(char *str, int new)
{
int i;
- register struct hash *hp, *hp0;
+ struct hash *hp, *hp0;
hp = hp0 = &bucket[lastchr(str) & 0177];
while (hp->hnext) {
@@ -319,7 +321,7 @@ hashit(str, new)
if (i >= 0)
return (hp->hpt + i);
}
- if ((hp = (struct hash *) calloc(1, sizeof (*hp))) == NULL) {
+ if ((hp = calloc(1, sizeof (*hp))) == NULL) {
perror("xstr");
(void) cleanup();
exit(8);
@@ -333,12 +335,13 @@ hashit(str, new)
return (hp->hpt);
}
-flushsh()
+void
+flushsh(void)
{
- register int i;
- register struct hash *hp;
- register FILE *mesgwrit;
- register int old = 0, new = 0;
+ int i;
+ struct hash *hp;
+ FILE *mesgwrit;
+ int old = 0, new = 0;
for (i = 0; i < BUCKETS; i++)
for (hp = bucket[i].hnext; hp != NULL; hp = hp->hnext)
@@ -355,9 +358,9 @@ flushsh()
for (hp = bucket[i].hnext; hp != NULL; hp = hp->hnext) {
found(hp->hnew, hp->hpt, hp->hstr);
if (hp->hnew) {
- fseek(mesgwrit, hp->hpt, 0);
- ignore(fwrite(hp->hstr,
- strlen(hp->hstr) + 1, 1, mesgwrit));
+ (void) fseek(mesgwrit, hp->hpt, 0);
+ (void) fwrite(hp->hstr,
+ strlen(hp->hstr) + 1, 1, mesgwrit);
if (ferror(mesgwrit)) {
perror(strings);
(void) cleanup();
@@ -369,50 +372,49 @@ flushsh()
perror(strings), (void) cleanup(), exit(4);
}
-found(new, off, str)
- int new;
- off_t off;
- char *str;
+void
+found(int new, off_t off, char *str)
{
if (vflg == 0)
return;
if (!new)
- fprintf(stderr, "found at %d:", (int) off);
+ (void) fprintf(stderr, "found at %d:", (int)off);
else
- fprintf(stderr, "new at %d:", (int) off);
+ (void) fprintf(stderr, "new at %d:", (int)off);
prstr(str);
- fprintf(stderr, "\n");
+ (void) fprintf(stderr, "\n");
}
-prstr(cp)
- register char *cp;
+void
+prstr(char *cp)
{
- register int c;
+ int c;
- while (c = (*cp++ & 0377))
+ while ((c = (*cp++ & 0377)) != 0)
if (c < ' ')
- fprintf(stderr, "^%c", c + '`');
+ (void) fprintf(stderr, "^%c", c + '`');
else if (c == 0177)
- fprintf(stderr, "^?");
+ (void) fprintf(stderr, "^?");
else if (c > 0200)
- fprintf(stderr, "\\%03o", c);
+ (void) fprintf(stderr, "\\%03o", c);
else
- fprintf(stderr, "%c", c);
+ (void) fprintf(stderr, "%c", c);
}
-xsdotc()
+void
+xsdotc(void)
{
- register FILE *strf = fopen(strings, "r");
- register FILE *xdotcf;
+ FILE *strf = fopen(strings, "r");
+ FILE *xdotcf;
if (strf == NULL)
perror(strings), exit(5);
xdotcf = fopen("xs.c", "w");
if (xdotcf == NULL)
perror("xs.c"), exit(6);
- fprintf(xdotcf, "char\t%s[] = {\n", xname);
+ (void) fprintf(xdotcf, "char\t%s[] = {\n", xname);
for (;;) {
- register int i, c;
+ int i, c;
for (i = 0; i < 8; i++) {
c = getc(strf);
@@ -421,45 +423,44 @@ xsdotc()
onintr();
}
if (feof(strf)) {
- fprintf(xdotcf, "\n");
+ (void) fprintf(xdotcf, "\n");
goto out;
}
- fprintf(xdotcf, "0x%02x,", c);
+ (void) fprintf(xdotcf, "0x%02x,", c);
}
- fprintf(xdotcf, "\n");
+ (void) fprintf(xdotcf, "\n");
}
out:
- fprintf(xdotcf, "};\n");
- ignore(fclose(xdotcf));
- ignore(fclose(strf));
+ (void) fprintf(xdotcf, "};\n");
+ (void) fclose(xdotcf);
+ (void) fclose(strf);
}
char *
-savestr(cp)
- register char *cp;
+savestr(char *cp)
{
- register char *dp;
+ char *dp;
- if ((dp = (char *) calloc(1, strlen(cp) + 1)) == NULL) {
+ if ((dp = calloc(1, strlen(cp) + 1)) == NULL) {
perror("xstr");
exit(8);
}
return (strcpy(dp, cp));
}
-lastchr(cp)
- register char *cp;
+int
+lastchr(char *cp)
{
while (cp[0] && cp[1])
cp++;
- return (*cp);
+ return ((int)*cp);
}
-istail(str, of)
- register char *str, *of;
+int
+istail(char *str, char *of)
{
- register int d = strlen(of) - strlen(str);
+ int d = strlen(of) - strlen(str);
if (d < 0 || strcmp(&of[d], str) != 0)
return (-1);
@@ -467,19 +468,20 @@ istail(str, of)
}
void
-onintr()
+onintr(void)
{
- ignore(signal(SIGINT, SIG_IGN));
+ (void) signal(SIGINT, SIG_IGN);
(void) cleanup();
- ignore(unlink("x.c"));
- ignore(unlink("xs.c"));
+ (void) unlink("x.c");
+ (void) unlink("xs.c");
exit(7);
}
+
void
cleanup(void)
{
if (strings[0] == '/') {
- ignore(unlink(strings));
+ (void) unlink(strings);
}
}