Update.
[glibc.git] / sysdeps / unix / sysv / linux / alpha / oldglob.c
blob97284ab3e9ab8e610fff2b00cd0e80c1f03e2b44
1 /* Copyright (C) 1998 Free Software Foundation, Inc.
3 This library is free software; you can redistribute it and/or
4 modify it under the terms of the GNU Library General Public License as
5 published by the Free Software Foundation; either version 2 of the
6 License, or (at your option) any later version.
8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details.
13 You should have received a copy of the GNU Library General Public
14 License along with this library; see the file COPYING.LIB. If not,
15 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
16 Boston, MA 02111-1307, USA. */
18 /* This file contains only wrappers around the real glob functions. It
19 became necessary since the glob_t structure changed. */
20 #include <glob.h>
22 #if defined PIC && DO_VERSIONING
24 /* This is the old structure. The difference is that the gl_pathc and
25 gl_offs elements have type `int'. */
26 typedef struct
28 int gl_pathc; /* Count of paths matched by the pattern. */
29 char **gl_pathv; /* List of matched pathnames. */
30 int gl_offs; /* Slots to reserve in `gl_pathv'. */
31 int gl_flags; /* Set to FLAGS, maybe | GLOB_MAGCHAR. */
33 /* If the GLOB_ALTDIRFUNC flag is set, the following functions
34 are used instead of the normal file access functions. */
35 void (*gl_closedir) __P ((void *));
36 struct dirent *(*gl_readdir) __P ((void *));
37 __ptr_t (*gl_opendir) __P ((__const char *));
38 int (*gl_lstat) __P ((__const char *, struct stat *));
39 int (*gl_stat) __P ((__const char *, struct stat *));
40 } old_glob_t;
43 int
44 __old_glob (const char *pattern, int flags,
45 int (*errfunc) __P ((const char *, int)),
46 old_glob_t *pglob)
48 glob_t correct;
49 int result;
51 /* Construct an object of correct type. */
52 correct.gl_pathc = pglob->gl_pathc;
53 correct.gl_pathv = pglob->gl_pathv;
54 correct.gl_offs = pglob->gl_offs;
55 correct.gl_flags = pglob->gl_flags;
56 correct.gl_closedir = pglob->gl_closedir;
57 correct.gl_readdir = pglob->gl_readdir;
58 correct.gl_opendir = pglob->gl_opendir;
59 correct.gl_lstat = pglob->gl_lstat;
60 correct.gl_stat = pglob->gl_stat;
62 result = glob (pattern, flags, errfunc, &correct);
64 /* And convert it back. */
65 pglob->gl_pathc = correct.gl_pathc;
66 pglob->gl_pathv = correct.gl_pathv;
67 pglob->gl_offs = correct.gl_offs;
68 pglob->gl_flags = correct.gl_flags;
69 pglob->gl_closedir = correct.gl_closedir;
70 pglob->gl_readdir = correct.gl_readdir;
71 pglob->gl_opendir = correct.gl_opendir;
72 pglob->gl_lstat = correct.gl_lstat;
73 pglob->gl_stat = correct.gl_stat;
75 return result;
77 symbol_version(__old_glob, glob, GLIBC_2.0)
80 /* Free storage allocated in PGLOB by a previous `glob' call. */
81 void
82 __old_globfree (old_glob_t *pglob)
84 glob_t correct;
86 /* We only need these two symbols. */
87 correct.gl_pathc = pglob->gl_pathc;
88 correct.gl_pathv = pglob->gl_pathv;
90 globfree (&correct);
92 symbol_version(__old_globfree, globfree, GLIBC_2.0)
94 #endif