1 /* Copyright (C) 1998-2017 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
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.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library. If not, see
16 <http://www.gnu.org/licenses/>. */
18 /* This file contains only wrappers around the real glob functions. It
19 became necessary since the glob_t structure changed. */
20 #include <sys/types.h>
22 #include <shlib-compat.h>
24 #if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
26 /* This is the old structure. The difference is that the gl_pathc and
27 gl_offs elements have type `int'. */
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. */
35 /* If the GLOB_ALTDIRFUNC flag is set, the following functions
36 are used instead of the normal file access functions. */
37 void (*gl_closedir
) (void *);
38 struct dirent
*(*gl_readdir
) (void *);
39 __ptr_t (*gl_opendir
) (const char *);
40 int (*gl_lstat
) (const char *, struct stat
*);
41 int (*gl_stat
) (const char *, struct stat
*);
46 attribute_compat_text_section
47 __old_glob (const char *pattern
, int flags
,
48 int (*errfunc
) (const char *, int),
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
;
65 result
= glob (pattern
, flags
, errfunc
, &correct
);
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
;
80 compat_symbol (libc
, __old_glob
, glob
, GLIBC_2_0
);
83 /* Free storage allocated in PGLOB by a previous `glob' call. */
85 attribute_compat_text_section
86 __old_globfree (old_glob_t
*pglob
)
90 /* We only need these two symbols. */
91 correct
.gl_pathc
= pglob
->gl_pathc
;
92 correct
.gl_pathv
= pglob
->gl_pathv
;
93 correct
.gl_offs
= pglob
->gl_offs
;
97 compat_symbol (libc
, __old_globfree
, globfree
, GLIBC_2_0
);