make -Wall clean

remove -lcompat dependency
This commit is contained in:
Oliver Lehmann 2006-06-01 06:56:25 +00:00
parent b9499ee45b
commit 7d5d07246d
5 changed files with 205 additions and 9 deletions

View File

@ -9,28 +9,27 @@ INCL = /usr/include
BIN = is ready for installation in /bin BIN = is ready for installation in /bin
# Cflags # Cflags
#CFLAGS = -O -s CFLAGS+= -Wall
LDFLAGS = -lcompat
# #
# Abhaengigkeiten und Aktionen # Abhaengigkeiten und Aktionen
# #
default: putfile getfile local default: putfile getfile local remote
putfile: putfile.c $(INCL)/sgtty.h $(INCL)/sys/types.h \ putfile: putfile.c $(INCL)/sgtty.h $(INCL)/sys/types.h \
$(INCL)/sys/stat.h $(INCL)/signal.h $(INCL)/sys/stat.h $(INCL)/signal.h
$(CC) $(CFLAGS) putfile.c -o $@ $(LDFLAGS) $(CC) $(CFLAGS) putfile.c -o $@
$(ECHO) $@ $(BIN) $(ECHO) $@ $(BIN)
$(ECHO) with mode: 751 owner: bin group: 0 $(ECHO) with mode: 751 owner: bin group: 0
local: local.c $(INCL)/sgtty.h local: local.c $(INCL)/sgtty.h
$(CC) $(CFLAGS) local.c -o $@ $(LDFLAGS) $(CC) $(CFLAGS) local.c -o $@
$(ECHO) $@ $(BIN) $(ECHO) $@ $(BIN)
$(ECHO) with mode: 751 owner: bin group: 0 $(ECHO) with mode: 751 owner: bin group: 0
getfile: getfile.c $(INCL)/sgtty.h $(INCL)/signal.h getfile: getfile.c $(INCL)/sgtty.h $(INCL)/signal.h
$(CC) $(CFLAGS) getfile.c -o $@ $(LDFLAGS) $(CC) $(CFLAGS) getfile.c -o $@
$(ECHO) $@ $(BIN) $(ECHO) $@ $(BIN)
$(ECHO) with mode: 751 owner: bin group: 0 $(ECHO) with mode: 751 owner: bin group: 0
@ -39,3 +38,6 @@ remote: remote.c $(INCL)/termios.h $(INCL)/signal.h $(INCL)/stdio.h \
$(CC) $(CFLAGS) remote.c -o $@ $(CC) $(CFLAGS) remote.c -o $@
$(ECHO) $@ $(BIN) $(ECHO) $@ $(BIN)
$(ECHO) with mode: 751 owner: bin group: 0 $(ECHO) with mode: 751 owner: bin group: 0
clean:
rm -f putfile getfile local remote

View File

@ -21,9 +21,24 @@
#define EXEC 0x10 /* mode flag is sent after the filename */ #define EXEC 0x10 /* mode flag is sent after the filename */
#define SECONDS 20 /* timeout interval */ #define SECONDS 20 /* timeout interval */
#include <sgtty.h>
#include <signal.h> #include <signal.h>
#ifdef __FreeBSD__
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <term.h>
#include <sys/stat.h>
void look_for_etx();
void aread();
struct termios targ;
#define RAW ICANON
#define CRMOD OPOST
#define XTABS OXTABS
#define TANDEM IXON|IXOFF
#else
#include <sgtty.h>
struct sgttyb targ; struct sgttyb targ;
#endif
char *tty, *ttyname(); char *tty, *ttyname();
@ -35,6 +50,9 @@ int timeout = 0;
char *fname; char *fname;
char flags = 0; char flags = 0;
#ifdef __FreeBSD__
int
#endif
main (argc, argv) main (argc, argv)
int argc; int argc;
@ -52,11 +70,19 @@ char **argv;
if (chmod(tty, 0600) == -1) /* write protect the terminal */ if (chmod(tty, 0600) == -1) /* write protect the terminal */
printf ("\ngetfile: unable to write protect the terminal\n"); printf ("\ngetfile: unable to write protect the terminal\n");
#ifdef __FreeBSD__
tcgetattr(0, &targ); /* get current terminal parameters */
tflags = targ.c_oflag; /* save flag word */
targ.c_oflag |= RAW; /* set 1-char input, no parity output */
targ.c_oflag &= ~(ECHO | TANDEM); /* turn off echo, xon-xoff handling */
tcsetattr(0, TCSADRAIN, &targ);
#else
gtty (0, &targ); /* get current terminal parameters */ gtty (0, &targ); /* get current terminal parameters */
tflags = targ.sg_flags; /* save flag word */ tflags = targ.sg_flags; /* save flag word */
targ.sg_flags |= RAW ; /* set 1-char input, no parity output */ targ.sg_flags |= RAW ; /* set 1-char input, no parity output */
targ.sg_flags &= ~(ECHO | TANDEM); /* turn off echo, xon-xoff handling */ targ.sg_flags &= ~(ECHO | TANDEM); /* turn off echo, xon-xoff handling */
stty (0, &targ); stty (0, &targ);
#endif
while (--argc > 0) /* process all command line args */ while (--argc > 0) /* process all command line args */
{ {
@ -136,7 +162,11 @@ char **argv;
look_for_etx(); /* flush chars coming from local sys */ look_for_etx(); /* flush chars coming from local sys */
printf("%c", CAN); /* send cancel */ printf("%c", CAN); /* send cancel */
printf ("\n\nunable to open file on remote system\r\n"); printf ("\n\nunable to open file on remote system\r\n");
#ifdef __FreeBSD__
scanf("%c",&c); /* wait for CAN from local sys */
#else
scanf("%c",c); /* wait for CAN from local sys */ scanf("%c",c); /* wait for CAN from local sys */
#endif
} }
else /* file was opened with no error */ else /* file was opened with no error */
@ -229,13 +259,21 @@ char **argv;
flags &= ~BINARY; /* default to ascii type next file */ flags &= ~BINARY; /* default to ascii type next file */
} }
} }
#ifdef __FreeBSD__
targ.c_oflag = tflags; /* restore initial terminal flags */
tcsetattr(0, TCSADRAIN, &targ);
#else
targ.sg_flags = tflags; /* restore initial terminal flags */ targ.sg_flags = tflags; /* restore initial terminal flags */
stty (0, &targ); stty (0, &targ);
#endif
printf ("\ngetfile: %d successful transfers %d unsuccessful transfers\n", printf ("\ngetfile: %d successful transfers %d unsuccessful transfers\n",
success, unsuccess); success, unsuccess);
if (chmod(tty, 0622) == -1) /* un-write protect the terminal */ if (chmod(tty, 0622) == -1) /* un-write protect the terminal */
printf ("\ngetfile: unable to un-write protect the terminal\n"); printf ("\ngetfile: unable to un-write protect the terminal\n");
#ifdef __FreeBSD__
return 0;
#endif
} }
#ifdef __FreeBSD__ #ifdef __FreeBSD__
@ -247,6 +285,9 @@ time_out()
timeout = 1; timeout = 1;
} }
#ifdef __FreeBSD__
void
#endif
look_for_etx() /* look for etx and chksum */ look_for_etx() /* look for etx and chksum */
{ {
while (c != ETX) while (c != ETX)
@ -258,6 +299,9 @@ look_for_etx() /* look for etx and chksum */
if(timeout) return; if(timeout) return;
} }
#ifdef __FreeBSD__
void
#endif
aread() /* alarm read */ aread() /* alarm read */
{ {
timeout = 0; /* assume no timeout */ timeout = 0; /* assume no timeout */

View File

@ -9,13 +9,28 @@
#define SOH 0x01 /* ascii start-of-header character */ #define SOH 0x01 /* ascii start-of-header character */
#define ESC 0x1b /* ascii escape character */ #define ESC 0x1b /* ascii escape character */
#include <pwd.h> #ifdef __FreeBSD__
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <term.h>
struct termios targ;
#define RAW ICANON
#else
#include <sgtty.h> #include <sgtty.h>
struct sgttyb targ; struct sgttyb targ;
#endif
#include <pwd.h>
int tflags; int tflags;
char c; char c;
#ifdef __FreeBSD__
int
#endif
main (argc, argv) main (argc, argv)
int argc; int argc;
char *argv[]; char *argv[];
@ -29,11 +44,19 @@ char *argv[];
exit(0); exit(0);
} }
#ifdef __FreeBSD__
tcgetattr(0, &targ); /* get current terminal parameters */
tflags = targ.c_oflag; /* save flag word */
targ.c_oflag |= RAW; /* set 1-char input, no parity output */
targ.c_oflag &= ~ECHO; /* turn off echo, xon-xoff handling */
tcsetattr(0, TCSADRAIN, &targ);
#else
gtty (0, &targ); /* get current terminal parameters */ gtty (0, &targ); /* get current terminal parameters */
tflags = targ.sg_flags; /* save flag word */ tflags = targ.sg_flags; /* save flag word */
targ.sg_flags |= RAW; /* set RAW mode for program duration */ targ.sg_flags |= RAW; /* set RAW mode for program duration */
targ.sg_flags &= ~ECHO; /* turn off character echo */ targ.sg_flags &= ~ECHO; /* turn off character echo */
stty (0, &targ); stty (0, &targ);
#endif
printf ("%c%c", SOH, ESC); /* soh, escape - code for a special request */ printf ("%c%c", SOH, ESC); /* soh, escape - code for a special request */
@ -55,6 +78,12 @@ char *argv[];
c = getchar(); /* wait for acknowledge */ c = getchar(); /* wait for acknowledge */
} }
#ifdef __FreeBSD__
targ.c_oflag = tflags;
tcsetattr(0, TCSADRAIN, &targ);
return 0;
#else
targ.sg_flags = tflags; /* restore initial terminal mode */ targ.sg_flags = tflags; /* restore initial terminal mode */
stty (0, &targ); stty (0, &targ);
#endif
} }

View File

@ -20,9 +20,21 @@
#define EXEC 0x10 #define EXEC 0x10
#define SECONDS 20 /* timeout interval */ #define SECONDS 20 /* timeout interval */
#include <sgtty.h>
#include <signal.h> #include <signal.h>
#ifdef __FreeBSD__
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <term.h>
struct termios targ;
#define RAW ICANON
#define CRMOD OPOST
#define XTABS OXTABS
#define TANDEM IXON|IXOFF
#else
#include <sgtty.h>
struct sgttyb targ; struct sgttyb targ;
#endif
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
@ -36,6 +48,9 @@ int timeout = 0;
char *fname; char *fname;
char flags = 0; char flags = 0;
#ifdef __FreeBSD__
int
#endif
main (argc, argv) main (argc, argv)
int argc; int argc;
@ -53,12 +68,21 @@ char **argv;
if (chmod(tty, 0600) == -1) /* write protect terminal */ if (chmod(tty, 0600) == -1) /* write protect terminal */
printf ("\nputfile: unable to write protect the terminal\n"); printf ("\nputfile: unable to write protect the terminal\n");
#ifdef __FreeBSD__
tcgetattr(0, &targ); /* get current terminal parameters */
tflags = targ.c_oflag; /* save flag word */
targ.c_oflag |= RAW; /* set 1-char input, no parity output */
targ.c_oflag &= ~(ECHO|CRMOD|XTABS|TANDEM); /* turn off echo, carr. return */
/* subst. and tab replacement */
tcsetattr(0, TCSADRAIN, &targ);
#else
gtty (0, &targ); /* get current terminal parameters */ gtty (0, &targ); /* get current terminal parameters */
tflags = targ.sg_flags; /* save flag word */ tflags = targ.sg_flags; /* save flag word */
targ.sg_flags |= RAW; /* set 1-char input, no parity output */ targ.sg_flags |= RAW; /* set 1-char input, no parity output */
targ.sg_flags &= ~(ECHO|CRMOD|XTABS|TANDEM); /* turn off echo, carr. return */ targ.sg_flags &= ~(ECHO|CRMOD|XTABS|TANDEM); /* turn off echo, carr. return */
/* subst. and tab replacement */ /* subst. and tab replacement */
stty (0, &targ); stty (0, &targ);
#endif
while (--argc > 0) /* process all command line args */ while (--argc > 0) /* process all command line args */
{ {
@ -195,13 +219,21 @@ char **argv;
} }
} }
} }
#ifdef __FreeBSD__
targ.c_oflag = tflags; /* restore initial terminal flags */
tcsetattr(0, TCSADRAIN, &targ);
#else
targ.sg_flags = tflags; /* restore initial terminal flags */ targ.sg_flags = tflags; /* restore initial terminal flags */
stty (0, &targ); stty (0, &targ);
#endif
printf ("\nputfile: %d successful transfers %d unsuccessful transfers\n", printf ("\nputfile: %d successful transfers %d unsuccessful transfers\n",
success, unsuccess); success, unsuccess);
if (chmod(tty, 0622) == -1) /* un-write protect */ if (chmod(tty, 0622) == -1) /* un-write protect */
printf ("\nputfile: unable to un-write protect the terminal\n"); printf ("\nputfile: unable to un-write protect the terminal\n");
#ifdef __FreeBSD__
return 0;
#endif
} }
#ifdef __FreeBSD__ #ifdef __FreeBSD__

View File

@ -68,6 +68,13 @@ char esc = ESC;
char exc = EXEC; char exc = EXEC;
#ifdef __FreeBSD__ #ifdef __FreeBSD__
#include <sys/types.h>
#include <sys/uio.h>
#include <sys/wait.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <fcntl.h>
#include <termios.h> #include <termios.h>
#include <sys/ttycom.h> #include <sys/ttycom.h>
#define TCGETA TIOCGETA #define TCGETA TIOCGETA
@ -77,6 +84,8 @@ char exc = EXEC;
#define CBAUD 0010017 #define CBAUD 0010017
#define TCFLSH TCIOFLUSH #define TCFLSH TCIOFLUSH
#define termio termios #define termio termios
void logout();
int try();
#else #else
#include <termio.h> #include <termio.h>
#endif #endif
@ -93,18 +102,29 @@ static char line[100],*p; /* buffer for reading in database */
static int lockfd,pterm; static int lockfd,pterm;
static struct termio targ; /* defined in termio.h */ static struct termio targ; /* defined in termio.h */
static struct termio tflags, ptflags; /* original tty flags */ static struct termio tflags, ptflags; /* original tty flags */
#ifdef __FreeBSD__
static struct termio ptxlflags; /* xlucent flags */
#else
static struct termio txlflags, ptxlflags; /* xlucent flags */ static struct termio txlflags, ptxlflags; /* xlucent flags */
#endif
#ifdef __FreeBSD__ #ifdef __FreeBSD__
#define curint SIG_DFL #define curint SIG_DFL
#else #else
int (*curint)(); /* initial SIGINT value */ int (*curint)(); /* initial SIGINT value */
#endif #endif
#ifdef __FreeBSD__
void
#endif
xlucent (term, targp, savterm) /* make terminal interface translucent and */ xlucent (term, targp, savterm) /* make terminal interface translucent and */
int term; /* return the previous configuration */ int term; /* return the previous configuration */
struct termio *targp, *savterm; struct termio *targp, *savterm;
{ {
#ifdef __FreeBSD__
int iospeed = 0, i;
#else
int iospeed, i; int iospeed, i;
#endif
ioctl (term, TCGETA, targp); /* get terminal parameters */ ioctl (term, TCGETA, targp); /* get terminal parameters */
savterm->c_iflag = targp->c_iflag; savterm->c_iflag = targp->c_iflag;
@ -151,6 +171,9 @@ struct termio *targp, *savterm;
} }
#ifdef __FreeBSD__
void
#endif
xparent (term, targp, savterm) /* make terminal interface transparent and */ xparent (term, targp, savterm) /* make terminal interface transparent and */
int term; /* return the previous configuration */ int term; /* return the previous configuration */
struct termio *targp, *savterm; struct termio *targp, *savterm;
@ -177,6 +200,9 @@ struct termio *targp, *savterm;
} }
/* return terminal interface to its initial state */ /* return terminal interface to its initial state */
#ifdef __FreeBSD__
void
#endif
tinit (term, savterm, targp) tinit (term, savterm, targp)
int term; int term;
struct termio *savterm, *targp; struct termio *savterm, *targp;
@ -198,6 +224,9 @@ struct termio *savterm, *targp;
return; return;
} }
#ifdef __FreeBSD__
void
#endif
term_to_wega (pterm) /* send all input from terminal to wega */ term_to_wega (pterm) /* send all input from terminal to wega */
int pterm; int pterm;
{ {
@ -251,6 +280,9 @@ int pterm;
} }
} }
#ifdef __FreeBSD__
void
#endif
watch_for_abort (parent) /* child executes this routine during file */ watch_for_abort (parent) /* child executes this routine during file */
int parent; /* transfers to detect user abort requests */ int parent; /* transfers to detect user abort requests */
{ {
@ -297,6 +329,9 @@ time_out () /* set flag to indicate a read timed out */
timeout = 1; timeout = 1;
} }
#ifdef __FreeBSD__
void
#endif
message (pterm) /* get a message from the remote system */ message (pterm) /* get a message from the remote system */
int pterm; /* an ETX ends the message */ int pterm; /* an ETX ends the message */
{ {
@ -311,6 +346,9 @@ int pterm; /* an ETX ends the message */
} }
#ifdef __FreeBSD__
void
#endif
aread (pterm, cptr) /* time out a read using the alarm clock */ aread (pterm, cptr) /* time out a read using the alarm clock */
int pterm; int pterm;
char *cptr; char *cptr;
@ -322,6 +360,9 @@ char *cptr;
} }
#ifdef __FreeBSD__
void
#endif
wait_etx (pterm) /* wait for etx, checksum from remote system */ wait_etx (pterm) /* wait for etx, checksum from remote system */
int pterm; int pterm;
{ {
@ -334,6 +375,9 @@ int pterm;
return; return;
} }
#ifdef __FreeBSD__
int
#endif
getname (pterm, name) /* get a file name from the remote system */ getname (pterm, name) /* get a file name from the remote system */
int pterm; int pterm;
char *name; char *name;
@ -393,6 +437,9 @@ char *name;
} }
} }
#ifdef __FreeBSD__
int
#endif
getrec (pterm, fd) /* get a file record from remote system */ getrec (pterm, fd) /* get a file record from remote system */
int pterm; int pterm;
int fd; /* file descriptor of local system file */ int fd; /* file descriptor of local system file */
@ -490,6 +537,9 @@ int fd; /* file descriptor of local system file */
} }
} }
#ifdef __FreeBSD__
int
#endif
load (pterm) /* download a file from the remote system */ load (pterm) /* download a file from the remote system */
int pterm; int pterm;
{ {
@ -505,7 +555,11 @@ int pterm;
printmsg = (flags & FATAL) ? 0 : 1; /* print or suppress non-fatal msgs */ printmsg = (flags & FATAL) ? 0 : 1; /* print or suppress non-fatal msgs */
#ifdef __FreeBSD__
if (getname (pterm, fname) < 0) return -1; /* get the file name */
#else
if (getname (pterm, fname) < 0) return; /* get the file name */ if (getname (pterm, fname) < 0) return; /* get the file name */
#endif
c = 'y'; c = 'y';
if(flags & QUERY) /* test for existing file */ if(flags & QUERY) /* test for existing file */
@ -521,8 +575,13 @@ int pterm;
{ {
write(pterm, &can, 1); /* cancel the transfer */ write(pterm, &can, 1); /* cancel the transfer */
aread(pterm, &c); /* wait for CAN from remote sys */ aread(pterm, &c); /* wait for CAN from remote sys */
#ifdef __FreeBSD__
write(pterm, &ack, 1); /* tell remote sys to proceed */
return 0;
#else
write(pterm &ack, 1); /* tell remote sys to proceed */ write(pterm &ack, 1); /* tell remote sys to proceed */
return; return;
#endif
} }
printf ("\n\r%s", fname); /* print file name */ printf ("\n\r%s", fname); /* print file name */
@ -559,7 +618,11 @@ int pterm;
close (dnfd); /* end of file sent */ close (dnfd); /* end of file sent */
printf ("\n\r"); printf ("\n\r");
write (pterm, &ack, 1); write (pterm, &ack, 1);
#ifdef __FreeBSD__
return 0;
#else
return; return;
#endif
case 4: case 4:
write (pterm, &can, 1); /* user requests cancellation */ write (pterm, &can, 1); /* user requests cancellation */
break; /* remote system should return a cancel */ break; /* remote system should return a cancel */
@ -570,6 +633,9 @@ int pterm;
} }
} }
#ifdef __FreeBSD__
int
#endif
sendrec (pterm, fd, fname) /* upload one file record */ sendrec (pterm, fd, fname) /* upload one file record */
int pterm; /* send the record here */ int pterm; /* send the record here */
int fd; /* get the record from this file */ int fd; /* get the record from this file */
@ -633,6 +699,9 @@ char *fname; /* file name used for message only */
} }
} }
#ifdef __FreeBSD__
int
#endif
send (pterm) /* upload a file to the remote system */ send (pterm) /* upload a file to the remote system */
int pterm; int pterm;
{ {
@ -650,7 +719,11 @@ int pterm;
printmsg = (flags & FATAL) ? 0 : 1; /* print or suppress non-fatal msgs */ printmsg = (flags & FATAL) ? 0 : 1; /* print or suppress non-fatal msgs */
#ifdef __FreeBSD__
if (getname (pterm, fname) < 0) return -1; /* get the file name */
#else
if (getname (pterm, fname) < 0) return; /* get the file name */ if (getname (pterm, fname) < 0) return; /* get the file name */
#endif
printf ("\n\r%s", fname); /* print file name */ printf ("\n\r%s", fname); /* print file name */
if ((upfd = open (fname, 0)) < 0) /* open the file */ if ((upfd = open (fname, 0)) < 0) /* open the file */
@ -694,10 +767,17 @@ int pterm;
} }
write (pterm, &ack, 1); /* tell remote system to proceed */ write (pterm, &ack, 1); /* tell remote system to proceed */
#ifdef __FreeBSD__
return 0;
#else
return; return;
#endif
} }
#ifdef __FreeBSD__
int
#endif
main (argc, argv) main (argc, argv)
int argc; int argc;
char **argv; char **argv;
@ -867,6 +947,9 @@ char **argv;
} }
} }
#ifdef __FreeBSD__
int
#endif
try(device) try(device)
char *device; char *device;
{ {
@ -917,6 +1000,9 @@ char *device;
xlucent (0, &targ, &tflags); /* set new terminal parameters */ xlucent (0, &targ, &tflags); /* set new terminal parameters */
xlucent (pterm, &targ, &ptflags); /* set new pseudo terminal parameters */ xlucent (pterm, &targ, &ptflags); /* set new pseudo terminal parameters */
signal(SIGINT, curint); /* reset to original SIGINT value */ signal(SIGINT, curint); /* reset to original SIGINT value */
#ifdef __FreeBSD__
return 0;
#endif
} }
#ifdef __FreeBSD__ #ifdef __FreeBSD__
@ -929,6 +1015,9 @@ cleanup() /* interrupt or hang up, so exit gracefully */
logout(); logout();
} }
#ifdef __FreeBSD__
void
#endif
logout() /* logout processing */ logout() /* logout processing */
{ {
ioctl(pterm, TCFLSH, 2); /* flush remote line */ ioctl(pterm, TCFLSH, 2); /* flush remote line */