Deleted Added
full compact
shlib.c (140241) shlib.c (201217)
1/*
2 * Copyright (c) 1993 Paul Kranenburg
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 13 unchanged lines hidden (view full) ---

22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 *
1/*
2 * Copyright (c) 1993 Paul Kranenburg
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 13 unchanged lines hidden (view full) ---

22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 *
30 * $FreeBSD: head/libexec/rtld-aout/shlib.c 140241 2005-01-14 12:22:57Z delphij $
30 * $FreeBSD: head/libexec/rtld-aout/shlib.c 201217 2009-12-29 21:07:17Z ed $
31 */
32
33#include <sys/param.h>
34#include <sys/types.h>
35#include <sys/stat.h>
36#include <sys/file.h>
37#include <sys/time.h>
38#include <a.out.h>

--- 38 unchanged lines hidden (view full) ---

77 return;
78 n_search_dirs++;
79 search_dirs = (char **)
80 xrealloc(search_dirs, n_search_dirs * sizeof search_dirs[0]);
81 search_dirs[n_search_dirs - 1] = strdup(name);
82}
83
84void
31 */
32
33#include <sys/param.h>
34#include <sys/types.h>
35#include <sys/stat.h>
36#include <sys/file.h>
37#include <sys/time.h>
38#include <a.out.h>

--- 38 unchanged lines hidden (view full) ---

77 return;
78 n_search_dirs++;
79 search_dirs = (char **)
80 xrealloc(search_dirs, n_search_dirs * sizeof search_dirs[0]);
81 search_dirs[n_search_dirs - 1] = strdup(name);
82}
83
84void
85add_search_path(path)
86char *path;
85add_search_path(char *path)
87{
88 register char *cp, *dup;
89
90 if (path == NULL)
91 return;
92
93 /* Add search directories from `path' */
94 path = dup = strdup(path);
95 while ((cp = strsep(&path, ":")) != NULL)
96 add_search_dir(cp);
97 free(dup);
98}
99
100void
86{
87 register char *cp, *dup;
88
89 if (path == NULL)
90 return;
91
92 /* Add search directories from `path' */
93 path = dup = strdup(path);
94 while ((cp = strsep(&path, ":")) != NULL)
95 add_search_dir(cp);
96 free(dup);
97}
98
99void
101std_search_path()
100std_search_path(void)
102{
103 int i, n;
104
105 /* Append standard search directories */
106 n = sizeof standard_search_dirs / sizeof standard_search_dirs[0];
107 for (i = 0; i < n; i++)
108 add_search_dir(standard_search_dirs[i]);
109}
110
111/*
112 * Return true if CP points to a valid dewey number.
113 * Decode and leave the result in the array DEWEY.
114 * Return the number of decoded entries in DEWEY.
115 */
116
117int
101{
102 int i, n;
103
104 /* Append standard search directories */
105 n = sizeof standard_search_dirs / sizeof standard_search_dirs[0];
106 for (i = 0; i < n; i++)
107 add_search_dir(standard_search_dirs[i]);
108}
109
110/*
111 * Return true if CP points to a valid dewey number.
112 * Decode and leave the result in the array DEWEY.
113 * Return the number of decoded entries in DEWEY.
114 */
115
116int
118getdewey(dewey, cp)
119int dewey[];
120char *cp;
117getdewey(int dewey[], char *cp)
121{
122 int i, n;
123
124 for (n = 0, i = 0; i < MAXDEWEY; i++) {
125 if (*cp == '\0')
126 break;
127
128 if (*cp == '.') cp++;

--- 8 unchanged lines hidden (view full) ---

137
138/*
139 * Compare two dewey arrays.
140 * Return -1 if `d1' represents a smaller value than `d2'.
141 * Return 1 if `d1' represents a greater value than `d2'.
142 * Return 0 if equal.
143 */
144int
118{
119 int i, n;
120
121 for (n = 0, i = 0; i < MAXDEWEY; i++) {
122 if (*cp == '\0')
123 break;
124
125 if (*cp == '.') cp++;

--- 8 unchanged lines hidden (view full) ---

134
135/*
136 * Compare two dewey arrays.
137 * Return -1 if `d1' represents a smaller value than `d2'.
138 * Return 1 if `d1' represents a greater value than `d2'.
139 * Return 0 if equal.
140 */
141int
145cmpndewey(d1, n1, d2, n2)
146int d1[], d2[];
147int n1, n2;
142cmpndewey(int d1[], int n1, int d2[], int n2)
148{
149 register int i;
150
151 for (i = 0; i < n1 && i < n2; i++) {
152 if (d1[i] < d2[i])
153 return -1;
154 if (d1[i] > d2[i])
155 return 1;

--- 24 unchanged lines hidden (view full) ---

180 * be fruitless.
181 *
182 * The return value is a full pathname to the matching library. The
183 * string is dynamically allocated. If no matching library is found, the
184 * function returns NULL.
185 */
186
187char *
143{
144 register int i;
145
146 for (i = 0; i < n1 && i < n2; i++) {
147 if (d1[i] < d2[i])
148 return -1;
149 if (d1[i] > d2[i])
150 return 1;

--- 24 unchanged lines hidden (view full) ---

175 * be fruitless.
176 *
177 * The return value is a full pathname to the matching library. The
178 * string is dynamically allocated. If no matching library is found, the
179 * function returns NULL.
180 */
181
182char *
188findshlib(name, majorp, minorp, do_dot_a)
189char *name;
190int *majorp, *minorp;
191int do_dot_a;
183findshlib(char *name, int *majorp, int *minorp, int do_dot_a)
192{
193 int i;
194
195 for (i = 0; i < n_search_dirs; i++) {
196 char *path;
197
198 path = search_lib_dir(search_dirs[i], name, majorp, minorp,
199 do_dot_a);

--- 7 unchanged lines hidden (view full) ---

207/*
208 * Search library directories for a file with the given name. The
209 * return value is a full pathname to the matching file. The string
210 * is dynamically allocated. If no matching file is found, the function
211 * returns NULL.
212 */
213
214char *
184{
185 int i;
186
187 for (i = 0; i < n_search_dirs; i++) {
188 char *path;
189
190 path = search_lib_dir(search_dirs[i], name, majorp, minorp,
191 do_dot_a);

--- 7 unchanged lines hidden (view full) ---

199/*
200 * Search library directories for a file with the given name. The
201 * return value is a full pathname to the matching file. The string
202 * is dynamically allocated. If no matching file is found, the function
203 * returns NULL.
204 */
205
206char *
215find_lib_file(name)
216 const char *name;
207find_lib_file(const char *name)
217{
218 int i;
219
220 for (i = 0; i < n_search_dirs; i++) {
221 char *path = concat(search_dirs[i], "/", name);
222 struct stat sb;
223
224 if (lstat(path, &sb) != -1) /* We found it */

--- 31 unchanged lines hidden (view full) ---

256 * any case.
257 *
258 * The return value is a full pathname to the matching library. The
259 * string is dynamically allocated. If no matching library is found, the
260 * function returns NULL.
261 */
262
263char *
208{
209 int i;
210
211 for (i = 0; i < n_search_dirs; i++) {
212 char *path = concat(search_dirs[i], "/", name);
213 struct stat sb;
214
215 if (lstat(path, &sb) != -1) /* We found it */

--- 31 unchanged lines hidden (view full) ---

247 * any case.
248 *
249 * The return value is a full pathname to the matching library. The
250 * string is dynamically allocated. If no matching library is found, the
251 * function returns NULL.
252 */
253
254char *
264search_lib_dir(dir, name, majorp, minorp, do_dot_a)
265 char *dir;
266 char *name;
267 int *majorp;
268 int *minorp;
269 int do_dot_a;
255search_lib_dir(char *dir, char *name, int *majorp, int *minorp, int do_dot_a)
270{
271 size_t namelen;
272 DIR *dd;
273 struct dirent *dp;
274 int best_dewey[MAXDEWEY];
275 int best_ndewey;
276 char dot_a_name[MAXNAMLEN+1];
277 char dot_so_name[MAXNAMLEN+1];

--- 62 unchanged lines hidden ---
256{
257 size_t namelen;
258 DIR *dd;
259 struct dirent *dp;
260 int best_dewey[MAXDEWEY];
261 int best_ndewey;
262 char dot_a_name[MAXNAMLEN+1];
263 char dot_so_name[MAXNAMLEN+1];

--- 62 unchanged lines hidden ---