Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 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 | * |
Theodore Ts'o | 06cefee | 1999-10-23 01:16:22 +0000 | [diff] [blame] | 9 | * Permission to use, copy, modify, and distribute this software and |
| 10 | * its documentation for any purpose is hereby granted, provided that |
| 11 | * the names of M.I.T. and the M.I.T. S.I.P.B. not be used in |
| 12 | * advertising or publicity pertaining to distribution of the software |
| 13 | * without specific, written prior permission. M.I.T. and the |
| 14 | * M.I.T. S.I.P.B. make no representations about the suitability of |
| 15 | * this software for any purpose. It is provided "as is" without |
| 16 | * express or implied warranty. |
Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 17 | */ |
| 18 | |
Theodore Ts'o | d1154eb | 2011-09-18 17:34:37 -0400 | [diff] [blame] | 19 | #include "config.h" |
Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 20 | #include <stdio.h> |
Theodore Ts'o | f3db356 | 1997-04-26 13:34:30 +0000 | [diff] [blame] | 21 | #include <errno.h> |
Theodore Ts'o | 50e1e10 | 1997-04-26 13:58:21 +0000 | [diff] [blame] | 22 | #ifdef HAVE_STDLIB_H |
Theodore Ts'o | f3db356 | 1997-04-26 13:34:30 +0000 | [diff] [blame] | 23 | #include <stdlib.h> |
| 24 | #endif |
| 25 | #include "com_err.h" |
Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 26 | #include "error_table.h" |
Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 27 | |
Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 28 | struct foobar { |
| 29 | struct et_list etl; |
| 30 | struct error_table et; |
| 31 | }; |
| 32 | |
Theodore Ts'o | d51b819 | 2005-06-20 17:59:06 -0400 | [diff] [blame] | 33 | extern struct et_list * _et_dynamic_list; |
Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 34 | |
Theodore Ts'o | 58f9d9e | 2003-05-06 00:31:55 -0400 | [diff] [blame] | 35 | int init_error_table(const char * const *msgs, long base, int count) |
Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 36 | { |
| 37 | struct foobar * new_et; |
| 38 | |
| 39 | if (!base || !count || !msgs) |
| 40 | return 0; |
| 41 | |
| 42 | new_et = (struct foobar *) malloc(sizeof(struct foobar)); |
| 43 | if (!new_et) |
Theodore Ts'o | f3db356 | 1997-04-26 13:34:30 +0000 | [diff] [blame] | 44 | return ENOMEM; /* oops */ |
Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 45 | new_et->etl.table = &new_et->et; |
| 46 | new_et->et.msgs = msgs; |
| 47 | new_et->et.base = base; |
| 48 | new_et->et.n_msgs= count; |
| 49 | |
Theodore Ts'o | d51b819 | 2005-06-20 17:59:06 -0400 | [diff] [blame] | 50 | new_et->etl.next = _et_dynamic_list; |
| 51 | _et_dynamic_list = &new_et->etl; |
Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 52 | return 0; |
| 53 | } |