aboutsummaryrefslogtreecommitdiffstats
path: root/apps/mainloop.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/mainloop.c')
-rw-r--r--apps/mainloop.c48
1 files changed, 26 insertions, 22 deletions
diff --git a/apps/mainloop.c b/apps/mainloop.c
index 851f296..fd2947f 100644
--- a/apps/mainloop.c
+++ b/apps/mainloop.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 ***
*
@@ -62,8 +65,8 @@ static char rcsid[] = "$Id$";
#include <sys/time.h>
#include <sympathy.h>
+#include "mainloop.h"
-#include "client.h"
#include "clients.h"
typedef struct
@@ -233,11 +236,11 @@ check_status (Context * c, Clients * cs)
status = get_status (c->t, cs);
if (!memcmp (&status, &old_status, sizeof (status)))
return;
- old_status = status;
-
log_line_changes (c, old_status.lines, status.lines);
+ old_status = status;
+
ptr += sprintf (ptr, "CTRL-B ");
t = c->t->name;
@@ -293,7 +296,7 @@ check_status (Context * c, Clients * cs)
if (cs)
send_status (cs, buf);
else
- cmd_new_status (c->d, c, m->status.status);
+ cmd_new_status (c->d, c, buf);
}
@@ -317,7 +320,7 @@ msg_from_server (IPC_Msg * m, Context * c)
abort ();
*(c->v) = m->vt102.vt102;
- //FIXME HTML hook
+ //FIXME HTML hook
break;
case IPC_MSG_TYPE_TERM:
vt102_parse (c, m->term.term, m->term.len);
@@ -332,23 +335,22 @@ msg_from_server (IPC_Msg * m, Context * c)
void
-mainloop (TTY * tty, Socket * server_socket, Socket * client_socket, Ansi * a,
- Log * log)
+mainloop (TTY * tty, Socket * server_socket, Socket * client_socket,
+ ANSI * ansi, Log * log, int nhistory)
{
fd_set rfds, wfds;
- Context c={0};
+ Context c = { 0 };
Clients *clients;
c.v = vt102_new ();
- c.h = history_new (200);
+ c.h = history_new (nhistory);
c.l = log;
- /* are we being fed by a tty or a socket */
- if (client_socket)
+ /* are we being fed by a tty or a socket */
+ if (client_socket)
{
if (server_socket)
abort ();
- c.s = client_socket;
c.k = keydis_ipc_new (client_socket);
}
else
@@ -386,8 +388,12 @@ mainloop (TTY * tty, Socket * server_socket, Socket * client_socket, Ansi * a,
{
struct timeval tv = { 1, 0 };
- /*update the status lines, locally or remotely*/
- check_status (&c, clients);
+ if ((c.d) && (c.d->disconnect))
+ break;
+
+ /*update the status lines, locally or remotely */
+ if (c.t)
+ check_status (&c, clients);
FD_ZERO (&rfds);
FD_ZERO (&wfds);
@@ -414,7 +420,7 @@ mainloop (TTY * tty, Socket * server_socket, Socket * client_socket, Ansi * a,
{
Socket *new_client_socket;
if (FD_ISSET (server_socket->fd, &rfds)
- && ((new_client_socket = socket_accept (s))))
+ && ((new_client_socket = socket_accept (server_socket))))
{
{
Client *new_client;
@@ -444,14 +450,15 @@ mainloop (TTY * tty, Socket * server_socket, Socket * client_socket, Ansi * a,
if (red)
{
- send_output (clients, buf, red);
+ if (clients)
+ send_output (clients, buf, red);
vt102_parse (&c, buf, red);
}
}
- /*any data from the server*/
+ /*any data from the server */
if (client_socket)
{
if (socket_post_select (client_socket, &rfds, &wfds))
@@ -465,7 +472,7 @@ mainloop (TTY * tty, Socket * server_socket, Socket * client_socket, Ansi * a,
}
- /*update our local screen*/
+ /*update our local screen */
if (ansi)
{
if (ansi_dispatch (ansi, &c))
@@ -476,8 +483,5 @@ mainloop (TTY * tty, Socket * server_socket, Socket * client_socket, Ansi * a,
}
if (clients)
- {
- clients_shutdown (clients);
- }
- printf ("QUAT\n");
+ clients_shutdown (clients);
}