From d7565f9da9ada7a0aa90abdb6d8d1ba192075791 Mon Sep 17 00:00:00 2001 From: james <> Date: Thu, 6 Mar 2008 16:49:05 +0000 Subject: *** empty log message *** --- apps/sympathy.c | 60 +++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 41 insertions(+), 19 deletions(-) (limited to 'apps/sympathy.c') diff --git a/apps/sympathy.c b/apps/sympathy.c index f5ed2e0..dc9dd66 100644 --- a/apps/sympathy.c +++ b/apps/sympathy.c @@ -11,6 +11,9 @@ static char rcsid[] = /* * $Log$ + * Revision 1.33 2008/03/06 16:49:05 james + * *** empty log message *** + * * Revision 1.32 2008/03/03 06:04:42 james * *** empty log message *** * @@ -433,11 +436,14 @@ get_hostname (void) int main (int argc, char *argv[]) { + Context ctx_store={0},*ctx=&ctx_store; int c; extern char *optarg; extern int optind, opterr, optopt; CRT_Pos size = { VT102_COLS_80, VT102_ROWS_24 }; + ANSI *ansi=NULL; + int csnok_pipe[2] = { 0 }; int csnok = 0; @@ -445,9 +451,6 @@ main (int argc, char *argv[]) char *oargs[128]; Socket *server_socket = NULL, *client_socket = NULL; - ANSI *ansi = NULL; - TTY *tty = NULL; - Log *log = NULL; int history = 200; int pid; @@ -458,7 +461,7 @@ main (int argc, char *argv[]) memset (oflags, 0, sizeof (oflags)); memset (oargs, 0, sizeof (oargs)); - while ((c = getopt (argc, argv, "RP:vw:utscr:lKHd:pb:fL:Fk:n:")) != EOF) + while ((c = getopt (argc, argv, "I:NRP:vw:utscr:lKHd:pb:fL:Fk:n:")) != EOF) { switch (c) { @@ -548,6 +551,9 @@ main (int argc, char *argv[]) if (oflags['c'] && oflags['s'] && oflags['F']) fatal_moan ("-F is incompatible with -c -s"); + if (oflags['H'] && oflags['N']) + fatal_moan ("-H is incompatible with -N"); + /*implement server and client: this process forks. The parent */ /*becomes the client and the child forks again to become the */ /*server. If there's no -k argument the client (parent) needs */ @@ -566,6 +572,8 @@ main (int argc, char *argv[]) case 0: /*child becomes the server */ oflags['c'] = 0; oflags['H'] = 0; + oflags['N'] = 0; + oflags['I'] = 0; if (csnok) close (csnok_pipe[0]); @@ -612,6 +620,9 @@ main (int argc, char *argv[]) if (oflags['c'] && !oflags['k'] && !oflags['r']) fatal_moan ("-c requires a socket to be specified with -s or -k or -r"); + if ((oflags['H'] || oflags['N'] || oflags['I'] ) && oflags['s']) + fatal_moan("-s is incompatible with -H, -N and -I"); + if ((oflags['p'] || oflags['d'] || oflags['K'] || oflags['b'] || oflags['f'] || oflags['L'] || oflags['R'] || oflags['P']) && oflags['c']) fatal_moan @@ -701,15 +712,15 @@ main (int argc, char *argv[]) if (oflags['L']) { - log = file_log_new (oargs['L'], oflags['R']); - if (!log) + ctx->l = file_log_new (oargs['L'], oflags['R']); + if (!ctx->l) fatal_moan ("unable to access log file %s", oargs['L']); } if (oflags['p']) { - tty = ptty_open (NULL, NULL, &size); - if (!tty) + ctx->t = ptty_open (NULL, NULL, &size); + if (!ctx->t) fatal_moan ("unable to open a ptty"); } else @@ -740,11 +751,11 @@ main (int argc, char *argv[]) fatal_moan ("/proc/cmdline contains %s", search_string); } - tty = + ctx->t = serial_open (oargs['d'], oflags['K'] ? SERIAL_LOCK_ACTIVE : SERIAL_LOCK_PASSIVE); - if (!tty) + if (!ctx->t) fatal_moan ("unable to open serial port %s", oargs['d']); } @@ -755,11 +766,11 @@ main (int argc, char *argv[]) if (baud < 0) fatal_moan ("Unable to parse baudrate %s", oargs['b']); - tty_set_baud (tty, baud); + tty_set_baud (ctx->t, baud); } - tty_set_flow (tty, oflags['f'] ? 1 : 0); + tty_set_flow (ctx->t, oflags['f'] ? 1 : 0); } @@ -795,8 +806,10 @@ main (int argc, char *argv[]) if (oflags['c'] || oflags['t']) { - - if (oflags['H']) + if (oflags['N']) { + ctx->r=rx_new_raw(0,1); + ansi=ansi_new_raw(0,1); + } else if (oflags['H']) { ansi = ansi_new_html (stdout); } @@ -808,9 +821,18 @@ main (int argc, char *argv[]) oflags['u'] ? 0 : 1); ansi->reset (ansi, NULL); } + if (oflags['I']) { + //FIXME ... + } } - mainloop (tty, server_socket, client_socket, ansi, log, history, &size); + + ctx->v = vt102_new (&size); + ctx->h = history_new (history); + + mainloop (ctx,ansi, server_socket, client_socket); + +// mainloop (tty, server_socket, client_socket, ansi, log, history, &size); if (ansi) { @@ -818,11 +840,11 @@ main (int argc, char *argv[]) terminal_atexit (); } - if (tty) - tty->close (tty); + if (ctx->t) + ctx->t->close (ctx->t); - if (log) - log->close (log); + if (ctx->l) + ctx->l->close (ctx->l); if (server_socket) socket_free (server_socket); if (client_socket) -- cgit v1.2.3