|
|
1.1 root 1: /*
2: *
3: * $Header: init_et.c,v 1.1 86/11/10 21:42:26 spook Exp $
4: * $Source: /mit/s/p/spook/Work/et/RCS/init_et.c,v $
5: * $Locker: spook $
6: *
7: * Copyright 1986 by MIT Information Systems and
8: * MIT Student Information Processing Board
9: *
10: * For copyright info, see mit-sipb-copyright.h.
11: *
12: */
13:
14: #include <stdio.h>
15: #include "error_table.h"
16: #include "mit-sipb-copyright.h"
17:
18: static char copyright[] = "Copyright 1987 by MIT Student Information Processing Board";
19:
20: extern char *malloc(), *realloc();
21:
22: /* useful */
23: typedef error_table *etp;
24: typedef etp *etpp;
25:
26: etpp _et_list = (etpp)NULL;
27: static int n_allocated = 0, n_used = 0;
28:
29: int
30: init_error_table(msgs, base, count)
31: char **msgs;
32: register int base;
33: int count;
34: {
35: register int i;
36: register etp new_et;
37: register etpp list;
38:
39: if (!base || !count || !msgs)
40: return;
41:
42: new_et = (etp)malloc(sizeof(error_table));
43: new_et->msgs = msgs;
44: new_et->base = base;
45: new_et->n_msgs= count;
46:
47: list = _et_list;
48: if (list == (etpp)NULL) {
49: _et_list = (etpp) malloc(10*sizeof(etp));
50: list = _et_list;
51: if (list == (etpp)NULL)
52: return; /* oops */
53: list[0] = new_et;
54: list[1] = (etp)NULL;
55: n_allocated = 10;
56: n_used = 1;
57: return;
58: }
59: for (i = 0; i < n_used; i++)
60: if (list[i]->base == base)
61: return; /* avoid duplicates */
62: if (n_used+2 > n_allocated) {
63: n_allocated += 10; /* don't re-allocate too often */
64: list = (etpp) realloc((char *)list,
65: (unsigned)n_allocated * sizeof(etp));
66: _et_list = list;
67: if (list == (etpp)NULL)
68: return; /* oops */
69: }
70: list[n_used++] = new_et;
71: list[n_used] = (etp)NULL;
72: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.