1 /* esrchc.f -- translated by f2c (version 19980913).
2 You must link the resulting object file with the libraries:
3 -lf2c -lm (in that order)
4 */
5
6 #include "f2c.h"
7
8 /* $Procedure ESRCHC ( Equivalence search, character ) */
esrchc_(char * value,integer * ndim,char * array,ftnlen value_len,ftnlen array_len)9 integer esrchc_(char *value, integer *ndim, char *array, ftnlen value_len,
10 ftnlen array_len)
11 {
12 /* System generated locals */
13 integer ret_val, i__1;
14
15 /* Local variables */
16 integer i__;
17 extern logical eqstr_(char *, char *, ftnlen, ftnlen);
18
19 /* $ Abstract */
20
21 /* Search for a given value within a character string array. */
22 /* Return the index of the first equivalent array entry, or zero */
23 /* if no equivalent element is found. */
24
25 /* $ Disclaimer */
26
27 /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
28 /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
29 /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
30 /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
31 /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
32 /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
33 /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
34 /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
35 /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
36 /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
37
38 /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
39 /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
40 /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
41 /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
42 /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
43 /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
44
45 /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
46 /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
47 /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
48 /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
49
50 /* $ Required_Reading */
51
52 /* None. */
53
54 /* $ Keywords */
55
56 /* ARRAY, SEARCH */
57
58 /* $ Declarations */
59 /* $ Brief_I/O */
60
61 /* VARIABLE I/O DESCRIPTION */
62 /* -------- --- -------------------------------------------------- */
63 /* VALUE I Key value to be found in ARRAY. */
64 /* NDIM I Dimension of ARRAY. */
65 /* ARRAY I Character string array to search. */
66
67 /* The function returns the index of the first array entry */
68 /* equivalent to VALUE, or zero if none is found. */
69
70 /* $ Detailed_Input */
71
72 /* VALUE I is an arbitrary character string. */
73
74 /* NDIM I is the dimension of (number of elements in) */
75 /* an array of character strings. */
76
77 /* ARRAY I is the array. */
78
79 /* $ Detailed_Output */
80
81 /* The function returns the index of the first element of the */
82 /* input array equivalent to the input value, or zero if the */
83 /* array contains no such elements. */
84
85 /* Two strings are equivalent if they contain the same characters */
86 /* in the same order, when blanks are ignored and uppercase and */
87 /* lowercase characters are considered equal. */
88
89 /* $ Parameters */
90
91 /* None. */
92
93 /* $ Files */
94
95 /* None. */
96
97 /* $ Exceptions */
98
99 /* None. */
100
101 /* $ Particulars */
102
103 /* ESRCHC is identical to ISRCHC, except that it looks for */
104 /* the first equivalent string (as defined by EQSTR) instead */
105 /* of the first identical one. */
106
107 /* $ Examples */
108
109 /* Let ARRAY contain the following elements: */
110
111 /* ARRAY(1) = 'This' */
112 /* ARRAY(2) = 'little' */
113 /* ARRAY(3) = 'piggy' */
114 /* ARRAY(4) = 'went' */
115 /* ARRAY(5) = 'to' */
116 /* ARRAY(6) = 'market' */
117
118 /* Then */
119
120 /* ESRCHC ( 'PIGGY', 6, ARRAY ) = 3 */
121 /* ESRCHC ( ' LiTtLe ', 6, ARRAY ) = 2 */
122 /* ESRCHC ( 'W e n t', 6, ARRAY ) = 4 */
123 /* ESRCHC ( 'mall', 6, ARRAY ) = 0 */
124
125 /* $ Restrictions */
126
127 /* ESRCHC assumes that the function EQSTR does not participate */
128 /* in normal SPICELIB error handling. */
129
130 /* $ Literature_References */
131
132 /* None. */
133
134 /* $ Author_and_Institution */
135
136 /* I.M. Underwood (JPL) */
137
138 /* $ Version */
139
140 /* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
141
142 /* Comment section for permuted index source lines was added */
143 /* following the header. */
144
145 /* - SPICELIB Version 1.0.0, 31-JAN-1990 (IMU) */
146
147 /* -& */
148 /* $ Index_Entries */
149
150 /* search array for equivalent character_string */
151
152 /* -& */
153
154 /* SPICELIB functions */
155
156
157 /* Local variables */
158
159
160 /* Just like ISRCHC. */
161
162 ret_val = 0;
163 i__1 = *ndim;
164 for (i__ = 1; i__ <= i__1; ++i__) {
165 if (eqstr_(array + (i__ - 1) * array_len, value, array_len, value_len)
166 ) {
167 ret_val = i__;
168 return ret_val;
169 }
170 }
171 return ret_val;
172 } /* esrchc_ */
173
174