1 /* Copyright (C) 1998, 2000, 2004 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, write to the Free
16 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 /* This file contains only wrappers around the real glob functions. It
20 became necessary since the glob_t structure changed. */
21 #include <sys/types.h>
23 #include <shlib-compat.h>
25 #if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
27 /* This is the old structure. The difference is that the gl_pathc and
28 gl_offs elements have type `int'. */
31 int gl_pathc
; /* Count of paths matched by the pattern. */
32 char **gl_pathv
; /* List of matched pathnames. */
33 int gl_offs
; /* Slots to reserve in `gl_pathv'. */
34 int gl_flags
; /* Set to FLAGS, maybe | GLOB_MAGCHAR. */
36 /* If the GLOB_ALTDIRFUNC flag is set, the following functions
37 are used instead of the normal file access functions. */
38 void (*gl_closedir
) (void *);
39 struct dirent
*(*gl_readdir
) (void *);
40 __ptr_t (*gl_opendir
) (__const
char *);
41 int (*gl_lstat
) (__const
char *, struct stat
*);
42 int (*gl_stat
) (__const
char *, struct stat
*);
47 attribute_compat_text_section
48 __old_glob (const char *pattern
, int flags
,
49 int (*errfunc
) (const char *, int),
55 /* Construct an object of correct type. */
56 correct
.gl_pathc
= pglob
->gl_pathc
;
57 correct
.gl_pathv
= pglob
->gl_pathv
;
58 correct
.gl_offs
= pglob
->gl_offs
;
59 correct
.gl_flags
= pglob
->gl_flags
;
60 correct
.gl_closedir
= pglob
->gl_closedir
;
61 correct
.gl_readdir
= pglob
->gl_readdir
;
62 correct
.gl_opendir
= pglob
->gl_opendir
;
63 correct
.gl_lstat
= pglob
->gl_lstat
;
64 correct
.gl_stat
= pglob
->gl_stat
;
66 result
= glob (pattern
, flags
, errfunc
, &correct
);
68 /* And convert it back. */
69 pglob
->gl_pathc
= correct
.gl_pathc
;
70 pglob
->gl_pathv
= correct
.gl_pathv
;
71 pglob
->gl_offs
= correct
.gl_offs
;
72 pglob
->gl_flags
= correct
.gl_flags
;
73 pglob
->gl_closedir
= correct
.gl_closedir
;
74 pglob
->gl_readdir
= correct
.gl_readdir
;
75 pglob
->gl_opendir
= correct
.gl_opendir
;
76 pglob
->gl_lstat
= correct
.gl_lstat
;
77 pglob
->gl_stat
= correct
.gl_stat
;
81 compat_symbol (libc
, __old_glob
, glob
, GLIBC_2_0
);
84 /* Free storage allocated in PGLOB by a previous `glob' call. */
86 attribute_compat_text_section
87 __old_globfree (old_glob_t
*pglob
)
91 /* We only need these two symbols. */
92 correct
.gl_pathc
= pglob
->gl_pathc
;
93 correct
.gl_pathv
= pglob
->gl_pathv
;
97 compat_symbol (libc
, __old_globfree
, globfree
, GLIBC_2_0
);