chiark / gitweb /
Change James's email address
[sympathy.git] / src / history.c
1 /* 
2  * history.c:
3  *
4  * Copyright (c) 2008 James McKenzie <sympathy@madingley.org>,
5  * All rights reserved.
6  *
7  */
8
9 static char rcsid[] = "$Id: history.c,v 1.7 2008/03/07 13:16:02 james Exp $";
10
11 /* 
12  * $Log: history.c,v $
13  * Revision 1.7  2008/03/07 13:16:02  james
14  * *** empty log message ***
15  *
16  * Revision 1.6  2008/03/07 12:37:04  james
17  * *** empty log message ***
18  *
19  * Revision 1.5  2008/03/03 06:04:42  james
20  * *** empty log message ***
21  *
22  * Revision 1.4  2008/03/02 10:37:56  james
23  * *** empty log message ***
24  *
25  * Revision 1.3  2008/02/13 16:57:29  james
26  * *** empty log message ***
27  *
28  * Revision 1.2  2008/02/12 22:36:46  james
29  * *** empty log message ***
30  *
31  * Revision 1.1  2008/02/08 15:06:42  james
32  * *** empty log message ***
33  *
34  */
35
36 #include "project.h"
37
38 History *
39 history_new (int n)
40 {
41   History *ret;
42
43   ret = (History *) xmalloc (sizeof (History));
44   ret->lines = xmalloc (n * sizeof (History_ent));
45   memset (ret->lines, 0, n * sizeof (History_ent));
46
47   ret->wptr = 0;
48   ret->nlines = n;
49
50   return ret;
51 }
52
53 void
54 history_free (History * h)
55 {
56   if (!h)
57     return;
58   if (h->lines)
59     free (h->lines);
60   free (h);
61 }
62
63
64 void
65 history_add (History * h, CRT_CA * c)
66 {
67   History_ent *e;
68   if (!h)
69     return;
70
71   e = &h->lines[h->wptr];
72   HISTORY_INC (h, h->wptr);
73
74   memcpy (e->line, c, sizeof (CRT_CA) * CRT_COLS);
75   time (&e->t);
76   e->valid = 1;
77
78 #if 0
79   {
80     int i = CRT_COLS;
81     while (i--) {
82       fputc (c->chr, stderr);
83       c++;
84     }
85     fputc ('\n', stderr);
86   }
87 #endif
88
89
90 }