diff --git a/WEGA/contrib/WEGA-Remote/Makefile b/WEGA/contrib/WEGA-Remote/Makefile index 5feafb8..53a60b3 100755 --- a/WEGA/contrib/WEGA-Remote/Makefile +++ b/WEGA/contrib/WEGA-Remote/Makefile @@ -9,28 +9,27 @@ INCL = /usr/include BIN = is ready for installation in /bin # Cflags -#CFLAGS = -O -s -LDFLAGS = -lcompat +CFLAGS+= -Wall # # Abhaengigkeiten und Aktionen # -default: putfile getfile local +default: putfile getfile local remote putfile: putfile.c $(INCL)/sgtty.h $(INCL)/sys/types.h \ $(INCL)/sys/stat.h $(INCL)/signal.h - $(CC) $(CFLAGS) putfile.c -o $@ $(LDFLAGS) + $(CC) $(CFLAGS) putfile.c -o $@ $(ECHO) $@ $(BIN) $(ECHO) with mode: 751 owner: bin group: 0 local: local.c $(INCL)/sgtty.h - $(CC) $(CFLAGS) local.c -o $@ $(LDFLAGS) + $(CC) $(CFLAGS) local.c -o $@ $(ECHO) $@ $(BIN) $(ECHO) with mode: 751 owner: bin group: 0 getfile: getfile.c $(INCL)/sgtty.h $(INCL)/signal.h - $(CC) $(CFLAGS) getfile.c -o $@ $(LDFLAGS) + $(CC) $(CFLAGS) getfile.c -o $@ $(ECHO) $@ $(BIN) $(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 $@ $(ECHO) $@ $(BIN) $(ECHO) with mode: 751 owner: bin group: 0 + +clean: + rm -f putfile getfile local remote diff --git a/WEGA/contrib/WEGA-Remote/getfile.c b/WEGA/contrib/WEGA-Remote/getfile.c index 9da9927..0217677 100644 --- a/WEGA/contrib/WEGA-Remote/getfile.c +++ b/WEGA/contrib/WEGA-Remote/getfile.c @@ -21,9 +21,24 @@ #define EXEC 0x10 /* mode flag is sent after the filename */ #define SECONDS 20 /* timeout interval */ -#include #include +#ifdef __FreeBSD__ +#include +#include +#include +#include +#include +void look_for_etx(); +void aread(); +struct termios targ; +#define RAW ICANON +#define CRMOD OPOST +#define XTABS OXTABS +#define TANDEM IXON|IXOFF +#else +#include struct sgttyb targ; +#endif char *tty, *ttyname(); @@ -35,6 +50,9 @@ int timeout = 0; char *fname; char flags = 0; +#ifdef __FreeBSD__ +int +#endif main (argc, argv) int argc; @@ -52,11 +70,19 @@ char **argv; if (chmod(tty, 0600) == -1) /* write protect the terminal */ 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 */ tflags = targ.sg_flags; /* save flag word */ targ.sg_flags |= RAW ; /* set 1-char input, no parity output */ targ.sg_flags &= ~(ECHO | TANDEM); /* turn off echo, xon-xoff handling */ stty (0, &targ); +#endif while (--argc > 0) /* process all command line args */ { @@ -136,7 +162,11 @@ char **argv; look_for_etx(); /* flush chars coming from local sys */ printf("%c", CAN); /* send cancel */ 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 */ +#endif } else /* file was opened with no error */ @@ -229,13 +259,21 @@ char **argv; 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 */ stty (0, &targ); +#endif printf ("\ngetfile: %d successful transfers %d unsuccessful transfers\n", success, unsuccess); if (chmod(tty, 0622) == -1) /* un-write protect the terminal */ printf ("\ngetfile: unable to un-write protect the terminal\n"); +#ifdef __FreeBSD__ + return 0; +#endif } #ifdef __FreeBSD__ @@ -247,6 +285,9 @@ time_out() timeout = 1; } +#ifdef __FreeBSD__ +void +#endif look_for_etx() /* look for etx and chksum */ { while (c != ETX) @@ -258,6 +299,9 @@ look_for_etx() /* look for etx and chksum */ if(timeout) return; } +#ifdef __FreeBSD__ +void +#endif aread() /* alarm read */ { timeout = 0; /* assume no timeout */ diff --git a/WEGA/contrib/WEGA-Remote/local.c b/WEGA/contrib/WEGA-Remote/local.c index 09cbf44..4fb3800 100644 --- a/WEGA/contrib/WEGA-Remote/local.c +++ b/WEGA/contrib/WEGA-Remote/local.c @@ -9,13 +9,28 @@ #define SOH 0x01 /* ascii start-of-header character */ #define ESC 0x1b /* ascii escape character */ -#include +#ifdef __FreeBSD__ +#include +#include +#include +#include +#include +#include +struct termios targ; +#define RAW ICANON +#else #include struct sgttyb targ; +#endif + +#include int tflags; char c; +#ifdef __FreeBSD__ +int +#endif main (argc, argv) int argc; char *argv[]; @@ -29,11 +44,19 @@ char *argv[]; 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 */ tflags = targ.sg_flags; /* save flag word */ targ.sg_flags |= RAW; /* set RAW mode for program duration */ targ.sg_flags &= ~ECHO; /* turn off character echo */ stty (0, &targ); +#endif printf ("%c%c", SOH, ESC); /* soh, escape - code for a special request */ @@ -55,6 +78,12 @@ char *argv[]; 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 */ stty (0, &targ); +#endif } diff --git a/WEGA/contrib/WEGA-Remote/putfile.c b/WEGA/contrib/WEGA-Remote/putfile.c index 73f8893..e9d9d6c 100644 --- a/WEGA/contrib/WEGA-Remote/putfile.c +++ b/WEGA/contrib/WEGA-Remote/putfile.c @@ -20,9 +20,21 @@ #define EXEC 0x10 #define SECONDS 20 /* timeout interval */ -#include #include +#ifdef __FreeBSD__ +#include +#include +#include +#include +struct termios targ; +#define RAW ICANON +#define CRMOD OPOST +#define XTABS OXTABS +#define TANDEM IXON|IXOFF +#else +#include struct sgttyb targ; +#endif #include #include @@ -36,6 +48,9 @@ int timeout = 0; char *fname; char flags = 0; +#ifdef __FreeBSD__ +int +#endif main (argc, argv) int argc; @@ -53,12 +68,21 @@ char **argv; if (chmod(tty, 0600) == -1) /* write protect terminal */ 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 */ tflags = targ.sg_flags; /* save flag word */ targ.sg_flags |= RAW; /* set 1-char input, no parity output */ targ.sg_flags &= ~(ECHO|CRMOD|XTABS|TANDEM); /* turn off echo, carr. return */ /* subst. and tab replacement */ stty (0, &targ); +#endif 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 */ stty (0, &targ); +#endif printf ("\nputfile: %d successful transfers %d unsuccessful transfers\n", success, unsuccess); if (chmod(tty, 0622) == -1) /* un-write protect */ printf ("\nputfile: unable to un-write protect the terminal\n"); +#ifdef __FreeBSD__ + return 0; +#endif } #ifdef __FreeBSD__ diff --git a/WEGA/contrib/WEGA-Remote/remote.c b/WEGA/contrib/WEGA-Remote/remote.c index 6252697..2d2f86f 100644 --- a/WEGA/contrib/WEGA-Remote/remote.c +++ b/WEGA/contrib/WEGA-Remote/remote.c @@ -68,6 +68,13 @@ char esc = ESC; char exc = EXEC; #ifdef __FreeBSD__ +#include +#include +#include +#include +#include +#include +#include #include #include #define TCGETA TIOCGETA @@ -77,6 +84,8 @@ char exc = EXEC; #define CBAUD 0010017 #define TCFLSH TCIOFLUSH #define termio termios +void logout(); +int try(); #else #include #endif @@ -93,18 +102,29 @@ static char line[100],*p; /* buffer for reading in database */ static int lockfd,pterm; static struct termio targ; /* defined in termio.h */ static struct termio tflags, ptflags; /* original tty flags */ +#ifdef __FreeBSD__ +static struct termio ptxlflags; /* xlucent flags */ +#else static struct termio txlflags, ptxlflags; /* xlucent flags */ +#endif #ifdef __FreeBSD__ #define curint SIG_DFL #else int (*curint)(); /* initial SIGINT value */ #endif +#ifdef __FreeBSD__ +void +#endif xlucent (term, targp, savterm) /* make terminal interface translucent and */ int term; /* return the previous configuration */ struct termio *targp, *savterm; { +#ifdef __FreeBSD__ + int iospeed = 0, i; +#else int iospeed, i; +#endif ioctl (term, TCGETA, targp); /* get terminal parameters */ 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 */ int term; /* return the previous configuration */ struct termio *targp, *savterm; @@ -177,6 +200,9 @@ struct termio *targp, *savterm; } /* return terminal interface to its initial state */ +#ifdef __FreeBSD__ +void +#endif tinit (term, savterm, targp) int term; struct termio *savterm, *targp; @@ -198,6 +224,9 @@ struct termio *savterm, *targp; return; } +#ifdef __FreeBSD__ +void +#endif term_to_wega (pterm) /* send all input from terminal to wega */ int pterm; { @@ -251,6 +280,9 @@ int pterm; } } +#ifdef __FreeBSD__ +void +#endif watch_for_abort (parent) /* child executes this routine during file */ int parent; /* transfers to detect user abort requests */ { @@ -297,6 +329,9 @@ time_out () /* set flag to indicate a read timed out */ timeout = 1; } +#ifdef __FreeBSD__ +void +#endif message (pterm) /* get a message from the remote system */ 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 */ int pterm; char *cptr; @@ -322,6 +360,9 @@ char *cptr; } +#ifdef __FreeBSD__ +void +#endif wait_etx (pterm) /* wait for etx, checksum from remote system */ int pterm; { @@ -334,6 +375,9 @@ int pterm; return; } +#ifdef __FreeBSD__ +int +#endif getname (pterm, name) /* get a file name from the remote system */ int pterm; char *name; @@ -393,6 +437,9 @@ char *name; } } +#ifdef __FreeBSD__ +int +#endif getrec (pterm, fd) /* get a file record from remote system */ int pterm; 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 */ int pterm; { @@ -505,7 +555,11 @@ int pterm; 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 */ +#endif c = 'y'; if(flags & QUERY) /* test for existing file */ @@ -521,8 +575,13 @@ int pterm; { write(pterm, &can, 1); /* cancel the transfer */ 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 */ return; +#endif } printf ("\n\r%s", fname); /* print file name */ @@ -559,7 +618,11 @@ int pterm; close (dnfd); /* end of file sent */ printf ("\n\r"); write (pterm, &ack, 1); +#ifdef __FreeBSD__ + return 0; +#else return; +#endif case 4: write (pterm, &can, 1); /* user requests cancellation */ 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 */ int pterm; /* send the record here */ 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 */ int pterm; { @@ -650,7 +719,11 @@ int pterm; 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 */ +#endif printf ("\n\r%s", fname); /* print file name */ if ((upfd = open (fname, 0)) < 0) /* open the file */ @@ -694,10 +767,17 @@ int pterm; } write (pterm, &ack, 1); /* tell remote system to proceed */ +#ifdef __FreeBSD__ + return 0; +#else return; +#endif } +#ifdef __FreeBSD__ +int +#endif main (argc, argv) int argc; char **argv; @@ -867,6 +947,9 @@ char **argv; } } +#ifdef __FreeBSD__ +int +#endif try(device) char *device; { @@ -917,6 +1000,9 @@ char *device; xlucent (0, &targ, &tflags); /* set new terminal parameters */ xlucent (pterm, &targ, &ptflags); /* set new pseudo terminal parameters */ signal(SIGINT, curint); /* reset to original SIGINT value */ +#ifdef __FreeBSD__ + return 0; +#endif } #ifdef __FreeBSD__ @@ -929,6 +1015,9 @@ cleanup() /* interrupt or hang up, so exit gracefully */ logout(); } +#ifdef __FreeBSD__ +void +#endif logout() /* logout processing */ { ioctl(pterm, TCFLSH, 2); /* flush remote line */