From 25e8adb8a26cb114bb9bdc099ab8bc1ab7b4950c Mon Sep 17 00:00:00 2001 From: kapyar Date: Sat, 27 Sep 2003 13:22:52 +0000 Subject: [PATCH] Fixed for compilation under Cygwin environment --- src/main.c | 45 ++++++++++++++++++++++++++++++++++++++++++--- src/tty.c | 7 ++++++- src/tty.h | 15 +++++++++++---- 3 files changed, 59 insertions(+), 8 deletions(-) diff --git a/src/main.c b/src/main.c index bd6fb85..b89513a 100644 --- a/src/main.c +++ b/src/main.c @@ -28,7 +28,7 @@ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: main.c,v 1.1 2003/09/13 20:38:16 kapyar Exp $ + * $Id: main.c,v 1.2 2003/09/27 13:22:52 kapyar Exp $ */ #include "globals.h" @@ -39,7 +39,7 @@ #include "queue.h" #include "sig.h" #ifdef LOG -#include "log.h" +# include "log.h" #endif int isdaemon = TRUE; @@ -53,6 +53,46 @@ ttydata_t tty; /* Connections queue descriptor */ queue_t queue; +#ifndef HAVE_DAEMON +#include +#include +/* + * System function daemon() replacement based on FreeBSD implementation. + * Original source file CVS tag: + * $FreeBSD: src/lib/libc/gen/daemon.c,v 1.3 2000/01/27 23:06:14 jasone Exp $ + */ +int +daemon(nochdir, noclose) + int nochdir, noclose; +{ + int fd; + + switch (fork()) { + case -1: + return (-1); + case 0: + break; + default: + _exit(0); + } + + if (setsid() == -1) + return (-1); + + if (!nochdir) + (void)chdir("/"); + + if (!noclose && (fd = _open("/dev/null", O_RDWR, 0)) != -1) { + (void)dup2(fd, STDIN_FILENO); + (void)dup2(fd, STDOUT_FILENO); + (void)dup2(fd, STDERR_FILENO); + if (fd > 2) + (void)_close(fd); + } + return (0); +} +#endif + void usage(char *exename) { @@ -244,4 +284,3 @@ main(int argc, char *argv[]) #endif return (err); } - diff --git a/src/tty.c b/src/tty.c index 034f8b1..408658b 100644 --- a/src/tty.c +++ b/src/tty.c @@ -28,7 +28,7 @@ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: tty.c,v 1.1 2003/09/13 20:38:28 kapyar Exp $ + * $Id: tty.c,v 1.2 2003/09/27 13:22:52 kapyar Exp $ */ #include "tty.h" @@ -134,7 +134,12 @@ tty_set_attr(ttydata_t *mod) mod->tios.c_lflag = FALSE; mod->tios.c_cc[VTIME] = 0; mod->tios.c_cc[VMIN] = 1; +#ifdef HAVE_CFSETSPEED cfsetspeed(&mod->tios, tty_transpeed(mod->speed)); +#else + cfsetispeed(&mod->tios, tty_transpeed(mod->speed)); + cfsetospeed(&mod->tios, tty_transpeed(mod->speed)); +#endif if (tcsetattr(mod->fd, TCSANOW, &mod->tios)) return RC_ERR; #if defined(TIOCSETA) diff --git a/src/tty.h b/src/tty.h index 97839c2..a21ef38 100644 --- a/src/tty.h +++ b/src/tty.h @@ -28,7 +28,7 @@ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: tty.h,v 1.1 2003/09/13 20:38:28 kapyar Exp $ + * $Id: tty.h,v 1.2 2003/09/27 13:22:52 kapyar Exp $ */ #ifndef _TTY_H @@ -45,7 +45,14 @@ /* * Default tty port parameters */ -#define DEFAULT_PORT "/dev/cuaa0" +#if defined (__CYGWIN__) +# define DEFAULT_PORT "/dev/COM1" +#elif defined (__linux__) +# define DEFAULT_PORT "/dev/ttyS0" +#else +# define DEFAULT_PORT "/dev/cuaa0" +#endif + #define DEFAULT_SPEED 19200 #define DEFAULT_BSPEED B19200 @@ -58,8 +65,8 @@ * TRX control types */ #ifdef TRX_CTL -#define TRX_ADDC 0 -#define TRX_RTS !TRX_ADDC +# define TRX_ADDC 0 +# define TRX_RTS !TRX_ADDC #endif /*