]>
Commit | Line | Data |
---|---|---|
b168057a | 1 | /* Copyright (C) 1998-2015 Free Software Foundation, Inc. |
3214b89b | 2 | This file is part of the GNU C Library. |
59f4b0c8 | 3 | |
3214b89b AJ |
4 | The GNU C Library is free software; you can redistribute it and/or |
5 | modify it under the terms of the GNU Lesser General Public | |
6 | License as published by the Free Software Foundation; either | |
7 | version 2.1 of the License, or (at your option) any later version. | |
59f4b0c8 | 8 | |
3214b89b | 9 | The GNU C Library is distributed in the hope that it will be useful, |
59f4b0c8 UD |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
3214b89b | 12 | Lesser General Public License for more details. |
59f4b0c8 | 13 | |
3214b89b | 14 | You should have received a copy of the GNU Lesser General Public |
ab84e3ff PE |
15 | License along with the GNU C Library. If not, see |
16 | <http://www.gnu.org/licenses/>. */ | |
59f4b0c8 UD |
17 | |
18 | /* This file contains only wrappers around the real glob functions. It | |
19 | became necessary since the glob_t structure changed. */ | |
bde3fab6 | 20 | #include <sys/types.h> |
59f4b0c8 | 21 | #include <glob.h> |
0772663d | 22 | #include <shlib-compat.h> |
59f4b0c8 | 23 | |
0772663d | 24 | #if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1) |
59f4b0c8 UD |
25 | |
26 | /* This is the old structure. The difference is that the gl_pathc and | |
27 | gl_offs elements have type `int'. */ | |
28 | typedef struct | |
29 | { | |
30 | int gl_pathc; /* Count of paths matched by the pattern. */ | |
31 | char **gl_pathv; /* List of matched pathnames. */ | |
32 | int gl_offs; /* Slots to reserve in `gl_pathv'. */ | |
33 | int gl_flags; /* Set to FLAGS, maybe | GLOB_MAGCHAR. */ | |
34 | ||
35 | /* If the GLOB_ALTDIRFUNC flag is set, the following functions | |
36 | are used instead of the normal file access functions. */ | |
0772663d UD |
37 | void (*gl_closedir) (void *); |
38 | struct dirent *(*gl_readdir) (void *); | |
24d6e175 MT |
39 | __ptr_t (*gl_opendir) (const char *); |
40 | int (*gl_lstat) (const char *, struct stat *); | |
41 | int (*gl_stat) (const char *, struct stat *); | |
59f4b0c8 UD |
42 | } old_glob_t; |
43 | ||
44 | ||
45 | int | |
25366174 | 46 | attribute_compat_text_section |
59f4b0c8 | 47 | __old_glob (const char *pattern, int flags, |
f41d856f | 48 | int (*errfunc) (const char *, int), |
59f4b0c8 UD |
49 | old_glob_t *pglob) |
50 | { | |
51 | glob_t correct; | |
52 | int result; | |
53 | ||
54 | /* Construct an object of correct type. */ | |
55 | correct.gl_pathc = pglob->gl_pathc; | |
56 | correct.gl_pathv = pglob->gl_pathv; | |
57 | correct.gl_offs = pglob->gl_offs; | |
58 | correct.gl_flags = pglob->gl_flags; | |
59 | correct.gl_closedir = pglob->gl_closedir; | |
60 | correct.gl_readdir = pglob->gl_readdir; | |
61 | correct.gl_opendir = pglob->gl_opendir; | |
62 | correct.gl_lstat = pglob->gl_lstat; | |
63 | correct.gl_stat = pglob->gl_stat; | |
64 | ||
65 | result = glob (pattern, flags, errfunc, &correct); | |
66 | ||
67 | /* And convert it back. */ | |
68 | pglob->gl_pathc = correct.gl_pathc; | |
69 | pglob->gl_pathv = correct.gl_pathv; | |
70 | pglob->gl_offs = correct.gl_offs; | |
71 | pglob->gl_flags = correct.gl_flags; | |
72 | pglob->gl_closedir = correct.gl_closedir; | |
73 | pglob->gl_readdir = correct.gl_readdir; | |
74 | pglob->gl_opendir = correct.gl_opendir; | |
75 | pglob->gl_lstat = correct.gl_lstat; | |
76 | pglob->gl_stat = correct.gl_stat; | |
77 | ||
78 | return result; | |
79 | } | |
0772663d | 80 | compat_symbol (libc, __old_glob, glob, GLIBC_2_0); |
59f4b0c8 UD |
81 | |
82 | ||
83 | /* Free storage allocated in PGLOB by a previous `glob' call. */ | |
84 | void | |
25366174 | 85 | attribute_compat_text_section |
59f4b0c8 UD |
86 | __old_globfree (old_glob_t *pglob) |
87 | { | |
88 | glob_t correct; | |
89 | ||
90 | /* We only need these two symbols. */ | |
91 | correct.gl_pathc = pglob->gl_pathc; | |
92 | correct.gl_pathv = pglob->gl_pathv; | |
9259ad13 | 93 | correct.gl_offs = pglob->gl_offs; |
59f4b0c8 UD |
94 | |
95 | globfree (&correct); | |
96 | } | |
0772663d | 97 | compat_symbol (libc, __old_globfree, globfree, GLIBC_2_0); |
59f4b0c8 UD |
98 | |
99 | #endif |