Whamcloud - gitweb
ChangeLog, dumpe2fs.8.in, dumpe2fs.c, mke2fs.8.in, mke2fs.c, partinfo.c:
[tools/e2fsprogs.git] / lib / et / init_et.c
1 /*
2  * $Header$
3  * $Source$
4  * $Locker$
5  *
6  * Copyright 1986, 1987, 1988 by MIT Information Systems and
7  *      the MIT Student Information Processing Board.
8  *
9  * This file may be copied under the terms of the GNU Public License.
10  */
11
12 #include <stdio.h>
13 #include <errno.h>
14 #ifdef HAVE_STDLIB_H
15 #include <stdlib.h>
16 #endif
17 #include "com_err.h"
18 #include "error_table.h"
19
20 #ifndef __STDC__
21 #define const
22 #endif
23
24 struct foobar {
25     struct et_list etl;
26     struct error_table et;
27 };
28
29 extern struct et_list * _et_list;
30
31 #ifdef __STDC__
32 int init_error_table(const char * const *msgs, int base, int count)
33 #else
34 int init_error_table(msgs, base, count)
35     const char * const * msgs;
36     int base;
37     int count;
38 #endif
39 {
40     struct foobar * new_et;
41
42     if (!base || !count || !msgs)
43         return 0;
44
45     new_et = (struct foobar *) malloc(sizeof(struct foobar));
46     if (!new_et)
47         return ENOMEM;  /* oops */
48     new_et->etl.table = &new_et->et;
49     new_et->et.msgs = msgs;
50     new_et->et.base = base;
51     new_et->et.n_msgs= count;
52
53     new_et->etl.next = _et_list;
54     _et_list = &new_et->etl;
55     return 0;
56 }