aboutsummaryrefslogtreecommitdiff
path: root/src/util/et/init_et.c
blob: c47acb7bbfd49aa2ffcbf75a3e298c0ccb2d8d02 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/*
 * Copyright 1997 by Massachusetts Institute of Technology
 * 
 * Copyright 1986, 1987, 1988 by MIT Student Information Processing Board
 *
 * Permission to use, copy, modify, and distribute this software
 * and its documentation for any purpose and without fee is
 * hereby granted, provided that the above copyright notice
 * appear in all copies and that both that copyright notice and
 * this permission notice appear in supporting documentation,
 * and that the names of M.I.T. and the M.I.T. S.I.P.B. not be
 * used in advertising or publicity pertaining to distribution
 * of the software without specific, written prior permission.
 * Furthermore if you modify this software you must label
 * your software as modified software and not distribute it in such a
 * fashion that it might be confused with the original M.I.T. software.
 * M.I.T. and the M.I.T. S.I.P.B. make no representations about
 * the suitability of this software for any purpose.  It is
 * provided "as is" without express or implied warranty.
 */

#include <stdio.h>
#include <stdlib.h>
#include "com_err.h"
#include "error_table.h"

#if 0
/*
 * XXX This function is provided without any prototypes in the public
 * interface, and isn't used internally.  It's probably safe to make
 * it go away.
 */
struct foobar {
    struct et_list etl;
    struct error_table et;
};

int init_error_table(msgs, base, count)
    const char FAR * const FAR * msgs;
    int base;
    int count;
{
    struct foobar FAR * new_et;

    if (!base || !count || !msgs)
	return 0;

    new_et = (struct foobar *) malloc(sizeof(struct foobar));
    if (!new_et)
	return errno;	/* oops */
    new_et->etl.table = &new_et->et;
    new_et->et.msgs = msgs;
    new_et->et.base = base;
    new_et->et.n_msgs= count;

    new_et->etl.next = _et_list;
    _et_list = &new_et->etl;
    return 0;
}

extern errcode_t KRB5_CALLCONV et_init(ectx)
	et_ctx FAR *ectx;
{
	struct et_context FAR *ctx;

	ctx = malloc(sizeof(struct et_context));
	if (!ctx)
		return ENOMEM;
	ctx->tables = 0;
	ctx->hook_func = 0;
	ctx->hook_func_data = 0;
	
	*ectx = ctx;
	return 0;
}

extern void KRB5_CALLCONV et_shutdown(ectx)
	et_ctx ectx;	
{
	struct et_list FAR *p, FAR *n;

	p = ectx->tables;
	while (p) {
		n = p->next;
		free(p);
		p = n;
	}
	free(ectx);
}

extern errcode_t KRB5_CALLCONV et_add_error_table(ectx, tbl)
	et_ctx ectx;
	struct error_table FAR *tbl;
{
	struct et_list FAR *e;

	e = malloc(sizeof(struct et_list));
	if (!e)
		return ENOMEM;
	
	e->table = tbl;
	e->next = ectx->tables;
	ectx->tables = e;
	
	return 0;
}

#endif