aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjames <>2008-02-20 18:33:37 +0000
committerjames <>2008-02-20 18:33:37 +0000
commit2bd12c505855b89712fa3bc287d4a504d737e0e3 (patch)
tree721943b314be6eb069ac97a089a7e31f8f3585e5
parente87e545fd99fa20f207e6960b1ee7647fd5573b3 (diff)
downloadsympathy-2bd12c505855b89712fa3bc287d4a504d737e0e3.tar.gz
sympathy-2bd12c505855b89712fa3bc287d4a504d737e0e3.tar.bz2
sympathy-2bd12c505855b89712fa3bc287d4a504d737e0e3.zip
*** empty log message ***
-rw-r--r--apps/Makefile.am8
-rw-r--r--apps/usage.c4
-rw-r--r--src/prototypes.h6
-rw-r--r--src/symsocket.c63
-rw-r--r--src/symsocket.h5
-rw-r--r--src/tty.c10
6 files changed, 88 insertions, 8 deletions
diff --git a/apps/Makefile.am b/apps/Makefile.am
index 57a6f69..f81709b 100644
--- a/apps/Makefile.am
+++ b/apps/Makefile.am
@@ -7,6 +7,9 @@
# $Id$
#
# $Log$
+# Revision 1.9 2008/02/20 18:33:37 james
+# *** empty log message ***
+#
# Revision 1.8 2008/02/20 18:31:44 james
# *** empty log message ***
#
@@ -41,10 +44,7 @@ noinst_PROGRAMS = sympathyd sympathy
noinst_HEADERS=clients.h client.h
sympathy_SOURCES = sympathy.c usage.c clients.c mainloop.c
-sympathy_LDADD = ../src/libsympathy.a -lutil
-
-sympathyd_SOURCES = sympathyd.c clients.c client.c
-sympathyd_LDADD = ../src/libsympathy.a -lutil
+sympathy_LDADD = ../src/libsympathy.la -lutil
AM_CFLAGS=-g -Werror
diff --git a/apps/usage.c b/apps/usage.c
index 0ef2667..b34d75b 100644
--- a/apps/usage.c
+++ b/apps/usage.c
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
/*
* $Log$
+ * Revision 1.5 2008/02/20 18:31:44 james
+ * *** empty log message ***
+ *
* Revision 1.4 2008/02/20 17:18:33 james
* *** empty log message ***
*
@@ -24,6 +27,7 @@ static char rcsid[] = "$Id$";
*
*/
+#include <stdio.h>
void
usage (void)
diff --git a/src/prototypes.h b/src/prototypes.h
index 69ef02d..cdb3111 100644
--- a/src/prototypes.h
+++ b/src/prototypes.h
@@ -77,6 +77,7 @@ extern int tty_get_status(TTY *t, TTY_Status *s);
extern void tty_set_baud(TTY *t, int rate);
extern void tty_send_break(TTY *t);
extern void tty_set_flow(TTY *t, int flow);
+extern void tty_hangup(TTY *t);
/* keydis.c */
extern KeyDis *keydis_vt102_new(void);
extern KeyDis *keydis_ipc_new(Socket *s);
@@ -122,6 +123,7 @@ extern int ipc_msg_send_status(Socket *s, char *buf);
extern int ipc_msg_send_setbaud(Socket *s, int baud);
extern int ipc_msg_send_sendbreak(Socket *s);
extern int ipc_msg_send_setflow(Socket *s, int flow);
+extern int ipc_msg_send_hangup(Socket *s);
/* slide.c */
extern void slide_free(Slide *s);
extern void slide_consume(Slide *s, int n);
@@ -129,7 +131,10 @@ extern void slide_added(Slide *s, int n);
extern Slide *slide_new(int n);
extern void slide_expand(Slide *s, int n);
/* symsocket.c */
+extern int wrap_recv(int fd, void *buf, int len);
+extern int wrap_send(int fd, void *buf, int len);
extern void socket_free(Socket *s);
+extern void socket_free_parent(Socket *s);
extern Socket *socket_listen(char *path);
extern Socket *socket_accept(Socket *l);
extern Socket *socket_connect(char *path);
@@ -165,4 +170,3 @@ extern void lockfile_unlock(Filelist *fl);
extern int serial_lock_check(Serial_lock *l);
extern void serial_lock_free(Serial_lock *l);
extern Serial_lock *serial_lock_new(char *dev, int mode);
-extern int main(int argc, char *argv[]);
diff --git a/src/symsocket.c b/src/symsocket.c
index 061ff6d..bb8f4ff 100644
--- a/src/symsocket.c
+++ b/src/symsocket.c
@@ -11,6 +11,9 @@ static char rcsid[] =
/*
* $Log$
+ * Revision 1.4 2008/02/20 18:31:53 james
+ * *** empty log message ***
+ *
* Revision 1.3 2008/02/14 02:46:44 james
* *** empty log message ***
*
@@ -29,6 +32,38 @@ static char rcsid[] =
#define BUF_SIZE 16384
#define MAX_TXN 4096
+int
+wrap_recv (int fd, void *buf, int len)
+{
+ int red;
+
+ red = recv (fd, buf, len,0);
+ if (!red)
+ return -1;
+
+ if ((red < 0) && (errno == EAGAIN))
+ red = 0;
+
+ return red;
+}
+
+int
+wrap_send (int fd, void *buf, int len)
+{
+ int writ;
+
+ errno = 0;
+
+ writ = send (fd, buf, len,MSG_NOSIGNAL);
+
+ if (!writ)
+ return -1;
+
+ if ((writ < 0) && (errno == EAGAIN))
+ writ = 0;
+
+ return writ;
+}
void
socket_free (Socket * s)
@@ -39,7 +74,28 @@ socket_free (Socket * s)
slide_free (s->read_buf);
if (s->write_buf)
slide_free (s->write_buf);
+ if (s->path_to_unlink) {
+ unlink(s->path_to_unlink);
+ free(s->path_to_unlink);
+ }
+ close (s->fd);
+ free(s);
+}
+
+void
+socket_free_parent (Socket * s)
+{
+ if (!s)
+ return;
+ if (s->read_buf)
+ slide_free (s->read_buf);
+ if (s->write_buf)
+ slide_free (s->write_buf);
+ if (s->path_to_unlink)
+ free(s->path_to_unlink);
close (s->fd);
+
+ free(s);
}
@@ -89,6 +145,7 @@ socket_listen (char *path)
ret->write_buf = NULL;
ret->fd = fd;
+ ret->path_to_unlink=strdup(path);
return ret;
@@ -215,7 +272,7 @@ socket_post_select (Socket * s, fd_set * rfds, fd_set * wfds)
n =
(SLIDE_BYTES (s->write_buf) >
MAX_TXN) ? MAX_TXN : SLIDE_BYTES (s->write_buf);
- n = wrap_write (s->fd, SLIDE_RPTR (s->write_buf), n);
+ n = wrap_send (s->fd, SLIDE_RPTR (s->write_buf), n);
if (n > 0)
slide_consume (s->write_buf, n);
if (n < 0)
@@ -227,7 +284,7 @@ socket_post_select (Socket * s, fd_set * rfds, fd_set * wfds)
n =
(SLIDE_SPACE (s->read_buf) >
MAX_TXN) ? MAX_TXN : SLIDE_SPACE (s->read_buf);
- n = wrap_read (s->fd, SLIDE_WPTR (s->read_buf), n);
+ n = wrap_recv (s->fd, SLIDE_WPTR (s->read_buf), n);
if (n > 0)
slide_added (s->read_buf, n);
if (n < 0)
@@ -253,7 +310,7 @@ socket_write (Socket * s, void *buf, int len)
n =
(SLIDE_BYTES (s->write_buf) >
MAX_TXN) ? MAX_TXN : SLIDE_BYTES (s->write_buf);
- n = wrap_write (s->fd, SLIDE_RPTR (s->write_buf), n);
+ n = wrap_send (s->fd, SLIDE_RPTR (s->write_buf), n);
{
uint8_t *c = SLIDE_RPTR (s->write_buf);
}
diff --git a/src/symsocket.h b/src/symsocket.h
index 3996816..34961d0 100644
--- a/src/symsocket.h
+++ b/src/symsocket.h
@@ -12,6 +12,9 @@
/*
* $Log$
+ * Revision 1.2 2008/02/20 18:31:53 james
+ * *** empty log message ***
+ *
* Revision 1.1 2008/02/13 18:05:06 james
* *** empty log message ***
*
@@ -29,6 +32,8 @@ typedef struct
IPC_Msg *msg;
+ char *path_to_unlink;
+
} Socket;
#define SOCKET_IS_LISTENER(s) (!((s)->read_buf))
diff --git a/src/tty.c b/src/tty.c
index de1bdca..1765878 100644
--- a/src/tty.c
+++ b/src/tty.c
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
/*
* $Log$
+ * Revision 1.11 2008/02/20 18:31:53 james
+ * *** empty log message ***
+ *
* Revision 1.10 2008/02/15 23:52:12 james
* *** empty log message ***
*
@@ -223,7 +226,9 @@ tty_pre_select (TTY * t, fd_set * rfds, fd_set * wfds)
timersub (&now, &t->hangup_clock, &dif);
if (dif.tv_sec)
{
+#if 0
fprintf (stderr, "+DTR\n");
+#endif
line = TIOCM_DTR;
ioctl (t->rfd, TIOCMBIS, &line);
@@ -241,8 +246,11 @@ tty_get_status (TTY * t, TTY_Status * s)
s->lines = 0;
ioctl (t->rfd, TIOCMGET, &s->lines);
+
+#if 0
if (t->hanging_up)
fprintf (stderr, "s->lines & TIOCM_DTR=%x\n", s->lines & TIOCM_DTR);
+#endif
if (tcgetattr (t->rfd, &s->termios))
return -1;
@@ -305,7 +313,9 @@ tty_hangup (TTY * t)
t->hanging_up = 1;
gettimeofday (&t->hangup_clock, NULL);
+#if 0
fprintf (stderr, "-DTR\n");
+#endif
}