Whamcloud - gitweb
Many files:
[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  * For copyright info, see mit-sipb-copyright.h.
10  */
11
12 #include <stdio.h>
13 #include <errno.h>
14 #ifdef HAS_STDLIB_H
15 #include <stdlib.h>
16 #endif
17 #include "com_err.h"
18 #include "error_table.h"
19 #include "mit-sipb-copyright.h"
20
21 #ifndef __STDC__
22 #define const
23 #endif
24
25 struct foobar {
26     struct et_list etl;
27     struct error_table et;
28 };
29
30 extern struct et_list * _et_list;
31
32 #ifdef __STDC__
33 int init_error_table(const char * const *msgs, int base, int count)
34 #else
35 int init_error_table(msgs, base, count)
36     const char * const * msgs;
37     int base;
38     int count;
39 #endif
40 {
41     struct foobar * new_et;
42
43     if (!base || !count || !msgs)
44         return 0;
45
46     new_et = (struct foobar *) malloc(sizeof(struct foobar));
47     if (!new_et)
48         return ENOMEM;  /* oops */
49     new_et->etl.table = &new_et->et;
50     new_et->et.msgs = msgs;
51     new_et->et.base = base;
52     new_et->et.n_msgs= count;
53
54     new_et->etl.next = _et_list;
55     _et_list = &new_et->etl;
56     return 0;
57 }