chiark / gitweb /
*** empty log message ***
[sympathy.git] / apps / sympathyd.c
index 2e45ed1b8d74f2c0eedbc4243608a9f0342a4693..6480713e0dde94ae52868c601e458576eb2bd4bf 100644 (file)
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
 
 /*
  * $Log$
+ * Revision 1.6  2008/02/14 00:57:58  james
+ * *** empty log message ***
+ *
  * Revision 1.5  2008/02/13 18:05:06  james
  * *** empty log message ***
  *
@@ -32,6 +35,27 @@ static char rcsid[] = "$Id$";
 #include "client.h"
 #include "clients.h"
 
+
+static void send_history(History *h,Client *c)
+{
+int rptr=h->wptr;
+
+HISTORY_INC(h,rptr);
+
+HISTORY_INC(h,rptr);
+while (rptr!=h->wptr)
+{
+History_ent *l=&h->lines[rptr];
+if (l->valid) { 
+
+if (ipc_msg_send_history(c->s,l))
+       c->dead++;
+
+}
+HISTORY_INC(h,rptr);
+}
+}
+
 int main (int argc,char *argv[])
 {
   fd_set rfds, wfds;
@@ -64,21 +88,25 @@ int main (int argc,char *argv[])
       FD_ZERO (&wfds);
 
       tty_pre_select (c.t, &rfds,&wfds);
-      tty_pre_select (a.terminal, &rfds,&wfds);
+
+      FD_SET(s->fd,&rfds);
 
       socket_pre_select (s, &rfds, &wfds);
 
       clients_pre_select (clients,&rfds,&wfds);
 
-      select (FD_SETSIZE, &rfds, NULL, NULL, &tv);
-
-      cs = socket_post_select (s, &rfds, &wfds);
+      select (FD_SETSIZE, &rfds, &wfds, NULL, &tv);
 
-      if (cs)
+      if (FD_ISSET (s->fd, &rfds) && ((cs=socket_accept (s)))) {
         {
+         Client *cl;
           /*New client connexion */
-          clients_new_client (clients, cs, &c);
+          cl=clients_new_client (clients, cs, &c);
+
+         send_history(c.h,cl);
+         
         }
+      }
 
 
       clients_post_select (clients, &c, &rfds, &wfds);
@@ -102,6 +130,8 @@ int main (int argc,char *argv[])
 
       ansi_dispatch (&a, &c);
       ansi_update (&a, &c);
+
+      
     }
 
   clients_shutdown (clients);