]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/unix/sysv/linux/alpha/oldglob.c
Update copyright dates with scripts/update-copyrights
[thirdparty/glibc.git] / sysdeps / unix / sysv / linux / alpha / oldglob.c
CommitLineData
2b778ceb 1/* Copyright (C) 1998-2021 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 15 License along with the GNU C Library. If not, see
5a82c748 16 <https://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'. */
28typedef 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 *);
f17a4233 39 void *(*gl_opendir) (const char *);
24d6e175
MT
40 int (*gl_lstat) (const char *, struct stat *);
41 int (*gl_stat) (const char *, struct stat *);
59f4b0c8
UD
42 } old_glob_t;
43
44
45int
25366174 46attribute_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;
ccf970c7
AZ
62 /* Set gl_lstat and gl_stat for both gl_stat for compatibility with old
63 implementation that did not follow dangling symlinks. */
64 correct.gl_lstat = pglob->gl_stat;
59f4b0c8
UD
65 correct.gl_stat = pglob->gl_stat;
66
67 result = glob (pattern, flags, errfunc, &correct);
68
69 /* And convert it back. */
70 pglob->gl_pathc = correct.gl_pathc;
71 pglob->gl_pathv = correct.gl_pathv;
72 pglob->gl_offs = correct.gl_offs;
73 pglob->gl_flags = correct.gl_flags;
74 pglob->gl_closedir = correct.gl_closedir;
75 pglob->gl_readdir = correct.gl_readdir;
76 pglob->gl_opendir = correct.gl_opendir;
ccf970c7 77 /* Only need to restore gl_stat. */
59f4b0c8
UD
78 pglob->gl_stat = correct.gl_stat;
79
80 return result;
81}
0772663d 82compat_symbol (libc, __old_glob, glob, GLIBC_2_0);
59f4b0c8
UD
83
84
85/* Free storage allocated in PGLOB by a previous `glob' call. */
86void
25366174 87attribute_compat_text_section
59f4b0c8
UD
88__old_globfree (old_glob_t *pglob)
89{
90 glob_t correct;
91
92 /* We only need these two symbols. */
93 correct.gl_pathc = pglob->gl_pathc;
94 correct.gl_pathv = pglob->gl_pathv;
9259ad13 95 correct.gl_offs = pglob->gl_offs;
59f4b0c8
UD
96
97 globfree (&correct);
98}
0772663d 99compat_symbol (libc, __old_globfree, globfree, GLIBC_2_0);
59f4b0c8
UD
100
101#endif