1 /* init_et.c
2  *
3  * Copyright (c) 1994-2008 Carnegie Mellon University.  All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  *
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in
14  *    the documentation and/or other materials provided with the
15  *    distribution.
16  *
17  * 3. The name "Carnegie Mellon University" must not be used to
18  *    endorse or promote products derived from this software without
19  *    prior written permission. For permission or any legal
20  *    details, please contact
21  *      Carnegie Mellon University
22  *      Center for Technology Transfer and Enterprise Creation
23  *      4615 Forbes Avenue
24  *      Suite 302
25  *      Pittsburgh, PA  15213
26  *      (412) 268-7393, fax: (412) 268-7395
27  *      innovation@andrew.cmu.edu
28  *
29  * 4. Redistributions of any form whatsoever must retain the following
30  *    acknowledgment:
31  *    "This product includes software developed by Computing Services
32  *     at Carnegie Mellon University (http://www.cmu.edu/computing/)."
33  *
34  * CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
35  * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
36  * AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
37  * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
38  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
39  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
40  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
41  *
42  * Copyright 1986, 1987, 1988 by MIT Information Systems and
43  *      the MIT Student Information Processing Board.
44  *
45  * For copyright info, see mit-sipb-copyright.h.
46  */
47 
48 #include <stdio.h>
49 #include <stdlib.h>
50 #include "error_table.h"
51 #include "mit-sipb-copyright.h"
52 
53 struct foobar {
54     struct et_list etl;
55     struct error_table et;
56 };
57 
58 extern struct et_list * _et_list;
59 
init_error_table(msgs,base,count)60 int init_error_table(msgs, base, count)
61     const char * const * msgs;
62     int base;
63     int count;
64 {
65     struct foobar * new_et;
66 
67     if (!base || !count || !msgs)
68         return 0;
69 
70     new_et = (struct foobar *) malloc(sizeof(struct foobar));
71     if (!new_et)
72         return errno;   /* oops */
73     new_et->etl.table = &new_et->et;
74     new_et->et.msgs = msgs;
75     new_et->et.base = base;
76     new_et->et.n_msgs= count;
77 
78     new_et->etl.next = _et_list;
79     _et_list = &new_et->etl;
80     return 0;
81 }
82