aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjames <>2008-03-02 10:38:18 +0000
committerjames <>2008-03-02 10:38:18 +0000
commitef21e0368adf8ae0e557e9c02fe776f69818ace6 (patch)
treecdfceba6afd3c2570cfe6d3e0c4f8fb46f182d15
parentf23e17f2eac3f506afe9a1e44302112cc363b59f (diff)
downloadsympathy-ef21e0368adf8ae0e557e9c02fe776f69818ace6.tar.gz
sympathy-ef21e0368adf8ae0e557e9c02fe776f69818ace6.tar.bz2
sympathy-ef21e0368adf8ae0e557e9c02fe776f69818ace6.zip
*** empty log message ***
-rw-r--r--apps/sympathy.c12
-rw-r--r--src/lockfile.c6
-rw-r--r--src/lockfile.h12
-rw-r--r--src/log.c68
-rw-r--r--src/log.h6
-rw-r--r--src/prototypes.h307
-rw-r--r--src/ptty.c77
-rw-r--r--src/ring.c29
-rw-r--r--src/ring.h6
-rw-r--r--src/serial.c66
-rw-r--r--src/slide.c12
-rw-r--r--src/slide.h6
-rw-r--r--src/symsocket.c96
-rw-r--r--src/symsocket.h6
-rw-r--r--src/terminal.c67
-rw-r--r--src/tty.c394
-rw-r--r--src/tty.h12
-rw-r--r--src/utf8.c187
-rw-r--r--src/utf8.h6
-rw-r--r--src/vt102.c1937
-rw-r--r--src/vt102.h12
21 files changed, 1592 insertions, 1732 deletions
diff --git a/apps/sympathy.c b/apps/sympathy.c
index 0cbd75d..91ed6da 100644
--- a/apps/sympathy.c
+++ b/apps/sympathy.c
@@ -11,6 +11,9 @@ static char rcsid[] =
/*
* $Log$
+ * Revision 1.30 2008/03/02 10:38:18 james
+ * *** empty log message ***
+ *
* Revision 1.29 2008/03/02 10:37:56 james
* *** empty log message ***
*
@@ -153,7 +156,7 @@ fatal_moan (char *fmt, ...)
char *
-teedious_snprintf (char *fmt, va_list ap)
+teedious_snprintf (char *fmt, va_list ap)
{
va_list aq;
int size = 1024;
@@ -298,7 +301,8 @@ list_sockets_in_dir (char *sockdir)
int hostname_len = strlen (hostname);
- if (!dir) return;
+ if (!dir)
+ return;
rewinddir (dir);
@@ -350,8 +354,8 @@ list_sockets (void)
list_sockets_in_dir (h);
- if (**ptr == '~')
- free (h);
+ if (**ptr == '~')
+ free (h);
}
diff --git a/src/lockfile.c b/src/lockfile.c
index 94cee44..646ba01 100644
--- a/src/lockfile.c
+++ b/src/lockfile.c
@@ -6,10 +6,14 @@
*
*/
-static char rcsid[] = "$Id$";
+static char rcsid[] =
+ "$Id$";
/*
* $Log$
+ * Revision 1.11 2008/03/02 10:38:18 james
+ * *** empty log message ***
+ *
* Revision 1.10 2008/03/02 10:37:56 james
* *** empty log message ***
*
diff --git a/src/lockfile.h b/src/lockfile.h
index 6941a1e..4364216 100644
--- a/src/lockfile.h
+++ b/src/lockfile.h
@@ -12,6 +12,9 @@
/*
* $Log$
+ * Revision 1.8 2008/03/02 10:37:56 james
+ * *** empty log message ***
+ *
* Revision 1.7 2008/02/23 11:48:37 james
* *** empty log message ***
*
@@ -43,20 +46,17 @@
#define FILE_LIST_MAX_LEN 1024
-typedef struct Filelist_ent
-{
+typedef struct Filelist_ent {
char name[FILE_LIST_MAX_LEN];
struct Filelist_ent *next;
} Filelist_ent;
-typedef struct
-{
+typedef struct {
Filelist_ent *head;
} Filelist;
-typedef struct
-{
+typedef struct {
int mode;
int i;
struct timeval last_stale_purge;
diff --git a/src/log.c b/src/log.c
index 7c04f23..979489a 100644
--- a/src/log.c
+++ b/src/log.c
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
/*
* $Log$
+ * Revision 1.6 2008/03/02 10:37:56 james
+ * *** empty log message ***
+ *
* Revision 1.5 2008/02/27 01:31:14 james
* *** empty log message ***
*
@@ -29,8 +32,7 @@ static char rcsid[] = "$Id$";
#include "project.h"
-typedef struct
-{
+typedef struct {
LOG_SIGNATURE;
int do_close;
FILE *fp;
@@ -85,17 +87,14 @@ file_log_new (char *fn)
FILE *f;
int dc = 1;
- if (fn && strcmp (fn, "-"))
- {
- f = fopen (fn, "a+");
- if (!f)
- return NULL;
- }
- else
- {
- f = stderr;
- dc = 0;
- }
+ if (fn && strcmp (fn, "-")) {
+ f = fopen (fn, "a+");
+ if (!f)
+ return NULL;
+ } else {
+ f = stderr;
+ dc = 0;
+ }
l = malloc (sizeof (File_Log));
@@ -121,35 +120,32 @@ log_f (Log * log, char *fmt, ...)
if (!log)
return;
- if (!size)
- {
- size = 128;
- buf = malloc (size);
- }
+ if (!size) {
+ size = 128;
+ buf = malloc (size);
+ }
if (!buf)
return;
- while (1)
- {
- va_start (ap, fmt);
- n = vsnprintf (buf, size, fmt, ap);
- va_end (ap);
+ while (1) {
+ va_start (ap, fmt);
+ n = vsnprintf (buf, size, fmt, ap);
+ va_end (ap);
- if (n > -1 && n < size)
- {
- log->log (log, buf);
- return;
- }
+ if (n > -1 && n < size) {
+ log->log (log, buf);
+ return;
+ }
- if (n > -1) /* glibc 2.1 */
- size = n + 1;
- else /* glibc 2.0 */
- size *= 2; /* twice the old size */
+ if (n > -1) /* glibc 2.1 */
+ size = n + 1;
+ else /* glibc 2.0 */
+ size *= 2; /* twice the old size */
- buf = realloc (buf, size);
+ buf = realloc (buf, size);
- if (!buf)
- return;
- }
+ if (!buf)
+ return;
+ }
}
diff --git a/src/log.h b/src/log.h
index 475fe16..56b690f 100644
--- a/src/log.h
+++ b/src/log.h
@@ -12,6 +12,9 @@
/*
* $Log$
+ * Revision 1.3 2008/03/02 10:37:56 james
+ * *** empty log message ***
+ *
* Revision 1.2 2008/02/23 11:48:37 james
* *** empty log message ***
*
@@ -27,8 +30,7 @@
void (*log)(struct Log_struct *,char *); \
void (*close)(struct Log_struct *)
-typedef struct Log_struct
-{
+typedef struct Log_struct {
LOG_SIGNATURE;
} Log;
diff --git a/src/prototypes.h b/src/prototypes.h
index 074f1a9..8044c3d 100644
--- a/src/prototypes.h
+++ b/src/prototypes.h
@@ -1,181 +1,182 @@
/* ansi.c */
-extern int ansi_key(ANSI *a, Context *c, int key);
-extern int ansi_dispatch(ANSI *a, Context *c);
-extern ANSI *ansi_new_from_terminal(TTY *t, int utf8);
+extern int ansi_key (ANSI * a, Context * c, int key);
+extern int ansi_dispatch (ANSI * a, Context * c);
+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 crt_scroll_up(CRT *c, CRT_Pos s, CRT_Pos e, int ea, int color);
-extern void crt_scroll_down(CRT *c, CRT_Pos s, CRT_Pos e, int ea, int color);
-extern void crt_reset(CRT *c);
-extern void crt_insert(CRT *c, CRT_CA ca);
+extern void crt_erase (CRT * c, CRT_Pos s, CRT_Pos e, int ea, int color);
+extern void crt_cls (CRT * c);
+extern void crt_scroll_up (CRT * c, CRT_Pos s, CRT_Pos e, int ea, int color);
+extern void crt_scroll_down (CRT * c, CRT_Pos s, CRT_Pos e, int ea,
+ int color);
+extern void crt_reset (CRT * c);
+extern void crt_insert (CRT * c, CRT_CA ca);
/* html.c */
-extern ANSI *ansi_new_html(FILE *f);
+extern ANSI *ansi_new_html (FILE * f);
/* libsympathy.c */
/* render.c */
/* version.c */
-extern char *libsympathy_version(void);
+extern char *libsympathy_version (void);
/* vt102.c */
extern int vt102_cmd_length[128];
extern int vt102_cmd_termination[128];
-extern void vt102_crt_update(Context *c);
-extern void vt102_do_resize(Context *c);
-extern void vt102_log_line(Context *c, int line);
-extern void vt102_history(Context *c, CRT_Pos t, CRT_Pos b);
-extern void vt102_clip_cursor(VT102 *v, CRT_Pos tl, CRT_Pos br);
-extern void vt102_cursor_normalize(VT102 *v);
-extern void vt102_cursor_carriage_return(VT102 *v);
-extern void vt102_cursor_advance_line(Context *c);
-extern void vt102_cursor_retreat_line(Context *c);
-extern void vt102_do_pending_wrap(Context *c);
-extern void vt102_cursor_advance(Context *c);
-extern void vt102_cursor_retreat(VT102 *v);
-extern void vt102_reset_tabs(VT102 *v);
-extern void vt102_cursor_advance_tab(VT102 *v);
-extern void vt102_cursor_retreat_tab(VT102 *v);
-extern int vt102_cursor_home(VT102 *v);
-extern int vt102_cursor_absolute(VT102 *v, int x, int y);
-extern int vt102_cursor_relative(VT102 *v, int x, int y);
-extern void vt102_delete_from_line(VT102 *v, CRT_Pos p);
-extern void vt102_insert_into_line(VT102 *v, CRT_Pos p);
-extern void vt102_change_mode(Context *c, int private, char *ns, int set);
-extern void vt102_parse_mode_string(Context *c, char *buf, int len);
-extern void vt102_change_attr(VT102 *v, char *na);
-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, uint32_t ch);
-extern int vt102_send_id(Context *c, char *buf);
-extern void vt102_scs(Context *c, int g, int s);
-extern void vt102_parse_csi(Context *c, char *buf, int len);
-extern void vt102_parse_esc(Context *c);
-extern void vt102_status_line(VT102 *v, char *str);
-extern void vt102_parser_reset(VT102_parser *p);
-extern void vt102_reset_state(Context *c);
-extern void vt102_parse_char(Context *c, int ch);
-extern void vt102_send(Context *c, uint8_t key);
-extern void vt102_reset(Context *c);
-extern VT102 *vt102_new(CRT_Pos *size);
-extern void vt102_set_ansi(VT102 *v, int ansi);
-extern void vt102_resize(Context *c, CRT_Pos size);
-extern void vt102_free(VT102 *v);
+extern void vt102_crt_update (Context * c);
+extern void vt102_do_resize (Context * c);
+extern void vt102_log_line (Context * c, int line);
+extern void vt102_history (Context * c, CRT_Pos t, CRT_Pos b);
+extern void vt102_clip_cursor (VT102 * v, CRT_Pos tl, CRT_Pos br);
+extern void vt102_cursor_normalize (VT102 * v);
+extern void vt102_cursor_carriage_return (VT102 * v);
+extern void vt102_cursor_advance_line (Context * c);
+extern void vt102_cursor_retreat_line (Context * c);
+extern void vt102_do_pending_wrap (Context * c);
+extern void vt102_cursor_advance (Context * c);
+extern void vt102_cursor_retreat (VT102 * v);
+extern void vt102_reset_tabs (VT102 * v);
+extern void vt102_cursor_advance_tab (VT102 * v);
+extern void vt102_cursor_retreat_tab (VT102 * v);
+extern int vt102_cursor_home (VT102 * v);
+extern int vt102_cursor_absolute (VT102 * v, int x, int y);
+extern int vt102_cursor_relative (VT102 * v, int x, int y);
+extern void vt102_delete_from_line (VT102 * v, CRT_Pos p);
+extern void vt102_insert_into_line (VT102 * v, CRT_Pos p);
+extern void vt102_change_mode (Context * c, int private, char *ns, int set);
+extern void vt102_parse_mode_string (Context * c, char *buf, int len);
+extern void vt102_change_attr (VT102 * v, char *na);
+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, uint32_t ch);
+extern int vt102_send_id (Context * c, char *buf);
+extern void vt102_scs (Context * c, int g, int s);
+extern void vt102_parse_csi (Context * c, char *buf, int len);
+extern void vt102_parse_esc (Context * c);
+extern void vt102_status_line (VT102 * v, char *str);
+extern void vt102_parser_reset (VT102_parser * p);
+extern void vt102_reset_state (Context * c);
+extern void vt102_parse_char (Context * c, int ch);
+extern void vt102_send (Context * c, uint8_t key);
+extern void vt102_reset (Context * c);
+extern VT102 *vt102_new (CRT_Pos * size);
+extern void vt102_set_ansi (VT102 * v, int ansi);
+extern void vt102_resize (Context * c, CRT_Pos size);
+extern void vt102_free (VT102 * v);
/* tty.c */
-extern void tty_pre_select(TTY *t, fd_set *rfds, fd_set *wfds);
-extern int tty_get_status(TTY *t, TTY_Status *s);
-extern int tty_get_baud(TTY *t);
-extern void tty_set_baud(TTY *t, int rate);
-extern void tty_send_break(TTY *t);
-extern void tty_set_flow(TTY *t, int flow);
-extern void tty_hangup(TTY *t);
-extern void tty_length(TTY *t, int l);
-extern void tty_winch(TTY *t, CRT_Pos size);
-extern void tty_parse_reset(Context *c);
-extern void tty_analyse(Context *c);
-extern TTY_Parser *tty_parser_new(void);
-extern void tty_parse(Context *c, uint8_t *buf, int len);
+extern void tty_pre_select (TTY * t, fd_set * rfds, fd_set * wfds);
+extern int tty_get_status (TTY * t, TTY_Status * s);
+extern int tty_get_baud (TTY * t);
+extern void tty_set_baud (TTY * t, int rate);
+extern void tty_send_break (TTY * t);
+extern void tty_set_flow (TTY * t, int flow);
+extern void tty_hangup (TTY * t);
+extern void tty_length (TTY * t, int l);
+extern void tty_winch (TTY * t, CRT_Pos size);
+extern void tty_parse_reset (Context * c);
+extern void tty_analyse (Context * c);
+extern TTY_Parser *tty_parser_new (void);
+extern void tty_parse (Context * c, uint8_t * buf, int len);
/* keydis.c */
-extern KeyDis *keydis_vt102_new(void);
-extern KeyDis *keydis_ipc_new(Socket *s);
+extern KeyDis *keydis_vt102_new (void);
+extern KeyDis *keydis_ipc_new (Socket * s);
/* history.c */
-extern History *history_new(int n);
-extern void history_free(History *h);
-extern void history_add(History *h, CRT_CA *c);
+extern History *history_new (int n);
+extern void history_free (History * h);
+extern void history_add (History * h, CRT_CA * c);
/* ring.c */
-extern int ring_read(Ring *r, void *b, int n);
-extern int ring_write(Ring *r, void *b, int n);
-extern int ring_space(Ring *r);
-extern int ring_bytes(Ring *r);
-extern Ring *ring_new(int n);
+extern int ring_read (Ring * r, void *b, int n);
+extern int ring_write (Ring * r, void *b, int n);
+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[], CRT_Pos *size);
+extern TTY *ptty_open (char *path, char *argv[], CRT_Pos * size);
/* terminal.c */
extern int terminal_winches;
-extern void terminal_atexit(void);
-extern void terminal_getsize(TTY *_t);
-extern void terminal_dispatch(void);
-extern void terminal_register_handlers(void);
-extern TTY *terminal_open(int rfd, int wfd);
+extern void terminal_atexit (void);
+extern void terminal_getsize (TTY * _t);
+extern void terminal_dispatch (void);
+extern void terminal_register_handlers (void);
+extern TTY *terminal_open (int rfd, int wfd);
/* util.c */
-extern int wrap_read(int fd, void *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 default_termios(struct termios *termios);
-extern void client_termios(struct termios *termios);
-extern int fput_cp(FILE *f, uint32_t ch);
+extern int wrap_read (int fd, void *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 default_termios (struct termios *termios);
+extern void client_termios (struct termios *termios);
+extern int fput_cp (FILE * f, uint32_t ch);
/* log.c */
-extern Log *file_log_new(char *fn);
-extern void log_f(Log *log, char *fmt, ...);
+extern Log *file_log_new (char *fn);
+extern void log_f (Log * log, char *fmt, ...);
/* ipc.c */
-extern IPC_Msg *ipc_check_for_message_in_slide(Slide *s);
-extern void ipc_consume_message_in_slide(Slide *s);
-extern int ipc_msg_send(Socket *s, IPC_Msg *m);
-extern int ipc_msg_send_debug(Socket *s, char *msg);
-extern int ipc_msg_send_history(Socket *s, History_ent *l);
-extern int ipc_msg_send_vt102(Socket *s, VT102 *v);
-extern int ipc_msg_send_key(Socket *s, int key);
-extern int ipc_msg_send_term(Socket *s, void *buf, int len);
-extern int ipc_msg_send_status(Socket *s, char *buf);
-extern int ipc_msg_send_setbaud(Socket *s, int baud);
-extern int ipc_msg_send_sendbreak(Socket *s);
-extern int ipc_msg_send_setflow(Socket *s, int flow);
-extern int ipc_msg_send_setansi(Socket *s, int ansi);
-extern int ipc_msg_send_hangup(Socket *s);
-extern int ipc_msg_send_setsize(Socket *s, CRT_Pos size);
-extern int ipc_msg_send_reset(Socket *s);
+extern IPC_Msg *ipc_check_for_message_in_slide (Slide * s);
+extern void ipc_consume_message_in_slide (Slide * s);
+extern int ipc_msg_send (Socket * s, IPC_Msg * m);
+extern int ipc_msg_send_debug (Socket * s, char *msg);
+extern int ipc_msg_send_history (Socket * s, History_ent * l);
+extern int ipc_msg_send_vt102 (Socket * s, VT102 * v);
+extern int ipc_msg_send_key (Socket * s, int key);
+extern int ipc_msg_send_term (Socket * s, void *buf, int len);
+extern int ipc_msg_send_status (Socket * s, char *buf);
+extern int ipc_msg_send_setbaud (Socket * s, int baud);
+extern int ipc_msg_send_sendbreak (Socket * s);
+extern int ipc_msg_send_setflow (Socket * s, int flow);
+extern int ipc_msg_send_setansi (Socket * s, int ansi);
+extern int ipc_msg_send_hangup (Socket * s);
+extern int ipc_msg_send_setsize (Socket * s, CRT_Pos size);
+extern int ipc_msg_send_reset (Socket * s);
/* slide.c */
-extern void slide_free(Slide *s);
-extern void slide_consume(Slide *s, int n);
-extern void slide_added(Slide *s, int n);
-extern Slide *slide_new(int n);
-extern void slide_expand(Slide *s, int n);
+extern void slide_free (Slide * s);
+extern void slide_consume (Slide * s, int n);
+extern void slide_added (Slide * s, int n);
+extern Slide *slide_new (int n);
+extern void slide_expand (Slide * s, int n);
/* symsocket.c */
-extern int wrap_recv(int fd, void *buf, int len);
-extern int wrap_send(int fd, void *buf, int len);
-extern void socket_free(Socket *s);
-extern void socket_free_parent(Socket *s);
-extern Socket *socket_listen(char *path);
-extern Socket *socket_accept(Socket *l);
-extern Socket *socket_connect(char *path);
-extern void socket_consume_msg(Socket *s);
-extern void socket_pre_select(Socket *s, fd_set *rfds, fd_set *wfds);
-extern int socket_post_select(Socket *s, fd_set *rfds, fd_set *wfds);
-extern int socket_write(Socket *s, void *buf, int len);
+extern int wrap_recv (int fd, void *buf, int len);
+extern int wrap_send (int fd, void *buf, int len);
+extern void socket_free (Socket * s);
+extern void socket_free_parent (Socket * s);
+extern Socket *socket_listen (char *path);
+extern Socket *socket_accept (Socket * l);
+extern Socket *socket_connect (char *path);
+extern void socket_consume_msg (Socket * s);
+extern void socket_pre_select (Socket * s, fd_set * rfds, fd_set * wfds);
+extern int socket_post_select (Socket * s, fd_set * rfds, fd_set * wfds);
+extern int socket_write (Socket * s, void *buf, int len);
/* serial.c */
-extern TTY *serial_open(char *path, int lock_mode);
+extern TTY *serial_open (char *path, int lock_mode);
/* cmd.c */
-extern int cmd_parse(Cmd *c, Context *ctx, ANSI *a, char *buf);
-extern void cmd_show_status(Cmd *c, Context *ctx);
-extern int cmd_key(Cmd *c, Context *ctx, ANSI *a, int key);
-extern int cmd_deactivate(Cmd *c, Context *ctx);
-extern int cmd_activate(Cmd *c, Context *ctx);
-extern void cmd_new_status(Cmd *c, Context *ctx, char *msg);
-extern Cmd *cmd_new(void);
+extern int cmd_parse (Cmd * c, Context * ctx, ANSI * a, char *buf);
+extern void cmd_show_status (Cmd * c, Context * ctx);
+extern int cmd_key (Cmd * c, Context * ctx, ANSI * a, int key);
+extern int cmd_deactivate (Cmd * c, Context * ctx);
+extern int cmd_activate (Cmd * c, Context * ctx);
+extern void cmd_new_status (Cmd * c, Context * ctx, char *msg);
+extern Cmd *cmd_new (void);
/* lockfile.c */
-extern Filelist *filelist_new(void);
-extern void filelist_remove(Filelist *fl, Filelist_ent *fle);
-extern void filelist_add(Filelist *fl, char *fn);
-extern void filelist_free(Filelist *fl);
-extern void filelist_print(Filelist *fl, FILE *f);
-extern int lockfile_make(char *name);
-extern void lockfile_add_places(Filelist *fl, char *leaf);
-extern void lockfile_regularize_and_add(Filelist *fl, char *leaf);
-extern void lockfile_add_name_from_path(Filelist *fl, char *file);
-extern void lockfile_add_name_from_dev(Filelist *fl, dev_t dev);
-extern void lockfile_check_dir_for_dev(Filelist *fl, char *dir, dev_t dev);
-extern Filelist *lockfile_make_list(char *device);
-extern void lockfile_remove_stale(Filelist *fl);
-extern Filelist *lockfile_lock(Filelist *fl);
-extern void lockfile_unlock(Filelist *fl);
-extern int serial_lock_check(Serial_lock *l);
-extern void serial_lock_free(Serial_lock *l);
-extern Serial_lock *serial_lock_new(char *dev, int mode);
+extern Filelist *filelist_new (void);
+extern void filelist_remove (Filelist * fl, Filelist_ent * fle);
+extern void filelist_add (Filelist * fl, char *fn);
+extern void filelist_free (Filelist * fl);
+extern void filelist_print (Filelist * fl, FILE * f);
+extern int lockfile_make (char *name);
+extern void lockfile_add_places (Filelist * fl, char *leaf);
+extern void lockfile_regularize_and_add (Filelist * fl, char *leaf);
+extern void lockfile_add_name_from_path (Filelist * fl, char *file);
+extern void lockfile_add_name_from_dev (Filelist * fl, dev_t dev);
+extern void lockfile_check_dir_for_dev (Filelist * fl, char *dir, dev_t dev);
+extern Filelist *lockfile_make_list (char *device);
+extern void lockfile_remove_stale (Filelist * fl);
+extern Filelist *lockfile_lock (Filelist * fl);
+extern void lockfile_unlock (Filelist * fl);
+extern int serial_lock_check (Serial_lock * l);
+extern void serial_lock_free (Serial_lock * l);
+extern Serial_lock *serial_lock_new (char *dev, int mode);
/* utf8.c */
-extern void utf8_flush(Context *c);
-extern void utf8_parse(Context *c, uint32_t ch);
-extern UTF8 *utf8_new(void);
-extern int utf8_encode(char *ptr, int ch);
-extern void utf8_emit(TTY *t, int ch);
+extern void utf8_flush (Context * c);
+extern void utf8_parse (Context * c, uint32_t ch);
+extern UTF8 *utf8_new (void);
+extern int utf8_encode (char *ptr, int ch);
+extern void utf8_emit (TTY * t, int ch);
/* vt102_charset.c */
extern uint32_t vt102_charset_c0[128];
extern uint32_t vt102_charset_us[128];
diff --git a/src/ptty.c b/src/ptty.c
index f8b6b9f..d97919c 100644
--- a/src/ptty.c
+++ b/src/ptty.c
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
/*
* $Log$
+ * Revision 1.17 2008/03/02 10:37:56 james
+ * *** empty log message ***
+ *
* Revision 1.16 2008/02/28 16:57:52 james
* *** empty log message ***
*
@@ -78,8 +81,7 @@ static char rcsid[] = "$Id$";
#include "project.h"
-typedef struct
-{
+typedef struct {
TTY_SIGNATURE;
int fd;
pid_t child;
@@ -106,19 +108,18 @@ ptty_read (TTY * _t, void *buf, int len)
PTTY *t = (PTTY *) _t;
int red, done = 0;
- do
- {
+ do {
- red = wrap_read (t->fd, buf, len);
- if (red < 0)
- return -1;
- if (!red)
- return done;
+ red = wrap_read (t->fd, buf, len);
+ if (red < 0)
+ return -1;
+ if (!red)
+ return done;
- buf += red;
- len -= red;
- done += red;
- }
+ buf += red;
+ len -= red;
+ done += red;
+ }
while (len);
@@ -132,19 +133,18 @@ ptty_write (TTY * _t, void *buf, int len)
int writ, done = 0;
PTTY *t = (PTTY *) _t;
- do
- {
+ do {
- writ = wrap_write (t->fd, buf, len);
- if (writ < 0)
- return -1;
- if (!writ)
- sleep (1);
+ writ = wrap_write (t->fd, buf, len);
+ if (writ < 0)
+ return -1;
+ if (!writ)
+ sleep (1);
- buf += writ;
- len -= writ;
- done += writ;
- }
+ buf += writ;
+ len -= writ;
+ done += writ;
+ }
while (len);
@@ -169,21 +169,20 @@ ptty_open (char *path, char *argv[], CRT_Pos * size)
child = forkpty (&fd, name, &ctermios, &winsize);
- switch (child)
- {
- case -1: /*boo hiss */
- return NULL;
- case 0: /*waaah */
- setenv ("TERM", "xterm", 1);
- if (!path)
- path = "/bin/sh";
-
- if (!argv)
- argv = default_argv;
-
- execv (path, argv);
- _exit (-1);
- }
+ switch (child) {
+ case -1: /*boo hiss */
+ return NULL;
+ case 0: /*waaah */
+ setenv ("TERM", "xterm", 1);
+ if (!path)
+ path = "/bin/sh";
+
+ if (!argv)
+ argv = default_argv;
+
+ execv (path, argv);
+ _exit (-1);
+ }
set_nonblocking (fd);
diff --git a/src/ring.c b/src/ring.c
index ca412ab..b5bcf76 100644
--- a/src/ring.c
+++ b/src/ring.c
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
/*
* $Log$
+ * Revision 1.5 2008/03/02 10:37:56 james
+ * *** empty log message ***
+ *
* Revision 1.4 2008/02/13 16:57:29 james
* *** empty log message ***
*
@@ -31,15 +34,14 @@ ring_read (Ring * r, void *b, int n)
{
int red = 0;
- while (n--)
- {
+ while (n--) {
- if (!ring_read_one (r, b))
- break;
+ if (!ring_read_one (r, b))
+ break;
- b++;
- red++;
- }
+ b++;
+ red++;
+ }
return red;
}
@@ -49,15 +51,14 @@ ring_write (Ring * r, void *b, int n)
{
int writ = 0;
- while (n--)
- {
+ while (n--) {
- if (!ring_write_one (r, b))
- break;
+ if (!ring_write_one (r, b))
+ break;
- b++;
- writ++;
- }
+ b++;
+ writ++;
+ }
return writ;
}
diff --git a/src/ring.h b/src/ring.h
index bd15cd4..05a0333 100644
--- a/src/ring.h
+++ b/src/ring.h
@@ -12,6 +12,9 @@
/*
* $Log$
+ * Revision 1.3 2008/03/02 10:37:56 james
+ * *** empty log message ***
+ *
* Revision 1.2 2008/02/12 22:36:46 james
* *** empty log message ***
*
@@ -23,8 +26,7 @@
#ifndef __RING_H__
#define __RING_H__
-typedef struct
-{
+typedef struct {
uint8_t *ring;
int wptr;
int rptr;
diff --git a/src/serial.c b/src/serial.c
index e269c83..0284703 100644
--- a/src/serial.c
+++ b/src/serial.c
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
/*
* $Log$
+ * Revision 1.13 2008/03/02 10:37:56 james
+ * *** empty log message ***
+ *
* Revision 1.12 2008/02/28 16:57:52 james
* *** empty log message ***
*
@@ -81,8 +84,7 @@ static char rcsid[] = "$Id$";
#include <sys/stat.h>
-typedef struct
-{
+typedef struct {
TTY_SIGNATURE;
Serial_lock *lock;
int fd;
@@ -114,19 +116,18 @@ serial_read (TTY * _t, void *buf, int len)
if (t->blocked)
return 0;
- do
- {
+ do {
- red = wrap_read (t->fd, buf, len);
- if (red < 0)
- return -1;
- if (!red)
- return done;
+ red = wrap_read (t->fd, buf, len);
+ if (red < 0)
+ return -1;
+ if (!red)
+ return done;
- buf += red;
- len -= red;
- done += red;
- }
+ buf += red;
+ len -= red;
+ done += red;
+ }
while (len);
@@ -144,19 +145,18 @@ serial_write (TTY * _t, void *buf, int len)
if (t->blocked)
return 0;
- do
- {
+ do {
- writ = wrap_write (t->fd, buf, len);
- if (writ < 0)
- return -1;
- if (!writ)
- sleep (1);
+ writ = wrap_write (t->fd, buf, len);
+ if (writ < 0)
+ return -1;
+ if (!writ)
+ sleep (1);
- buf += writ;
- len -= writ;
- done += writ;
- }
+ buf += writ;
+ len -= writ;
+ done += writ;
+ }
while (len);
@@ -184,18 +184,16 @@ serial_open (char *path, int lock_mode)
set_nonblocking (fd);
- if (tcgetattr (fd, &termios))
- {
- close (fd);
- return NULL;
- }
+ if (tcgetattr (fd, &termios)) {
+ close (fd);
+ return NULL;
+ }
default_termios (&termios);
- if (tcsetattr (fd, TCSANOW, &termios))
- {
- close (fd);
- return NULL;
- }
+ if (tcsetattr (fd, TCSANOW, &termios)) {
+ close (fd);
+ return NULL;
+ }
t = (Serial *) malloc (sizeof (Serial));
diff --git a/src/slide.c b/src/slide.c
index 06c7768..3581f86 100644
--- a/src/slide.c
+++ b/src/slide.c
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
/*
* $Log$
+ * Revision 1.4 2008/03/02 10:37:56 james
+ * *** empty log message ***
+ *
* Revision 1.3 2008/02/14 02:46:44 james
* *** empty log message ***
*
@@ -49,11 +52,10 @@ slide_consume (Slide * s, int n)
memmove (s->slide, s->slide + n, s->nbytes);
- if ((s->size > s->target_size) && (s->nbytes <= s->target_size))
- {
- s->size = s->target_size;
- s->slide = realloc (s->slide, s->size);
- }
+ if ((s->size > s->target_size) && (s->nbytes <= s->target_size)) {
+ s->size = s->target_size;
+ s->slide = realloc (s->slide, s->size);
+ }
}
diff --git a/src/slide.h b/src/slide.h
index d9a7059..9705d5f 100644
--- a/src/slide.h
+++ b/src/slide.h
@@ -12,6 +12,9 @@
/*
* $Log$
+ * Revision 1.2 2008/03/02 10:37:56 james
+ * *** empty log message ***
+ *
* Revision 1.1 2008/02/13 16:57:29 james
* *** empty log message ***
*
@@ -26,8 +29,7 @@
#ifndef __SLIDE_H__
#define __SLIDE_H__
-typedef struct
-{
+typedef struct {
uint8_t *slide;
int nbytes;
int target_size;
diff --git a/src/symsocket.c b/src/symsocket.c
index 22f0bf6..6f33fe7 100644
--- a/src/symsocket.c
+++ b/src/symsocket.c
@@ -11,6 +11,9 @@ static char rcsid[] =
/*
* $Log$
+ * Revision 1.7 2008/03/02 10:37:56 james
+ * *** empty log message ***
+ *
* Revision 1.6 2008/02/27 00:27:22 james
* *** empty log message ***
*
@@ -80,11 +83,10 @@ socket_free (Socket * s)
slide_free (s->read_buf);
if (s->write_buf)
slide_free (s->write_buf);
- if (s->path_to_unlink)
- {
- unlink (s->path_to_unlink);
- free (s->path_to_unlink);
- }
+ if (s->path_to_unlink) {
+ unlink (s->path_to_unlink);
+ free (s->path_to_unlink);
+ }
close (s->fd);
free (s);
}
@@ -129,20 +131,18 @@ socket_listen (char *path)
sun->sun_family = AF_UNIX;
strcpy (sun->sun_path, path);
- if (bind (fd, (struct sockaddr *) sun, SUN_LEN (sun)) < 0)
- {
- free (sun);
- close (fd);
- return NULL;
- }
+ if (bind (fd, (struct sockaddr *) sun, SUN_LEN (sun)) < 0) {
+ free (sun);
+ close (fd);
+ return NULL;
+ }
free (sun);
- if (listen (fd, 5) < 0)
- {
- close (fd);
- return NULL;
- }
+ if (listen (fd, 5) < 0) {
+ close (fd);
+ return NULL;
+ }
set_nonblocking (fd);
@@ -210,12 +210,11 @@ socket_connect (char *path)
sun->sun_family = AF_UNIX;
strcpy (sun->sun_path, path);
- if (connect (fd, (struct sockaddr *) sun, SUN_LEN (sun)))
- {
- free (sun);
- close (fd);
- return NULL;
- }
+ if (connect (fd, (struct sockaddr *) sun, SUN_LEN (sun))) {
+ free (sun);
+ close (fd);
+ return NULL;
+ }
free (sun);
@@ -252,11 +251,10 @@ socket_pre_select (Socket * s, fd_set * rfds, fd_set * wfds)
int n;
/*Server socket */
- if (SOCKET_IS_LISTENER (s))
- {
- FD_SET (s->fd, rfds);
- return;
- }
+ if (SOCKET_IS_LISTENER (s)) {
+ FD_SET (s->fd, rfds);
+ return;
+ }
if (!SLIDE_EMPTY (s->write_buf))
FD_SET (s->fd, wfds);
@@ -274,29 +272,27 @@ socket_post_select (Socket * s, fd_set * rfds, fd_set * wfds)
int error = 0;
- if ((!SLIDE_EMPTY (s->write_buf)) && FD_ISSET (s->fd, wfds))
- {
- n =
- (SLIDE_BYTES (s->write_buf) >
- MAX_TXN) ? MAX_TXN : SLIDE_BYTES (s->write_buf);
- n = wrap_send (s->fd, SLIDE_RPTR (s->write_buf), n);
- if (n > 0)
- slide_consume (s->write_buf, n);
- if (n < 0)
- error = -1;
- }
-
- if (!SLIDE_FULL (s->read_buf) && FD_ISSET (s->fd, rfds))
- {
- n =
- (SLIDE_SPACE (s->read_buf) >
- MAX_TXN) ? MAX_TXN : SLIDE_SPACE (s->read_buf);
- n = wrap_recv (s->fd, SLIDE_WPTR (s->read_buf), n);
- if (n > 0)
- slide_added (s->read_buf, n);
- if (n < 0)
- error = -1;
- }
+ if ((!SLIDE_EMPTY (s->write_buf)) && FD_ISSET (s->fd, wfds)) {
+ n =
+ (SLIDE_BYTES (s->write_buf) >
+ MAX_TXN) ? MAX_TXN : SLIDE_BYTES (s->write_buf);
+ n = wrap_send (s->fd, SLIDE_RPTR (s->write_buf), n);
+ if (n > 0)
+ slide_consume (s->write_buf, n);
+ if (n < 0)
+ error = -1;
+ }
+
+ if (!SLIDE_FULL (s->read_buf) && FD_ISSET (s->fd, rfds)) {
+ n =
+ (SLIDE_SPACE (s->read_buf) >
+ MAX_TXN) ? MAX_TXN : SLIDE_SPACE (s->read_buf);
+ n = wrap_recv (s->fd, SLIDE_WPTR (s->read_buf), n);
+ if (n > 0)
+ slide_added (s->read_buf, n);
+ if (n < 0)
+ error = -1;
+ }
s->msg = ipc_check_for_message_in_slide (s->read_buf);
diff --git a/src/symsocket.h b/src/symsocket.h
index 34961d0..aa6cef0 100644
--- a/src/symsocket.h
+++ b/src/symsocket.h
@@ -12,6 +12,9 @@
/*
* $Log$
+ * Revision 1.3 2008/03/02 10:37:56 james
+ * *** empty log message ***
+ *
* Revision 1.2 2008/02/20 18:31:53 james
* *** empty log message ***
*
@@ -23,8 +26,7 @@
#ifndef __SYMSOCKET_H__
#define __SYMSOCKET_H__
-typedef struct
-{
+typedef struct {
int fd;
Slide *read_buf;
diff --git a/src/terminal.c b/src/terminal.c
index a3be09b..ca317b7 100644
--- a/src/terminal.c
+++ b/src/terminal.c
@@ -11,6 +11,9 @@ static char rcsid[] =
/*
* $Log$
+ * Revision 1.13 2008/03/02 10:37:56 james
+ * *** empty log message ***
+ *
* Revision 1.12 2008/02/28 16:57:52 james
* *** empty log message ***
*
@@ -70,8 +73,7 @@ static char rcsid[] =
#include "project.h"
-typedef struct TERMINAL_struct
-{
+typedef struct TERMINAL_struct {
TTY_SIGNATURE;
struct termios orig_termios;
struct TERMINAL_struct *next;
@@ -113,7 +115,7 @@ terminal_close (TTY * _t)
t->xmit (_t, "\017", 1); //Select G0
t->xmit (_t, "\033[r", 3); //No margins
t->xmit (_t, "\033[0m", 4); //Default attributes
- i = sprintf (buf, "\033[%d;%dH", t->displayed_length ?(t->displayed_length+1): (CRT_ROWS +1), 1); //Cursor to bottom
+ i = sprintf (buf, "\033[%d;%dH", t->displayed_length ? (t->displayed_length + 1) : (CRT_ROWS + 1), 1); //Cursor to bottom
t->xmit (_t, buf, i);
t->xmit (_t, "\033[J", 3); //erase rest of screen
@@ -154,16 +156,13 @@ terminal_getsize (TTY * _t)
if (!t)
return;
- if (ioctl (t->wfd, TIOCGWINSZ, &sz))
- {
- t->size.x = CRT_COLS;
- t->size.y = CRT_ROWS;
- }
- else
- {
- t->size.x = sz.ws_col;
- t->size.y = sz.ws_row;
- }
+ if (ioctl (t->wfd, TIOCGWINSZ, &sz)) {
+ t->size.x = CRT_COLS;
+ t->size.y = CRT_ROWS;
+ } else {
+ t->size.x = sz.ws_col;
+ t->size.y = sz.ws_row;
+ }
}
@@ -193,19 +192,18 @@ terminal_read (TTY * _t, void *buf, int len)
terminal_dispatch ();
set_nonblocking (t->rfd);
- do
- {
+ do {
- red = wrap_read (t->rfd, buf, len);
- if (red < 0)
- return -1;
- if (!red)
- return done;
+ red = wrap_read (t->rfd, buf, len);
+ if (red < 0)
+ return -1;
+ if (!red)
+ return done;
- buf += red;
- len -= red;
- done += red;
- }
+ buf += red;
+ len -= red;
+ done += red;
+ }
while (len);
@@ -223,20 +221,19 @@ terminal_write (TTY * _t, void *buf, int len)
set_blocking (t->wfd);
- do
- {
+ do {
- writ = wrap_write (t->wfd, buf, len);
- if (writ < 0)
- return -1;
+ writ = wrap_write (t->wfd, buf, len);
+ if (writ < 0)
+ return -1;
- if (!writ)
- usleep (1000);
+ if (!writ)
+ usleep (1000);
- buf += writ;
- len -= writ;
- done += writ;
- }
+ buf += writ;
+ len -= writ;
+ done += writ;
+ }
while (len);
diff --git a/src/tty.c b/src/tty.c
index df7c13f..b7ebd19 100644
--- a/src/tty.c
+++ b/src/tty.c
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
/*
* $Log$
+ * Revision 1.20 2008/03/02 10:37:56 james
+ * *** empty log message ***
+ *
* Revision 1.19 2008/02/28 16:57:52 james
* *** empty log message ***
*
@@ -69,85 +72,84 @@ static char rcsid[] = "$Id$";
static int
speed_t_to_baud (speed_t s)
{
- switch (s)
- {
+ switch (s) {
#ifdef B0
- case B0:
- return 0;
+ case B0:
+ return 0;
#endif
#ifdef B50
- case B50:
- return 50;
+ case B50:
+ return 50;
#endif
#ifdef B75
- case B75:
- return 75;
+ case B75:
+ return 75;
#endif
#ifdef B110
- case B110:
- return 110;
+ case B110:
+ return 110;
#endif
#ifdef B134
- case B134:
- return 134;
+ case B134:
+ return 134;
#endif
#ifdef B150
- case B150:
- return 150;
+ case B150:
+ return 150;
#endif
#ifdef B200
- case B200:
- return 200;
+ case B200:
+ return 200;
#endif
#ifdef B300
- case B300:
- return 300;
+ case B300:
+ return 300;
#endif
#ifdef B600
- case B600:
- return 600;
+ case B600:
+ return 600;
#endif
#ifdef B1200
- case B1200:
- return 1200;
+ case B1200:
+ return 1200;
#endif
#ifdef B1800
- case B1800:
- return 1800;
+ case B1800:
+ return 1800;
#endif
#ifdef B2400
- case B2400:
- return 2400;
+ case B2400:
+ return 2400;
#endif
#ifdef B4800
- case B4800:
- return 4800;
+ case B4800:
+ return 4800;
#endif
#ifdef B9600
- case B9600:
- return 9600;
+ case B9600:
+ return 9600;
#endif
#ifdef B19200
- case B19200:
- return 19200;
+ case B19200:
+ return 19200;
#endif
#ifdef B38400
- case B38400:
- return 38400;
+ case B38400:
+ return 38400;
#endif
#ifdef B57600
- case B57600:
- return 57600;
+ case B57600:
+ return 57600;
#endif
#ifdef B115200
- case B115200:
- return 115200;
+ case B115200:
+ return 115200;
#endif
#ifdef B230400
- case B230400:
- return 230400;
+ case B230400:
+ return 230400;
#endif
- }
+ }
return -1;
}
@@ -155,85 +157,84 @@ speed_t_to_baud (speed_t s)
static speed_t
baud_to_speed_t (int baud)
{
- switch (baud)
- {
+ switch (baud) {
#ifdef B0
- case 0:
- return B0;
+ case 0:
+ return B0;
#endif
#ifdef B50
- case 50:
- return B50;
+ case 50:
+ return B50;
#endif
#ifdef B75
- case 75:
- return B75;
+ case 75:
+ return B75;
#endif
#ifdef B110
- case 110:
- return B110;
+ case 110:
+ return B110;
#endif
#ifdef B134
- case 134:
- return B134;
+ case 134:
+ return B134;
#endif
#ifdef B150
- case 150:
- return B150;
+ case 150:
+ return B150;
#endif
#ifdef B200
- case 200:
- return B200;
+ case 200:
+ return B200;
#endif
#ifdef B300
- case 300:
- return B300;
+ case 300:
+ return B300;
#endif
#ifdef B600
- case 600:
- return B600;
+ case 600:
+ return B600;
#endif
#ifdef B1200
- case 1200:
- return B1200;
+ case 1200:
+ return B1200;
#endif
#ifdef B1800
- case 1800:
- return B1800;
+ case 1800:
+ return B1800;
#endif
#ifdef B2400
- case 2400:
- return B2400;
+ case 2400:
+ return B2400;
#endif
#ifdef B4800
- case 4800:
- return B4800;
+ case 4800:
+ return B4800;
#endif
#ifdef B9600
- case 9600:
- return B9600;
+ case 9600:
+ return B9600;
#endif
#ifdef B19200
- case 19200:
- return B19200;
+ case 19200:
+ return B19200;
#endif
#ifdef B38400
- case 38400:
- return B38400;
+ case 38400:
+ return B38400;
#endif
#ifdef B57600
- case 57600:
- return B57600;
+ case 57600:
+ return B57600;
#endif
#ifdef B115200
- case 115200:
- return B115200;
+ case 115200:
+ return B115200;
#endif
#ifdef B230400
- case 230400:
- return B230400;
+ case 230400:
+ return B230400;
#endif
- }
+ }
return -1;
}
@@ -243,18 +244,16 @@ tty_pre_select (TTY * t, fd_set * rfds, fd_set * wfds)
int line;
struct timeval now, dif;
- if (t->hanging_up)
- {
-
- gettimeofday (&now, NULL);
- timersub (&now, &t->hangup_clock, &dif);
- if (dif.tv_sec)
- {
- line = TIOCM_DTR;
- ioctl (t->rfd, TIOCMBIS, &line);
- t->hanging_up = 0;
- }
+ if (t->hanging_up) {
+
+ gettimeofday (&now, NULL);
+ timersub (&now, &t->hangup_clock, &dif);
+ if (dif.tv_sec) {
+ line = TIOCM_DTR;
+ ioctl (t->rfd, TIOCMBIS, &line);
+ t->hanging_up = 0;
}
+ }
FD_SET (t->rfd, rfds);
@@ -343,9 +342,10 @@ tty_hangup (TTY * t)
}
-void tty_length(TTY *t,int l)
+void
+tty_length (TTY * t, int l)
{
-t->displayed_length=l;
+ t->displayed_length = l;
}
void
@@ -362,8 +362,7 @@ tty_winch (TTY * t, CRT_Pos size)
#if 0
-typedef struct
-{
+typedef struct {
int in_dle;
int in_errmark;
@@ -371,9 +370,7 @@ typedef struct
int errs;
}
#endif
-
#define DLE 0377
-
#define bit(p,b,z,o) \
do { \
if ((b && z)) { \
@@ -393,7 +390,6 @@ typedef struct
z++; \
} \
while (0)
-
static void
tty_bit_analyse (Context * c, int err, int ch)
{
@@ -404,31 +400,28 @@ tty_bit_analyse (Context * c, int err, int ch)
bit (p, 0, zc, oc);
- for (d = 1; d < 0x100; d <<= 1)
- {
- bit (p, ch & d, zc, oc);
- }
+ for (d = 1; d < 0x100; d <<= 1) {
+ bit (p, ch & d, zc, oc);
+ }
bit (p, 1, zc, oc);
- if (err)
- {
- p->biterrs++;
- gettimeofday (&p->lasterr, NULL);
- }
+ if (err) {
+ p->biterrs++;
+ gettimeofday (&p->lasterr, NULL);
+ }
- if (p->biterrs)
- {
- log_f (c->l,
- "<tty_bit_analyse: 0%d%d%d%d%d%d%d%d1 [%d,%d,%d,%d,%d,%d,%d,%d,%d,%d]>",
- ch & 0x01 ? 1 : 0, ch & 0x02 ? 1 : 0, ch & 0x04 ? 1 : 0,
- ch & 0x08 ? 1 : 0, ch & 0x10 ? 1 : 0, ch & 0x20 ? 1 : 0,
- ch & 0x40 ? 1 : 0, ch & 0x80 ? 1 : 0, p->bitfreq[0],
- p->bitfreq[1], p->bitfreq[2], p->bitfreq[3], p->bitfreq[4],
- p->bitfreq[5], p->bitfreq[6], p->bitfreq[7], p->bitfreq[8],
- p->bitfreq[9]);
- }
+ if (p->biterrs) {
+ log_f (c->l,
+ "<tty_bit_analyse: 0%d%d%d%d%d%d%d%d1 [%d,%d,%d,%d,%d,%d,%d,%d,%d,%d]>",
+ ch & 0x01 ? 1 : 0, ch & 0x02 ? 1 : 0, ch & 0x04 ? 1 : 0,
+ ch & 0x08 ? 1 : 0, ch & 0x10 ? 1 : 0, ch & 0x20 ? 1 : 0,
+ ch & 0x40 ? 1 : 0, ch & 0x80 ? 1 : 0, p->bitfreq[0],
+ p->bitfreq[1], p->bitfreq[2], p->bitfreq[3], p->bitfreq[4],
+ p->bitfreq[5], p->bitfreq[6], p->bitfreq[7], p->bitfreq[8],
+ p->bitfreq[9]);
+ }
}
@@ -448,64 +441,54 @@ tty_analyse (Context * c)
struct timeval now, dif;
int i, j, max;
- if (!p->biterrs)
- {
- p->guessed_baud = 0;
- return;
- }
+ if (!p->biterrs) {
+ p->guessed_baud = 0;
+ return;
+ }
gettimeofday (&now, NULL);
timersub (&now, &p->lasterr, &dif);
- if (dif.tv_sec > 10)
- {
- tty_parse_reset (c);
- return;
- }
+ if (dif.tv_sec > 10) {
+ tty_parse_reset (c);
+ return;
+ }
max = -1;
j = 0;
- for (i = 0; i < TTY_BITFREQ_LEN; ++i)
- {
- if (p->bitfreq[i] > max)
- {
- max = p->bitfreq[i];
- j = i;
- }
+ for (i = 0; i < TTY_BITFREQ_LEN; ++i) {
+ if (p->bitfreq[i] > max) {
+ max = p->bitfreq[i];
+ j = i;
}
+ }
if (c->t)
i = tty_get_baud (c->t);
else
i = -1;
- if (j == 1)
- {
- /*Closest bit edge is one bit, so the baud rate is too low */
- p->guessed_baud = -1;
+ if (j == 1) {
+ /*Closest bit edge is one bit, so the baud rate is too low */
+ p->guessed_baud = -1;
- }
- else
- {
- if (i > 0)
- p->guessed_baud = i / j;
- else
- p->guessed_baud = 0;
+ } else {
+ if (i > 0)
+ p->guessed_baud = i / j;
+ else
+ p->guessed_baud = 0;
- }
+ }
- if (p->guessed_baud == -1)
- {
- log_f (c->l, "<tty_analyse: %6d errors, current rate %db is too low>",
- p->biterrs, i);
- }
- else
- {
- log_f (c->l, "<tty_analyse: %6d errors, current rate %db, suggest %db>",
- p->biterrs, i, p->guessed_baud);
- }
+ if (p->guessed_baud == -1) {
+ log_f (c->l, "<tty_analyse: %6d errors, current rate %db is too low>",
+ p->biterrs, i);
+ } else {
+ log_f (c->l, "<tty_analyse: %6d errors, current rate %db, suggest %db>",
+ p->biterrs, i, p->guessed_baud);
+ }
}
@@ -528,56 +511,47 @@ tty_parse (Context * c, uint8_t * buf, int len)
p = c->tp;
- while (len--)
- {
-
- if (p->in_dle)
- {
- p->in_dle = 0;
- switch (*buf)
- {
- case DLE:
- tty_bit_analyse (c, 0, *buf);
- utf8_parse (c, *buf);
- break;
- case 0:
- p->in_errmark = 1;
- break;
- default:
- log_f (c->l, "%s:%d DLE parsing error: \\377 \\%03o", __FILE__,
- __LINE__, *buf);
- }
- }
- else if (p->in_errmark)
- {
- p->in_errmark = 0;
-
- log_f (c->l, "<tty reports error: \\377 \\000 \\%03o>",
- __FILE__, __LINE__, *buf);
-
- tty_bit_analyse (c, 1, *buf);
-
- tty_analyse (c);
-
- utf8_parse (c, *buf);
-
- utf8_parse (c, SYM_CHAR_RESET);
-
- }
- else if (*buf == DLE)
- {
- p->in_dle = 1;
-
- }
- else
- {
- tty_bit_analyse (c, 0, *buf);
-
- tty_analyse (c);
-
- utf8_parse (c, *buf);
-
- }
- buf++;
+ while (len--) {
+
+ if (p->in_dle) {
+ p->in_dle = 0;
+ switch (*buf) {
+ case DLE:
+ tty_bit_analyse (c, 0, *buf);
+ utf8_parse (c, *buf);
+ break;
+ case 0:
+ p->in_errmark = 1;
+ break;
+ default:
+ log_f (c->l, "%s:%d DLE parsing error: \\377 \\%03o", __FILE__,
+ __LINE__, *buf);
+ }
+ } else if (p->in_errmark) {
+ p->in_errmark = 0;
+
+ log_f (c->l, "<tty reports error: \\377 \\000 \\%03o>",
+ __FILE__, __LINE__, *buf);
+
+ tty_bit_analyse (c, 1, *buf);
+
+ tty_analyse (c);
+
+ utf8_parse (c, *buf);
+
+ utf8_parse (c, SYM_CHAR_RESET);
+
+ } else if (*buf == DLE) {
+ p->in_dle = 1;
+
+ } else {
+ tty_bit_analyse (c, 0, *buf);
+
+ tty_analyse (c);
+
+ utf8_parse (c, *buf);
+
}
+ buf++;
+ }
}
diff --git a/src/tty.h b/src/tty.h
index d91500e..427fabb 100644
--- a/src/tty.h
+++ b/src/tty.h
@@ -12,6 +12,9 @@
/*
* $Log$
+ * Revision 1.13 2008/03/02 10:37:56 james
+ * *** empty log message ***
+ *
* Revision 1.12 2008/02/28 16:57:52 james
* *** empty log message ***
*
@@ -72,8 +75,7 @@
#define TTY_BITFREQ_LEN 10
-typedef struct
-{
+typedef struct {
int in_dle;
int in_errmark;
@@ -85,13 +87,11 @@ typedef struct
} TTY_Parser;
-typedef struct TTY_struct
-{
+typedef struct TTY_struct {
TTY_SIGNATURE;
} TTY;
-typedef struct
-{
+typedef struct {
int lines;
int blocked;
struct termios termios;
diff --git a/src/utf8.c b/src/utf8.c
index aaa5ffc..d1a36d8 100644
--- a/src/utf8.c
+++ b/src/utf8.c
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
/*
* $Log$
+ * Revision 1.10 2008/03/02 10:37:56 james
+ * *** empty log message ***
+ *
* Revision 1.9 2008/02/27 01:31:14 james
* *** empty log message ***
*
@@ -48,25 +51,24 @@ utf8_flush (Context * c)
UTF8 *u = c->u;
int i;
- switch (u->utf_ptr)
- {
- case 1:
- log_f (c->l, "<invalid utf-8 sequence: \\%03o>", u->utf_buf[0]);
- break;
- case 2:
- log_f (c->l, "<invalid utf-8 sequence: \\%03o \\%03o>",
- u->utf_buf[0], u->utf_buf[1]);
- break;
- case 3:
- log_f (c->l, "<invalid utf-8 sequence: \\%03o \\%03o \\%03o>",
- u->utf_buf[0], u->utf_buf[1], u->utf_buf[2]);
- break;
- case 4:
- log_f (c->l,
- "<invalid utf-8 sequence: \\%03o \\%03o \\%03o \\%03o>",
- u->utf_buf[0], u->utf_buf[1], u->utf_buf[2], u->utf_buf[3]);
- break;
- }
+ switch (u->utf_ptr) {
+ case 1:
+ log_f (c->l, "<invalid utf-8 sequence: \\%03o>", u->utf_buf[0]);
+ break;
+ case 2:
+ log_f (c->l, "<invalid utf-8 sequence: \\%03o \\%03o>",
+ u->utf_buf[0], u->utf_buf[1]);
+ break;
+ case 3:
+ log_f (c->l, "<invalid utf-8 sequence: \\%03o \\%03o \\%03o>",
+ u->utf_buf[0], u->utf_buf[1], u->utf_buf[2]);
+ break;
+ case 4:
+ log_f (c->l,
+ "<invalid utf-8 sequence: \\%03o \\%03o \\%03o \\%03o>",
+ u->utf_buf[0], u->utf_buf[1], u->utf_buf[2], u->utf_buf[3]);
+ break;
+ }
for (i = 0; i < u->utf_ptr; ++i)
vt102_parse_char (c, u->utf_buf[i]);
@@ -80,68 +82,52 @@ utf8_parse (Context * c, uint32_t ch)
{
UTF8 *u = c->u;
- if (ch == SYM_CHAR_RESET)
- {
- u->in_utf8 = 0;
- vt102_parse_char (c, ch);
- return;
- }
+ if (ch == SYM_CHAR_RESET) {
+ u->in_utf8 = 0;
+ vt102_parse_char (c, ch);
+ return;
+ }
- if (!u->in_utf8)
- {
- /*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);
- }
- else if ((ch & 0xe0) == 0xc0)
- { /*Start of two byte unicode sequence */
- u->in_utf8 = 1;
- u->utf_ptr = 0;
- u->utf_buf[u->utf_ptr++] = ch;
- u->ch = (ch & 0x1f) << 6;
- u->sh = 0;
- }
- else if ((ch & 0xf0) == 0xe0)
- { /*Start of three byte unicode sequence */
- u->in_utf8 = 2;
- u->utf_ptr = 0;
- u->utf_buf[u->utf_ptr++] = ch;
- u->ch = (ch & 0x0f) << 12;
- u->sh = 6;
- }
- else if ((ch & 0xf8) == 0xf0)
- {
- u->in_utf8 = 3;
- u->utf_ptr = 0;
- u->utf_buf[u->utf_ptr++] = ch;
- u->ch = (ch & 0x07) << 18;
- u->sh = 12;
- }
- else
- {
- vt102_parse_char (c, ch);
- }
+ if (!u->in_utf8) {
+ /*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);
+ } else if ((ch & 0xe0) == 0xc0) { /*Start of two byte unicode sequence */
+ u->in_utf8 = 1;
+ u->utf_ptr = 0;
+ u->utf_buf[u->utf_ptr++] = ch;
+ u->ch = (ch & 0x1f) << 6;
+ u->sh = 0;
+ } else if ((ch & 0xf0) == 0xe0) { /*Start of three byte unicode sequence */
+ u->in_utf8 = 2;
+ u->utf_ptr = 0;
+ u->utf_buf[u->utf_ptr++] = ch;
+ u->ch = (ch & 0x0f) << 12;
+ u->sh = 6;
+ } else if ((ch & 0xf8) == 0xf0) {
+ u->in_utf8 = 3;
+ u->utf_ptr = 0;
+ u->utf_buf[u->utf_ptr++] = ch;
+ u->ch = (ch & 0x07) << 18;
+ u->sh = 12;
+ } else {
+ vt102_parse_char (c, ch);
}
- else
- {
- if ((ch & 0xc0) != 0x80)
- {
- utf8_flush (c);
- vt102_parse_char (c, ch);
- }
- else
- {
- u->utf_buf[u->utf_ptr++] = ch;
- u->ch |= (ch & 0x3f) << u->sh;
- u->sh -= 6;
- u->in_utf8--;
-
- if (!u->in_utf8)
- vt102_parse_char (c, u->ch);
- }
+ } else {
+ if ((ch & 0xc0) != 0x80) {
+ utf8_flush (c);
+ vt102_parse_char (c, ch);
+ } else {
+ u->utf_buf[u->utf_ptr++] = ch;
+ u->ch |= (ch & 0x3f) << u->sh;
+ u->sh -= 6;
+ u->in_utf8--;
+
+ if (!u->in_utf8)
+ vt102_parse_char (c, u->ch);
}
+ }
}
@@ -161,32 +147,25 @@ int
utf8_encode (char *ptr, int ch)
{
- if (ch < 0x80)
- {
- ptr[0] = ch;
- return 1;
- }
- else if (ch < 0x800)
- {
- ptr[0] = 0xc0 | (ch >> 6);
- ptr[1] = 0x80 | (ch & 0x3f);
- return 2;
- }
- else if (ch < 0x10000)
- {
- ptr[0] = 0xe0 | (ch >> 12);
- ptr[1] = 0x80 | ((ch >> 6) & 0x3f);
- ptr[2] = 0x80 | (ch & 0x3f);
- return 3;
- }
- else if (ch < 0x1fffff)
- {
- ptr[0] = 0xf0 | (ch >> 18);
- ptr[1] = 0x80 | ((ch >> 12) & 0x3f);
- ptr[2] = 0x80 | ((ch >> 6) & 0x3f);
- ptr[3] = 0x80 | (ch & 0x3f);
- return 4;
- }
+ if (ch < 0x80) {
+ ptr[0] = ch;
+ return 1;
+ } else if (ch < 0x800) {
+ ptr[0] = 0xc0 | (ch >> 6);
+ ptr[1] = 0x80 | (ch & 0x3f);
+ return 2;
+ } else if (ch < 0x10000) {
+ ptr[0] = 0xe0 | (ch >> 12);
+ ptr[1] = 0x80 | ((ch >> 6) & 0x3f);
+ ptr[2] = 0x80 | (ch & 0x3f);
+ return 3;
+ } else if (ch < 0x1fffff) {
+ ptr[0] = 0xf0 | (ch >> 18);
+ ptr[1] = 0x80 | ((ch >> 12) & 0x3f);
+ ptr[2] = 0x80 | ((ch >> 6) & 0x3f);
+ ptr[3] = 0x80 | (ch & 0x3f);
+ return 4;
+ }
return 0;
}
diff --git a/src/utf8.h b/src/utf8.h
index 22ee915..651dc1e 100644
--- a/src/utf8.h
+++ b/src/utf8.h
@@ -12,6 +12,9 @@
/*
* $Log$
+ * Revision 1.5 2008/03/02 10:37:56 james
+ * *** empty log message ***
+ *
* Revision 1.4 2008/02/24 00:42:53 james
* *** empty log message ***
*
@@ -31,8 +34,7 @@
#define __UTF8_H__
-typedef struct
-{
+typedef struct {
int in_utf8;
uint8_t utf_buf[4];
diff --git a/src/vt102.c b/src/vt102.c
index 5c360ac..66c0b40 100644
--- a/src/vt102.c
+++ b/src/vt102.c
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
/*
* $Log$
+ * Revision 1.54 2008/03/02 10:37:56 james
+ * *** empty log message ***
+ *
* Revision 1.53 2008/02/29 18:33:39 james
* *** empty log message ***
*
@@ -418,11 +421,10 @@ vt102_crt_update (Context * c)
v->crt.hide_cursor =
v->private_modes[VT102_PRIVATE_MODE_SHOW_CURSOR] ? 0 : 1;
- if (v->current_line.y != v->pos.y)
- {
- vt102_log_line (c, v->current_line.y);
- v->current_line = v->pos;
- }
+ if (v->current_line.y != v->pos.y) {
+ vt102_log_line (c, v->current_line.y);
+ v->current_line = v->pos;
+ }
if (c->d)
cmd_show_status (c->d, c);
@@ -463,19 +465,17 @@ vt102_log_line (Context * c, int line)
return;
- for (; e.x > 0; --e.x)
- {
- if (c->v->crt.screen[CRT_ADDR_POS (&e)].chr != ' ')
- break;
- }
-
- for (; p.x <= e.x; ++p.x)
- {
- int ch = c->v->crt.screen[CRT_ADDR_POS (&p)].chr;
- if (ch < 32)
- ch = ' ';
- logptr += utf8_encode (logptr, ch);
- }
+ for (; e.x > 0; --e.x) {
+ if (c->v->crt.screen[CRT_ADDR_POS (&e)].chr != ' ')
+ break;
+ }
+
+ for (; p.x <= e.x; ++p.x) {
+ int ch = c->v->crt.screen[CRT_ADDR_POS (&p)].chr;
+ if (ch < 32)
+ ch = ' ';
+ logptr += utf8_encode (logptr, ch);
+ }
*logptr = 0;
c->l->log (c->l, logbuf);
@@ -513,14 +513,11 @@ vt102_cursor_normalize (VT102 * v)
{
CRT_Pos *top, *bottom;
- if (v->private_modes[VT102_PRIVATE_MODE_ORIGIN_MODE])
- {
- vt102_clip_cursor (v, v->top_margin, v->bottom_margin);
- }
- else
- {
- vt102_clip_cursor (v, v->screen_start, v->screen_end);
- }
+ if (v->private_modes[VT102_PRIVATE_MODE_ORIGIN_MODE]) {
+ vt102_clip_cursor (v, v->top_margin, v->bottom_margin);
+ } else {
+ vt102_clip_cursor (v, v->screen_start, v->screen_end);
+ }
}
@@ -540,15 +537,14 @@ vt102_cursor_advance_line (Context * c)
/*have wraped off end of last line in scrolling region */
/* (|| not necessary, but shuts compiler up */
if (((v->pos.y == v->bottom_margin.y) || (v->pos.y == v->screen_end.y)) &&
- (couldscroll))
- {
- vt102_log_line (c, v->pos.y);
+ (couldscroll)) {
+ vt102_log_line (c, v->pos.y);
- vt102_history (c, v->top_margin, v->bottom_margin);
+ vt102_history (c, v->top_margin, v->bottom_margin);
- crt_scroll_up (&v->crt, v->top_margin, v->bottom_margin, 1, v->color);
- return;
- }
+ crt_scroll_up (&v->crt, v->top_margin, v->bottom_margin, 1, v->color);
+ return;
+ }
if (v->pos.y != v->screen_end.y)
v->pos.y++;
@@ -565,13 +561,12 @@ vt102_cursor_retreat_line (Context * c)
/*have wraped off end of last line in scrolling region */
/* (|| not necessary, but shuts compiler up */
if (((v->pos.y == v->top_margin.y) || (v->pos.y == v->screen_start.y)) &&
- (couldscroll))
- {
- vt102_log_line (c, v->pos.y);
+ (couldscroll)) {
+ vt102_log_line (c, v->pos.y);
- crt_scroll_down (&v->crt, v->top_margin, v->bottom_margin, 1, v->color);
- return;
- }
+ crt_scroll_down (&v->crt, v->top_margin, v->bottom_margin, 1, v->color);
+ return;
+ }
if (v->pos.y != v->screen_start.y)
v->pos.y--;
@@ -602,14 +597,11 @@ vt102_do_pending_wrap (Context * c)
if ((v->pos.y == v->screen_end.y) && (!couldscroll))
return;
- if (couldscroll)
- {
- v->pos.x = v->top_margin.x;
- }
- else
- {
- v->pos.x = 0;
- }
+ if (couldscroll) {
+ v->pos.x = v->top_margin.x;
+ } else {
+ v->pos.x = 0;
+ }
vt102_cursor_advance_line (c);
}
@@ -619,13 +611,12 @@ vt102_cursor_advance (Context * c)
{
VT102 *v = c->v;
- if (v->pos.x < v->bottom_margin.x)
- {
+ if (v->pos.x < v->bottom_margin.x) {
/*Normal advance*/
- v->pos.x++;
- v->pending_wrap = 0;
- return;
- }
+ v->pos.x++;
+ v->pending_wrap = 0;
+ return;
+ }
v->pending_wrap++;
if (!c->v->xn_glitch)
vt102_do_pending_wrap (c);
@@ -636,10 +627,9 @@ vt102_cursor_advance (Context * c)
void
vt102_cursor_retreat (VT102 * v)
{
- if (v->pos.x != v->top_margin.x)
- {
- v->pos.x--;
- }
+ if (v->pos.x != v->top_margin.x) {
+ v->pos.x--;
+ }
v->pending_wrap = 0;
}
@@ -651,22 +641,20 @@ vt102_reset_tabs (VT102 * v)
memset (v->tabs, 0, sizeof (v->tabs));
- for (i = 0; i < VT102_MAX_COLS; i += 8)
- {
- v->tabs[i]++;
- }
+ for (i = 0; i < VT102_MAX_COLS; i += 8) {
+ v->tabs[i]++;
+ }
}
void
vt102_cursor_advance_tab (VT102 * v)
{
if (v->pos.x == v->bottom_margin.x)
return;
- while (v->pos.x < v->bottom_margin.x)
- {
- v->pos.x++;
- if (v->tabs[v->pos.x])
- break;
- }
+ while (v->pos.x < v->bottom_margin.x) {
+ v->pos.x++;
+ if (v->tabs[v->pos.x])
+ break;
+ }
v->pending_wrap = 0;
}
@@ -675,12 +663,11 @@ vt102_cursor_retreat_tab (VT102 * v)
{
if (v->pos.x == v->top_margin.x)
return;
- while (v->pos.x > v->top_margin.x)
- {
- v->pos.x--;
- if (v->tabs[v->pos.x])
- break;
- }
+ while (v->pos.x > v->top_margin.x) {
+ v->pos.x--;
+ if (v->tabs[v->pos.x])
+ break;
+ }
v->pending_wrap = 0;
}
@@ -694,16 +681,13 @@ vt102_cursor_home (VT102 * v)
vt102_cursor_absolute (VT102 * v, int x, int y)
{
- if (v->private_modes[VT102_PRIVATE_MODE_ORIGIN_MODE])
- {
- v->pos.x = x + v->top_margin.x;
- v->pos.y = y + v->top_margin.y;
- }
- else
- {
- v->pos.x = x;
- v->pos.y = y;
- }
+ if (v->private_modes[VT102_PRIVATE_MODE_ORIGIN_MODE]) {
+ v->pos.x = x + v->top_margin.x;
+ v->pos.y = y + v->top_margin.y;
+ } else {
+ v->pos.x = x;
+ v->pos.y = y;
+ }
vt102_cursor_normalize (v);
v->pending_wrap = 0;
}
@@ -726,12 +710,11 @@ vt102_delete_from_line (VT102 * v, CRT_Pos p)
if (n < 0)
return;
- if (n)
- {
+ if (n) {
- memmove (&v->crt.screen[CRT_ADDR_POS (&p)],
- &v->crt.screen[CRT_ADDR_POS (&p) + 1], sizeof (CRT_CA) * n);
- }
+ memmove (&v->crt.screen[CRT_ADDR_POS (&p)],
+ &v->crt.screen[CRT_ADDR_POS (&p) + 1], sizeof (CRT_CA) * n);
+ }
v->crt.screen[CRT_ADDR (p.y, v->bottom_margin.x)].chr = ' ';
/*But not attr due to vt102 bug*/
@@ -745,12 +728,11 @@ vt102_insert_into_line (VT102 * v, CRT_Pos p)
if (n < 0)
return;
- if (n)
- {
+ if (n) {
- memmove (&v->crt.screen[CRT_ADDR_POS (&p) + 1],
- &v->crt.screen[CRT_ADDR_POS (&p)], sizeof (CRT_CA) * n);
- }
+ memmove (&v->crt.screen[CRT_ADDR_POS (&p) + 1],
+ &v->crt.screen[CRT_ADDR_POS (&p)], sizeof (CRT_CA) * n);
+ }
v->crt.screen[CRT_ADDR_POS (&p)].chr = ' ';
v->crt.screen[CRT_ADDR_POS (&p)].attr = CRT_ATTR_NORMAL;
@@ -766,50 +748,44 @@ vt102_change_mode (Context * c, int private, char *ns, int set)
int m;
- if (*ns)
- {
- m = atoi (ns);
- }
- else
- {
- m = 1;
- }
+ if (*ns) {
+ m = atoi (ns);
+ } else {
+ m = 1;
+ }
if (m < 0)
return;
if (m >= VT102_NMODES)
return;
- if (private)
- {
- v->private_modes[m] = set;
- switch (m)
- {
- case VT102_PRIVATE_MODE_CURSOR_MODE:
- if (v->application_keypad_mode)
- v->private_modes[m] = 0;
+ if (private) {
+ v->private_modes[m] = set;
+ switch (m) {
+ case VT102_PRIVATE_MODE_CURSOR_MODE:
+ if (v->application_keypad_mode)
+ v->private_modes[m] = 0;
#if 0
- fprintf (stderr, "APPLICATION CURSOR MODE %d wanted %d\n",
- v->private_modes[m], set);
+ fprintf (stderr, "APPLICATION CURSOR MODE %d wanted %d\n",
+ v->private_modes[m], set);
#endif
- break;
- case VT102_PRIVATE_MODE_ORIGIN_MODE:
- vt102_cursor_home (v);
- break;
- case VT102_PRIVATE_MODE_132COLS:
- /* We don't implement 132 col mode - yet */
-
- v->current_size.x =
- v->
- private_modes[VT102_PRIVATE_MODE_132COLS] ? VT102_COLS_132 :
- VT102_COLS_80;
+ break;
+ case VT102_PRIVATE_MODE_ORIGIN_MODE:
+ vt102_cursor_home (v);
+ break;
+ case VT102_PRIVATE_MODE_132COLS:
+ /* We don't implement 132 col mode - yet */
- vt102_do_resize (c);
- break;
- }
+ v->current_size.x =
+ v->
+ private_modes[VT102_PRIVATE_MODE_132COLS] ? VT102_COLS_132 :
+ VT102_COLS_80;
+ vt102_do_resize (c);
+ break;
}
- else
+
+ } else
v->modes[m] = set;
#if 0
@@ -831,36 +807,33 @@ vt102_parse_mode_string (Context * c, char *buf, int len)
len--;
- if (*buf == '?')
- {
- private++;
- buf++;
- len--;
- }
+ if (*buf == '?') {
+ private++;
+ buf++;
+ len--;
+ }
if (len < 0)
return;
- while (len--)
- {
- if (*buf == ';')
- {
- vt102_change_mode (c, private, &num[o], last == 'h');
- memset (num, 0, sizeof (num));
- o = sizeof (num) - 1;
- buf++;
- continue;
- }
+ while (len--) {
+ if (*buf == ';') {
+ vt102_change_mode (c, private, &num[o], last == 'h');
+ memset (num, 0, sizeof (num));
+ o = sizeof (num) - 1;
+ buf++;
+ continue;
+ }
- num[0] = num[1];
- num[1] = num[2];
- num[2] = *buf;
+ num[0] = num[1];
+ num[1] = num[2];
+ num[2] = *buf;
- if (o)
- o--;
+ if (o)
+ o--;
- buf++;
- }
+ buf++;
+ }
vt102_change_mode (c, private, &num[o], last == 'h');
@@ -873,115 +846,111 @@ vt102_change_attr (VT102 * v, char *na)
int a;
- if (*na)
- {
- a = atoi (na);
- }
- else
- {
- a = 0;
- }
-
- switch (a)
- {
- case 0:
- v->attr = CRT_ATTR_NORMAL;
- v->color = CRT_COLOR_NORMAL;
- break;
- case 1:
- v->attr |= CRT_ATTR_BOLD;
- break;
- case 21:
- case 22:
- v->attr &= ~CRT_ATTR_BOLD;
- break;
- case 4:
- v->attr |= CRT_ATTR_UNDERLINE;
- break;
- case 24:
- v->attr &= ~CRT_ATTR_UNDERLINE;
- break;
- case 5:
- v->attr |= CRT_ATTR_BLINK;
- break;
- case 25:
- v->attr &= ~CRT_ATTR_BLINK;
- break;
- case 7:
- v->attr |= CRT_ATTR_REVERSE;
- break;
- case 27:
- v->attr &= ~CRT_ATTR_REVERSE;
- break;
- case 30:
- case 31:
- case 32:
- case 33:
- case 34:
- case 35:
- case 36:
- case 37:
- v->color &= ~CRT_COLOR_FG_MASK;
- v->color |= ((a - 30) << CRT_COLOR_FG_SHIFT) & CRT_COLOR_FG_MASK;
- break;
- case 90:
- case 91:
- case 92:
- case 93:
- case 94:
- case 95:
- case 96:
- case 97:
- v->color &= ~CRT_COLOR_FG_MASK;
- v->color |=
- (((a -
- 90) | CRT_COLOR_INTENSITY) << CRT_COLOR_FG_SHIFT) &
- CRT_COLOR_FG_MASK;
- break;
- case 39:
- case 99:
- v->color &= ~CRT_COLOR_FG_MASK;
- v->color |=
- (CRT_FGCOLOR_NORMAL << CRT_COLOR_FG_SHIFT) & CRT_COLOR_FG_MASK;
- break;
- case 40:
- case 41:
- case 42:
- case 43:
- case 44:
- case 45:
- case 46:
- case 47:
- v->color &= ~CRT_COLOR_BG_MASK;
- v->color |= ((a - 40) << CRT_COLOR_BG_SHIFT) & CRT_COLOR_BG_MASK;
- break;
- case 100:
- case 101:
- case 102:
- case 103:
- case 104:
- case 105:
- case 106:
- case 107:
- v->color &= ~CRT_COLOR_BG_MASK;
- v->color |=
- (((a -
- 100) | CRT_COLOR_INTENSITY) << CRT_COLOR_BG_SHIFT) &
- CRT_COLOR_BG_MASK;
- break;
- case 49:
- case 109:
- v->color &= ~CRT_COLOR_BG_MASK;
- v->color |=
- (CRT_BGCOLOR_NORMAL << CRT_COLOR_BG_SHIFT) & CRT_COLOR_BG_MASK;
- break;
-
- default:
- ;
+ if (*na) {
+ a = atoi (na);
+ } else {
+ a = 0;
+ }
+
+ switch (a) {
+ case 0:
+ v->attr = CRT_ATTR_NORMAL;
+ v->color = CRT_COLOR_NORMAL;
+ break;
+ case 1:
+ v->attr |= CRT_ATTR_BOLD;
+ break;
+ case 21:
+ case 22:
+ v->attr &= ~CRT_ATTR_BOLD;
+ break;
+ case 4:
+ v->attr |= CRT_ATTR_UNDERLINE;
+ break;
+ case 24:
+ v->attr &= ~CRT_ATTR_UNDERLINE;
+ break;
+ case 5:
+ v->attr |= CRT_ATTR_BLINK;
+ break;
+ case 25:
+ v->attr &= ~CRT_ATTR_BLINK;
+ break;
+ case 7:
+ v->attr |= CRT_ATTR_REVERSE;
+ break;
+ case 27:
+ v->attr &= ~CRT_ATTR_REVERSE;
+ break;
+ case 30:
+ case 31:
+ case 32:
+ case 33:
+ case 34:
+ case 35:
+ case 36:
+ case 37:
+ v->color &= ~CRT_COLOR_FG_MASK;
+ v->color |= ((a - 30) << CRT_COLOR_FG_SHIFT) & CRT_COLOR_FG_MASK;
+ break;
+ case 90:
+ case 91:
+ case 92:
+ case 93:
+ case 94:
+ case 95:
+ case 96:
+ case 97:
+ v->color &= ~CRT_COLOR_FG_MASK;
+ v->color |=
+ (((a -
+ 90) | CRT_COLOR_INTENSITY) << CRT_COLOR_FG_SHIFT) &
+ CRT_COLOR_FG_MASK;
+ break;
+ case 39:
+ case 99:
+ v->color &= ~CRT_COLOR_FG_MASK;
+ v->color |=
+ (CRT_FGCOLOR_NORMAL << CRT_COLOR_FG_SHIFT) & CRT_COLOR_FG_MASK;
+ break;
+ case 40:
+ case 41:
+ case 42:
+ case 43:
+ case 44:
+ case 45:
+ case 46:
+ case 47:
+ v->color &= ~CRT_COLOR_BG_MASK;
+ v->color |= ((a - 40) << CRT_COLOR_BG_SHIFT) & CRT_COLOR_BG_MASK;
+ break;
+ case 100:
+ case 101:
+ case 102:
+ case 103:
+ case 104:
+ case 105:
+ case 106:
+ case 107:
+ v->color &= ~CRT_COLOR_BG_MASK;
+ v->color |=
+ (((a -
+ 100) | CRT_COLOR_INTENSITY) << CRT_COLOR_BG_SHIFT) &
+ CRT_COLOR_BG_MASK;
+ break;
+ case 49:
+ case 109:
+ v->color &= ~CRT_COLOR_BG_MASK;
+ v->color |=
+ (CRT_BGCOLOR_NORMAL << CRT_COLOR_BG_SHIFT) & CRT_COLOR_BG_MASK;
+ break;
+
+ default:
+ ;
#if 0
- fprintf (stderr, "unhandled SGR %d\n", a);
+ fprintf (stderr, "unhandled SGR %d\n", a);
#endif
- }
+ }
}
@@ -1002,26 +971,24 @@ vt102_parse_attr_string (VT102 * v, char *buf, int len)
if (len < 0)
return;
- while (len--)
- {
- if (*buf == ';')
- {
- vt102_change_attr (v, &num[o]);
- memset (num, 0, sizeof (num));
- o = sizeof (num) - 1;
- buf++;
- continue;
- }
+ while (len--) {
+ if (*buf == ';') {
+ vt102_change_attr (v, &num[o]);
+ memset (num, 0, sizeof (num));
+ o = sizeof (num) - 1;
+ buf++;
+ continue;
+ }
- num[0] = num[1];
- num[1] = num[2];
- num[2] = *buf;
+ num[0] = num[1];
+ num[1] = num[2];
+ num[2] = *buf;
- if (o)
- o--;
+ if (o)
+ o--;
- buf++;
- }
+ buf++;
+ }
vt102_change_attr (v, &num[o]);
}
@@ -1059,18 +1026,14 @@ vt102_regular_char (Context * c, VT102 * v, uint32_t ch)
v->last_reg_char = ch;
- if (ch < VT102_CHARSET_SIZE)
- {
- int cs;
- if ((cs = vt102_charset_c0[ch]))
- {
- ch = cs;
- }
- else if ((cs = charset_from_csid[v->g[v->cs]][ch]))
- {
- ch = cs;
- }
+ if (ch < VT102_CHARSET_SIZE) {
+ int cs;
+ if ((cs = vt102_charset_c0[ch])) {
+ ch = cs;
+ } else if ((cs = charset_from_csid[v->g[v->cs]][ch])) {
+ ch = cs;
}
+ }
v->crt.screen[CRT_ADDR_POS (&v->pos)].chr = ch;
v->crt.screen[CRT_ADDR_POS (&v->pos)].attr = v->attr;
v->crt.screen[CRT_ADDR_POS (&v->pos)].color = v->color;
@@ -1081,11 +1044,10 @@ vt102_regular_char (Context * c, VT102 * v, uint32_t ch)
vt102_send_id (Context * c, char *buf)
{
- if (c->t)
- {
- int l = strlen (buf);
- c->t->xmit (c->t, buf, l);
- }
+ if (c->t) {
+ int l = strlen (buf);
+ c->t->xmit (c->t, buf, l);
+ }
}
void
@@ -1095,30 +1057,28 @@ vt102_scs (Context * c, int g, int s)
int cs = VT102_CSID_US;
- switch (s)
- {
- case 'A':
- cs = VT102_CSID_UK;
- break;
- case '1':
- case '2':
- case 'B':
- cs = VT102_CSID_US;
- break;
- case '0':
- cs = VT102_CSID_GL;
- break;
- }
-
- switch (g)
- {
- case '(':
- v->g[0] = cs;
- break;
- case ')':
- v->g[1] = cs;
- break;
- }
+ switch (s) {
+ case 'A':
+ cs = VT102_CSID_UK;
+ break;
+ case '1':
+ case '2':
+ case 'B':
+ cs = VT102_CSID_US;
+ break;
+ case '0':
+ cs = VT102_CSID_GL;
+ break;
+ }
+
+ switch (g) {
+ case '(':
+ v->g[0] = cs;
+ break;
+ case ')':
+ v->g[1] = cs;
+ break;
+ }
}
@@ -1139,279 +1099,258 @@ vt102_parse_csi (Context * c, char *buf, int len)
buf[len - 1] = 0;
#endif
- if (len > 2)
- {
- narg = atoi (arg);
- }
- else
- {
- narg = 1;
- }
+ if (len > 2) {
+ narg = atoi (arg);
+ } else {
+ narg = 1;
+ }
+
+ switch (buf[0]) {
+ case '[':
+ switch (last) {
+ case '@':
+ while (narg--)
+ vt102_insert_into_line (v, v->pos);
+ break;
+ case 'A':
+ vt102_cursor_relative (v, 0, -narg);
+ break;
+ case 'e':
+ case 'B':
+ vt102_cursor_relative (v, 0, narg);
+ break;
+ case 'a':
+ case 'C':
+ vt102_cursor_relative (v, narg, 0);
+ break;
+ case 'D':
+ vt102_cursor_relative (v, -narg, 0);
+ break;
+ case 'E':
+ vt102_cursor_relative (v, 0, narg);
+ vt102_cursor_carriage_return (v);
+ break;
+ case 'F':
+ vt102_cursor_relative (v, 0, -narg);
+ vt102_cursor_carriage_return (v);
+ break;
+ case 'G':
+ vt102_cursor_absolute (v, narg - 1, v->pos.y);
+ break;
+ case 'H':
+ case 'f':
+ {
+ int x, y;
- switch (buf[0])
- {
- case '[':
- switch (last)
- {
- case '@':
- while (narg--)
- vt102_insert_into_line (v, v->pos);
- break;
- case 'A':
- vt102_cursor_relative (v, 0, -narg);
- break;
- case 'e':
- case 'B':
- vt102_cursor_relative (v, 0, narg);
- break;
- case 'a':
- case 'C':
- vt102_cursor_relative (v, narg, 0);
- break;
- case 'D':
- vt102_cursor_relative (v, -narg, 0);
- break;
- case 'E':
- vt102_cursor_relative (v, 0, narg);
- vt102_cursor_carriage_return (v);
- break;
- case 'F':
- vt102_cursor_relative (v, 0, -narg);
- vt102_cursor_carriage_return (v);
- break;
- case 'G':
- vt102_cursor_absolute (v, narg - 1, v->pos.y);
- break;
- case 'H':
- case 'f':
- {
- int x, y;
+ y = narg - 1;
- y = narg - 1;
+ ptr = index (arg, ';');
+ if (ptr)
+ x = atoi (ptr + 1) - 1;
+ else
+ x = 0;
- ptr = index (arg, ';');
- if (ptr)
- x = atoi (ptr + 1) - 1;
- else
- x = 0;
+ vt102_cursor_absolute (v, x, y);
+ }
+ break;
+ case 'I':
+ while (narg--)
+ vt102_cursor_advance_tab (c->v);
+ break;
+ case 'J':
+ if (len == 2)
+ narg = 0; /*Different default */
+ switch (narg) {
+ case 0:
+ crt_erase (&v->crt, v->pos, v->screen_end, 1, v->color);
+ break;
+ case 1:
+ crt_erase (&v->crt, v->screen_start, v->pos, 1, v->color);
+ break;
+ case 2:
+ crt_erase (&v->crt, v->screen_start, v->screen_end, 1, v->color);
+ break;
+ }
+ break;
+ case 'K':
+ {
+ CRT_Pos ls = { 0, v->pos.y };
+ CRT_Pos le = { v->current_size.x - 1, v->pos.y };
+ if (len == 2)
+ narg = 0; /*Different default */
- vt102_cursor_absolute (v, x, y);
- }
+ switch (narg) {
+ case 0:
+ crt_erase (&v->crt, v->pos, le, 1, v->color);
break;
- case 'I':
- while (narg--)
- vt102_cursor_advance_tab (c->v);
+ case 1:
+ crt_erase (&v->crt, ls, v->pos, 1, v->color);
break;
- case 'J':
- if (len == 2)
- narg = 0; /*Different default */
- switch (narg)
- {
- case 0:
- crt_erase (&v->crt, v->pos, v->screen_end, 1, v->color);
- break;
- case 1:
- crt_erase (&v->crt, v->screen_start, v->pos, 1, v->color);
- break;
- case 2:
- crt_erase (&v->crt, v->screen_start, v->screen_end, 1,
- v->color);
- break;
- }
- break;
- case 'K':
- {
- CRT_Pos ls = { 0, v->pos.y };
- CRT_Pos le = { v->current_size.x - 1, v->pos.y };
- if (len == 2)
- narg = 0; /*Different default */
-
- switch (narg)
- {
- case 0:
- crt_erase (&v->crt, v->pos, le, 1, v->color);
- break;
- case 1:
- crt_erase (&v->crt, ls, v->pos, 1, v->color);
- break;
- case 2:
- crt_erase (&v->crt, ls, le, 1, v->color);
- break;
- }
- }
+ case 2:
+ crt_erase (&v->crt, ls, le, 1, v->color);
break;
+ }
+ }
+ break;
- case 'L':
- if ((v->pos.y >= v->top_margin.y)
- && (v->pos.y <= v->bottom_margin.y))
- {
- while (narg--)
- crt_scroll_down (&v->crt, v->pos, v->bottom_margin, 1,
- v->color);
- }
- break;
+ case 'L':
+ if ((v->pos.y >= v->top_margin.y)
+ && (v->pos.y <= v->bottom_margin.y)) {
+ while (narg--)
+ crt_scroll_down (&v->crt, v->pos, v->bottom_margin, 1, v->color);
+ }
+ break;
- case 'M':
- if ((v->pos.y >= v->top_margin.y)
- && (v->pos.y <= v->bottom_margin.y))
- {
- while (narg--)
- {
- vt102_history (c, v->pos, v->bottom_margin);
- crt_scroll_up (&v->crt, v->pos, v->bottom_margin, 1,
- v->color);
- }
- }
- break;
- case 'P':
- while (narg--)
- vt102_delete_from_line (v, v->pos);
- break;
- case 'S':
- while (narg--)
- {
- vt102_history (c, v->top_margin, v->bottom_margin);
- crt_scroll_up (&v->crt, v->top_margin, v->bottom_margin, 1,
- v->color);
- }
- break;
- case 'T':
- while (narg--)
- crt_scroll_down (&v->crt, v->top_margin, v->bottom_margin, 1,
- v->color);
- break;
- case 'X':
- {
- CRT_Pos end = v->pos;
- if (!narg)
- narg++;
-
- end.x += narg - 1;
- if (end.x > v->bottom_margin.x)
- end.x = v->bottom_margin.x;
-
- crt_erase (&v->crt, v->pos, end, 1, v->color);
- }
- break;
- case 'Z':
- while (narg--)
- vt102_cursor_retreat_tab (c->v);
- break;
- case '`':
- vt102_cursor_absolute (v, narg - 1, v->pos.y);
- break;
- case 'b':
- while (narg--)
- vt102_regular_char (c, v, v->last_reg_char);
- break;
- case 'c':
- /* For some obscure reason some programs seem to send */
- /* CSI [ ? .. c, which we ignore */
- if (buf[1]!='?')
- vt102_send_id (c, "\033[?2c");
- break;
- case 'd':
- vt102_cursor_absolute (v, v->pos.x, narg - 1);
- break;
- case 'g':
- if (len == 2)
- narg = 0; /*Different default */
-
- switch (narg)
- {
- case 0:
- v->tabs[v->pos.x] = 0;
- break;
- case 2: //FIXME: - LA120 says current line only WTF?
- case 3:
- memset (v->tabs, 0, sizeof (v->tabs));
- break;
- }
- break;
+ case 'M':
+ if ((v->pos.y >= v->top_margin.y)
+ && (v->pos.y <= v->bottom_margin.y)) {
+ while (narg--) {
+ vt102_history (c, v->pos, v->bottom_margin);
+ crt_scroll_up (&v->crt, v->pos, v->bottom_margin, 1, v->color);
+ }
+ }
+ break;
+ case 'P':
+ while (narg--)
+ vt102_delete_from_line (v, v->pos);
+ break;
+ case 'S':
+ while (narg--) {
+ vt102_history (c, v->top_margin, v->bottom_margin);
+ crt_scroll_up (&v->crt, v->top_margin, v->bottom_margin, 1, v->color);
+ }
+ break;
+ case 'T':
+ while (narg--)
+ crt_scroll_down (&v->crt, v->top_margin, v->bottom_margin, 1,
+ v->color);
+ break;
+ case 'X':
+ {
+ CRT_Pos end = v->pos;
+ if (!narg)
+ narg++;
- case 'i': //Printer commands
- //FIXME
- break;
- case 'h':
- case 'l':
- vt102_parse_mode_string (c, &buf[1], len - 1);
- break;
+ end.x += narg - 1;
+ if (end.x > v->bottom_margin.x)
+ end.x = v->bottom_margin.x;
+ crt_erase (&v->crt, v->pos, end, 1, v->color);
+ }
+ break;
+ case 'Z':
+ while (narg--)
+ vt102_cursor_retreat_tab (c->v);
+ break;
+ case '`':
+ vt102_cursor_absolute (v, narg - 1, v->pos.y);
+ break;
+ case 'b':
+ while (narg--)
+ vt102_regular_char (c, v, v->last_reg_char);
+ break;
+ case 'c':
+ /* For some obscure reason some programs seem to send */
+ /* CSI [ ? .. c, which we ignore */
+ if (buf[1] != '?')
+ vt102_send_id (c, "\033[?2c");
+ break;
+ case 'd':
+ vt102_cursor_absolute (v, v->pos.x, narg - 1);
+ break;
+ case 'g':
+ if (len == 2)
+ narg = 0; /*Different default */
- case 'm':
- vt102_parse_attr_string (v, &buf[1], len - 1);
- break;
- case 'n': //Device status report
- switch (buf[1])
- {
- case '5':
- vt102_send_id (c, "\033[0n");
- break;
- case '6':
- if (c->t)
- {
- char buf[16];
- int i;
- i =
- sprintf (buf, "\033[%d;%dR", v->pos.y + 1, v->pos.x + 1);
- c->t->xmit (c->t, buf, i);
- }
- break;
- default:
- //?15n printer status
- log_f (c->l, "<%s:%d unhandled DSR: \\033%s>", __FILE__,
- __LINE__, buf);
- }
- break;
- case 'q': //Load LED on off
- break;
- case 'r':
- v->top_margin = v->screen_start;
- v->bottom_margin = v->screen_end;
-
- if ((len > 2) && (ptr = index (arg, ';')))
- {
- ptr++;
- v->top_margin.y = narg - 1;
- v->bottom_margin.y = atoi (ptr) - 1;
- }
-
- if (v->top_margin.y < v->screen_start.y)
- v->top_margin.y = v->screen_start.y;
- if (v->top_margin.y > v->screen_end.y)
- v->top_margin.y = v->screen_end.y;
- if (v->bottom_margin.y < v->screen_start.y)
- v->bottom_margin.y = v->screen_start.y;
- if (v->bottom_margin.y > v->screen_end.y)
- v->bottom_margin.y = v->screen_end.y;
-
- vt102_cursor_home (v);
- break;
- case 's':
- v->saved.pos = v->pos;
- break;
- case 'u':
- v->pos = v->saved.pos;
- vt102_cursor_normalize (v);
- v->pending_wrap = 0;
- break;
- case 'y': //Invoke confidence test
- break;
- case 'z': //request terminal parameters
- break;
+ switch (narg) {
+ case 0:
+ v->tabs[v->pos.x] = 0;
+ break;
+ case 2: //FIXME: - LA120 says current line only WTF?
+ case 3:
+ memset (v->tabs, 0, sizeof (v->tabs));
+ break;
+ }
+ break;
- default:
- log_f (c->l, "<%s:%d unhandled CSI: \\033%s>", __FILE__, __LINE__,
- buf);
+ case 'i': //Printer commands
+ //FIXME
+ break;
+ case 'h':
+ case 'l':
+ vt102_parse_mode_string (c, &buf[1], len - 1);
+ break;
- ;
+
+ case 'm':
+ vt102_parse_attr_string (v, &buf[1], len - 1);
+ break;
+ case 'n': //Device status report
+ switch (buf[1]) {
+ case '5':
+ vt102_send_id (c, "\033[0n");
+ break;
+ case '6':
+ if (c->t) {
+ char buf[16];
+ int i;
+ i = sprintf (buf, "\033[%d;%dR", v->pos.y + 1, v->pos.x + 1);
+ c->t->xmit (c->t, buf, i);
}
+ break;
+ default:
+ //?15n printer status
+ log_f (c->l, "<%s:%d unhandled DSR: \\033%s>", __FILE__,
+ __LINE__, buf);
+ }
break;
+ case 'q': //Load LED on off
+ break;
+ case 'r':
+ v->top_margin = v->screen_start;
+ v->bottom_margin = v->screen_end;
+
+ if ((len > 2) && (ptr = index (arg, ';'))) {
+ ptr++;
+ v->top_margin.y = narg - 1;
+ v->bottom_margin.y = atoi (ptr) - 1;
+ }
+
+ if (v->top_margin.y < v->screen_start.y)
+ v->top_margin.y = v->screen_start.y;
+ if (v->top_margin.y > v->screen_end.y)
+ v->top_margin.y = v->screen_end.y;
+ if (v->bottom_margin.y < v->screen_start.y)
+ v->bottom_margin.y = v->screen_start.y;
+ if (v->bottom_margin.y > v->screen_end.y)
+ v->bottom_margin.y = v->screen_end.y;
+
+ vt102_cursor_home (v);
+ break;
+ case 's':
+ v->saved.pos = v->pos;
+ break;
+ case 'u':
+ v->pos = v->saved.pos;
+ vt102_cursor_normalize (v);
+ v->pending_wrap = 0;
+ break;
+ case 'y': //Invoke confidence test
+ break;
+ case 'z': //request terminal parameters
+ break;
+
default:
- log_f (c->l, "<%s:%d unhandled sequence: \\033%s>", __FILE__,
- __LINE__, buf);
+ log_f (c->l, "<%s:%d unhandled CSI: \\033%s>", __FILE__, __LINE__, buf);
+
;
}
+ break;
+ default:
+ log_f (c->l, "<%s:%d unhandled sequence: \\033%s>", __FILE__,
+ __LINE__, buf);
+ ;
+ }
@@ -1430,107 +1369,62 @@ vt102_parse_esc (Context * c)
!v->private_modes[VT102_PRIVATE_MODE_VT52], p->cmd_buf);
#endif
- if (!v->private_modes[VT102_PRIVATE_MODE_VT52])
- {
- int ate = 1;
-
- switch (p->cmd_buf[0])
- {
- case 'A':
- vt102_cursor_relative (v, 0, -1);
- break;
- case 'B':
- vt102_cursor_relative (v, 0, 1);
- break;
- case 'C':
- vt102_cursor_relative (v, 1, 0);
- break;
- case 'D':
- vt102_cursor_relative (v, -1, 0);
- break;
- case 'F':
- v->cs = 1;
- v->g[1] = VT102_CSID_VT52;
- break;
- case 'G':
- v->cs = 0;
- v->g[0] = VT102_CSID_US;
- break;
- case 'H':
- vt102_cursor_absolute (v, 0, 0);
- break;
- case 'I':
- vt102_cursor_retreat_line (c);
- break;
- case 'J':
- crt_erase (&v->crt, v->pos, v->screen_end, 1, v->color);
- break;
- case 'K':
- {
- CRT_Pos le = { v->current_size.x - 1, v->pos.y };
- crt_erase (&v->crt, v->pos, le, 1, v->color);
- }
- break;
- case 'Y':
- vt102_cursor_absolute (v, p->cmd_buf[2] - 040, p->cmd_buf[1] - 040);
- break;
- case 'V': //Print current line
- break;
- case 'W': //Printer on
- break;
- case 'X': //printer off
- break;
- case ']': //print screen
- break;
- case 'Z': //ID
- vt102_send_id (c, "\033/K");
- break;
- case '^': //Autoprint on
- break;
- case '_': //Autoprint off
- break;
- case '=':
- v->application_keypad_mode = 1;
- break;
- case '>':
- v->application_keypad_mode = 0;
- break;
- default:
- ate = 0;
- }
- if (ate)
- return;
- }
-
+ if (!v->private_modes[VT102_PRIVATE_MODE_VT52]) {
+ int ate = 1;
-/*If you edit this switch don't forget to edit the length and termination tables*/
- switch (p->cmd_buf[0])
- {
+ switch (p->cmd_buf[0]) {
+ case 'A':
+ vt102_cursor_relative (v, 0, -1);
+ break;
+ case 'B':
+ vt102_cursor_relative (v, 0, 1);
+ break;
+ case 'C':
+ vt102_cursor_relative (v, 1, 0);
+ break;
case 'D':
- vt102_cursor_advance_line (c);
+ vt102_cursor_relative (v, -1, 0);
break;
-
- case 'E':
- vt102_cursor_advance_line (c);
- v->pos.x = v->top_margin.x;
- vt102_cursor_normalize (v);
- v->pending_wrap = 0;
+ case 'F':
+ v->cs = 1;
+ v->g[1] = VT102_CSID_VT52;
+ break;
+ case 'G':
+ v->cs = 0;
+ v->g[0] = VT102_CSID_US;
break;
case 'H':
- v->tabs[v->pos.x]++;
+ vt102_cursor_absolute (v, 0, 0);
break;
- case 'M':
+ case 'I':
vt102_cursor_retreat_line (c);
break;
- case 'N': //select G2 for one char
+ case 'J':
+ crt_erase (&v->crt, v->pos, v->screen_end, 1, v->color);
break;
- case 'O': //select G3 for one char
+ case 'K':
+ {
+ CRT_Pos le = { v->current_size.x - 1, v->pos.y };
+ crt_erase (&v->crt, v->pos, le, 1, v->color);
+ }
break;
- case 'Z':
- vt102_send_id (c, terminal_id);
+ case 'Y':
+ vt102_cursor_absolute (v, p->cmd_buf[2] - 040, p->cmd_buf[1] - 040);
break;
- case 'c':
- vt102_reset (c);
+ case 'V': //Print current line
+ break;
+ case 'W': //Printer on
+ break;
+ case 'X': //printer off
+ break;
+ case ']': //print screen
+ break;
+ case 'Z': //ID
+ vt102_send_id (c, "\033/K");
+ break;
+ case '^': //Autoprint on
+ break;
+ case '_': //Autoprint off
break;
case '=':
v->application_keypad_mode = 1;
@@ -1538,62 +1432,102 @@ vt102_parse_esc (Context * c)
case '>':
v->application_keypad_mode = 0;
break;
+ default:
+ ate = 0;
+ }
+ if (ate)
+ return;
+ }
- case '#':
- switch (p->cmd_buf[1])
- {
- case '3': //top of double height line
- case '4': //bottom of double height line
- case '5': //single width line
- case '6': //double width line
- break;
- case '8':
- /*DECALN*/
- {
- int i;
- crt_erase (&v->crt, v->screen_start, v->screen_end, 1,
- CRT_COLOR_NORMAL);
- for (i = 0; i < CRT_ADDR_POS (&v->screen_end); ++i)
- v->crt.screen[i].chr = 'E';
- }
- break;
- default:
-
- log_f (c->l,
- "<%s:%d unhandled ESC: \\033 \\043 \\%03o (ESC # %c)>",
- __FILE__, __LINE__, p->cmd_buf[1], safe_ch (p->cmd_buf[1]));
-
- }
- break;
- case '<':
- /*Set ansi mode - ignored */
- break;
- case '7':
- vt102_save_state (v);
+/*If you edit this switch don't forget to edit the length and termination tables*/
+ switch (p->cmd_buf[0]) {
+ case 'D':
+ vt102_cursor_advance_line (c);
+ break;
+
+ case 'E':
+ vt102_cursor_advance_line (c);
+ v->pos.x = v->top_margin.x;
+ vt102_cursor_normalize (v);
+ v->pending_wrap = 0;
+ break;
+ case 'H':
+ v->tabs[v->pos.x]++;
+ break;
+ case 'M':
+ vt102_cursor_retreat_line (c);
+ break;
+ case 'N': //select G2 for one char
+ break;
+ case 'O': //select G3 for one char
+ break;
+ case 'Z':
+ vt102_send_id (c, terminal_id);
+ break;
+ case 'c':
+ vt102_reset (c);
+ break;
+ case '=':
+ v->application_keypad_mode = 1;
+ break;
+ case '>':
+ v->application_keypad_mode = 0;
+ break;
+
+ case '#':
+ switch (p->cmd_buf[1]) {
+ case '3': //top of double height line
+ case '4': //bottom of double height line
+ case '5': //single width line
+ case '6': //double width line
break;
case '8':
- vt102_restore_state (v);
- break;
- case ']': /*Set various titles */
- //FIXME:
- break;
- case '[':
- vt102_parse_csi (c, p->cmd_buf, p->cmd_ptr);
- break;
- case '(': /*Charsets */
- case ')':
- case '+':
- case '*':
- case '%':
- vt102_scs (c, p->cmd_buf[0], p->cmd_buf[1]);
+ /*DECALN*/ {
+ int i;
+ crt_erase (&v->crt, v->screen_start, v->screen_end, 1,
+ CRT_COLOR_NORMAL);
+ for (i = 0; i < CRT_ADDR_POS (&v->screen_end); ++i)
+ v->crt.screen[i].chr = 'E';
+ }
break;
default:
- log_f (c->l, "<%s:%d unhandled ESC: \\033 \\%03o (ESC %c)>", __FILE__,
- __LINE__, p->cmd_buf[0], safe_ch (p->cmd_buf[0]));
- ;
+ log_f (c->l,
+ "<%s:%d unhandled ESC: \\033 \\043 \\%03o (ESC # %c)>",
+ __FILE__, __LINE__, p->cmd_buf[1], safe_ch (p->cmd_buf[1]));
+
}
+ break;
+ case '<':
+ /*Set ansi mode - ignored */
+ break;
+
+ case '7':
+ vt102_save_state (v);
+ break;
+ case '8':
+ vt102_restore_state (v);
+ break;
+ case ']': /*Set various titles */
+ //FIXME:
+ break;
+ case '[':
+ vt102_parse_csi (c, p->cmd_buf, p->cmd_ptr);
+ break;
+ case '(': /*Charsets */
+ case ')':
+ case '+':
+ case '*':
+ case '%':
+ vt102_scs (c, p->cmd_buf[0], p->cmd_buf[1]);
+ break;
+ default:
+ log_f (c->l, "<%s:%d unhandled ESC: \\033 \\%03o (ESC %c)>", __FILE__,
+ __LINE__, p->cmd_buf[0], safe_ch (p->cmd_buf[0]));
+
+ ;
+ }
p->cmd_buf[p->cmd_ptr] = 0;
#ifdef DEBUG
@@ -1608,23 +1542,21 @@ vt102_status_line (VT102 * v, char *str)
int i;
CRT_CA *ca = &v->crt.screen[CRT_ADDR (v->current_size.y, 0)];
- for (i = 0; i < v->current_size.x; ++i)
- {
- ca->attr = CRT_ATTR_REVERSE;
- ca->color = CRT_COLOR_NORMAL;
- ca->chr = *str ? *str : ' ';
- if (*str)
- str++;
- ca++;
- }
-
- for (; i < VT102_MAX_COLS; ++i)
- {
- ca->attr = CRT_ATTR_NORMAL;
- ca->color = CRT_COLOR_NORMAL;
- ca->chr = ' ';
- ca++;
- }
+ for (i = 0; i < v->current_size.x; ++i) {
+ ca->attr = CRT_ATTR_REVERSE;
+ ca->color = CRT_COLOR_NORMAL;
+ ca->chr = *str ? *str : ' ';
+ if (*str)
+ str++;
+ ca++;
+ }
+
+ for (; i < VT102_MAX_COLS; ++i) {
+ ca->attr = CRT_ATTR_NORMAL;
+ ca->color = CRT_COLOR_NORMAL;
+ ca->chr = ' ';
+ ca++;
+ }
}
@@ -1681,19 +1613,17 @@ pre_parse_cmd (int ch, VT102_parser * p)
p->in_cmd = 0;
p->cmd_termination = vt102_cmd_termination[ch];
- if (p->cmd_termination)
- {
- p->in_cmd++;
- return;
- }
+ if (p->cmd_termination) {
+ p->in_cmd++;
+ return;
+ }
p->cmd_more_bytes = vt102_cmd_length[ch];
- if (p->cmd_more_bytes)
- {
- p->in_cmd++;
- return;
- }
+ if (p->cmd_more_bytes) {
+ p->in_cmd++;
+ return;
+ }
}
void
@@ -1710,214 +1640,115 @@ vt102_parse_char (Context * c, int ch)
/* Turn anything non-ascii into '?' */
#if 0
- if ((ch != SYM_CHAR_RESET) && (ch != 0xb9) && (ch > 127))
- {
- ch = '?';
- }
+ if ((ch != SYM_CHAR_RESET) && (ch != 0xb9) && (ch > 127)) {
+ ch = '?';
+ }
#endif
#if 0
- if (p->dca_ptr == 2)
- {
- p->in_dca = 0;
- }
+ if (p->dca_ptr == 2) {
+ p->in_dca = 0;
+ }
#endif
- if (ch == SYM_CHAR_RESET)
- {
- vt102_reset_state (c);
- }
- else if (p->in_cmd && !ctrl_chr (ch, p->cmd_termination))
- {
- p->cmd_buf[p->cmd_ptr++] = ch;
- if (p->cmd_ptr == VT102_CMD_LEN)
- p->in_cmd = 0;
- if (p->cmd_more_bytes)
- {
- p->cmd_more_bytes--;
-
+ if (ch == SYM_CHAR_RESET) {
+ vt102_reset_state (c);
+ } else if (p->in_cmd && !ctrl_chr (ch, p->cmd_termination)) {
+ p->cmd_buf[p->cmd_ptr++] = ch;
+ if (p->cmd_ptr == VT102_CMD_LEN)
+ p->in_cmd = 0;
+ if (p->cmd_more_bytes) {
+ p->cmd_more_bytes--;
- if (!p->cmd_more_bytes == 1)
- p->in_cmd = 0;
- }
-
- switch (p->cmd_termination)
- {
- case 0:
- break;
- default:
- if (p->cmd_termination == ch)
- p->in_cmd = 0;
- break;
- case CSI_ENDER:
- if (csi_ender (ch))
- p->in_cmd = 0;
- break;
- }
- if (!p->in_cmd)
- {
- vt102_parse_esc (c);
- p->cmd_more_bytes = 0;
- p->cmd_termination = 0;
- }
+ if (!p->cmd_more_bytes == 1)
+ p->in_cmd = 0;
}
- else if (p->in_escape && !ctrl_chr (ch, 0))
- {
- p->cmd_ptr = 0;
- p->cmd_buf[p->cmd_ptr++] = ch;
- p->in_escape = 0;
-
- pre_parse_cmd (ch, p);
- if (!p->in_cmd)
- vt102_parse_esc (c);
+ switch (p->cmd_termination) {
+ case 0:
+ break;
+ default:
+ if (p->cmd_termination == ch)
+ p->in_cmd = 0;
+ break;
+ case CSI_ENDER:
+ if (csi_ender (ch))
+ p->in_cmd = 0;
+ break;
}
- else if (ch == 0x9b) /*One byte CSI */
- {
- p->cmd_ptr = 0;
- p->cmd_buf[p->cmd_ptr++] = '[';
- pre_parse_cmd (ch, p);
+ if (!p->in_cmd) {
+ vt102_parse_esc (c);
+ p->cmd_more_bytes = 0;
+ p->cmd_termination = 0;
}
- else
- {
-#ifdef DEBUG
- if (ch != 27)
- log_f (c->l,
- "<chr in x=%3d y=%2d aw=%d \\%03o %3d %c",
- v->pos.x, v->pos.y, v->pending_wrap, ch, ch, safe_ch (ch));
+ } else if (p->in_escape && !ctrl_chr (ch, 0)) {
+ p->cmd_ptr = 0;
+ p->cmd_buf[p->cmd_ptr++] = ch;
+ p->in_escape = 0;
-#endif
+ pre_parse_cmd (ch, p);
- switch (ch)
- {
-#if 0
- /*NUL*/ case 0:
- /*SOH*/ case 1:
- /*STX*/ case 2:
- /*ETX*/ case 3:
- /*EOT*/ case 4:
- break;
-#endif
- /*ENQ*/ case 5:
- vt102_send_id (c, terminal_id);
- break;
-#if 0
- /*ACK*/ case 6:
- break;
-#endif
- /*BEL*/ case 7:
- //FIXME beep
- break;
- /*BS*/ case 8:
- vt102_cursor_retreat (c->v);
- break;
- /*HT*/ case 9:
- vt102_cursor_advance_tab (c->v);
- break;
- /*LF*/ case 10:
- /*VT*/ case 11:
- /*FF*/ case 12:
- vt102_cursor_advance_line (c);
- if (!v->modes[VT102_MODE_NEWLINE_MODE])
- break;
- /*CR*/ case 13:
- vt102_cursor_carriage_return (v);
- break;
- /*SO*/ case 14:
- /*select G1 */
- v->cs = 1;
- break;
- /*SI*/ case 15:
- /*select G0 */
- v->cs = 0;
- break;
-#if 0
- /*DLE*/ case 16:
- /*DC1 */ case 17:
- /*DC2 */ case 18:
- /*DC3 */ case 19:
- /*DC4 */ case 20:
- /*NAK*/ case 21:
- /*SYN*/ case 22:
- /*ETB*/ case 23:
- /*CAN*/ case 24:
- /*EM*/ case 25:
- /*SUB*/ case 26:
- break;
-#endif
- /*ESC*/ case 27:
- p->in_escape++;
- return;
-#if 0
- /*FS*/ case 28:
- /*GS*/ case 29:
- /*RS*/ case 30:
- /*US*/ case 31:
- /*DEL*/ case 127:
- break;
-#endif
- /*regular character */ default:
- vt102_regular_char (c, v, ch);
- }
+ if (!p->in_cmd)
+ vt102_parse_esc (c);
+ } else if (ch == 0x9b) { /*One byte CSI */
+ p->cmd_ptr = 0;
+ p->cmd_buf[p->cmd_ptr++] = '[';
+ pre_parse_cmd (ch, p);
+ } else {
#ifdef DEBUG
- if (ch != 27)
- log_f (c->l, "<chr out x=%3d y=%2d aw=%d>", v->pos.x, v->pos.y,
- v->pending_wrap);
-#endif
- }
+ if (ch != 27)
+ log_f (c->l,
+ "<chr in x=%3d y=%2d aw=%d \\%03o %3d %c",
+ v->pos.x, v->pos.y, v->pending_wrap, ch, ch, safe_ch (ch));
- vt102_crt_update (c);
-
-
-}
-
-void
-vt102_send (Context * c, uint8_t key)
-{
- uint8_t ch;
-
- if (!c->t)
- return;
-
-#if 0
- fprintf (stderr, "vts: %d(%c)\n", key, (key > 31) ? key : ' ');
#endif
- if ((key > 31) && (key < 127))
- {
- c->t->xmit (c->t, &key, 1);
- return;
- }
- switch (key)
- {
+ switch (ch) {
+#if 0
/*NUL*/ case 0:
/*SOH*/ case 1:
/*STX*/ case 2:
/*ETX*/ case 3:
/*EOT*/ case 4:
+ break;
+#endif
/*ENQ*/ case 5:
+ vt102_send_id (c, terminal_id);
+ break;
+#if 0
/*ACK*/ case 6:
+ break;
+#endif
/*BEL*/ case 7:
+ //FIXME beep
+ break;
/*BS*/ case 8:
+ vt102_cursor_retreat (c->v);
+ break;
/*HT*/ case 9:
+ vt102_cursor_advance_tab (c->v);
+ break;
/*LF*/ case 10:
/*VT*/ case 11:
/*FF*/ case 12:
- c->t->xmit (c->t, &key, 1);
- break;
+ vt102_cursor_advance_line (c);
+ if (!v->modes[VT102_MODE_NEWLINE_MODE])
+ break;
/*CR*/ case 13:
- c->t->xmit (c->t, &key, 1);
- if (c->v->modes[VT102_MODE_NEWLINE_MODE])
- {
- ch = 10;
- c->t->xmit (c->t, &ch, 1);
- }
+ vt102_cursor_carriage_return (v);
break;
/*SO*/ case 14:
+ /*select G1 */
+ v->cs = 1;
+ break;
/*SI*/ case 15:
+ /*select G0 */
+ v->cs = 0;
+ break;
+#if 0
/*DLE*/ case 16:
/*DC1 */ case 17:
/*DC2 */ case 18:
@@ -1929,116 +1760,187 @@ vt102_send (Context * c, uint8_t key)
/*CAN*/ case 24:
/*EM*/ case 25:
/*SUB*/ case 26:
- c->t->xmit (c->t, &key, 1);
break;
+#endif
/*ESC*/ case 27:
+ p->in_escape++;
+ return;
+#if 0
/*FS*/ case 28:
/*GS*/ case 29:
/*RS*/ case 30:
/*US*/ case 31:
/*DEL*/ case 127:
- c->t->xmit (c->t, &key, 1);
break;
+#endif
+ /*regular character */ default:
+ vt102_regular_char (c, v, ch);
+ }
- case KEY_UP:
- case KEY_DOWN:
- case KEY_RIGHT:
- case KEY_LEFT:
- case KEY_HOME:
- case KEY_MIDDLE:
- case KEY_END:
+#ifdef DEBUG
+ if (ch != 27)
+ log_f (c->l, "<chr out x=%3d y=%2d aw=%d>", v->pos.x, v->pos.y,
+ v->pending_wrap);
+#endif
+ }
- if (c->v->private_modes[VT102_PRIVATE_MODE_CURSOR_MODE])
- {
- uint8_t buf[] = { 033, 'O', 'A' + (key - KEY_UP) };
- c->t->xmit (c->t, &buf, sizeof (buf));
- }
- else
- {
- uint8_t buf[] = { 033, '[', 'A' + (key - KEY_UP) };
- c->t->xmit (c->t, &buf, sizeof (buf));
- }
- break;
- case KEY_STAR:
- case KEY_PLUS:
- case KEY_COMMA:
- case KEY_PERIOD:
- case KEY_DIVIDE:
- case KEY_0:
- case KEY_1:
- case KEY_2:
- case KEY_3:
- case KEY_4:
- case KEY_5:
- case KEY_6:
- case KEY_7:
- case KEY_8:
- case KEY_9:
- if (c->v->application_keypad_mode)
- {
- uint8_t buf[] = { 033, 'O', 'a' + (key - KEY_154) };
- c->t->xmit (c->t, &buf, sizeof (buf));
- }
- else
- {
- static char kpoff[KEY_NUM] = {
- [KEY_STAR] = '*',
- [KEY_PLUS] = '+',
- [KEY_COMMA] = ',',
- [KEY_MINUS] = '-',
- [KEY_PERIOD] = '.',
- [KEY_DIVIDE] = '/',
- [KEY_0] = '0',
- [KEY_1] = '1',
- [KEY_2] = '2',
- [KEY_3] = '3',
- [KEY_4] = '4',
- [KEY_5] = '5',
- [KEY_6] = '6',
- [KEY_7] = '7',
- [KEY_8] = '8',
- [KEY_9] = '9'
- };
-
- c->t->xmit (c->t, &kpoff[key], 1);
- }
- break;
- case KEY_ENTER:
- if (c->v->application_keypad_mode)
- {
- uint8_t buf[] = { 033, 'O', 'M' };
- c->t->xmit (c->t, &buf, sizeof (buf));
- }
- else
- {
- ch = 13;
- c->t->xmit (c->t, &ch, 1);
- if (c->v->modes[VT102_MODE_NEWLINE_MODE])
- {
- ch = 10;
- c->t->xmit (c->t, &ch, 1);
- }
- }
- break;
- case KEY_PF1:
- case KEY_PF2:
- case KEY_PF3:
- case KEY_PF4:
- {
- uint8_t buf[] = { 033, 'O', 'P' + (key - KEY_PF1) };
- c->t->xmit (c->t, &buf, sizeof (buf));
- }
- break;
- case KEY_INSERT:
- case KEY_DELETE:
- case KEY_PGUP:
- case KEY_PGDN:
- {
- uint8_t buf[] = { 033, '[', '0' + (key - KEY_180), '~' };
- c->t->xmit (c->t, &buf, sizeof (buf));
+ vt102_crt_update (c);
+
+
+}
+
+void
+vt102_send (Context * c, uint8_t key)
+{
+ uint8_t ch;
+
+ if (!c->t)
+ return;
+
+#if 0
+ fprintf (stderr, "vts: %d(%c)\n", key, (key > 31) ? key : ' ');
+#endif
+ if ((key > 31) && (key < 127)) {
+ c->t->xmit (c->t, &key, 1);
+ return;
+ }
+
+ switch (key) {
+ /*NUL*/ case 0:
+ /*SOH*/ case 1:
+ /*STX*/ case 2:
+ /*ETX*/ case 3:
+ /*EOT*/ case 4:
+ /*ENQ*/ case 5:
+ /*ACK*/ case 6:
+ /*BEL*/ case 7:
+ /*BS*/ case 8:
+ /*HT*/ case 9:
+ /*LF*/ case 10:
+ /*VT*/ case 11:
+ /*FF*/ case 12:
+ c->t->xmit (c->t, &key, 1);
+ break;
+ /*CR*/ case 13:
+ c->t->xmit (c->t, &key, 1);
+ if (c->v->modes[VT102_MODE_NEWLINE_MODE]) {
+ ch = 10;
+ c->t->xmit (c->t, &ch, 1);
+ }
+ break;
+ /*SO*/ case 14:
+ /*SI*/ case 15:
+ /*DLE*/ case 16:
+ /*DC1 */ case 17:
+ /*DC2 */ case 18:
+ /*DC3 */ case 19:
+ /*DC4 */ case 20:
+ /*NAK*/ case 21:
+ /*SYN*/ case 22:
+ /*ETB*/ case 23:
+ /*CAN*/ case 24:
+ /*EM*/ case 25:
+ /*SUB*/ case 26:
+ c->t->xmit (c->t, &key, 1);
+ break;
+ /*ESC*/ case 27:
+ /*FS*/ case 28:
+ /*GS*/ case 29:
+ /*RS*/ case 30:
+ /*US*/ case 31:
+ /*DEL*/ case 127:
+ c->t->xmit (c->t, &key, 1);
+ break;
+
+ case KEY_UP:
+ case KEY_DOWN:
+ case KEY_RIGHT:
+ case KEY_LEFT:
+ case KEY_HOME:
+ case KEY_MIDDLE:
+ case KEY_END:
+
+ if (c->v->private_modes[VT102_PRIVATE_MODE_CURSOR_MODE]) {
+ uint8_t buf[] = { 033, 'O', 'A' + (key - KEY_UP) };
+ c->t->xmit (c->t, &buf, sizeof (buf));
+ } else {
+ uint8_t buf[] = { 033, '[', 'A' + (key - KEY_UP) };
+ c->t->xmit (c->t, &buf, sizeof (buf));
+ }
+ break;
+ case KEY_STAR:
+ case KEY_PLUS:
+ case KEY_COMMA:
+ case KEY_PERIOD:
+ case KEY_DIVIDE:
+ case KEY_0:
+ case KEY_1:
+ case KEY_2:
+ case KEY_3:
+ case KEY_4:
+ case KEY_5:
+ case KEY_6:
+ case KEY_7:
+ case KEY_8:
+ case KEY_9:
+ if (c->v->application_keypad_mode) {
+ uint8_t buf[] = { 033, 'O', 'a' + (key - KEY_154) };
+ c->t->xmit (c->t, &buf, sizeof (buf));
+ } else {
+ static char kpoff[KEY_NUM] = {
+ [KEY_STAR] = '*',
+ [KEY_PLUS] = '+',
+ [KEY_COMMA] = ',',
+ [KEY_MINUS] = '-',
+ [KEY_PERIOD] = '.',
+ [KEY_DIVIDE] = '/',
+ [KEY_0] = '0',
+ [KEY_1] = '1',
+ [KEY_2] = '2',
+ [KEY_3] = '3',
+ [KEY_4] = '4',
+ [KEY_5] = '5',
+ [KEY_6] = '6',
+ [KEY_7] = '7',
+ [KEY_8] = '8',
+ [KEY_9] = '9'
+ };
+
+ c->t->xmit (c->t, &kpoff[key], 1);
+ }
+ break;
+ case KEY_ENTER:
+ if (c->v->application_keypad_mode) {
+ uint8_t buf[] = { 033, 'O', 'M' };
+ c->t->xmit (c->t, &buf, sizeof (buf));
+ } else {
+ ch = 13;
+ c->t->xmit (c->t, &ch, 1);
+ if (c->v->modes[VT102_MODE_NEWLINE_MODE]) {
+ ch = 10;
+ c->t->xmit (c->t, &ch, 1);
}
- break;
}
+ break;
+ case KEY_PF1:
+ case KEY_PF2:
+ case KEY_PF3:
+ case KEY_PF4:
+ {
+ uint8_t buf[] = { 033, 'O', 'P' + (key - KEY_PF1) };
+ c->t->xmit (c->t, &buf, sizeof (buf));
+ }
+ break;
+ case KEY_INSERT:
+ case KEY_DELETE:
+ case KEY_PGUP:
+ case KEY_PGDN:
+ {
+ uint8_t buf[] = { 033, '[', '0' + (key - KEY_180), '~' };
+ c->t->xmit (c->t, &buf, sizeof (buf));
+ }
+ break;
+ }
}
@@ -2086,26 +1988,23 @@ vt102_new (CRT_Pos * size)
v->xn_glitch = 1;
- if (size)
- {
- v->original_size = *size;
+ if (size) {
+ v->original_size = *size;
- if (v->original_size.x < 1)
- v->original_size.x = 1;
- if (v->original_size.y < 1)
- v->original_size.y = 1;
+ if (v->original_size.x < 1)
+ v->original_size.x = 1;
+ if (v->original_size.y < 1)
+ v->original_size.y = 1;
- if (v->original_size.x > VT102_MAX_COLS)
- v->original_size.x = VT102_MAX_COLS;
- if (v->original_size.y > VT102_MAX_ROWS)
- v->original_size.y = VT102_MAX_ROWS;
+ if (v->original_size.x > VT102_MAX_COLS)
+ v->original_size.x = VT102_MAX_COLS;
+ if (v->original_size.y > VT102_MAX_ROWS)
+ v->original_size.y = VT102_MAX_ROWS;
- }
- else
- {
- v->original_size.x = VT102_COLS_80;
- v->original_size.y = VT102_ROWS_24;
- }
+ } else {
+ v->original_size.x = VT102_COLS_80;
+ v->original_size.y = VT102_ROWS_24;
+ }
return v;
}
diff --git a/src/vt102.h b/src/vt102.h
index 02fdf99..428abfc 100644
--- a/src/vt102.h
+++ b/src/vt102.h
@@ -12,6 +12,9 @@
/*
* $Log$
+ * Revision 1.22 2008/03/02 10:37:56 james
+ * *** empty log message ***
+ *
* Revision 1.21 2008/02/28 16:57:52 james
* *** empty log message ***
*
@@ -92,8 +95,7 @@
#define VT102_NMODES 32
-typedef struct
-{
+typedef struct {
int in_escape;
int in_cmd;
@@ -103,8 +105,7 @@ typedef struct
char cmd_buf[VT102_CMD_LEN];
} VT102_parser;
-typedef struct
-{
+typedef struct {
CRT_Pos pos;
int attr;
int color;
@@ -112,8 +113,7 @@ typedef struct
} VT102_State;
-typedef struct
-{
+typedef struct {
CRT_Pos top_margin, bottom_margin;
CRT_Pos screen_start, screen_end;
VT102_parser parser;