# $Id$
#
# $Log$
+# Revision 1.2 2008/02/24 00:42:52 james
+# *** empty log message ***
+#
# Revision 1.1 2008/02/03 16:20:23 james
# *** empty log message ***
#
echo "s/%VERSION%/${VNUM}/g" > version.sed; \
fi
+protos:
+ (cd src && ${MAKE} protos)
+
+tidy:
+ cvs commit -m ""
+ (cd src && ${MAKE} tidy)
+ (cd apps && ${MAKE} tidy)
+
+
# $Id$
#
# $Log$
+# Revision 1.11 2008/02/24 00:42:53 james
+# *** empty log message ***
+#
# Revision 1.10 2008/02/20 18:35:10 james
# *** empty log message ***
#
bin_PROGRAMS = sympathy
-noinst_HEADERS=clients.h mainloop.h
+HDRS=clients.h mainloop.h
+SRCS=sympathy.c usage.c clients.c mainloop.c
-sympathy_SOURCES = sympathy.c usage.c clients.c mainloop.c
+noinst_HEADERS=${HDRS}
+
+sympathy_SOURCES = ${SRCS}
sympathy_LDADD = ../src/libsympathy.la -lutil
+tidy: ${SRCS} ${HDRS}
+ indent -i2 -ts0 ${SRCS} ${HDRS}
+ /bin/rm -f *~
+
AM_CFLAGS=-g -Werror
*
*/
-static char rcsid[] = "$Id$";
+static char rcsid[] =
+ "$Id$";
/*
* $Log$
+ * Revision 1.11 2008/02/24 00:43:55 james
+ * *** empty log message ***
+ *
* Revision 1.10 2008/02/23 13:05:57 staffcvs
* *** empty log message ***
*
/*
* $Log$
+ * Revision 1.14 2008/02/24 00:43:55 james
+ * *** empty log message ***
+ *
+ * Revision 1.13 2008/02/24 00:42:53 james
+ * *** empty log message ***
+ *
* Revision 1.12 2008/02/23 11:48:52 james
* *** empty log message ***
*
"sympathy -c [-H] -k skt\n"
"sympathy -r id [-H]\n" "sympathy {-l|-ls}\n"
#endif
- while ((c = getopt (argc, argv, "tscr:lKHd:pb:fL:Fk:n:")) != EOF)
+ while ((c = getopt (argc, argv, "utscr:lKHd:pb:fL:Fk:n:")) != EOF)
{
switch (c)
{
else
{
terminal_register_handlers ();
- ansi = ansi_new_from_terminal (terminal_open (0, 1));
+ ansi =
+ ansi_new_from_terminal (terminal_open (0, 1),
+ oflags['u'] ? 0 : 1);
ansi->reset (ansi, NULL);
}
}
/*
* $Log$
+ * Revision 1.9 2008/02/24 00:43:55 james
+ * *** empty log message ***
+ *
+ * Revision 1.8 2008/02/24 00:42:53 james
+ * *** empty log message ***
+ *
* Revision 1.7 2008/02/23 11:48:52 james
* *** empty log message ***
*
{
fprintf (stderr, "Usage:\n"
- "sympathy -t [-K] [-d serialdev|-p] [-b baud] [-f] [-L log]\n"
- "sympathy -s [-K] [-d serialdev|-p] [-b baud] [-f] [-L log] [-F] [-k skt]\n"
- " [-n hlines]\n"
- "sympathy [-s -c] [-K] [-d serialdev|-p] [-b baud] [-f] [-L log] [-k skt]\n"
+ "sympathy -t [-K] [-d serialdev|-p] [-b baud] [-f] [-L log] [-u]\n"
+ "sympathy -s [-K] [-d serialdev|-p] [-b baud] [-f] [-L log] [-u] [-F]\n"
+ " [-k skt] [-n hlines]\n"
+ "sympathy [-s -c] [-K] [-d serialdev|-p] [-b baud] [-f] [-L log] [-u] [-k skt]\n"
" [-n hlines]\n"
- "sympathy -c [-H] -k skt\n"
- "sympathy -r id [-H]\n"
+ "sympathy -c [-H] [-u] -k skt\n"
+ "sympathy -r id [-H] [-u]\n"
"sympathy {-l|-ls}\n"
"sympathy -h\n"
"\n"
" emit HTML of the current state of the screen on stdout\n"
" -L log activity on the device to the file log\n"
" -n hlines the number of lines of history to store in the\n"
- " server, that are replayed on connexion\n");
+ " server, that are replayed on connexion\n"
+ " -u don't emit utf-8 instead map all non ascii characters as ?\n");
+
exit (1);
}
# $Id$
#
# $Log$
+# Revision 1.17 2008/02/24 00:42:53 james
+# *** empty log message ***
+#
# Revision 1.16 2008/02/22 23:39:27 james
# *** empty log message ***
#
tidy: ${SRCS} ${HDRS}
indent -i2 -ts0 ${SRCS} ${HDRS}
+ /bin/rm -f *~
sympathy.h: ${PROJECTHDRS} sympathy.h.head sympathy.h.tail
cat sympathy.h.head ${PROJECTHDRS} sympathy.h.tail > $@ || /bin/rm -f $@
/*
* $Log$
+ * Revision 1.30 2008/02/24 00:42:53 james
+ * *** empty log message ***
+ *
* Revision 1.29 2008/02/23 11:48:37 james
* *** empty log message ***
*
}
+static void
+ansi_emit_noutf8 (TTY * t, uint32_t ch)
+{
+ uint8_t c = (ch > 0x7f) ? '?' : ch;
+ t->xmit (t, &c, 1);
+}
static void
ansi_render (ANSI * a, CRT_CA ca)
{
int dif;
- if (ca.chr < 32)
+ if (ca.chr < 0x20)
ca.chr = ' ';
- if (ca.chr > 126)
+ if ((ca.chr > 0x7e) && (ca.chr < 0xa0))
ca.chr = ' ';
ansi_set_attr (a, ca.attr);
ansi_set_color (a, ca.color);
- a->terminal->xmit (a->terminal, &ca.chr, 1);
+ if (a->utf8)
+ utf8_emit (a->terminal, ca.chr);
+ else
+ ansi_emit_noutf8 (a->terminal, ca.chr);
a->pos.x++;
}
ANSI *
-ansi_new_from_terminal (TTY * t)
+ansi_new_from_terminal (TTY * t, int utf8)
{
ANSI *ret;
ret->terminal = t;
+ ret->utf8 = utf8;
ret->update = ansi_update;
ret->reset = ansi_reset;
ret->terminal_reset = ansi_terminal_reset;
/*
* $Log$
+ * Revision 1.13 2008/02/24 00:42:53 james
+ * *** empty log message ***
+ *
* Revision 1.12 2008/02/23 11:48:37 james
* *** empty log message ***
*
int attr;
int color;
+ int utf8;
+
int history_ptr;
FILE *file;
/*
* $Log$
+ * Revision 1.10 2008/02/24 00:42:53 james
+ * *** empty log message ***
+ *
* Revision 1.9 2008/02/20 19:25:09 james
* *** empty log message ***
*
#define CRT_COLOR_NORMAL CRT_MAKE_COLOR(CRT_FGCOLOR_NORMAL,CRT_BGCOLOR_NORMAL)
-typedef struct
+typedef struct __attribute__ ((packed))
{
- uint8_t chr;
+ uint32_t chr;
uint8_t attr;
uint8_t color;
} CRT_CA;
/* ansi.c */
extern int ansi_dispatch(ANSI *a, Context *c);
-extern ANSI *ansi_new_from_terminal(TTY *t);
+extern ANSI *ansi_new_from_terminal(TTY *t, int utf8);
/* crt.c */
extern void crt_erase(CRT *c, CRT_Pos s, CRT_Pos e, int ea, int color);
extern void crt_cls(CRT *c);
extern void vt102_parse_attr_string(VT102 *v, char *buf, int len);
extern void vt102_save_state(VT102 *v);
extern void vt102_restore_state(VT102 *v);
-extern void vt102_regular_char(Context *c, VT102 *v, char ch);
+extern void vt102_regular_char(Context *c, VT102 *v, int ch);
extern void vt102_scs(Context *c, int g, int s);
extern void vt102_parse_esc(Context *c, int ch);
extern void vt102_parse_csi(Context *c, char *buf, int len);
extern int wrap_write(int fd, void *buf, int len);
extern void set_nonblocking(int fd);
extern void set_blocking(int fd);
-extern void raw_termios(struct termios *termios);
extern void default_termios(struct termios *termios);
+extern void client_termios(struct termios *termios);
/* log.c */
extern Log *file_log_new(char *fn);
extern void log_f(Log *log, char *fmt, ...);
extern Serial_lock *serial_lock_new(char *dev, int mode);
/* utf8.c */
extern void utf8_flush(Context *c);
-extern void utf8_parse(Context *c, int ch);
+extern void utf8_parse(Context *c, uint32_t ch);
extern UTF8 *utf8_new(void);
+extern void utf8_emit(TTY *t, int ch);
/*
* $Log$
+ * Revision 1.10 2008/02/24 00:42:53 james
+ * *** empty log message ***
+ *
* Revision 1.9 2008/02/23 13:05:58 staffcvs
* *** empty log message ***
*
pid_t child;
char name[1024];
struct winsize winsize = { 0 };
- struct termios termios = { 0 };
+ struct termios ctermios = { 0 };
int fd;
char *default_argv[] = { "-", (char *) 0 };
- default_termios (&termios);
- cfsetispeed (&termios, B9600);
- cfsetospeed (&termios, B9600);
-
+ client_termios (&ctermios);
winsize.ws_row = VT102_ROWS;
winsize.ws_col = VT102_COLS;
- child = forkpty (&fd, name, &termios, &winsize);
+ child = forkpty (&fd, name, &ctermios, &winsize);
switch (child)
{
set_nonblocking (fd);
+#if 0
+ {
+ struct termios termios = { 0 };
+
+ tcgetattr (fd, &termios);
+ default_termios (&termios);
+ tcsetattr (fd, TCSANOW, &termios);
+ }
+#endif
+
t = (PTTY *) malloc (sizeof (PTTY));
strncpy (t->name, name, sizeof (t->name));
/*
* $Log$
+ * Revision 1.10 2008/02/24 00:47:14 james
+ * *** empty log message ***
+ *
+ * Revision 1.9 2008/02/24 00:42:53 james
+ * *** empty log message ***
+ *
* Revision 1.8 2008/02/23 13:05:58 staffcvs
* *** empty log message ***
*
/*
* $Log$
+ * Revision 1.5 2008/02/24 00:42:53 james
+ * *** empty log message ***
+ *
* Revision 1.4 2008/02/23 13:05:58 staffcvs
* *** empty log message ***
*
}
void
-utf8_parse (Context * c, int ch)
+utf8_parse (Context * c, uint32_t ch)
{
UTF8 *u = c->u;
if (!u->in_utf8)
{
- /*FIXME: for the moment we bodge utf8 support */
+ /*FIXME: for the moment we bodge utf8 support - need to do */
+ /* L->R and R->L and double width characters */
if (ch == 0xb9)
{ /*CSI, not a valid utf8 start char */
vt102_parse_char (c, ch);
u->in_utf8--;
if (!u->in_utf8)
- vt102_parse_char (c, ch);
+ vt102_parse_char (c, u->ch);
}
}
}
ret->in_utf8 = 0;
}
+
+
+
+void
+utf8_emit (TTY * t, int ch)
+{
+ uint8_t buf[4];
+
+ if (ch < 0x80)
+ {
+ buf[0] = ch;
+ t->xmit (t, buf, 1);
+ }
+ else if (ch < 0x800)
+ {
+ buf[0] = 0xc0 | (ch >> 6);
+ buf[1] = 0x80 | (ch & 0x3f);
+
+ t->xmit (t, buf, 2);
+ }
+ else if (ch < 0x10000)
+ {
+ buf[0] = 0xe0 | (ch >> 12);
+ buf[1] = 0x80 | ((ch >> 6) & 0x3f);
+ buf[2] = 0x80 | (ch & 0x3f);
+ t->xmit (t, buf, 3);
+ }
+ else if (ch < 0x1fffff)
+ {
+ buf[0] = 0xf0 | (ch >> 18);
+ buf[1] = 0x80 | ((ch >> 12) & 0x3f);
+ buf[2] = 0x80 | ((ch >> 6) & 0x3f);
+ buf[3] = 0x80 | (ch & 0x3f);
+ t->xmit (t, buf, 4);
+ }
+}
/*
* $Log$
+ * Revision 1.4 2008/02/24 00:42:53 james
+ * *** empty log message ***
+ *
* Revision 1.3 2008/02/23 11:48:37 james
* *** empty log message ***
*
uint8_t utf_buf[4];
int utf_ptr;
- int ch;
+ uint32_t ch;
int sh;
} UTF8;
/*
* $Log$
+ * Revision 1.5 2008/02/24 00:42:53 james
+ * *** empty log message ***
+ *
* Revision 1.4 2008/02/23 13:05:58 staffcvs
* *** empty log message ***
*
fcntl (fd, F_SETFL, arg);
}
+
+
void
-raw_termios (struct termios *termios)
+default_termios (struct termios *termios)
{
-
- termios->c_iflag = 0;
-/*ICRNL | IXON;*/
+ termios->c_iflag = PARMRK | INPCK;
termios->c_oflag = NL0 | CR0 | TAB0 | BS0 | VT0 | FF0;
termios->c_lflag = 0;
-/*
- ISIG | ICANON | IEXTEN | ECHO | ECHOE | ECHOK | ECHOCTL | ECHOKE;
-*/
+ termios->c_cflag = CS8 | CREAD | CLOCAL;
termios->c_cc[VINTR] = 003;
termios->c_cc[VQUIT] = 034;
termios->c_cc[VREPRINT] = 022;
termios->c_cc[VDISCARD] = 017;
+
}
void
-default_termios (struct termios *termios)
+client_termios (struct termios *termios)
{
+ memset (termios, 0, sizeof (termios));
-// memset (termios, 0, sizeof (termios));
+ termios->c_iflag = ICRNL | IXON | PARMRK | INPCK;
+ termios->c_oflag = OPOST | ONLCR | NL0 | CR0 | TAB0 | BS0 | VT0 | FF0;
+ termios->c_lflag =
+ ISIG | ICANON | IEXTEN | ECHO | ECHOE | ECHOK | ECHOCTL | ECHOKE;
+ termios->c_cflag = CS8 | CREAD | CLOCAL;
- raw_termios (termios);
+ termios->c_cc[VINTR] = 003;
+ termios->c_cc[VQUIT] = 034;
+ termios->c_cc[VERASE] = 0177;
+ termios->c_cc[VKILL] = 025;
+ termios->c_cc[VEOF] = 004;
+ termios->c_cc[VEOL] = 0;
+ termios->c_cc[VEOL2] = 0;
+ termios->c_cc[VSTART] = 021;
+ termios->c_cc[VSTOP] = 023;
+ termios->c_cc[VSUSP] = 032;
+ termios->c_cc[VLNEXT] = 026;
+ termios->c_cc[VWERASE] = 027;
+ termios->c_cc[VREPRINT] = 022;
+ termios->c_cc[VDISCARD] = 017;
- termios->c_cflag = CS8 | CREAD | CLOCAL;
- termios->c_iflag |= PARMRK | INPCK;
- //cfsetispeed (termios, B9600);
- //cfsetospeed (termios, B9600);
+ cfsetispeed (termios, B9600);
+ cfsetospeed (termios, B9600);
}
/*
* $Log$
+ * Revision 1.35 2008/02/24 00:42:53 james
+ * *** empty log message ***
+ *
* Revision 1.34 2008/02/23 11:48:37 james
* *** empty log message ***
*
}
void
-vt102_regular_char (Context * c, VT102 * v, char ch)
+vt102_regular_char (Context * c, VT102 * v, int ch)
{
vt102_do_pending_wrap (c);
#endif
/* Turn anything non-ascii into '?' */
+#if 0
if ((ch != SYM_CHAR_RESET) && (ch != 0xb9) && (ch > 127))
{
ch = '?';
}
+#endif
if (ch == SYM_CHAR_RESET)
/*
* $Log$
+ * Revision 1.15 2008/02/24 00:42:53 james
+ * *** empty log message ***
+ *
* Revision 1.14 2008/02/23 11:48:37 james
* *** empty log message ***
*
int application_keypad_mode;
- char last_reg_char;
+ int last_reg_char;
int xn_glitch;
} VT102;