X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=sympathy.git;a=blobdiff_plain;f=apps%2Fsympathy.c;h=6e869be9349028a24bc669b76019e04de786bfe1;hp=4a9f18aa743dde3730367fec0e2a33f2116c72fb;hb=f623a361f194ceff8bda6b737aca73d8024c0005;hpb=95d068f1b4e8100d6501944eda3bd9ff73460514 diff --git a/apps/sympathy.c b/apps/sympathy.c index 4a9f18a..6e869be 100644 --- a/apps/sympathy.c +++ b/apps/sympathy.c @@ -11,6 +11,21 @@ static char rcsid[] = /* * $Log$ + * Revision 1.20 2008/02/27 10:00:34 james + * *** empty log message *** + * + * Revision 1.19 2008/02/27 09:47:05 james + * *** empty log message *** + * + * Revision 1.18 2008/02/27 09:42:53 james + * *** empty log message *** + * + * Revision 1.17 2008/02/27 09:42:21 james + * *** empty log message *** + * + * Revision 1.16 2008/02/27 01:31:38 james + * *** empty log message *** + * * Revision 1.15 2008/02/27 01:31:14 james * *** empty log message *** * @@ -242,7 +257,7 @@ main (int argc, char *argv[]) int c; extern char *optarg; extern int optind, opterr, optopt; - int width=VT102_COLS_80; + CRT_Pos size = { VT102_COLS_80, VT102_ROWS }; int oflags[128]; char *oargs[128]; @@ -259,7 +274,7 @@ main (int argc, char *argv[]) memset (oflags, 0, sizeof (oflags)); memset (oargs, 0, sizeof (oargs)); - while ((c = getopt (argc, argv, "w:utscr:lKHd:pb:fL:Fk:n:")) != EOF) + while ((c = getopt (argc, argv, "vw:utscr:lKHd:pb:fL:Fk:n:")) != EOF) { switch (c) { @@ -292,26 +307,32 @@ main (int argc, char *argv[]) oflags['s'] = 0; - if (!oflags['s'] && !oflags['c'] && !oflags['t'] && !oflags['r'] - && !oflags['l']) - { - /*If no mode is specified behave like screen */ - oflags['s']++; - oflags['c']++; - } - - { int sum = 0; sum += oflags['t']; sum += (oflags['s'] || oflags['c']) ? 1 : 0; sum += oflags['r']; sum += oflags['l']; + sum += oflags['v']; + if (!sum) { + /*If no mode is specified behave like screen */ + oflags['s']++; + oflags['c']++; + sum++; + } + if (sum != 1) - fatal_moan ("specifiy exactly one of ( -c and or -s ), -t, -r and -l"); + fatal_moan + ("specifiy exactly one of ( -c and or -s ), -t, -r, -l and -v"); } + if (oflags['v']) + { + fprintf (stderr, "Version: %s\n", libsympathy_version ()); + fprintf (stderr, "Version: %s\n", rcsid); + return 0; + } if (oflags['l']) return list_sockets (); @@ -392,7 +413,7 @@ main (int argc, char *argv[]) oflags['f'] = 0; oflags['L'] = 0; oflags['n'] = 0; - oflags['w'] = 0; + oflags['w'] = 0; if (server_socket) { socket_free_parent (server_socket); @@ -415,11 +436,27 @@ main (int argc, char *argv[]) oflags['p']++; } - if (oflags['w']) { - width=safe_atoi(oargs['w']); - if ((width>VT102_MAX_COLS) || (width<1)) - fatal_moan("-w requires a width between 1 and %d\n",VT102_MAX_COLS); - } + if (oflags['w']) + { + char buf[128], *ptr; + strcpy (buf, oargs['w']); + ptr = index (buf, 'x'); + if (ptr) + { + *ptr = 0; + ptr++; + size.y = safe_atoi (ptr); + } + size.x = safe_atoi (buf); + + if ((size.x > VT102_MAX_COLS) || (size.x < 1)) + fatal_moan ("-w requires a width between 1 and %d\n", VT102_MAX_COLS); + + if ((size.y > VT102_ROWS) || (size.y < 1)) + fatal_moan ("-w requires a height between 1 and %d\n", + VT102_MAX_COLS); + + } if (oflags['s'] && !oflags['F']) { @@ -439,7 +476,7 @@ main (int argc, char *argv[]) if (oflags['p']) { - tty = ptty_open (NULL, NULL, width); + tty = ptty_open (NULL, NULL, &size); if (!tty) fatal_moan ("unable to open a ptty"); } @@ -496,7 +533,7 @@ main (int argc, char *argv[]) } } - mainloop (tty, server_socket, client_socket, ansi, log, history,width); + mainloop (tty, server_socket, client_socket, ansi, log, history, &size); if (ansi) {