summaryrefslogtreecommitdiffstats
path: root/eBones/lib/libkdb/krb_cache.c
blob: 1c7c9ce3d7f2782124aee27e5a4aadc702f15449 (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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
/*
 * Copyright 1988 by the Massachusetts Institute of Technology.
 * For copying and distribution information, please see the file
 * <Copyright.MIT>.
 *
 * This is where a cache would be implemented, if it were necessary.
 *
 *	from: krb_cache.c,v 4.5 89/01/24 18:12:34 jon Exp $
 *	$Id: krb_cache.c,v 1.3 1995/07/18 16:37:12 mark Exp $
 */

#if 0
#ifndef	lint
static char rcsid[] =
"$Id: krb_cache.c,v 1.3 1995/07/18 16:37:12 mark Exp $";
#endif	lint
#endif

#include <stdio.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <sys/uio.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <strings.h>
#include <des.h>
#include <krb.h>
#include <krb_db.h>

#ifdef DEBUG
extern int debug;
extern long kerb_debug;
#endif
static  init = 0;

/*
 * initialization routine for cache
 */

int
kerb_cache_init()
{
    init = 1;
    return (0);
}

/*
 * look up a principal in the cache returns number of principals found
 */

int
kerb_cache_get_principal(serv, inst, principal, max)
    char   *serv;		/* could have wild card */
    char   *inst;		/* could have wild card */
    Principal *principal;
    unsigned int max;		/* max number of name structs to return */

{
    int     found = 0;

    if (!init)
	kerb_cache_init();
#ifdef DEBUG
    if (kerb_debug & 2) {
	fprintf(stderr, "cache_get_principal for %s %s max = %d\n",
	    serv, inst, max);
	if (found) {
	    fprintf(stderr, "cache get %s %s found %s %s\n",
		serv, inst, principal->name, principal->instance);
	} else {
	    fprintf(stderr, "cache %s %s not found\n", serv,
		inst);
	}
    }
#endif
    return (found);
}

/*
 * insert/replace a principal in the cache returns number of principals
 * inserted
 */

int
kerb_cache_put_principal(principal, max)
    Principal *principal;
    unsigned int max;		/* max number of principal structs to
				 * insert */

{
    u_long  i;
    int     count = 0;

    if (!init)
	kerb_cache_init();

#ifdef DEBUG
    if (kerb_debug & 2) {
	fprintf(stderr, "kerb_cache_put_principal  max = %d",
	    max);
    }
#endif

    for (i = 0; i < max; i++) {
#ifdef DEBUG
	if (kerb_debug & 2)
	    fprintf(stderr, "\n %s %s",
		    principal->name, principal->instance);
#endif
	/* DO IT */
	count++;
	principal++;
    }
    return count;
}

/*
 * look up a dba in the cache returns number of dbas found
 */

int
kerb_cache_get_dba(serv, inst, dba, max)
    char   *serv;		/* could have wild card */
    char   *inst;		/* could have wild card */
    Dba    *dba;
    unsigned int max;		/* max number of name structs to return */

{
    int     found = 0;

    if (!init)
	kerb_cache_init();

#ifdef DEBUG
    if (kerb_debug & 2) {
	fprintf(stderr, "cache_get_dba for %s %s max = %d\n",
	    serv, inst, max);
	if (found) {
	    fprintf(stderr, "cache get %s %s found %s %s\n",
		serv, inst, dba->name, dba->instance);
	} else {
	    fprintf(stderr, "cache %s %s not found\n", serv, inst);
	}
    }
#endif
    return (found);
}

/*
 * insert/replace a dba in the cache returns number of dbas inserted
 */

int
kerb_cache_put_dba(dba, max)
    Dba    *dba;
    unsigned int max;		/* max number of dba structs to insert */

{
    u_long  i;
    int     count = 0;

    if (!init)
	kerb_cache_init();
#ifdef DEBUG
    if (kerb_debug & 2) {
	fprintf(stderr, "kerb_cache_put_dba  max = %d", max);
    }
#endif
    for (i = 0; i < max; i++) {
#ifdef DEBUG
	if (kerb_debug & 2)
	    fprintf(stderr, "\n %s %s",
		    dba->name, dba->instance);
#endif
	/* DO IT */
	count++;
	dba++;
    }
    return count;
}

OpenPOWER on IntegriCloud