diff --git a/WEGA/contrib/WEGA-Remote/getfile.c b/WEGA/contrib/WEGA-Remote/getfile.c index 0217677..bd409f1 100644 --- a/WEGA/contrib/WEGA-Remote/getfile.c +++ b/WEGA/contrib/WEGA-Remote/getfile.c @@ -22,14 +22,16 @@ #define SECONDS 20 /* timeout interval */ #include -#ifdef __FreeBSD__ #include #include + +void look_for_etx(); +void aread(); + +#ifdef __FreeBSD__ #include #include #include -void look_for_etx(); -void aread(); struct termios targ; #define RAW ICANON #define CRMOD OPOST @@ -50,20 +52,14 @@ int timeout = 0; char *fname; char flags = 0; -#ifdef __FreeBSD__ int -#endif main (argc, argv) int argc; char **argv; { -#ifdef __FreeBSD__ void time_out(); -#else - int time_out(); -#endif signal(SIGALRM,time_out); /* set up alarm handling */ tty = ttyname(1); /* get name of the output file */ @@ -106,7 +102,7 @@ char **argv; c = 'y'; /* assume we are proceeding */ if (flags & QUERY) /* test for existing file */ - if ((fd = open(*argv, 0)) != -1) /* file exists */ + if ((fd = open(*argv, O_RDONLY)) != -1) /* file exists */ { printf ("replace %s (y/n)?", *argv); c = getchar() & 0177; /* could have parity so mask bit 7 */ @@ -162,11 +158,7 @@ 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 */ @@ -271,23 +263,18 @@ char **argv; 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__ void -#endif time_out() { signal(SIGALRM,time_out); timeout = 1; } -#ifdef __FreeBSD__ void -#endif look_for_etx() /* look for etx and chksum */ { while (c != ETX) @@ -299,9 +286,7 @@ 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 4fb3800..6a9a773 100644 --- a/WEGA/contrib/WEGA-Remote/local.c +++ b/WEGA/contrib/WEGA-Remote/local.c @@ -9,8 +9,8 @@ #define SOH 0x01 /* ascii start-of-header character */ #define ESC 0x1b /* ascii escape character */ -#ifdef __FreeBSD__ #include +#ifdef __FreeBSD__ #include #include #include @@ -28,9 +28,7 @@ int tflags; char c; -#ifdef __FreeBSD__ int -#endif main (argc, argv) int argc; char *argv[]; @@ -81,9 +79,9 @@ char *argv[]; #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 + return 0; } diff --git a/WEGA/contrib/WEGA-Remote/putfile.c b/WEGA/contrib/WEGA-Remote/putfile.c index e9d9d6c..bf7d8d6 100644 --- a/WEGA/contrib/WEGA-Remote/putfile.c +++ b/WEGA/contrib/WEGA-Remote/putfile.c @@ -21,9 +21,10 @@ #define SECONDS 20 /* timeout interval */ #include -#ifdef __FreeBSD__ #include #include + +#ifdef __FreeBSD__ #include #include struct termios targ; @@ -48,20 +49,14 @@ int timeout = 0; char *fname; char flags = 0; -#ifdef __FreeBSD__ int -#endif main (argc, argv) int argc; char **argv; { -#ifdef __FreeBSD__ void time_out(); -#else - int time_out(); -#endif signal(SIGALRM,time_out); /* set up alarm handling */ tty = ttyname(1); /* get name of the output file */ @@ -104,7 +99,7 @@ char **argv; } else /* argument is a file name */ { - if ((fd = open(*argv, 0)) == -1) /* open file and test for error */ + if ((fd = open(*argv, O_RDONLY)) == -1) /* open file and test for error */ { printf ("\n%s\n\nunable to open file on remote system\r\n", *argv); unsuccess++; @@ -231,14 +226,11 @@ char **argv; 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__ void -#endif time_out() { signal(SIGALRM,time_out); diff --git a/WEGA/contrib/WEGA-Remote/remote.c b/WEGA/contrib/WEGA-Remote/remote.c index 2d2f86f..ef1ca84 100644 --- a/WEGA/contrib/WEGA-Remote/remote.c +++ b/WEGA/contrib/WEGA-Remote/remote.c @@ -67,14 +67,14 @@ char can = CAN; char esc = ESC; char exc = EXEC; + #ifdef __FreeBSD__ +#include #include #include #include #include #include -#include -#include #include #include #define TCGETA TIOCGETA @@ -84,11 +84,10 @@ char exc = EXEC; #define CBAUD 0010017 #define TCFLSH TCIOFLUSH #define termio termios -void logout(); -int try(); #else #include #endif +#include #include #include #include @@ -102,29 +101,17 @@ 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 +void logout(); +int try(); + -#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; @@ -171,9 +158,7 @@ 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; @@ -200,9 +185,7 @@ 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; @@ -224,16 +207,12 @@ struct termio *savterm, *targp; return; } -#ifdef __FreeBSD__ void -#endif term_to_wega (pterm) /* send all input from terminal to wega */ int pterm; { char c; -#ifdef __FreeBSD__ void cleanup(); -#endif while (1) /* do forever */ { @@ -280,9 +259,7 @@ int pterm; } } -#ifdef __FreeBSD__ void -#endif watch_for_abort (parent) /* child executes this routine during file */ int parent; /* transfers to detect user abort requests */ { @@ -301,9 +278,7 @@ int parent; /* transfers to detect user abort requests */ } -#ifdef __FreeBSD__ void -#endif total_abort () /* set flag to indicate all xfers to stop */ { signal (SIGQUIT, total_abort); /* set up the signal call again */ @@ -311,27 +286,21 @@ total_abort () /* set flag to indicate all xfers to stop */ } -#ifdef __FreeBSD__ void -#endif single_abort () /* set flag to stop xfer in progress */ { signal (SIGTERM, single_abort); /* set up the signal call again */ onestop = 1; } -#ifdef __FreeBSD__ void -#endif time_out () /* set flag to indicate a read timed out */ { signal (SIGALRM, time_out); /* set up the signal call again */ timeout = 1; } -#ifdef __FreeBSD__ void -#endif message (pterm) /* get a message from the remote system */ int pterm; /* an ETX ends the message */ { @@ -346,9 +315,7 @@ 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; @@ -360,9 +327,7 @@ char *cptr; } -#ifdef __FreeBSD__ void -#endif wait_etx (pterm) /* wait for etx, checksum from remote system */ int pterm; { @@ -375,9 +340,7 @@ int pterm; return; } -#ifdef __FreeBSD__ int -#endif getname (pterm, name) /* get a file name from the remote system */ int pterm; char *name; @@ -437,9 +400,7 @@ 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 */ @@ -537,9 +498,7 @@ int fd; /* file descriptor of local system file */ } } -#ifdef __FreeBSD__ int -#endif load (pterm) /* download a file from the remote system */ int pterm; { @@ -555,11 +514,7 @@ 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 */ @@ -575,13 +530,8 @@ 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 */ @@ -618,11 +568,7 @@ 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 */ @@ -633,9 +579,7 @@ 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 */ @@ -699,9 +643,7 @@ char *fname; /* file name used for message only */ } } -#ifdef __FreeBSD__ int -#endif send (pterm) /* upload a file to the remote system */ int pterm; { @@ -719,11 +661,7 @@ 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 */ @@ -767,39 +705,25 @@ 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; { char c, wega_to_term(); FILE *dbf; /* file descriptor for database */ -#ifdef __FreeBSD__ void total_abort(), single_abort(), time_out(), cleanup(), intrupt(); -#else - int total_abort(), single_abort(), time_out(), cleanup(), intrupt(); -#endif int inithookup; /* initial hookup flag */ char *eof,*nxtdev; /* end of file on database */ inithookup = 1; signal(SIGHUP, cleanup); /* watch for hangups */ /* get current SIGINT value, watch for interrupts before going to raw mode */ -#ifdef __FreeBSD__ signal(SIGINT, intrupt); -#else - curint = signal(SIGINT, intrupt); -#endif signal(SIGALRM, time_out); /* set up timeout for initial hookup */ /* attempt to open database file */ @@ -947,9 +871,7 @@ char **argv; } } -#ifdef __FreeBSD__ int -#endif try(device) char *device; { @@ -999,15 +921,11 @@ char *device; ioctl(pterm, TCFLSH, 2); 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__ + signal(SIGINT, SIG_DFL); /* reset to original SIGINT value */ return 0; -#endif } -#ifdef __FreeBSD__ void -#endif cleanup() /* interrupt or hang up, so exit gracefully */ { write(pterm, "logout\n", 7); @@ -1015,9 +933,7 @@ cleanup() /* interrupt or hang up, so exit gracefully */ logout(); } -#ifdef __FreeBSD__ void -#endif logout() /* logout processing */ { ioctl(pterm, TCFLSH, 2); /* flush remote line */ @@ -1031,9 +947,7 @@ logout() /* logout processing */ /* * this routine is used by both parent and child */ -#ifdef __FreeBSD__ void -#endif intrupt() { unlink(locknm);