chiark / gitweb /
*** empty log message ***
authorjames <james>
Wed, 27 Feb 2008 01:31:14 +0000 (01:31 +0000)
committerjames <james>
Wed, 27 Feb 2008 01:31:14 +0000 (01:31 +0000)
apps/mainloop.c
apps/mainloop.h
apps/sympathy.c
apps/usage.c
src/log.c
src/prototypes.h
src/ptty.c
src/utf8.c
src/util.c
src/vt102.c
src/vt102_charset.h [new file with mode: 0644]

index 07290e1a4125207adad489a9caf08df37ba2aed0..d546ac5152700504d1ca30582a75a76fac3ffeb2 100644 (file)
@@ -11,6 +11,9 @@ static char rcsid[] =
 
 /*
  * $Log$
+ * Revision 1.15  2008/02/27 01:31:38  james
+ * *** empty log message ***
+ *
  * Revision 1.14  2008/02/27 01:31:14  james
  * *** empty log message ***
  *
@@ -394,7 +397,7 @@ msg_from_server (ANSI * a, IPC_Msg * m, Context * c)
 
 void
 mainloop (TTY * tty, Socket * server_socket, Socket * client_socket,
-          ANSI * ansi, Log * log, int nhistory,int width)
+          ANSI * ansi, Log * log, int nhistory, int width)
 {
   fd_set rfds, wfds;
   Context c = { 0 };
index 3bbd960bac5bfd878547caeeec33d9f57c7fef9a..5d347e7f5fe23fa8114e1f1a5af8665ea0142d9c 100644 (file)
@@ -12,6 +12,9 @@
 
 /*
  * $Log$
+ * Revision 1.3  2008/02/27 01:31:14  james
+ * *** empty log message ***
+ *
  * Revision 1.2  2008/02/20 18:49:11  staffcvs
  * *** empty log message ***
  *
@@ -27,6 +30,6 @@
 
 extern void
 mainloop (TTY * tty, Socket * server_socket, Socket * client_socket, ANSI * a,
-          Log * log, int nhistory);
+          Log * log, int nhistory, int width);
 
 #endif /* __MAINLOOP_H__ */
index 4a9f18aa743dde3730367fec0e2a33f2116c72fb..a8dba28e16512e46bbe93e69b680bc8d95a6a852 100644 (file)
@@ -11,6 +11,9 @@ static char rcsid[] =
 
 /*
  * $Log$
+ * 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 +245,7 @@ main (int argc, char *argv[])
   int c;
   extern char *optarg;
   extern int optind, opterr, optopt;
-  int width=VT102_COLS_80;
+  int width = VT102_COLS_80;
 
   int oflags[128];
   char *oargs[128];
@@ -259,7 +262,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, "w:utscr:lKHd:pb:fL:Fk:n:")) != EOF)
     {
       switch (c)
         {
@@ -392,7 +395,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 +418,12 @@ 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'])
+    {
+      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['s'] && !oflags['F'])
     {
@@ -496,7 +500,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, width);
 
   if (ansi)
     {
index 62061fd3dcdf059f2b1eeac6b7d6bf987c7b3902..cf79d6d5b17069f7a6310b99dbdb4e984dea6a88 100644 (file)
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
 
 /*
  * $Log$
+ * Revision 1.11  2008/02/27 01:31:38  james
+ * *** empty log message ***
+ *
  * Revision 1.10  2008/02/27 01:31:14  james
  * *** empty log message ***
  *
@@ -96,8 +99,7 @@ usage (void)
            "   -n  hlines  the number of lines of history to store in the\n"
            "                 server, that are replayed on connexion\n"
            "   -u  don't emit utf-8 try to use ISO-2202 to the local terminal\n"
-          "   -w width  start session with a screen of width width<=132\n"
-          );
+           "   -w width  start session with a screen of width width<=132\n");
 
 
   exit (1);
index ef0dfb566d7ba20481f8bca95804bfe110d9353b..7c04f23772b3c47cab7e2f9a47c3bd7158aff2cf 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
 
 /*
  * $Log$
+ * Revision 1.5  2008/02/27 01:31:14  james
+ * *** empty log message ***
+ *
  * Revision 1.4  2008/02/27 00:54:16  james
  * *** empty log message ***
  *
@@ -101,7 +104,7 @@ file_log_new (char *fn)
   l->fp = f;
   l->do_close = dc;
 
-  fput_cp(f,0xffef);
+  fput_cp (f, 0xffef);
 
   return (Log *) l;
 }
index a1155924ea49e4fdb3c6fc6d826120ed5850f286..dd7dfeb841bdd939ffbaf528c967867637ef644a 100644 (file)
@@ -51,7 +51,7 @@ extern void vt102_reset_state(VT102 *v);
 extern void vt102_parse_char(Context *c, int ch);
 extern void vt102_send(Context *c, uint8_t key);
 extern void vt102_reset(VT102 *v);
-extern VT102 *vt102_new(void);
+extern VT102 *vt102_new(int width);
 extern void vt102_set_ansi(VT102 *v, int ansi);
 extern void vt102_free(VT102 *v);
 /* tty.c */
@@ -81,7 +81,7 @@ extern int ring_space(Ring *r);
 extern int ring_bytes(Ring *r);
 extern Ring *ring_new(int n);
 /* ptty.c */
-extern TTY *ptty_open(char *path, char *argv[]);
+extern TTY *ptty_open(char *path, char *argv[], int width);
 /* terminal.c */
 extern int terminal_winches;
 extern void terminal_atexit(void);
index b8e77b189cc2e87b86b7c20fc624b07d0fd3f81d..b2e5d0f15783cd1bbd23508bfbcc9cf9f7b62bb8 100644 (file)
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
 
 /*
  * $Log$
+ * Revision 1.13  2008/02/27 01:31:38  james
+ * *** empty log message ***
+ *
  * Revision 1.12  2008/02/27 01:31:14  james
  * *** empty log message ***
  *
@@ -140,7 +143,7 @@ ptty_write (TTY * _t, void *buf, int len)
 }
 
 TTY *
-ptty_open (char *path, char *argv[],int width)
+ptty_open (char *path, char *argv[], int width)
 {
   PTTY *t;
   pid_t child;
@@ -153,7 +156,7 @@ ptty_open (char *path, char *argv[],int width)
 
   client_termios (&ctermios);
   winsize.ws_row = VT102_ROWS;
-  winsize.ws_col = width ? width:VT102_COLS_80;
+  winsize.ws_col = width ? width : VT102_COLS_80;
 
   child = forkpty (&fd, name, &ctermios, &winsize);
 
index 7512c43ecb18eb272630e82cff6bedb5f34adcc5..aaa5ffc69cb13d6a79c1a2e0e9a8f14eef937d75 100644 (file)
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
 
 /*
  * $Log$
+ * Revision 1.9  2008/02/27 01:31:14  james
+ * *** empty log message ***
+ *
  * Revision 1.8  2008/02/27 00:54:16  james
  * *** empty log message ***
  *
@@ -154,26 +157,27 @@ utf8_new (void)
 
 }
 
-int  utf8_encode (char *ptr, int ch)
+int
+utf8_encode (char *ptr, int ch)
 {
 
   if (ch < 0x80)
     {
       ptr[0] = ch;
-       return 1;
+      return 1;
     }
   else if (ch < 0x800)
     {
       ptr[0] = 0xc0 | (ch >> 6);
       ptr[1] = 0x80 | (ch & 0x3f);
-       return 2;
+      return 2;
     }
   else if (ch < 0x10000)
     {
       ptr[0] = 0xe0 | (ch >> 12);
       ptr[1] = 0x80 | ((ch >> 6) & 0x3f);
       ptr[2] = 0x80 | (ch & 0x3f);
-       return 3;
+      return 3;
     }
   else if (ch < 0x1fffff)
     {
@@ -181,18 +185,19 @@ int  utf8_encode (char *ptr, int ch)
       ptr[1] = 0x80 | ((ch >> 12) & 0x3f);
       ptr[2] = 0x80 | ((ch >> 6) & 0x3f);
       ptr[3] = 0x80 | (ch & 0x3f);
-       return 4;
+      return 4;
     }
-       return 0;
+  return 0;
 }
 
 void
 utf8_emit (TTY * t, int ch)
 {
   uint8_t buf[4];
-int i;
-  i=utf8_encode(buf,ch);
-  if (!i) return;
+  int i;
+  i = utf8_encode (buf, ch);
+  if (!i)
+    return;
 
-      t->xmit (t, buf, i);
+  t->xmit (t, buf, i);
 }
index ea46e7727e9ee3f3f8cc0538c8f2eac328e7752a..91cb58b2ccfd850bb52b35e9c1761720f9c53e7b 100644 (file)
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
 
 /*
  * $Log$
+ * Revision 1.7  2008/02/27 01:31:14  james
+ * *** empty log message ***
+ *
  * Revision 1.6  2008/02/27 00:54:16  james
  * *** empty log message ***
  *
@@ -143,13 +146,15 @@ client_termios (struct termios *termios)
   cfsetospeed (termios, B9600);
 }
 
-int fput_cp(FILE *f,uint32_t ch)
+int
+fput_cp (FILE * f, uint32_t ch)
 {
-char buf[4];
-int i;
-i=utf8_encode(buf,ch);
+  char buf[4];
+  int i;
+  i = utf8_encode (buf, ch);
 
-if (!i) return 0;
+  if (!i)
+    return 0;
 
-return fwrite(buf,i,1,f);
+  return fwrite (buf, i, 1, f);
 }
index a879999359a729720987ca7921296d094df93929..52f7fb959f60f70d8a22e88a223394214fd68a8e 100644 (file)
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
 
 /*
  * $Log$
+ * Revision 1.46  2008/02/27 01:31:38  james
+ * *** empty log message ***
+ *
  * Revision 1.45  2008/02/27 01:31:14  james
  * *** empty log message ***
  *
@@ -2032,14 +2035,15 @@ vt102_new (int width)
 
   vt102_reset (v);
 
-  if (width) {
-          v->current_width =width;
-          v->crt.width = v->current_width;
-          v->screen_end.x = v->current_width - 1;
-          v->top_margin = v->screen_start;
-          v->bottom_margin = v->screen_end;
-          vt102_cursor_home (v);
-  }
+  if (width)
+    {
+      v->current_width = width;
+      v->crt.width = v->current_width;
+      v->screen_end.x = v->current_width - 1;
+      v->top_margin = v->screen_start;
+      v->bottom_margin = v->screen_end;
+      vt102_cursor_home (v);
+    }
 
   return v;
 }
diff --git a/src/vt102_charset.h b/src/vt102_charset.h
new file mode 100644 (file)
index 0000000..a1130fa
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * vt102_charset.h:
+ *
+ * Copyright (c) 2008 James McKenzie <james@fishsoup.dhs.org>,
+ * All rights reserved.
+ *
+ */
+
+/*
+ * $Id$
+ */
+
+/*
+ * $Log$
+ * Revision 1.1  2008/02/27 01:32:41  james
+ * *** empty log message ***
+ *
+ */
+
+#ifndef __VT102_CHARSET_H__
+#define __VT102_CHARSET_H__
+
+#define VT102_CHARSET_SIZE 128
+
+#define VT102_CSID_US  0
+#define VT102_CSID_UK  1
+#define VT102_CSID_GL  2
+#define VT102_CSID_VT52        3
+
+#endif /* __VT102_CHARSET_H__ */