1 #pragma ident "%Z%%M% %I% %E% SMI"
4 * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
6 * Openvision retains the copyright to derivative works of
7 * this source code. Do *NOT* create a derivative of this
8 * source code before consulting with your legal department.
9 * Do *NOT* integrate *ANY* of this source code into another
10 * product before consulting with your legal department.
12 * For further information, read the top-level Openvision
13 * copyright which is contained in the top-level MIT Kerberos
16 * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
24 * Copyright 1992 by the Massachusetts Institute of Technology.
25 * All Rights Reserved.
27 * Export of this software from the United States of America may
28 * require a specific license from the United States Government.
29 * It is the responsibility of any person or organization contemplating
30 * export to obtain such a license before exporting.
32 * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
33 * distribute this software and its documentation for any purpose and
34 * without fee is hereby granted, provided that the above copyright
35 * notice appear in all copies and that both that copyright notice and
36 * this permission notice appear in supporting documentation, and that
37 * the name of M.I.T. not be used in advertising or publicity pertaining
38 * to distribution of the software without specific, written prior
39 * permission. Furthermore if you modify this software you must label
40 * your software as modified software and not distribute it in such a
41 * fashion that it might be confused with the original M.I.T. software.
42 * M.I.T. makes no representations about the suitability of
43 * this software for any purpose. It is provided "as is" without express
44 * or implied warranty.
46 * Utilities for kdb5_edit.
48 * Some routines derived from code contributed by the Sandia National
49 * Laboratories. Sandia National Laboratories also makes no
50 * representations about the suitability of the modifications, or
51 * additions to this software for any purpose. It is provided "as is"
52 * without express or implied warranty.
57 #include "./kdb5_edit.h"
70 for ( i
= 0; i
< strlen(s1
); i
++) {
71 if (memcmp(temp_ptr
, s2
, strlen(s2
)) == 0) return(temp_ptr
);
76 #endif /* HAVE_STRSTR */
79 parse_token(token_in
, must_be_first_char
, num_tokens
, tokens_out
)
81 int *must_be_first_char
;
91 /* Eliminate Up Front Asterisks */
92 *must_be_first_char
= 1;
93 for (i
= 0; token_in
[i
] == '*'; i
++) {
94 *must_be_first_char
= 0;
97 if (i
== strlen(token_in
)) {
102 /* Fill first token_out */
104 while ((token_in
[i
] != '*') && (token_in
[i
] != '\0')) {
105 tokens_out
[j
] = token_in
[i
];
110 if (i
== strlen(token_in
)) {
111 tokens_out
[j
] = '\0';
112 *num_tokens
= token_count
;
116 /* Then All Subsequent Tokens */
117 while (i
< strlen(token_in
)) {
118 if (token_in
[i
] == '*') {
120 tokens_out
[j
] = '\t';
122 tokens_out
[j
] = token_in
[i
];
127 tokens_out
[j
] = '\0';
129 if (tokens_out
[j
- 1] == '\t') {
131 tokens_out
[j
- 1] = '\0';
134 *num_tokens
= token_count
;
139 check_for_match(search_field
, must_be_first_character
, chk_entry
,
141 int must_be_first_character
;
143 krb5_db_entry
*chk_entry
;
155 local_entry
= chk_entry
->princ
->data
[type
].data
;
157 token1
[0] = token2
[0] = token3
[0] = '\0';
159 (void) sscanf(search_field
, "%s\t%s\t%s", token1
, token2
, token3
);
161 found1
= strstr(local_entry
, token1
);
163 if (must_be_first_character
&& (found1
!= local_entry
)) return(0);
165 if (found1
&& (num_tokens
== 1)) return(1);
167 if (found1
&& (num_tokens
> 1)) {
168 found2
= strstr(local_entry
, token2
);
169 if (found2
&& (found2
> found1
) && (num_tokens
== 2)) return(1);
172 if ((found2
> found1
) && (num_tokens
== 3)) {
173 found3
= strstr(local_entry
, token3
);
174 if (found3
&& (found3
> found2
) && (found2
> found1
)) return(1);