Fixed for compilation under Cygwin environment

This commit is contained in:
kapyar 2003-09-27 13:22:52 +00:00
parent 013ded07df
commit 25e8adb8a2
3 changed files with 59 additions and 8 deletions

View File

@ -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 <fcntl.h>
#include <unistd.h>
/*
* 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);
}

View File

@ -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)

View File

@ -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
/*