aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorjames <>2008-02-13 17:21:55 +0000
committerjames <>2008-02-13 17:21:55 +0000
commit9644f7cf7d6949303984a058b9b3694c92ac9be5 (patch)
tree9fc223823ce856f9ea976328f821f72c4efd5a89 /apps
parent4d30d1456ad4052bd5d5bbec8cd7dbaad233c7a5 (diff)
downloadsympathy-9644f7cf7d6949303984a058b9b3694c92ac9be5.tar.gz
sympathy-9644f7cf7d6949303984a058b9b3694c92ac9be5.tar.bz2
sympathy-9644f7cf7d6949303984a058b9b3694c92ac9be5.zip
*** empty log message ***
Diffstat (limited to 'apps')
-rw-r--r--apps/ipc.c17
-rw-r--r--apps/ipc.h12
-rw-r--r--apps/sympathyd.c93
3 files changed, 69 insertions, 53 deletions
diff --git a/apps/ipc.c b/apps/ipc.c
deleted file mode 100644
index 708a5e1..0000000
--- a/apps/ipc.c
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * ipc.c:
- *
- * Copyright (c) 2008 James McKenzie <james@fishsoup.dhs.org>,
- * All rights reserved.
- *
- */
-
-static char rcsid[] = "$Id$";
-
-/*
- * $Log$
- * Revision 1.1 2008/02/07 15:42:49 james
- * *** empty log message ***
- *
- */
-
diff --git a/apps/ipc.h b/apps/ipc.h
deleted file mode 100644
index 33852fe..0000000
--- a/apps/ipc.h
+++ /dev/null
@@ -1,12 +0,0 @@
-
-#include <sys/socket.h>
-#include <sys/un.h>
-
-#define SOCKPATH "/tmp/sympathy"
-
-typedef struct {
-int type;
-int len;
-uint8_t data[0];
-} Sympathy_msg;
-
diff --git a/apps/sympathyd.c b/apps/sympathyd.c
index 4845c95..820f4d9 100644
--- a/apps/sympathyd.c
+++ b/apps/sympathyd.c
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
/*
* $Log$
+ * Revision 1.4 2008/02/13 17:21:55 james
+ * *** empty log message ***
+ *
* Revision 1.3 2008/02/08 15:06:52 james
* *** empty log message ***
*
@@ -22,39 +25,81 @@ static char rcsid[] = "$Id$";
*/
#include "sympathy.h"
-#include "ipc.h"
-#include "../src/crt.h"
-#include "../src/vt102.h"
+#include
+void main (int argc,char *argv[])
+{
+ fd_set rfd, wfd;
+ ANSI a = { 0 };
+ Context c;
+ Socket *s, *cs;
+ Client **clients;
-int main(int argc,char *argv[])
-{
-int fd;
-struct sockaddr_un sun={0};
+ s = socket_listen ("socket");
-fd=socket(PF_UNIX,SOCK_STREAM,0);
-if (fd<0) {
- perror("socket");
- exit(1);
-}
+ c.t = ptty_open (NULL, NULL);
+ c.v = vt102_new ();
+ c.h = history_new (200);
+ c.l = file_log_new ("log");
-sun.sun_family=AF_UNIX;
-strcpy(sun.sun_path,SOCKPATH);
+ terminal_register_handlers ();
+ a.terminal = terminal_open (0, 1);
-unlink(SOCKPATH);
+ ansi_reset (&a, NULL);
-if (bind(fd,(struct sockaddr *) &sun,sizeof(sun))<0) {
- perror("bind");
- exit(1);
-}
+ clients=clients_new();
-if (listen(fd,5)<0) {
- perror("listen");
- exit(1);
-}
+ for (;;)
+ {
+ struct timeval tv = { 0, 100000 };
+
+
+ FD_ZERO (&rfd);
+ FD_ZERO (&wfd);
+
+ tty_pre_select (c.t, &rfd);
+ tty_pre_select (a.terminal, &rfd);
+
+ socket_pre_select (s, &rfd, &wfd);
+
+ client_pre_select (clients);
+
+ select (FD_SETSIZE, &rfd, NULL, NULL, &tv);
+
+ cs = socket_post_select (s, &rfd, &wfd);
+
+ if (cs)
+ {
+ /*New client connexion */
+ clients_new (clients, cs, c);
+ }
+
+ clients_post_select (clients, c, &rfds, &wfds);
+
+ if (FD_ISSET (c->t->rfd, &rfds))
+ {
+ char buf[1024];
+ int red;
+
+ red = c->t->recv (c->t, buf, sizeof (buf));
+
+ if (red < 0)
+ break;
+ if (red)
+ {
+ clients_output (clients, buf, red);
+ vt102_parse (c, buf, red);
+ }
+ }
-printf("sizeof(VT102)=%d\n",sizeof(VT102));
+ ansi_dispatch (&a, &c);
+ ansi_update (&a, &c);
+ }
+ clients_shutdown (clients);
+ ansi_terminal_reset (&a);
+ terminal_atexit ();
+ printf ("QUAT\n");
}