/*
* $Log$
+ * Revision 1.7 2008/02/15 23:52:12 james
+ * *** empty log message ***
+ *
* Revision 1.6 2008/02/15 03:32:07 james
* *** empty log message ***
*
case IPC_MSG_TYPE_SETFLOW:
tty_set_flow (c->t, m->setflow.flow);
break;
+ case IPC_MSG_TYPE_HANGUP:
+ tty_hangup (c->t);
+ break;
default:
fprintf (stderr, "Unhandeled message type %d\n", m->hdr.type);
}
/*
* $Log$
+ * Revision 1.13 2008/02/15 23:52:12 james
+ * *** empty log message ***
+ *
* Revision 1.12 2008/02/15 03:32:07 james
* *** empty log message ***
*
return ptr;
lname = line_to_name (line);
+ *(ptr++) = ' ';
while (*lname)
*(ptr++) = *(lname++);
s = socket_listen ("socket");
- c.t = ptty_open (NULL, NULL);
+// c.t = ptty_open (NULL, NULL);
+ c.t = serial_open ("/dev/cellmodem", 0);
c.v = vt102_new ();
c.h = history_new (200);
c.l = file_log_new ("log");
/*
* $Log$
+ * Revision 1.2 2008/02/15 23:52:12 james
+ * *** empty log message ***
+ *
* Revision 1.1 2008/02/15 15:14:19 james
* *** empty log message ***
*
ctx->k->set_baud (ctx->k, ctx, atoi (buf + 4));
if (!strncmp (buf, "break", 4))
ctx->k->send_break (ctx->k, ctx);
+ if (!strncmp (buf, "hangup", 4))
+ ctx->k->hangup (ctx->k, ctx);
}
/*
* $Log$
+ * Revision 1.3 2008/02/15 23:52:12 james
+ * *** empty log message ***
+ *
* Revision 1.2 2008/02/15 03:32:07 james
* *** empty log message ***
*
m.flow = flow;
return ipc_msg_send (s, (IPC_Msg *) & m);
}
+
+int
+ipc_msg_send_hangup (Socket * s)
+{
+ IPC_Msg_hangup m;
+
+ m.size = sizeof (m);
+ m.type = IPC_MSG_TYPE_HANGUP;
+ return ipc_msg_send (s, (IPC_Msg *) & m);
+}
/*
* $Log$
+ * Revision 1.3 2008/02/15 23:52:12 james
+ * *** empty log message ***
+ *
* Revision 1.2 2008/02/15 03:32:07 james
* *** empty log message ***
*
#define IPC_MSG_TYPE_SETBAUD 7
#define IPC_MSG_TYPE_SENDBREAK 8
#define IPC_MSG_TYPE_SETFLOW 9
+#define IPC_MSG_TYPE_HANGUP 10
typedef struct
{
} IPC_Msg_setflow;
+typedef struct
+{
+ int32_t size;
+ int32_t type;
+} IPC_Msg_hangup;
+
+
typedef union
{
IPC_Msg_setbaud setbaud;
IPC_Msg_sendbreak sendbreak;
IPC_Msg_setflow setflow;
+IPC_Msg_hangup hangup;
} IPC_Msg;
/*
* $Log$
+ * Revision 1.3 2008/02/15 23:52:12 james
+ * *** empty log message ***
+ *
* Revision 1.2 2008/02/15 03:32:07 james
* *** empty log message ***
*
return 0;
}
+
+static int
+keydis_ipc_hangup (KeyDis * _t, Context * c)
+{
+ KeyDis_IPC *t = (KeyDis_IPC *) _t;
+
+ ipc_msg_send_hangup (t->s);
+
+ return 0;
+}
+
static int
keydis_vt102_key (KeyDis * _t, Context * c, int key)
{
}
+static int
+keydis_vt102_hangup (KeyDis * _t, Context * c)
+{
+ KeyDis_VT102 *t = (KeyDis_VT102 *) _t;
+
+ tty_hangup (c->t);
+
+ return 0;
+}
+
+
KeyDis *
keydis_vt102_new (void)
t->set_baud = keydis_vt102_set_baud;
t->send_break = keydis_vt102_send_break;
t->set_flow = keydis_vt102_set_flow;
+ t->hangup = keydis_vt102_hangup;
return (KeyDis *) t;
}
t->set_baud = keydis_ipc_set_baud;
t->send_break = keydis_ipc_send_break;
t->set_flow = keydis_ipc_set_flow;
+ t->hangup = keydis_ipc_hangup;
t->s = s;
return (KeyDis *) t;
}
/*
* $Log$
+ * Revision 1.3 2008/02/15 23:52:12 james
+ * *** empty log message ***
+ *
* Revision 1.2 2008/02/15 03:32:07 james
* *** empty log message ***
*
int (*key)(struct KeyDis_struct *,struct Context_struct *,int key); \
int (*set_baud)(struct KeyDis_struct *,struct Context_struct *,int rate); \
int (*send_break)(struct KeyDis_struct *,struct Context_struct *); \
- int (*set_flow)(struct KeyDis_struct *,struct Context_struct *,int flow)
+ int (*set_flow)(struct KeyDis_struct *,struct Context_struct *,int flow); \
+ int (*hangup)(struct KeyDis_struct *,struct Context_struct *)
/*
* $Log$
+ * Revision 1.9 2008/02/15 23:52:12 james
+ * *** empty log message ***
+ *
* Revision 1.8 2008/02/15 20:52:36 james
* *** empty log message ***
*
#define LOCK_ASCII
#undef LOCK_BINARY
+#define STALE_CHECK_INTERVAL 10
+
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <dirent.h>
#include <errno.h>
+#include <time.h>
+#include <sys/time.h>
#include "lockfile.h"
char *lock_dirs[] =
{ "/var/lock/uucp", "/var/spool/lock", "/var/spool/uucp", "/etc/locks",
"/usr/spool/uucp", "/var/spool/locks", "/usr/spool/lock",
- "/usr/spool/locks", "/usr/spool/uucp/LCK"
+ "/usr/spool/locks", "/usr/spool/uucp/LCK", "/var/lock"
};
int i;
if (l->mode == SERIAL_LOCK_ACTIVE)
return 0;
- for (fle = l->locks_to_check; fle; fle = fle->next)
+ for (fle = l->locks_to_check->head; fle; fle = fle->next)
{
if (!stat (fle->name, &buf))
locks_found++;
if (!locks_found)
return 0;
- getimeofday (&now, NULL);
+ gettimeofday (&now, NULL);
timersub (&now, &l->last_stale_purge, &dif);
if (dif.tv_sec > STALE_CHECK_INTERVAL)
serial_lock_new (char *dev, int mode)
{
Filelist *fl = lockfile_make_list (dev);
+ Serial_lock *l;
if (!fl)
return NULL;
+ l = (Serial_lock *) malloc (sizeof (Serial_lock));
+
l->mode = mode;
l->locks_to_check = fl;
l->locks_held = NULL;
}
-#if 1
+#if 0
int
main (int argc, char *argv[])
{
/*
* $Log$
+ * Revision 1.6 2008/02/15 23:52:12 james
+ * *** empty log message ***
+ *
* Revision 1.5 2008/02/15 20:52:36 james
* *** empty log message ***
*
int mode;
int i;
struct timeval last_stale_purge;
- Filelist locks_to_check;
- Filelist locks_held;
+ Filelist *locks_to_check;
+ Filelist *locks_held;
} Serial_lock;
/*
* $Log$
+ * Revision 1.5 2008/02/15 23:52:12 james
+ * *** empty log message ***
+ *
* Revision 1.4 2008/02/14 10:39:14 james
* *** empty log message ***
*
t->size.x = winsize.ws_row;
t->size.y = winsize.ws_col;
t->blocked = 0;
+ t->hanging_up = 0;
return (TTY *) t;
}
/*
* $Log$
+ * Revision 1.7 2008/02/15 23:52:12 james
+ * *** empty log message ***
+ *
* Revision 1.6 2008/02/15 19:51:30 james
* *** empty log message ***
*
if (!t)
return;
+ tcflush (t->fd, TCIOFLUSH);
close (t->fd);
free (t);
}
static int
-ptty_write (TTY * _t, void *buf, int len)
+serial_write (TTY * _t, void *buf, int len)
{
int writ, done = 0;
Serial *t = (Serial *) _t;
default_termios (&termios);
- fd = open (path, O_RDWR);
+ fd = open (path, O_RDWR | O_NOCTTY | O_NONBLOCK);
set_nonblocking (fd);
t->name[sizeof (t->name) - 1] = 0;
t->recv = serial_read;
- //t->xmit = serial_write;
+ t->xmit = serial_write;
t->close = serial_close;
t->fd = fd;
t->rfd = t->fd;
t->size.x = VT102_COLS;
t->size.y = VT102_ROWS;
t->blocked = serial_lock_check (t->lock);
+ t->hanging_up = 0;
return (TTY *) t;
}
/*
* $Log$
+ * Revision 1.10 2008/02/15 23:52:12 james
+ * *** empty log message ***
+ *
* Revision 1.9 2008/02/15 03:32:07 james
* *** empty log message ***
*
void
tty_pre_select (TTY * t, fd_set * rfds, fd_set * wfds)
{
+ int line;
+ struct timeval now, dif;
+
+ if (t->hanging_up)
+ {
+
+ gettimeofday (&now, NULL);
+ timersub (&now, &t->hangup_clock, &dif);
+ if (dif.tv_sec)
+ {
+ fprintf (stderr, "+DTR\n");
+
+ line = TIOCM_DTR;
+ ioctl (t->rfd, TIOCMBIS, &line);
+ t->hanging_up = 0;
+ }
+ }
+
+
FD_SET (t->rfd, rfds);
}
s->lines = 0;
ioctl (t->rfd, TIOCMGET, &s->lines);
+ if (t->hanging_up)
+ fprintf (stderr, "s->lines & TIOCM_DTR=%x\n", s->lines & TIOCM_DTR);
if (tcgetattr (t->rfd, &s->termios))
return -1;
}
+void
+tty_hangup (TTY * t)
+{
+ int line;
+
+ line = TIOCM_DTR;
+ ioctl (t->rfd, TIOCMBIC, &line);
+
+ t->hanging_up = 1;
+ gettimeofday (&t->hangup_clock, NULL);
+ fprintf (stderr, "-DTR\n");
+
+}
+
#if 0
int
/*
* $Log$
+ * Revision 1.8 2008/02/15 23:52:12 james
+ * *** empty log message ***
+ *
* Revision 1.7 2008/02/14 10:36:18 james
* *** empty log message ***
*
int (*recv)(struct TTY_struct *,void *buf,int len); \
int (*xmit)(struct TTY_struct *,void *buf,int len); \
int rfd; \
- int wfd
+ int wfd; \
+ int hanging_up; \
+ struct timeval hangup_clock
typedef struct TTY_struct
{
/*
* $Log$
+ * Revision 1.6 2008/02/15 23:52:12 james
+ * *** empty log message ***
+ *
* Revision 1.5 2008/02/14 10:34:30 james
* *** empty log message ***
*
c.v = vt102_new ();
c.h = history_new (200);
c.l = file_log_new ("log");
- c.k = keydis_vt102_new (&c);
+ c.k = keydis_vt102_new ();
terminal_register_handlers ();
a.terminal = terminal_open (0, 1);