- Fixed compile for linux

git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/trunk@195 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
Diane Bruce 2006-07-09 03:12:26 +00:00
parent 471d593dd7
commit 91cae5bd11

View File

@ -50,11 +50,11 @@
#ifdef HAVE_DEV_PPBUS_PPI_H #ifdef HAVE_DEV_PPBUS_PPI_H
# include <dev/ppbus/ppi.h> # include <dev/ppbus/ppi.h>
# include <dev/ppbus/ppbconf.h> # include <dev/ppbus/ppbconf.h>
#endif
int lp_reset (int fd); int lp_reset (int fd);
int lp_ptt (int fd, int onoff); int lp_ptt (int fd, int onoff);
#endif
#ifdef HAVE_SYS_STAT_H #ifdef HAVE_SYS_STAT_H
# include <sys/stat.h> # include <sys/stat.h>
#endif #endif
@ -82,11 +82,13 @@ char nm[MAXPATHLEN];
* *
* generic unix PTT routine called from Fortran * generic unix PTT routine called from Fortran
* *
* unused - Unused, to satisfy old windows calling convention * Inputs
* ptt_port - device name serial or parallel * unused Unused, to satisfy old windows calling convention
* ntx - pointer to fortran command on or off * ptt_port device name serial or parallel
* iptt - pointer to fortran command status on or off * ntx pointer to fortran command on or off
*/ * iptt pointer to fortran command status on or off
* Returns - non 0 if error
*/
/* Tiny state machine */ /* Tiny state machine */
#define STATE_PORT_CLOSED 0 #define STATE_PORT_CLOSED 0
@ -166,8 +168,6 @@ ptt_serial(int fd, int *ntx, int *iptt)
/* parport functions */ /* parport functions */
int lp_reset (int fd);
int lp_ptt (int fd, int onoff);
/* /*
* dev_is_parport(name): check to see whether 'name' is a parallel * dev_is_parport(name): check to see whether 'name' is a parallel
@ -183,21 +183,22 @@ dev_is_parport(const char *fname)
{ {
struct stat st; struct stat st;
int fd; int fd;
int m;
snprintf(nm, sizeof(nm), "/dev/%s", fname); snprintf(nm, sizeof(nm), "/dev/%s", fname);
if ((fd = open(nm, O_RDWR | O_NONBLOCK)) == -1) if ((fd = open(nm, O_RDWR | O_NONBLOCK)) == -1)
return (-1); return(-1);
if (fstat(fd, &st) == -1) if (fstat(fd, &st) == -1)
goto out; goto out;
if ((st.st_mode & S_IFMT) != S_IFCHR) if ((st.st_mode & S_IFMT) != S_IFCHR)
goto out; goto out;
if (ioctl(fd, PPGETMODE, &m) == -1) if (ioctl(fd, PPGETMODE, &m) == -1)
goto out; goto out;
return (fd); return(fd);
out: out:
close(fd); close(fd);
return (-1); return(-1);
} }
#elif defined(HAVE_DEV_PPBUS_PPI_H) /* FreeBSD (ppbus/ppi) */ #elif defined(HAVE_DEV_PPBUS_PPI_H) /* FreeBSD (ppbus/ppi) */
@ -216,17 +217,17 @@ dev_is_parport(const char *fname)
snprintf(nm, sizeof(nm), "/dev/%s", fname); snprintf(nm, sizeof(nm), "/dev/%s", fname);
if ((fd = open(nm, O_RDWR | O_NONBLOCK)) == -1) if ((fd = open(nm, O_RDWR | O_NONBLOCK)) == -1)
return (-1); return(-1);
if (fstat(fd, &st) == -1) if (fstat(fd, &st) == -1)
goto out; goto out;
if ((st.st_mode & S_IFMT) != S_IFCHR) if ((st.st_mode & S_IFMT) != S_IFCHR)
goto out; goto out;
if (ioctl(fd, PPISSTATUS, &c) == -1) if (ioctl(fd, PPISSTATUS, &c) == -1)
goto out; goto out;
return (fd); return(fd);
out: out:
close(fd); close(fd);
return (-1); return(-1);
} }
#else /* Fallback (nothing) */ #else /* Fallback (nothing) */
@ -234,7 +235,7 @@ out:
int int
dev_is_parport(const char *fname) dev_is_parport(const char *fname)
{ {
return (-1); return(-1);
} }
#endif #endif
@ -294,21 +295,21 @@ lp_init (int fd)
{ {
fprintf(stderr, "Setting parallel port mode"); fprintf(stderr, "Setting parallel port mode");
close (fd); close (fd);
exit (1); return(-1);
} }
if (ioctl (fd, PPEXCL, NULL) == -1) if (ioctl (fd, PPEXCL, NULL) == -1)
{ {
fprintf(stderr, "Parallel port %s is already in use", dev->desc); fprintf(stderr, "Parallel port is already in use.\n");
close (fd); close (fd);
exit (1); return(-1);
} }
if (ioctl (fd, PPCLAIM, NULL) == -1) if (ioctl (fd, PPCLAIM, NULL) == -1)
{ {
fprintf(stderr, "Claiming parallel port %s", dev->desc); fprintf(stderr, "Claiming parallel port.\n");
debug ("HINT: did you unload the lp kernel module?"); fprintf(stderr, "HINT: did you unload the lp kernel module?");
close (fd); close (fd);
exit (1); return(-1);
} }
/* Enable CW & PTT - /STROBE bit (pin 1) */ /* Enable CW & PTT - /STROBE bit (pin 1) */
@ -318,7 +319,7 @@ lp_init (int fd)
parport_control (fd, STROBE, STROBE); parport_control (fd, STROBE, STROBE);
#endif #endif
lp_reset (fd); lp_reset (fd);
return 0; return(0);
} }
/* release ppdev and close port */ /* release ppdev and close port */
@ -338,7 +339,7 @@ lp_free (int fd)
parport_control (fd, STROBE, 0); parport_control (fd, STROBE, 0);
#endif #endif
close (fd); close (fd);
return 0; return(0);
} }
/* set to a known state */ /* set to a known state */
@ -348,7 +349,7 @@ lp_reset (int fd)
#if defined (HAVE_LINUX_PPDEV_H) || defined (HAVE_DEV_PPBUS_PPI_H) #if defined (HAVE_LINUX_PPDEV_H) || defined (HAVE_DEV_PPBUS_PPI_H)
lp_ptt (fd, 0); lp_ptt (fd, 0);
#endif #endif
return 0; return(0);
} }
/* SSB PTT keying - /INIT bit (pin 16) (inverted) */ /* SSB PTT keying - /INIT bit (pin 16) (inverted) */
@ -369,7 +370,7 @@ lp_ptt (int fd, int onoff)
else else
parport_control (fd, nINIT, 0); parport_control (fd, nINIT, 0);
#endif #endif
return 0; return(0);
} }
/* /*