xref: /aosp_15_r20/external/e2fsprogs/lib/et/init_et.c (revision 6a54128f25917bfc36a8a6e9d722c04a0b4641b6)
1*6a54128fSAndroid Build Coastguard Worker /*
2*6a54128fSAndroid Build Coastguard Worker  * $Header$
3*6a54128fSAndroid Build Coastguard Worker  * $Source$
4*6a54128fSAndroid Build Coastguard Worker  * $Locker$
5*6a54128fSAndroid Build Coastguard Worker  *
6*6a54128fSAndroid Build Coastguard Worker  * Copyright 1986, 1987, 1988 by MIT Information Systems and
7*6a54128fSAndroid Build Coastguard Worker  *	the MIT Student Information Processing Board.
8*6a54128fSAndroid Build Coastguard Worker  *
9*6a54128fSAndroid Build Coastguard Worker  * Permission to use, copy, modify, and distribute this software and
10*6a54128fSAndroid Build Coastguard Worker  * its documentation for any purpose is hereby granted, provided that
11*6a54128fSAndroid Build Coastguard Worker  * the names of M.I.T. and the M.I.T. S.I.P.B. not be used in
12*6a54128fSAndroid Build Coastguard Worker  * advertising or publicity pertaining to distribution of the software
13*6a54128fSAndroid Build Coastguard Worker  * without specific, written prior permission.  M.I.T. and the
14*6a54128fSAndroid Build Coastguard Worker  * M.I.T. S.I.P.B. make no representations about the suitability of
15*6a54128fSAndroid Build Coastguard Worker  * this software for any purpose.  It is provided "as is" without
16*6a54128fSAndroid Build Coastguard Worker  * express or implied warranty.
17*6a54128fSAndroid Build Coastguard Worker  */
18*6a54128fSAndroid Build Coastguard Worker 
19*6a54128fSAndroid Build Coastguard Worker #include "config.h"
20*6a54128fSAndroid Build Coastguard Worker #include <stdio.h>
21*6a54128fSAndroid Build Coastguard Worker #include <errno.h>
22*6a54128fSAndroid Build Coastguard Worker #ifdef HAVE_STDLIB_H
23*6a54128fSAndroid Build Coastguard Worker #include <stdlib.h>
24*6a54128fSAndroid Build Coastguard Worker #endif
25*6a54128fSAndroid Build Coastguard Worker #include "com_err.h"
26*6a54128fSAndroid Build Coastguard Worker #include "error_table.h"
27*6a54128fSAndroid Build Coastguard Worker 
28*6a54128fSAndroid Build Coastguard Worker struct foobar {
29*6a54128fSAndroid Build Coastguard Worker     struct et_list etl;
30*6a54128fSAndroid Build Coastguard Worker     struct error_table et;
31*6a54128fSAndroid Build Coastguard Worker };
32*6a54128fSAndroid Build Coastguard Worker 
33*6a54128fSAndroid Build Coastguard Worker extern struct et_list * _et_dynamic_list;
34*6a54128fSAndroid Build Coastguard Worker 
init_error_table(const char * const * msgs,long base,int count)35*6a54128fSAndroid Build Coastguard Worker int init_error_table(const char * const *msgs, long base, int count)
36*6a54128fSAndroid Build Coastguard Worker {
37*6a54128fSAndroid Build Coastguard Worker     struct foobar * new_et;
38*6a54128fSAndroid Build Coastguard Worker 
39*6a54128fSAndroid Build Coastguard Worker     if (!base || !count || !msgs)
40*6a54128fSAndroid Build Coastguard Worker 	return 0;
41*6a54128fSAndroid Build Coastguard Worker 
42*6a54128fSAndroid Build Coastguard Worker     new_et = (struct foobar *) malloc(sizeof(struct foobar));
43*6a54128fSAndroid Build Coastguard Worker     if (!new_et)
44*6a54128fSAndroid Build Coastguard Worker 	return ENOMEM;	/* oops */
45*6a54128fSAndroid Build Coastguard Worker     new_et->etl.table = &new_et->et;
46*6a54128fSAndroid Build Coastguard Worker     new_et->et.msgs = msgs;
47*6a54128fSAndroid Build Coastguard Worker     new_et->et.base = base;
48*6a54128fSAndroid Build Coastguard Worker     new_et->et.n_msgs= count;
49*6a54128fSAndroid Build Coastguard Worker 
50*6a54128fSAndroid Build Coastguard Worker     new_et->etl.next = _et_dynamic_list;
51*6a54128fSAndroid Build Coastguard Worker     _et_dynamic_list = &new_et->etl;
52*6a54128fSAndroid Build Coastguard Worker     return 0;
53*6a54128fSAndroid Build Coastguard Worker }
54