mirror of
https://github.com/3cky/mbusd.git
synced 2025-02-05 23:21:28 +01:00
Fixed for compilation under Cygwin environment
This commit is contained in:
parent
013ded07df
commit
25e8adb8a2
45
src/main.c
45
src/main.c
@ -28,7 +28,7 @@
|
|||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* 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"
|
#include "globals.h"
|
||||||
@ -39,7 +39,7 @@
|
|||||||
#include "queue.h"
|
#include "queue.h"
|
||||||
#include "sig.h"
|
#include "sig.h"
|
||||||
#ifdef LOG
|
#ifdef LOG
|
||||||
#include "log.h"
|
# include "log.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int isdaemon = TRUE;
|
int isdaemon = TRUE;
|
||||||
@ -53,6 +53,46 @@ ttydata_t tty;
|
|||||||
/* Connections queue descriptor */
|
/* Connections queue descriptor */
|
||||||
queue_t queue;
|
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
|
void
|
||||||
usage(char *exename)
|
usage(char *exename)
|
||||||
{
|
{
|
||||||
@ -244,4 +284,3 @@ main(int argc, char *argv[])
|
|||||||
#endif
|
#endif
|
||||||
return (err);
|
return (err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* 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"
|
#include "tty.h"
|
||||||
@ -134,7 +134,12 @@ tty_set_attr(ttydata_t *mod)
|
|||||||
mod->tios.c_lflag = FALSE;
|
mod->tios.c_lflag = FALSE;
|
||||||
mod->tios.c_cc[VTIME] = 0;
|
mod->tios.c_cc[VTIME] = 0;
|
||||||
mod->tios.c_cc[VMIN] = 1;
|
mod->tios.c_cc[VMIN] = 1;
|
||||||
|
#ifdef HAVE_CFSETSPEED
|
||||||
cfsetspeed(&mod->tios, tty_transpeed(mod->speed));
|
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))
|
if (tcsetattr(mod->fd, TCSANOW, &mod->tios))
|
||||||
return RC_ERR;
|
return RC_ERR;
|
||||||
#if defined(TIOCSETA)
|
#if defined(TIOCSETA)
|
||||||
|
15
src/tty.h
15
src/tty.h
@ -28,7 +28,7 @@
|
|||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* 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
|
#ifndef _TTY_H
|
||||||
@ -45,7 +45,14 @@
|
|||||||
/*
|
/*
|
||||||
* Default tty port parameters
|
* 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_SPEED 19200
|
||||||
#define DEFAULT_BSPEED B19200
|
#define DEFAULT_BSPEED B19200
|
||||||
|
|
||||||
@ -58,8 +65,8 @@
|
|||||||
* TRX control types
|
* TRX control types
|
||||||
*/
|
*/
|
||||||
#ifdef TRX_CTL
|
#ifdef TRX_CTL
|
||||||
#define TRX_ADDC 0
|
# define TRX_ADDC 0
|
||||||
#define TRX_RTS !TRX_ADDC
|
# define TRX_RTS !TRX_ADDC
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user