aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ansi.h9
-rw-r--r--src/cmd.h6
-rw-r--r--src/context.h6
-rw-r--r--src/crt.h12
-rw-r--r--src/history.h9
-rw-r--r--src/ipc.h57
-rw-r--r--src/keydis.c9
-rw-r--r--src/keydis.h6
-rw-r--r--src/lockfile.h12
-rw-r--r--src/log.c87
-rw-r--r--src/log.h8
-rw-r--r--src/ptty.c6
-rw-r--r--src/raw.c9
-rw-r--r--src/ring.h6
-rw-r--r--src/rx.h6
-rw-r--r--src/serial.c6
-rw-r--r--src/slide.h6
-rw-r--r--src/symsocket.h6
-rw-r--r--src/terminal.c8
-rw-r--r--src/tty.c6
-rw-r--r--src/tty.h12
-rw-r--r--src/utf8.h6
-rw-r--r--src/vt102.h12
23 files changed, 199 insertions, 111 deletions
diff --git a/src/ansi.h b/src/ansi.h
index 5ea6cad..6f412c7 100644
--- a/src/ansi.h
+++ b/src/ansi.h
@@ -12,6 +12,9 @@
/*
* $Log$
+ * Revision 1.20 2008/03/10 11:49:32 james
+ * *** empty log message ***
+ *
* Revision 1.19 2008/03/07 12:37:04 james
* *** empty log message ***
*
@@ -79,8 +82,7 @@
#define ANSI_ESCAPE_BUF_LEN 10
#define ANSI_ESCAPE_TIMEOUT 100000 /* in ms */
-typedef struct
-{
+typedef struct {
int in_escape;
struct timeval last_escape;
char escape_buf[ANSI_ESCAPE_BUF_LEN];
@@ -90,8 +92,7 @@ typedef struct
struct CRT_struct;
struct Context_struct;
-typedef struct ANSI_struct
-{
+typedef struct ANSI_struct {
ANSI_Parser parser;
TTY *terminal;
diff --git a/src/cmd.h b/src/cmd.h
index 7094485..3e3f775 100644
--- a/src/cmd.h
+++ b/src/cmd.h
@@ -12,6 +12,9 @@
/*
* $Log$
+ * Revision 1.8 2008/03/10 11:49:32 james
+ * *** empty log message ***
+ *
* Revision 1.7 2008/03/07 12:37:04 james
* *** empty log message ***
*
@@ -41,8 +44,7 @@
#define CMD_KEY 2 /* CTRL B */
#define CMD_CANCEL_KEY 3 /* CTRL C */
-typedef struct
-{
+typedef struct {
int active;
int error;
int disconnect;
diff --git a/src/context.h b/src/context.h
index 139a8f0..a1ce8d2 100644
--- a/src/context.h
+++ b/src/context.h
@@ -12,6 +12,9 @@
/*
* $Log$
+ * Revision 1.13 2008/03/10 11:49:32 james
+ * *** empty log message ***
+ *
* Revision 1.12 2008/03/07 12:37:04 james
* *** empty log message ***
*
@@ -53,8 +56,7 @@
#ifndef __CONTEXT_H__
#define __CONTEXT_H__
-typedef struct Context_struct
-{
+typedef struct Context_struct {
VT102 *v;
TTY *t;
TTY_Parser *tp;
diff --git a/src/crt.h b/src/crt.h
index 7f5c1e1..68ecfd4 100644
--- a/src/crt.h
+++ b/src/crt.h
@@ -12,6 +12,9 @@
/*
* $Log$
+ * Revision 1.18 2008/03/10 11:49:33 james
+ * *** empty log message ***
+ *
* Revision 1.17 2008/03/07 12:37:04 james
* *** empty log message ***
*
@@ -114,22 +117,19 @@ typedef struct __attribute__ ((packed)) {
uint8_t color;
} CRT_CA;
-typedef struct
-{
+typedef struct {
int x;
int y;
} CRT_Pos;
-typedef struct
-{
+typedef struct {
CRT_Pos s;
CRT_Pos e;
int dir;
} CRT_ScrollHint;
-typedef struct CRT_struct
-{
+typedef struct CRT_struct {
CRT_CA screen[CRT_CELS];
CRT_Pos pos;
int hide_cursor;
diff --git a/src/history.h b/src/history.h
index 8ca80b2..3baa097 100644
--- a/src/history.h
+++ b/src/history.h
@@ -12,6 +12,9 @@
/*
* $Log$
+ * Revision 1.7 2008/03/10 11:49:33 james
+ * *** empty log message ***
+ *
* Revision 1.6 2008/03/07 12:37:04 james
* *** empty log message ***
*
@@ -35,15 +38,13 @@
#ifndef __HISTORY_H__
#define __HISTORY_H__
-typedef struct
-{
+typedef struct {
int valid;
time_t t;
CRT_CA line[CRT_COLS];
} History_ent;
-typedef struct
-{
+typedef struct {
History_ent *lines;
int nlines;
int wptr;
diff --git a/src/ipc.h b/src/ipc.h
index 9b2f438..212d3cf 100644
--- a/src/ipc.h
+++ b/src/ipc.h
@@ -12,6 +12,9 @@
/*
* $Log$
+ * Revision 1.12 2008/03/10 11:49:33 james
+ * *** empty log message ***
+ *
* Revision 1.11 2008/03/07 14:13:40 james
* *** empty log message ***
*
@@ -69,44 +72,38 @@
#define IPC_MSG_TYPE_RESET 14
#define IPC_MSG_TYPE_KILLME 15
-typedef struct
-{
+typedef struct {
int32_t size;
int32_t type;
uint8_t payload[0];
} IPC_Msg_hdr;
-typedef struct
-{
+typedef struct {
int32_t size;
int32_t type;
} IPC_Msg_noop;
-typedef struct
-{
+typedef struct {
int32_t size;
int32_t type;
char msg[0];
} IPC_Msg_debug;
-typedef struct
-{
+typedef struct {
int32_t size;
int32_t type;
char msg[0];
} IPC_Msg_initialize;
-typedef struct
-{
+typedef struct {
int32_t size;
int32_t type;
History_ent history;
} IPC_Msg_history;
-typedef struct
-{
+typedef struct {
int32_t size;
int32_t type;
int32_t len;
@@ -114,15 +111,13 @@ typedef struct
} IPC_Msg_VT102;
-typedef struct
-{
+typedef struct {
int32_t size;
int32_t type;
int32_t key;
} IPC_Msg_key;
-typedef struct
-{
+typedef struct {
int32_t size;
int32_t type;
int32_t len;
@@ -130,76 +125,66 @@ typedef struct
} IPC_Msg_term;
-typedef struct
-{
+typedef struct {
int32_t size;
int32_t type;
char status[0];
} IPC_Msg_status;
-typedef struct
-{
+typedef struct {
int32_t size;
int32_t type;
int32_t baud;
} IPC_Msg_setbaud;
-typedef struct
-{
+typedef struct {
int32_t size;
int32_t type;
} IPC_Msg_sendbreak;
-typedef struct
-{
+typedef struct {
int32_t size;
int32_t type;
int32_t flow;
} IPC_Msg_setflow;
-typedef struct
-{
+typedef struct {
int32_t size;
int32_t type;
int32_t ansi;
} IPC_Msg_setansi;
-typedef struct
-{
+typedef struct {
int32_t size;
int32_t type;
} IPC_Msg_hangup;
-typedef struct
-{
+typedef struct {
int32_t size;
int32_t type;
CRT_Pos winsize;
} IPC_Msg_setsize;
-typedef struct
-{
+typedef struct {
int32_t size;
int32_t type;
} IPC_Msg_reset;
-typedef struct
-{
+typedef struct {
int32_t size;
int32_t type;
} IPC_Msg_killme;
-typedef union
-{
+typedef union {
IPC_Msg_hdr hdr;
IPC_Msg_noop noop;
IPC_Msg_debug debug;
diff --git a/src/keydis.c b/src/keydis.c
index 75c6d98..ad75996 100644
--- a/src/keydis.c
+++ b/src/keydis.c
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
/*
* $Log$
+ * Revision 1.16 2008/03/10 11:49:33 james
+ * *** empty log message ***
+ *
* Revision 1.15 2008/03/07 13:16:02 james
* *** empty log message ***
*
@@ -65,13 +68,11 @@ static char rcsid[] = "$Id$";
#define CMD_BUFLEN 128
-typedef struct
-{
+typedef struct {
KEYDIS_SIGNATURE;
} KeyDis_VT102;
-typedef struct
-{
+typedef struct {
KEYDIS_SIGNATURE;
Socket *s;
} KeyDis_IPC;
diff --git a/src/keydis.h b/src/keydis.h
index ac69b7a..f1f2c2b 100644
--- a/src/keydis.h
+++ b/src/keydis.h
@@ -12,6 +12,9 @@
/*
* $Log$
+ * Revision 1.10 2008/03/10 11:49:33 james
+ * *** empty log message ***
+ *
* Revision 1.9 2008/03/07 12:37:04 james
* *** empty log message ***
*
@@ -63,8 +66,7 @@ struct Context_struct;
-typedef struct KeyDis_struct
-{
+typedef struct KeyDis_struct {
KEYDIS_SIGNATURE;
} KeyDis;
diff --git a/src/lockfile.h b/src/lockfile.h
index b8b1775..cfd1899 100644
--- a/src/lockfile.h
+++ b/src/lockfile.h
@@ -12,6 +12,9 @@
/*
* $Log$
+ * Revision 1.11 2008/03/10 11:49:33 james
+ * *** empty log message ***
+ *
* Revision 1.10 2008/03/07 12:37:04 james
* *** empty log message ***
*
@@ -52,20 +55,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 c117779..b8b2186 100644
--- a/src/log.c
+++ b/src/log.c
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
/*
* $Log$
+ * Revision 1.12 2008/03/10 11:49:33 james
+ * *** empty log message ***
+ *
* Revision 1.11 2008/03/07 13:16:02 james
* *** empty log message ***
*
@@ -47,8 +50,7 @@ static char rcsid[] = "$Id$";
#include "project.h"
-typedef struct
-{
+typedef struct {
LOG_SIGNATURE;
int do_close;
int rotate;
@@ -56,6 +58,69 @@ typedef struct
char *filename;
} File_Log;
+
+static Log *loggers = NULL;
+
+
+static void
+sighup (int dummy)
+{
+ Log *l;
+
+ for (l = loggers; l; l = l->next) {
+ if (l->sighup)
+ l->sighup (l);
+ }
+}
+
+
+void
+log_register_handlers (void)
+{
+ struct sigaction sa = { 0 };
+
+ sa.sa_handler = sighup;
+ sa.sa_flags = SA_RESTART;
+ sigaction (SIGHUP, &sa, NULL);
+}
+
+
+void
+log_add (Log * l)
+{
+ log_register_handlers ();
+
+ l->next = loggers;
+ loggers = l;
+}
+
+void
+log_remove (Log * l)
+{
+ Log **ptr = &loggers;
+
+ /* Take out of cleanup list */
+ while (*ptr && (*ptr != l))
+ ptr = &((*ptr)->next);
+
+ if (*ptr)
+ *ptr = l->next;
+}
+
+
+static void
+flog_sighup (Log * _l)
+{
+ File_Log *l = (File_Log *) _l;
+ if (!l->fp)
+ return;
+
+ fclose (l->fp);
+
+ l->fp = fopen (l->filename, "a+");
+}
+
+
static void
flog_log (Log * _l, char *buf)
{
@@ -110,28 +175,32 @@ Log *
file_log_new (char *fn, int rotate)
{
File_Log *l;
- FILE *f;
int dc = 1;
+ l = xmalloc (sizeof (File_Log));
+
if (fn && strcmp (fn, "-")) {
- f = fopen (fn, "a+");
- if (!f)
+ l->fp = fopen (fn, "a+");
+ if (!l->fp) {
+ free (l);
return NULL;
+ }
+ l->sighup = flog_sighup;
} else {
- f = stderr;
+ l->fp = stderr;
dc = 0;
}
- l = xmalloc (sizeof (File_Log));
l->log = flog_log;
l->close = flog_close;
- l->fp = f;
l->do_close = dc;
l->rotate = rotate;
l->filename = strdup (fn);
- fput_cp (f, 0xffef);
+ fput_cp (l->fp, 0xffef);
+
+ log_add ((Log *) l);
return (Log *) l;
}
diff --git a/src/log.h b/src/log.h
index 27510b9..81a95c4 100644
--- a/src/log.h
+++ b/src/log.h
@@ -12,6 +12,9 @@
/*
* $Log$
+ * Revision 1.6 2008/03/10 11:49:33 james
+ * *** empty log message ***
+ *
* Revision 1.5 2008/03/07 12:37:04 james
* *** empty log message ***
*
@@ -33,11 +36,12 @@
#define __LOG_H__
#define LOG_SIGNATURE \
+ struct Log_struct *next; \
void (*log)(struct Log_struct *,char *); \
+ void (*sighup)(struct Log_struct *); \
void (*close)(struct Log_struct *)
-typedef struct Log_struct
-{
+typedef struct Log_struct {
LOG_SIGNATURE;
} Log;
diff --git a/src/ptty.c b/src/ptty.c
index 393eab6..000587b 100644
--- a/src/ptty.c
+++ b/src/ptty.c
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
/*
* $Log$
+ * Revision 1.21 2008/03/10 11:49:33 james
+ * *** empty log message ***
+ *
* Revision 1.20 2008/03/07 13:16:02 james
* *** empty log message ***
*
@@ -90,8 +93,7 @@ static char rcsid[] = "$Id$";
#include "project.h"
-typedef struct
-{
+typedef struct {
TTY_SIGNATURE;
int fd;
pid_t child;
diff --git a/src/raw.c b/src/raw.c
index 15c12f8..4f4af5e 100644
--- a/src/raw.c
+++ b/src/raw.c
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
/*
* $Log$
+ * Revision 1.8 2008/03/10 11:49:33 james
+ * *** empty log message ***
+ *
* Revision 1.7 2008/03/07 13:16:02 james
* *** empty log message ***
*
@@ -36,15 +39,13 @@ static char rcsid[] = "$Id$";
#include "project.h"
-typedef struct
-{
+typedef struct {
RX_SIGNATURE;
int rfd;
int wfd;
} RX_Raw;
-typedef struct
-{
+typedef struct {
TTY_SIGNATURE;
} RAW_TERMINAL;
diff --git a/src/ring.h b/src/ring.h
index 303faca..51cf4c0 100644
--- a/src/ring.h
+++ b/src/ring.h
@@ -12,6 +12,9 @@
/*
* $Log$
+ * Revision 1.6 2008/03/10 11:49:33 james
+ * *** empty log message ***
+ *
* Revision 1.5 2008/03/07 12:37:04 james
* *** empty log message ***
*
@@ -32,8 +35,7 @@
#ifndef __RING_H__
#define __RING_H__
-typedef struct
-{
+typedef struct {
uint8_t *ring;
int wptr;
int rptr;
diff --git a/src/rx.h b/src/rx.h
index c1c58ea..d1a6110 100644
--- a/src/rx.h
+++ b/src/rx.h
@@ -12,6 +12,9 @@
/*
* $Log$
+ * Revision 1.5 2008/03/10 11:49:33 james
+ * *** empty log message ***
+ *
* Revision 1.4 2008/03/07 12:37:04 james
* *** empty log message ***
*
@@ -34,8 +37,7 @@
void (*close)(struct RX_struct *);
-typedef struct RX_struct
-{
+typedef struct RX_struct {
RX_SIGNATURE;
} RX;
diff --git a/src/serial.c b/src/serial.c
index 1592f9e..b32e48e 100644
--- a/src/serial.c
+++ b/src/serial.c
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
/*
* $Log$
+ * Revision 1.17 2008/03/10 11:49:33 james
+ * *** empty log message ***
+ *
* Revision 1.16 2008/03/07 13:16:02 james
* *** empty log message ***
*
@@ -93,8 +96,7 @@ static char rcsid[] = "$Id$";
#include <sys/stat.h>
-typedef struct
-{
+typedef struct {
TTY_SIGNATURE;
Serial_lock *lock;
int fd;
diff --git a/src/slide.h b/src/slide.h
index f42b99c..d92726b 100644
--- a/src/slide.h
+++ b/src/slide.h
@@ -12,6 +12,9 @@
/*
* $Log$
+ * Revision 1.5 2008/03/10 11:49:33 james
+ * *** empty log message ***
+ *
* Revision 1.4 2008/03/07 12:37:04 james
* *** empty log message ***
*
@@ -35,8 +38,7 @@
#ifndef __SLIDE_H__
#define __SLIDE_H__
-typedef struct
-{
+typedef struct {
uint8_t *slide;
int nbytes;
int target_size;
diff --git a/src/symsocket.h b/src/symsocket.h
index fdc4ff5..7d93beb 100644
--- a/src/symsocket.h
+++ b/src/symsocket.h
@@ -12,6 +12,9 @@
/*
* $Log$
+ * Revision 1.6 2008/03/10 11:49:33 james
+ * *** empty log message ***
+ *
* Revision 1.5 2008/03/07 12:37:04 james
* *** empty log message ***
*
@@ -32,8 +35,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 48f57a3..e01a6f6 100644
--- a/src/terminal.c
+++ b/src/terminal.c
@@ -11,6 +11,9 @@ static char rcsid[] =
/*
* $Log$
+ * Revision 1.20 2008/03/10 11:49:33 james
+ * *** empty log message ***
+ *
* Revision 1.19 2008/03/07 14:16:44 james
* *** empty log message ***
*
@@ -91,8 +94,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;
@@ -140,6 +142,8 @@ terminal_close (TTY * _t)
//
//
//
+ //
+ //
// to
// bottom
t->xmit (_t, buf, i);
diff --git a/src/tty.c b/src/tty.c
index df1ad8f..86551d1 100644
--- a/src/tty.c
+++ b/src/tty.c
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
/*
* $Log$
+ * Revision 1.26 2008/03/10 11:49:33 james
+ * *** empty log message ***
+ *
* Revision 1.25 2008/03/07 13:16:02 james
* *** empty log message ***
*
@@ -377,8 +380,7 @@ tty_winch (TTY * t, CRT_Pos size)
#if 0
-typedef struct
-{
+typedef struct {
int in_dle;
int in_errmark;
diff --git a/src/tty.h b/src/tty.h
index b5b3888..f695c41 100644
--- a/src/tty.h
+++ b/src/tty.h
@@ -12,6 +12,9 @@
/*
* $Log$
+ * Revision 1.16 2008/03/10 11:49:33 james
+ * *** empty log message ***
+ *
* Revision 1.15 2008/03/07 12:37:04 james
* *** empty log message ***
*
@@ -81,8 +84,7 @@
#define TTY_BITFREQ_LEN 10
-typedef struct
-{
+typedef struct {
int in_dle;
int in_errmark;
@@ -94,13 +96,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.h b/src/utf8.h
index e1958d5..0643e72 100644
--- a/src/utf8.h
+++ b/src/utf8.h
@@ -12,6 +12,9 @@
/*
* $Log$
+ * Revision 1.8 2008/03/10 11:49:33 james
+ * *** empty log message ***
+ *
* Revision 1.7 2008/03/07 12:37:04 james
* *** empty log message ***
*
@@ -40,8 +43,7 @@
#define __UTF8_H__
-typedef struct
-{
+typedef struct {
int in_utf8;
uint8_t utf_buf[4];
diff --git a/src/vt102.h b/src/vt102.h
index 54fa84c..246c6f0 100644
--- a/src/vt102.h
+++ b/src/vt102.h
@@ -12,6 +12,9 @@
/*
* $Log$
+ * Revision 1.25 2008/03/10 11:49:33 james
+ * *** empty log message ***
+ *
* Revision 1.24 2008/03/07 12:37:04 james
* *** empty log message ***
*
@@ -101,8 +104,7 @@
#define VT102_NMODES 32
-typedef struct
-{
+typedef struct {
int in_escape;
int in_cmd;
@@ -112,8 +114,7 @@ typedef struct
char cmd_buf[VT102_CMD_LEN];
} VT102_parser;
-typedef struct
-{
+typedef struct {
CRT_Pos pos;
int attr;
int color;
@@ -121,8 +122,7 @@ typedef struct
} VT102_State;
-typedef struct
-{
+typedef struct {
CRT_Pos top_margin, bottom_margin;
CRT_Pos screen_start, screen_end;
VT102_parser parser;