Commit 3e718271 3e718271bbdce86739f4b40655d57611d858bc59 by Sergey Poznyakoff

Added to the repository by gnulib-sync

1 parent 94a921a7
1 #serial 8
2
3 dnl From Jim Meyering.
4 dnl
5 dnl Check whether struct dirent has a member named d_type.
6 dnl
7
8 # Copyright (C) 1997, 1999, 2000, 2001, 2002, 2003, 2004 Free Software
9 # Foundation, Inc.
10 #
11 # This file is free software; the Free Software Foundation
12 # gives unlimited permission to copy and/or distribute it,
13 # with or without modifications, as long as this notice is preserved.
14
15 AC_DEFUN([gl_CHECK_TYPE_STRUCT_DIRENT_D_TYPE],
16 [AC_REQUIRE([AC_HEADER_DIRENT])dnl
17 AC_CACHE_CHECK([for d_type member in directory struct],
18 jm_cv_struct_dirent_d_type,
19 [AC_TRY_LINK(dnl
20 [
21 #include <sys/types.h>
22 #ifdef HAVE_DIRENT_H
23 # include <dirent.h>
24 #else /* not HAVE_DIRENT_H */
25 # define dirent direct
26 # ifdef HAVE_SYS_NDIR_H
27 # include <sys/ndir.h>
28 # endif /* HAVE_SYS_NDIR_H */
29 # ifdef HAVE_SYS_DIR_H
30 # include <sys/dir.h>
31 # endif /* HAVE_SYS_DIR_H */
32 # ifdef HAVE_NDIR_H
33 # include <ndir.h>
34 # endif /* HAVE_NDIR_H */
35 #endif /* HAVE_DIRENT_H */
36 ],
37 [struct dirent dp; dp.d_type = 0;],
38
39 jm_cv_struct_dirent_d_type=yes,
40 jm_cv_struct_dirent_d_type=no)
41 ]
42 )
43 if test $jm_cv_struct_dirent_d_type = yes; then
44 AC_DEFINE(HAVE_STRUCT_DIRENT_D_TYPE, 1,
45 [Define if there is a member named d_type in the struct describing
46 directory headers.])
47 fi
48 ]
49 )
1 #serial 1
2
3 # Copyright (C) 2005 Free Software Foundation, Inc.
4 #
5 # This file is free software; the Free Software Foundation
6 # gives unlimited permission to copy and/or distribute it,
7 # with or without modifications, as long as this notice is preserved.
8
9 dnl From Derek Price
10 dnl
11 dnl Provide getlogin_r when the system lacks it.
12 dnl
13
14 AC_DEFUN([gl_GETLOGIN_R_SUBSTITUTE],
15 [
16 gl_PREREQ_GETLOGIN_R
17 MU_LIBSOURCE([getlogin_r.h])
18 MU_LIBOBJ([getlogin_r])
19 ])
20
21 AC_DEFUN([gl_GETLOGIN_R],
22 [
23 MU_REPLACE_FUNCS([getlogin_r])
24 if test $ac_cv_func_getlogin_r = no; then
25 gl_GETLOGIN_R_SUBSTITUTE
26 fi
27 ])
28
29 AC_DEFUN([gl_PREREQ_GETLOGIN_R],
30 [
31 AC_CHECK_HEADERS_ONCE([unistd.h])
32 AC_CHECK_DECLS_ONCE([getlogin getlogin_r])
33 ])
1 # glob.m4 serial 3
2 dnl Copyright (C) 2005 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
6
7 # The glob module assumes you want GNU glob, with glob_pattern_p etc,
8 # rather than vanilla POSIX glob. This means your your code should
9 # always include <glob.h> for the glob prototypes.
10
11 AC_DEFUN([gl_GLOB_SUBSTITUTE],
12 [
13 gl_PREREQ_GLOB
14
15 GLOB_H=glob.h
16 MU_LIBSOURCES([glob.c, glob_.h, glob-libc.h])
17 MU_LIBOBJ([glob])
18 AC_SUBST([GLOB_H])
19 ])
20
21 AC_DEFUN([gl_GLOB],
22 [ GLOB_H=
23 AC_CHECK_HEADERS([glob.h], [], [GLOB_H=glob.h])
24
25 if test -z "$GLOB_H"; then
26 AC_CACHE_CHECK([for GNU glob interface version 1],
27 [gl_cv_gnu_glob_interface_version_1],
28 [ AC_COMPILE_IFELSE(
29 [[#include <gnu-versions.h>
30 char a[_GNU_GLOB_INTERFACE_VERSION == 1 ? 1 : -1];]],
31 [gl_cv_gnu_glob_interface_version_1=yes],
32 [gl_cv_gnu_glob_interface_version_1=no])])
33
34 if test "$gl_cv_gnu_glob_interface_version_1" = "no"; then
35 GLOB_H=glob.h
36 fi
37 fi
38
39 if test -z "$GLOB_H"; then
40 AC_CACHE_CHECK([whether glob lists broken symlinks],
41 [gl_cv_glob_lists_symlinks],
42 [ if ln -s conf-doesntexist conf$$-globtest 2>/dev/null; then
43 gl_cv_glob_lists_symlinks=maybe
44 else
45 # If we can't make a symlink, then we cannot test this issue. Be
46 # pessimistic about this.
47 gl_cv_glob_lists_symlinks=no
48 fi
49
50 if test $gl_cv_glob_lists_symlinks = maybe; then
51 AC_RUN_IFELSE(
52 AC_LANG_PROGRAM(
53 [[#include <stddef.h>
54 #include <glob.h>]],
55 [[glob_t found;
56 if (glob ("conf*-globtest", 0, NULL, &found) == GLOB_NOMATCH) return 1;]]),
57 [gl_cv_glob_lists_symlinks=yes],
58 [gl_cv_glob_lists_symlinks=no], [gl_cv_glob_lists_symlinks=no])
59 fi])
60
61 if test $gl_cv_glob_lists_symlinks = no; then
62 GLOB_H=glob.h
63 fi
64 fi
65
66 rm -f conf$$-globtest
67
68 if test -n "$GLOB_H"; then
69 gl_GLOB_SUBSTITUTE
70 fi
71 ])
72
73 # Prerequisites of lib/glob.*.
74 AC_DEFUN([gl_PREREQ_GLOB],
75 [ AC_REQUIRE([gl_CHECK_TYPE_STRUCT_DIRENT_D_TYPE])dnl
76 AC_REQUIRE([AC_GNU_SOURCE])dnl
77 AC_REQUIRE([AC_HEADER_DIRENT])dnl
78 AC_CHECK_HEADERS_ONCE([sys/cdefs.h unistd.h])dnl
79 AC_CHECK_FUNCS_ONCE([getlogin_r getpwnam_r])dnl
80 :])
1 # mbiter.m4 serial 2
2 dnl Copyright (C) 2005 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
6
7 dnl autoconf tests required for use of mbiter.h
8 dnl From Bruno Haible.
9
10 AC_DEFUN([gl_MBITER],
11 [
12 AC_REQUIRE([AC_TYPE_MBSTATE_T])
13 dnl The following line is that so the user can test HAVE_MBRTOWC before
14 dnl #include "mbiter.h" or "mbuiter.h".
15 AC_REQUIRE([gl_FUNC_MBRTOWC])
16 :
17 ])
1 #serial 2
2
3 # Copyright (C) 2005 Free Software Foundation, Inc.
4 #
5 # This file is free software; the Free Software Foundation
6 # gives unlimited permission to copy and/or distribute it,
7 # with or without modifications, as long as this notice is preserved.
8
9 AC_DEFUN([gl_STAT_MACROS],
10 [
11 MU_LIBSOURCES([stat-macros.h])
12
13 AC_REQUIRE([AC_HEADER_STAT])
14 ])
1 # stdint.m4 serial 4
2 dnl Copyright (C) 2001-2002, 2004-2005 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
6
7 dnl From Bruno Haible.
8 dnl Test whether <stdint.h> is supported or must be substituted.
9
10 AC_DEFUN([gl_STDINT_H],
11 [dnl Check for <inttypes.h>.
12 AC_REQUIRE([gt_HEADER_INTTYPES_H])
13 dnl Check for <sys/inttypes.h>.
14 AC_CHECK_HEADERS([sys/inttypes.h])
15
16 AC_MSG_CHECKING([for stdint.h])
17 AC_CACHE_VAL(gl_cv_header_stdint_h, [
18 AC_TRY_COMPILE([#include <stdint.h>], [],
19 gl_cv_header_stdint_h=yes, gl_cv_header_stdint_h=no)])
20 AC_MSG_RESULT([$gl_cv_header_stdint_h])
21 if test $gl_cv_header_stdint_h = yes; then
22 AC_DEFINE(HAVE_STDINT_H, 1,
23 [Define if you have a working <stdint.h> header file.])
24 STDINT_H=''
25 else
26 STDINT_H='stdint.h'
27
28 dnl Is long == int64_t ?
29 AC_CACHE_CHECK([whether 'long' is 64 bit wide], gl_cv_long_bitsize_64, [
30 AC_TRY_COMPILE([
31 #define POW63 ((((((long) 1 << 15) << 15) << 15) << 15) << 3)
32 #define POW64 ((((((long) 1 << 15) << 15) << 15) << 15) << 4)
33 typedef int array [2 * (POW63 != 0 && POW64 == 0) - 1];
34 ], , gl_cv_long_bitsize_64=yes, gl_cv_long_bitsize_64=no)])
35 if test $gl_cv_long_bitsize_64 = yes; then
36 HAVE_LONG_64BIT=1
37 else
38 HAVE_LONG_64BIT=0
39 fi
40 AC_SUBST(HAVE_LONG_64BIT)
41
42 dnl Is long long == int64_t ?
43 AC_CACHE_CHECK([whether 'long long' is 64 bit wide], gl_cv_longlong_bitsize_64, [
44 AC_TRY_COMPILE([
45 #define POW63 ((((((long long) 1 << 15) << 15) << 15) << 15) << 3)
46 #define POW64 ((((((long long) 1 << 15) << 15) << 15) << 15) << 4)
47 typedef int array [2 * (POW63 != 0 && POW64 == 0) - 1];
48 ], , gl_cv_longlong_bitsize_64=yes, gl_cv_longlong_bitsize_64=no)])
49 if test $gl_cv_longlong_bitsize_64 = yes; then
50 HAVE_LONG_LONG_64BIT=1
51 else
52 HAVE_LONG_LONG_64BIT=0
53 fi
54 AC_SUBST(HAVE_LONG_LONG_64BIT)
55
56 fi
57 AC_SUBST(STDINT_H)
58 ])
1 # strdup.m4 serial 6
2 dnl Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
6
7 AC_DEFUN([gl_FUNC_STRDUP],
8 [
9 MU_LIBSOURCES([strdup.c, strdup.h])
10
11 MU_REPLACE_FUNCS(strdup)
12 AC_CHECK_DECLS_ONCE(strdup)
13 gl_PREREQ_STRDUP
14 ])
15
16 # Prerequisites of lib/strdup.c.
17 AC_DEFUN([gl_PREREQ_STRDUP], [:])
1 /* Copyright (C) 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2001, 2002, 2003,
2 2005 Free Software Foundation, Inc.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
8
9 This program 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
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software Foundation,
16 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
17
18 #ifndef _FNMATCH_H
19 # define _FNMATCH_H 1
20
21 # ifdef __cplusplus
22 extern "C" {
23 # endif
24
25 /* We #undef these before defining them because some losing systems
26 (HP-UX A.08.07 for example) define these in <unistd.h>. */
27 # undef FNM_PATHNAME
28 # undef FNM_NOESCAPE
29 # undef FNM_PERIOD
30
31 /* Bits set in the FLAGS argument to `fnmatch'. */
32 # define FNM_PATHNAME (1 << 0) /* No wildcard can ever match `/'. */
33 # define FNM_NOESCAPE (1 << 1) /* Backslashes don't quote special chars. */
34 # define FNM_PERIOD (1 << 2) /* Leading `.' is matched only explicitly. */
35
36 # if !defined _POSIX_C_SOURCE || _POSIX_C_SOURCE < 2 || defined _GNU_SOURCE
37 # define FNM_FILE_NAME FNM_PATHNAME /* Preferred GNU name. */
38 # define FNM_LEADING_DIR (1 << 3) /* Ignore `/...' after a match. */
39 # define FNM_CASEFOLD (1 << 4) /* Compare without regard to case. */
40 # define FNM_EXTMATCH (1 << 5) /* Use ksh-like extended matching. */
41 # endif
42
43 /* Value returned by `fnmatch' if STRING does not match PATTERN. */
44 # define FNM_NOMATCH 1
45
46 /* This value is returned if the implementation does not support
47 `fnmatch'. Since this is not the case here it will never be
48 returned but the conformance test suites still require the symbol
49 to be defined. */
50 # ifdef _XOPEN_SOURCE
51 # define FNM_NOSYS (-1)
52 # endif
53
54 /* Match NAME against the file name pattern PATTERN,
55 returning zero if it matches, FNM_NOMATCH if not. */
56 extern int fnmatch (const char *__pattern, const char *__name,
57 int __flags);
58
59 # ifdef __cplusplus
60 }
61 # endif
62
63 #endif /* fnmatch.h */
1 /* Provide a working getlogin_r for systems which lack it.
2
3 Copyright (C) 2005 Free Software Foundation, Inc.
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2, or (at your option)
8 any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software Foundation,
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
18
19 /* written by Paul Eggert and Derek Price */
20
21 #ifdef HAVE_CONFIG_H
22 # include <config.h>
23 #endif
24
25 #include "getlogin_r.h"
26
27 #include <errno.h>
28 #include <string.h>
29
30 #if HAVE_UNISTD_H
31 # include <unistd.h>
32 #endif
33
34 #if !HAVE_DECL_GETLOGIN
35 char *getlogin (void);
36 #endif
37
38 /* See getlogin_r.h for documentation. */
39 int
40 getlogin_r (char *name, size_t size)
41 {
42 char *n;
43 size_t nlen;
44
45 errno = 0;
46 n = getlogin ();
47
48 /* A system function like getlogin_r is never supposed to set errno
49 to zero, so make sure errno is nonzero here. ENOENT is a
50 reasonable errno value if getlogin returns NULL. */
51 if (!errno)
52 errno = ENOENT;
53
54 if (!n)
55 return errno;
56 nlen = strlen (n);
57 if (size <= nlen)
58 return ERANGE;
59 memcpy (name, n, nlen + 1);
60 return 0;
61 }
1 /* getlogin_r declaration
2
3 Copyright (C) 2005 Free Software Foundation, Inc.
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2, or (at your option)
8 any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software Foundation,
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
18
19 /* Written by Paul Eggert and Derek Price. */
20
21 #include <stddef.h>
22
23 #if HAVE_UNISTD_H
24 # include <unistd.h>
25 #endif
26
27 /* Copies the user's login name to NAME.
28 The array pointed to by NAME has room for SIZE bytes.
29
30 Returns 0 if successful. Upon error, an error number is returned, or -1 in
31 the case that the login name cannot be found but no specific error is
32 provided (this case is hopefully rare but is left open by the POSIX spec).
33
34 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
35 */
36 #if !HAVE_DECL_GETLOGIN_R
37 int getlogin_r (char *name, size_t size);
38 #endif
1 /* Copyright (C) 1991,92,95-98,2000,2001,2004 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
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.
8
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.
13
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
17 02111-1307 USA. */
18
19 #ifndef _GLOB_H
20 #define _GLOB_H 1
21
22 #ifndef __GLOB_GNULIB
23 # include <sys/cdefs.h>
24 #endif
25
26 __BEGIN_DECLS
27
28 /* We need `size_t' for the following definitions. */
29 #ifndef __size_t
30 # if defined __GNUC__ && __GNUC__ >= 2
31 typedef __SIZE_TYPE__ __size_t;
32 # ifdef __USE_XOPEN
33 typedef __SIZE_TYPE__ size_t;
34 # endif
35 # else
36 # include <stddef.h>
37 # ifndef __size_t
38 # define __size_t size_t
39 # endif
40 # endif
41 #else
42 /* The GNU CC stddef.h version defines __size_t as empty. We need a real
43 definition. */
44 # undef __size_t
45 # define __size_t size_t
46 #endif
47
48 /* Bits set in the FLAGS argument to `glob'. */
49 #define GLOB_ERR (1 << 0)/* Return on read errors. */
50 #define GLOB_MARK (1 << 1)/* Append a slash to each name. */
51 #define GLOB_NOSORT (1 << 2)/* Don't sort the names. */
52 #define GLOB_DOOFFS (1 << 3)/* Insert PGLOB->gl_offs NULLs. */
53 #define GLOB_NOCHECK (1 << 4)/* If nothing matches, return the pattern. */
54 #define GLOB_APPEND (1 << 5)/* Append to results of a previous call. */
55 #define GLOB_NOESCAPE (1 << 6)/* Backslashes don't quote metacharacters. */
56 #define GLOB_PERIOD (1 << 7)/* Leading `.' can be matched by metachars. */
57
58 #if !defined __USE_POSIX2 || defined __USE_BSD || defined __USE_GNU
59 # define GLOB_MAGCHAR (1 << 8)/* Set in gl_flags if any metachars seen. */
60 # define GLOB_ALTDIRFUNC (1 << 9)/* Use gl_opendir et al functions. */
61 # define GLOB_BRACE (1 << 10)/* Expand "{a,b}" to "a" "b". */
62 # define GLOB_NOMAGIC (1 << 11)/* If no magic chars, return the pattern. */
63 # define GLOB_TILDE (1 << 12)/* Expand ~user and ~ to home directories. */
64 # define GLOB_ONLYDIR (1 << 13)/* Match only directories. */
65 # define GLOB_TILDE_CHECK (1 << 14)/* Like GLOB_TILDE but return an error
66 if the user name is not available. */
67 # define __GLOB_FLAGS (GLOB_ERR|GLOB_MARK|GLOB_NOSORT|GLOB_DOOFFS| \
68 GLOB_NOESCAPE|GLOB_NOCHECK|GLOB_APPEND| \
69 GLOB_PERIOD|GLOB_ALTDIRFUNC|GLOB_BRACE| \
70 GLOB_NOMAGIC|GLOB_TILDE|GLOB_ONLYDIR|GLOB_TILDE_CHECK)
71 #else
72 # define __GLOB_FLAGS (GLOB_ERR|GLOB_MARK|GLOB_NOSORT|GLOB_DOOFFS| \
73 GLOB_NOESCAPE|GLOB_NOCHECK|GLOB_APPEND| \
74 GLOB_PERIOD)
75 #endif
76
77 /* Error returns from `glob'. */
78 #define GLOB_NOSPACE 1 /* Ran out of memory. */
79 #define GLOB_ABORTED 2 /* Read error. */
80 #define GLOB_NOMATCH 3 /* No matches found. */
81 #define GLOB_NOSYS 4 /* Not implemented. */
82 #ifdef __USE_GNU
83 /* Previous versions of this file defined GLOB_ABEND instead of
84 GLOB_ABORTED. Provide a compatibility definition here. */
85 # define GLOB_ABEND GLOB_ABORTED
86 #endif
87
88 /* Structure describing a globbing run. */
89 #ifdef __USE_GNU
90 struct stat;
91 #endif
92 typedef struct
93 {
94 __size_t gl_pathc; /* Count of paths matched by the pattern. */
95 char **gl_pathv; /* List of matched pathnames. */
96 __size_t gl_offs; /* Slots to reserve in `gl_pathv'. */
97 int gl_flags; /* Set to FLAGS, maybe | GLOB_MAGCHAR. */
98
99 /* If the GLOB_ALTDIRFUNC flag is set, the following functions
100 are used instead of the normal file access functions. */
101 void (*gl_closedir) (void *);
102 #ifdef __USE_GNU
103 struct dirent *(*gl_readdir) (void *);
104 #else
105 void *(*gl_readdir) (void *);
106 #endif
107 void *(*gl_opendir) (__const char *);
108 #ifdef __USE_GNU
109 int (*gl_lstat) (__const char *__restrict, struct stat *__restrict);
110 int (*gl_stat) (__const char *__restrict, struct stat *__restrict);
111 #else
112 int (*gl_lstat) (__const char *__restrict, void *__restrict);
113 int (*gl_stat) (__const char *__restrict, void *__restrict);
114 #endif
115 } glob_t;
116
117 #if defined __USE_LARGEFILE64 && !defined __GLOB_GNULIB
118 # ifdef __USE_GNU
119 struct stat64;
120 # endif
121 typedef struct
122 {
123 __size_t gl_pathc;
124 char **gl_pathv;
125 __size_t gl_offs;
126 int gl_flags;
127
128 /* If the GLOB_ALTDIRFUNC flag is set, the following functions
129 are used instead of the normal file access functions. */
130 void (*gl_closedir) (void *);
131 # ifdef __USE_GNU
132 struct dirent64 *(*gl_readdir) (void *);
133 # else
134 void *(*gl_readdir) (void *);
135 # endif
136 void *(*gl_opendir) (__const char *);
137 # ifdef __USE_GNU
138 int (*gl_lstat) (__const char *__restrict, struct stat64 *__restrict);
139 int (*gl_stat) (__const char *__restrict, struct stat64 *__restrict);
140 # else
141 int (*gl_lstat) (__const char *__restrict, void *__restrict);
142 int (*gl_stat) (__const char *__restrict, void *__restrict);
143 # endif
144 } glob64_t;
145 #endif
146
147 #if __USE_FILE_OFFSET64 && __GNUC__ < 2 && !defined __GLOB_GNULIB
148 # define glob glob64
149 # define globfree globfree64
150 #endif
151
152 /* Do glob searching for PATTERN, placing results in PGLOB.
153 The bits defined above may be set in FLAGS.
154 If a directory cannot be opened or read and ERRFUNC is not nil,
155 it is called with the pathname that caused the error, and the
156 `errno' value from the failing call; if it returns non-zero
157 `glob' returns GLOB_ABEND; if it returns zero, the error is ignored.
158 If memory cannot be allocated for PGLOB, GLOB_NOSPACE is returned.
159 Otherwise, `glob' returns zero. */
160 #if !defined __USE_FILE_OFFSET64 || __GNUC__ < 2 || defined __GLOB_GNULIB
161 extern int glob (__const char *__restrict __pattern, int __flags,
162 int (*__errfunc) (__const char *, int),
163 glob_t *__restrict __pglob) __THROW;
164
165 /* Free storage allocated in PGLOB by a previous `glob' call. */
166 extern void globfree (glob_t *__pglob) __THROW;
167 #else
168 extern int __REDIRECT_NTH (glob, (__const char *__restrict __pattern,
169 int __flags,
170 int (*__errfunc) (__const char *, int),
171 glob_t *__restrict __pglob), glob64);
172
173 extern void __REDIRECT_NTH (globfree, (glob_t *__pglob), globfree64);
174 #endif
175
176 #if defined __USE_LARGEFILE64 && !defined __GLOB_GNULIB
177 extern int glob64 (__const char *__restrict __pattern, int __flags,
178 int (*__errfunc) (__const char *, int),
179 glob64_t *__restrict __pglob) __THROW;
180
181 extern void globfree64 (glob64_t *__pglob) __THROW;
182 #endif
183
184
185 #ifdef __USE_GNU
186 /* Return nonzero if PATTERN contains any metacharacters.
187 Metacharacters can be quoted with backslashes if QUOTE is nonzero.
188
189 This function is not part of the interface specified by POSIX.2
190 but several programs want to use it. */
191 extern int glob_pattern_p (__const char *__pattern, int __quote) __THROW;
192 #endif
193
194 __END_DECLS
195
196 #endif /* glob.h */
1 /* glob_.h -- Find a path matching a pattern.
2
3 Copyright (C) 2005 Free Software Foundation, Inc.
4
5 Written by Derek Price <derek@ximbiot.com> & Paul Eggert <eggert@CS.UCLA.EDU>
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software Foundation,
19 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
20
21 #ifndef GLOB_H
22 #define GLOB_H 1
23
24 #ifdef HAVE_SYS_CDEFS_H
25 # include <sys/cdefs.h>
26 #endif
27
28 #include <stddef.h>
29
30 #ifndef __BEGIN_DECLS
31 # define __BEGIN_DECLS
32 # define __END_DECLS
33 #endif
34 #ifndef __THROW
35 # define __THROW
36 #endif
37
38 #ifndef __size_t
39 # define __size_t size_t
40 #endif
41 #ifndef __const
42 # define __const const
43 #endif
44 #ifndef __restrict
45 # define __restrict restrict
46 #endif
47 #ifndef __USE_GNU
48 # define __USE_GNU 1
49 #endif
50
51
52 #ifndef HAVE_DIRENT_H
53 # define dirent direct
54 #endif
55
56 #define glob rpl_glob
57 #define globfree rpl_globfree
58 #define glob_pattern_p rpl_glob_pattern_p
59
60 #define __GLOB_GNULIB 1
61
62 /* Now the standard GNU C Library header should work. */
63 #include "glob-libc.h"
64
65 #endif /* GLOB_H */
1 /* malloc() function that is glibc compatible.
2 Copyright (C) 1997, 1998 Free Software Foundation, Inc.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
8
9 This program 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
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software Foundation,
16 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
17
18 /* written by Jim Meyering */
19
20 #ifdef HAVE_CONFIG_H
21 # include <config.h>
22 #endif
23 #undef malloc
24
25 #include <stdlib.h>
26
27 /* Allocate an N-byte block of memory from the heap.
28 If N is zero, allocate a 1-byte block. */
29
30 void *
31 rpl_malloc (size_t n)
32 {
33 if (n == 0)
34 n = 1;
35 return malloc (n);
36 }
1 /* Iterating through multibyte strings: macros for multi-byte encodings.
2 Copyright (C) 2001, 2005 Free Software Foundation, Inc.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
8
9 This program 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
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software Foundation,
16 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
17
18 /* Written by Bruno Haible <bruno@clisp.org>. */
19
20 /* The macros in this file implement forward iteration through a
21 multi-byte string, without knowing its length a-priori.
22
23 With these macros, an iteration loop that looks like
24
25 char *iter;
26 for (iter = buf; *iter != '\0'; iter++)
27 {
28 do_something (*iter);
29 }
30
31 becomes
32
33 mbui_iterator_t iter;
34 for (mbui_init (iter, buf); mbui_avail (iter); mbui_advance (iter))
35 {
36 do_something (mbui_cur_ptr (iter), mb_len (mbui_cur (iter)));
37 }
38
39 The benefit of these macros over plain use of mbrtowc is:
40 - Handling of invalid multibyte sequences is possible without
41 making the code more complicated, while still preserving the
42 invalid multibyte sequences.
43
44 Compared to mbiter.h, the macros here don't need to know the string's
45 length a-priori. The downside is that at each step, the look-ahead
46 that guards against overrunning the terminating '\0' is more expensive.
47 The mbui_* macros are therefore suitable when there is a high probability
48 that only the first few multibyte characters need to be inspected.
49 Whereas the mbi_* macros are better if usually the iteration runs
50 through the entire string.
51
52 mbui_iterator_t
53 is a type usable for variable declarations.
54
55 mbui_init (iter, startptr)
56 initializes the iterator, starting at startptr.
57
58 mbui_avail (iter)
59 returns true if there are more multibyte chracters available before
60 the end of string is reached. In this case, mbui_cur (iter) is
61 initialized to the next multibyte chracter.
62
63 mbui_advance (iter)
64 advances the iterator by one multibyte character.
65
66 mbui_cur (iter)
67 returns the current multibyte character, of type mbchar_t. All the
68 macros defined in mbchar.h can be used on it.
69
70 mbui_cur_ptr (iter)
71 return a pointer to the beginning of the current multibyte character.
72
73 mbui_reloc (iter, ptrdiff)
74 relocates iterator when the string is moved by ptrdiff bytes.
75
76 Here are the function prototypes of the macros.
77
78 extern void mbui_init (mbui_iterator_t iter, const char *startptr);
79 extern bool mbui_avail (mbui_iterator_t iter);
80 extern void mbui_advance (mbui_iterator_t iter);
81 extern mbchar_t mbui_cur (mbui_iterator_t iter);
82 extern const char * mbui_cur_ptr (mbui_iterator_t iter);
83 extern void mbui_reloc (mbui_iterator_t iter, ptrdiff_t ptrdiff);
84 */
85
86 #ifndef _MBUITER_H
87 #define _MBUITER_H 1
88
89 #include <assert.h>
90 #include <stdbool.h>
91 #include <stdlib.h>
92
93 /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
94 <wchar.h>.
95 BSD/OS 4.1 has a bug: <stdio.h> and <time.h> must be included before
96 <wchar.h>. */
97 #include <stdio.h>
98 #include <time.h>
99 #include <wchar.h>
100
101 #include "mbchar.h"
102 #include "strnlen1.h"
103
104 struct mbuiter_multi
105 {
106 bool in_shift; /* true if next byte may not be interpreted as ASCII */
107 mbstate_t state; /* if in_shift: current shift state */
108 bool next_done; /* true if mbui_avail has already filled the following */
109 struct mbchar cur; /* the current character:
110 const char *cur.ptr pointer to current character
111 The following are only valid after mbui_avail.
112 size_t cur.bytes number of bytes of current character
113 bool cur.wc_valid true if wc is a valid wide character
114 wchar_t cur.wc if wc_valid: the current character
115 */
116 };
117
118 static inline void
119 mbuiter_multi_next (struct mbuiter_multi *iter)
120 {
121 if (iter->next_done)
122 return;
123 if (iter->in_shift)
124 goto with_shift;
125 /* Handle most ASCII characters quickly, without calling mbrtowc(). */
126 if (is_basic (*iter->cur.ptr))
127 {
128 /* These characters are part of the basic character set. ISO C 99
129 guarantees that their wide character code is identical to their
130 char code. */
131 iter->cur.bytes = 1;
132 iter->cur.wc = *iter->cur.ptr;
133 iter->cur.wc_valid = true;
134 }
135 else
136 {
137 assert (mbsinit (&iter->state));
138 iter->in_shift = true;
139 with_shift:
140 iter->cur.bytes = mbrtowc (&iter->cur.wc, iter->cur.ptr,
141 strnlen1 (iter->cur.ptr, MB_CUR_MAX),
142 &iter->state);
143 if (iter->cur.bytes == (size_t) -1)
144 {
145 /* An invalid multibyte sequence was encountered. */
146 iter->cur.bytes = 1;
147 iter->cur.wc_valid = false;
148 /* Whether to set iter->in_shift = false and reset iter->state
149 or not is not very important; the string is bogus anyway. */
150 }
151 else if (iter->cur.bytes == (size_t) -2)
152 {
153 /* An incomplete multibyte character at the end. */
154 iter->cur.bytes = strlen (iter->cur.ptr);
155 iter->cur.wc_valid = false;
156 /* Whether to set iter->in_shift = false and reset iter->state
157 or not is not important; the string end is reached anyway. */
158 }
159 else
160 {
161 if (iter->cur.bytes == 0)
162 {
163 /* A null wide character was encountered. */
164 iter->cur.bytes = 1;
165 assert (*iter->cur.ptr == '\0');
166 assert (iter->cur.wc == 0);
167 }
168 iter->cur.wc_valid = true;
169
170 /* When in the initial state, we can go back treating ASCII
171 characters more quickly. */
172 if (mbsinit (&iter->state))
173 iter->in_shift = false;
174 }
175 }
176 iter->next_done = true;
177 }
178
179 static inline void
180 mbuiter_multi_reloc (struct mbuiter_multi *iter, ptrdiff_t ptrdiff)
181 {
182 iter->cur.ptr += ptrdiff;
183 }
184
185 /* Iteration macros. */
186 typedef struct mbuiter_multi mbui_iterator_t;
187 #define mbui_init(iter, startptr) \
188 ((iter).cur.ptr = (startptr), \
189 (iter).in_shift = false, memset (&(iter).state, '\0', sizeof (mbstate_t)), \
190 (iter).next_done = false)
191 #define mbui_avail(iter) \
192 (mbuiter_multi_next (&(iter)), !mb_isnul ((iter).cur))
193 #define mbui_advance(iter) \
194 ((iter).cur.ptr += (iter).cur.bytes, (iter).next_done = false)
195
196 /* Access to the current character. */
197 #define mbui_cur(iter) (iter).cur
198 #define mbui_cur_ptr(iter) (iter).cur.ptr
199
200 /* Relocation. */
201 #define mbui_reloc(iter, ptrdiff) mbuiter_multi_reloc (&iter, ptrdiff)
202
203 #endif /* _MBUITER_H */
1 /* stat-related macros
2
3 Copyright (C) 1993, 1994, 2001, 2002, 2004 Free Software Foundation, Inc.
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2, or (at your option)
8 any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software Foundation,
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
18
19 /* Written by Paul Eggert and Jim Meyering. */
20
21 #ifndef STAT_MACROS_H
22 # define STAT_MACROS_H 1
23
24 # if ! defined S_ISREG && ! defined S_IFREG
25 # error "you must include <sys/stat.h> before including this file"
26 # endif
27
28 # ifndef S_IFMT
29 # define S_IFMT 0170000
30 # endif
31
32 # if STAT_MACROS_BROKEN
33 # undef S_ISBLK
34 # undef S_ISCHR
35 # undef S_ISDIR
36 # undef S_ISDOOR
37 # undef S_ISFIFO
38 # undef S_ISLNK
39 # undef S_ISNAM
40 # undef S_ISMPB
41 # undef S_ISMPC
42 # undef S_ISNWK
43 # undef S_ISREG
44 # undef S_ISSOCK
45 # endif
46
47
48 # ifndef S_ISBLK
49 # ifdef S_IFBLK
50 # define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
51 # else
52 # define S_ISBLK(m) 0
53 # endif
54 # endif
55
56 # ifndef S_ISCHR
57 # ifdef S_IFCHR
58 # define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
59 # else
60 # define S_ISCHR(m) 0
61 # endif
62 # endif
63
64 # ifndef S_ISDIR
65 # ifdef S_IFDIR
66 # define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
67 # else
68 # define S_ISDIR(m) 0
69 # endif
70 # endif
71
72 # ifndef S_ISDOOR /* Solaris 2.5 and up */
73 # ifdef S_IFDOOR
74 # define S_ISDOOR(m) (((m) & S_IFMT) == S_IFDOOR)
75 # else
76 # define S_ISDOOR(m) 0
77 # endif
78 # endif
79
80 # ifndef S_ISFIFO
81 # ifdef S_IFIFO
82 # define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
83 # else
84 # define S_ISFIFO(m) 0
85 # endif
86 # endif
87
88 # ifndef S_ISLNK
89 # ifdef S_IFLNK
90 # define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
91 # else
92 # define S_ISLNK(m) 0
93 # endif
94 # endif
95
96 # ifndef S_ISMPB /* V7 */
97 # ifdef S_IFMPB
98 # define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
99 # define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
100 # else
101 # define S_ISMPB(m) 0
102 # define S_ISMPC(m) 0
103 # endif
104 # endif
105
106 # ifndef S_ISNAM /* Xenix */
107 # ifdef S_IFNAM
108 # define S_ISNAM(m) (((m) & S_IFMT) == S_IFNAM)
109 # else
110 # define S_ISNAM(m) 0
111 # endif
112 # endif
113
114 # ifndef S_ISNWK /* HP/UX */
115 # ifdef S_IFNWK
116 # define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
117 # else
118 # define S_ISNWK(m) 0
119 # endif
120 # endif
121
122 # ifndef S_ISREG
123 # ifdef S_IFREG
124 # define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
125 # else
126 # define S_ISREG(m) 0
127 # endif
128 # endif
129
130 # ifndef S_ISSOCK
131 # ifdef S_IFSOCK
132 # define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
133 # else
134 # define S_ISSOCK(m) 0
135 # endif
136 # endif
137
138
139 # ifndef S_TYPEISMQ
140 # define S_TYPEISMQ(p) 0
141 # endif
142
143 # ifndef S_TYPEISTMO
144 # define S_TYPEISTMO(p) 0
145 # endif
146
147
148 # ifndef S_TYPEISSEM
149 # ifdef S_INSEM
150 # define S_TYPEISSEM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSEM)
151 # else
152 # define S_TYPEISSEM(p) 0
153 # endif
154 # endif
155
156 # ifndef S_TYPEISSHM
157 # ifdef S_INSHD
158 # define S_TYPEISSHM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSHD)
159 # else
160 # define S_TYPEISSHM(p) 0
161 # endif
162 # endif
163
164 /* contiguous */
165 # ifndef S_ISCTG
166 # define S_ISCTG(p) 0
167 # endif
168
169 /* Cray DMF (data migration facility): off line, with data */
170 # ifndef S_ISOFD
171 # define S_ISOFD(p) 0
172 # endif
173
174 /* Cray DMF (data migration facility): off line, with no data */
175 # ifndef S_ISOFL
176 # define S_ISOFL(p) 0
177 # endif
178
179 /* If any of the following are undefined,
180 define them to their de facto standard values. */
181 # if !S_ISUID
182 # define S_ISUID 04000
183 # endif
184 # if !S_ISGID
185 # define S_ISGID 02000
186 # endif
187
188 /* S_ISVTX is a common extension to POSIX. */
189 # ifndef S_ISVTX
190 # define S_ISVTX 01000
191 # endif
192
193 # if !S_IRUSR && S_IREAD
194 # define S_IRUSR S_IREAD
195 # endif
196 # if !S_IRUSR
197 # define S_IRUSR 00400
198 # endif
199 # if !S_IRGRP
200 # define S_IRGRP (S_IRUSR >> 3)
201 # endif
202 # if !S_IROTH
203 # define S_IROTH (S_IRUSR >> 6)
204 # endif
205
206 # if !S_IWUSR && S_IWRITE
207 # define S_IWUSR S_IWRITE
208 # endif
209 # if !S_IWUSR
210 # define S_IWUSR 00200
211 # endif
212 # if !S_IWGRP
213 # define S_IWGRP (S_IWUSR >> 3)
214 # endif
215 # if !S_IWOTH
216 # define S_IWOTH (S_IWUSR >> 6)
217 # endif
218
219 # if !S_IXUSR && S_IEXEC
220 # define S_IXUSR S_IEXEC
221 # endif
222 # if !S_IXUSR
223 # define S_IXUSR 00100
224 # endif
225 # if !S_IXGRP
226 # define S_IXGRP (S_IXUSR >> 3)
227 # endif
228 # if !S_IXOTH
229 # define S_IXOTH (S_IXUSR >> 6)
230 # endif
231
232 # if !S_IRWXU
233 # define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
234 # endif
235 # if !S_IRWXG
236 # define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
237 # endif
238 # if !S_IRWXO
239 # define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
240 # endif
241
242 /* S_IXUGO is a common extension to POSIX. */
243 # if !S_IXUGO
244 # define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH)
245 # endif
246
247 # ifndef S_IRWXUGO
248 # define S_IRWXUGO (S_IRWXU | S_IRWXG | S_IRWXO)
249 # endif
250
251 /* All the mode bits that can be affected by chmod. */
252 # define CHMOD_MODE_BITS \
253 (S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO)
254
255 #endif /* STAT_MACROS_H */
1 /* Copyright (C) 2001-2002, 2004-2005 Free Software Foundation, Inc.
2 Written by Bruno Haible, Sam Steingold, Peter Burwood.
3 This file is part of gnulib.
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2, or (at your option)
8 any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software Foundation,
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
18
19 #ifndef _STDINT_H
20 #define _STDINT_H
21
22 /*
23 * ISO C 99 <stdint.h> for platforms that lack it.
24 * <http://www.opengroup.org/onlinepubs/007904975/basedefs/stdint.h.html>
25 */
26
27 /* Get wchar_t, WCHAR_MIN, WCHAR_MAX. */
28 #include <stddef.h>
29 /* Get CHAR_BIT, LONG_MIN, LONG_MAX, ULONG_MAX. */
30 #include <limits.h>
31
32 /* Get those types that are already defined in other system include files. */
33 #if defined(__FreeBSD__)
34 # include <sys/inttypes.h>
35 #endif
36 #if defined(__sun) && HAVE_SYS_INTTYPES_H
37 # include <sys/inttypes.h>
38 /* Solaris 7 <sys/inttypes.h> has the types except the *_fast*_t types, and
39 the macros except for *_FAST*_*, INTPTR_MIN, PTRDIFF_MIN, PTRDIFF_MAX.
40 But note that <sys/int_types.h> contains only the type definitions! */
41 # define _STDINT_H_HAVE_SYSTEM_INTTYPES
42 #endif
43 #if (defined(__hpux) || defined(_AIX)) && HAVE_INTTYPES_H
44 # include <inttypes.h>
45 /* HP-UX 10 <inttypes.h> has nearly everything, except UINT_LEAST8_MAX,
46 UINT_FAST8_MAX, PTRDIFF_MIN, PTRDIFF_MAX. */
47 /* AIX 4 <inttypes.h> has nearly everything, except INTPTR_MIN, INTPTR_MAX,
48 UINTPTR_MAX, PTRDIFF_MIN, PTRDIFF_MAX. */
49 # define _STDINT_H_HAVE_SYSTEM_INTTYPES
50 #endif
51 #if !(defined(UNIX_CYGWIN32) && defined(__BIT_TYPES_DEFINED__))
52 # define _STDINT_H_NEED_SIGNED_INT_TYPES
53 #endif
54
55 #if !defined(_STDINT_H_HAVE_SYSTEM_INTTYPES)
56
57 /* 7.18.1.1. Exact-width integer types */
58
59 #if !defined(__FreeBSD__)
60
61 #ifdef _STDINT_H_NEED_SIGNED_INT_TYPES
62 typedef signed char int8_t;
63 #endif
64 typedef unsigned char uint8_t;
65
66 #ifdef _STDINT_H_NEED_SIGNED_INT_TYPES
67 typedef short int16_t;
68 #endif
69 typedef unsigned short uint16_t;
70
71 #ifdef _STDINT_H_NEED_SIGNED_INT_TYPES
72 typedef int int32_t;
73 #endif
74 typedef unsigned int uint32_t;
75
76 #if @HAVE_LONG_64BIT@
77 #ifdef _STDINT_H_NEED_SIGNED_INT_TYPES
78 typedef long int64_t;
79 #endif
80 typedef unsigned long uint64_t;
81 #define _STDINT_H_HAVE_INT64
82 #elif @HAVE_LONG_LONG_64BIT@
83 #ifdef _STDINT_H_NEED_SIGNED_INT_TYPES
84 typedef long long int64_t;
85 #endif
86 typedef unsigned long long uint64_t;
87 #define _STDINT_H_HAVE_INT64
88 #elif defined(_MSC_VER)
89 typedef __int64 int64_t;
90 typedef unsigned __int64 uint64_t;
91 #define _STDINT_H_HAVE_INT64
92 #endif
93
94 #endif /* !FreeBSD */
95
96 /* 7.18.1.2. Minimum-width integer types */
97
98 typedef int8_t int_least8_t;
99 typedef uint8_t uint_least8_t;
100 typedef int16_t int_least16_t;
101 typedef uint16_t uint_least16_t;
102 typedef int32_t int_least32_t;
103 typedef uint32_t uint_least32_t;
104 #ifdef _STDINT_H_HAVE_INT64
105 typedef int64_t int_least64_t;
106 typedef uint64_t uint_least64_t;
107 #endif
108
109 /* 7.18.1.3. Fastest minimum-width integer types */
110
111 typedef int32_t int_fast8_t;
112 typedef uint32_t uint_fast8_t;
113 typedef int32_t int_fast16_t;
114 typedef uint32_t uint_fast16_t;
115 typedef int32_t int_fast32_t;
116 typedef uint32_t uint_fast32_t;
117 #ifdef _STDINT_H_HAVE_INT64
118 typedef int64_t int_fast64_t;
119 typedef uint64_t uint_fast64_t;
120 #endif
121
122 /* 7.18.1.4. Integer types capable of holding object pointers */
123
124 #if !defined(__FreeBSD__)
125
126 /* On some platforms (like IRIX6 MIPS with -n32) sizeof(void*) < sizeof(long),
127 but this doesn't matter here. */
128 typedef long intptr_t;
129 typedef unsigned long uintptr_t;
130
131 #endif /* !FreeBSD */
132
133 /* 7.18.1.5. Greatest-width integer types */
134
135 #ifdef _STDINT_H_HAVE_INT64
136 typedef int64_t intmax_t;
137 typedef uint64_t uintmax_t;
138 #else
139 typedef int32_t intmax_t;
140 typedef uint32_t uintmax_t;
141 #endif
142
143 /* 7.18.2. Limits of specified-width integer types */
144
145 #if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS)
146
147 /* 7.18.2.1. Limits of exact-width integer types */
148
149 #define INT8_MIN -128
150 #define INT8_MAX 127
151 #define UINT8_MAX 255U
152 #define INT16_MIN -32768
153 #define INT16_MAX 32767
154 #define UINT16_MAX 65535U
155 #define INT32_MIN (~INT32_MAX)
156 #define INT32_MAX 2147483647
157 #define UINT32_MAX 4294967295U
158 #ifdef _STDINT_H_HAVE_INT64
159 #define INT64_MIN (~INT64_MAX)
160 #if @HAVE_LONG_64BIT@
161 #define INT64_MAX 9223372036854775807L
162 #define UINT64_MAX 18446744073709551615UL
163 #elif @HAVE_LONG_LONG_64BIT@
164 #define INT64_MAX 9223372036854775807LL
165 #define UINT64_MAX 18446744073709551615ULL
166 #elif defined(_MSC_VER)
167 #define INT64_MAX 9223372036854775807i64
168 #define UINT64_MAX 18446744073709551615ui64
169 #endif
170 #endif
171
172 /* 7.18.2.2. Limits of minimum-width integer types */
173
174 #define INT_LEAST8_MIN INT8_MIN
175 #define INT_LEAST8_MAX INT8_MAX
176 #define UINT_LEAST8_MAX UINT8_MAX
177 #define INT_LEAST16_MIN INT16_MIN
178 #define INT_LEAST16_MAX INT16_MAX
179 #define UINT_LEAST16_MAX UINT16_MAX
180 #define INT_LEAST32_MIN INT32_MIN
181 #define INT_LEAST32_MAX INT32_MAX
182 #define UINT_LEAST32_MAX UINT32_MAX
183 #ifdef _STDINT_H_HAVE_INT64
184 #define INT_LEAST64_MIN INT64_MIN
185 #define INT_LEAST64_MAX INT64_MAX
186 #define UINT_LEAST64_MAX UINT64_MAX
187 #endif
188
189 /* 7.18.2.3. Limits of fastest minimum-width integer types */
190
191 #define INT_FAST8_MIN INT32_MIN
192 #define INT_FAST8_MAX INT32_MAX
193 #define UINT_FAST8_MAX UINT32_MAX
194 #define INT_FAST16_MIN INT32_MIN
195 #define INT_FAST16_MAX INT32_MAX
196 #define UINT_FAST16_MAX UINT32_MAX
197 #define INT_FAST32_MIN INT32_MIN
198 #define INT_FAST32_MAX INT32_MAX
199 #define UINT_FAST32_MAX UINT32_MAX
200 #ifdef _STDINT_H_HAVE_INT64
201 #define INT_FAST64_MIN INT64_MIN
202 #define INT_FAST64_MAX INT64_MAX
203 #define UINT_FAST64_MAX UINT64_MAX
204 #endif
205
206 /* 7.18.2.4. Limits of integer types capable of holding object pointers */
207
208 #define INTPTR_MIN LONG_MIN
209 #define INTPTR_MAX LONG_MAX
210 #define UINTPTR_MAX ULONG_MAX
211
212 /* 7.18.2.5. Limits of greatest-width integer types */
213
214 #ifdef _STDINT_H_HAVE_INT64
215 #define INTMAX_MIN INT64_MIN
216 #define INTMAX_MAX INT64_MAX
217 #define UINTMAX_MAX UINT64_MAX
218 #else
219 #define INTMAX_MIN INT32_MIN
220 #define INTMAX_MAX INT32_MAX
221 #define UINTMAX_MAX UINT32_MAX
222 #endif
223
224 /* 7.18.3. Limits of other integer types */
225
226 #define PTRDIFF_MIN (~(ptrdiff_t)0 << (sizeof(ptrdiff_t)*CHAR_BIT-1))
227 #define PTRDIFF_MAX (~PTRDIFF_MIN)
228
229 /* This may be wrong... */
230 #define SIG_ATOMIC_MIN 0
231 #define SIG_ATOMIC_MAX 127
232
233 #define SIZE_MAX (~(size_t)0)
234
235 /* wchar_t limits already defined in <stddef.h>. */
236 /* wint_t limits already defined in <wchar.h>. */
237
238 #endif
239
240 /* 7.18.4. Macros for integer constants */
241
242 #if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS)
243
244 /* 7.18.4.1. Macros for minimum-width integer constants */
245
246 #define INT8_C(x) x
247 #define UINT8_C(x) x##U
248 #define INT16_C(x) x
249 #define UINT16_C(x) x##U
250 #define INT32_C(x) x
251 #define UINT32_C(x) x##U
252 #if @HAVE_LONG_64BIT@
253 #define INT64_C(x) x##L
254 #define UINT64_C(x) x##UL
255 #elif @HAVE_LONG_LONG_64BIT@
256 #define INT64_C(x) x##LL
257 #define UINT64_C(x) x##ULL
258 #elif defined(_MSC_VER)
259 #define INT64_C(x) x##i64
260 #define UINT64_C(x) x##ui64
261 #endif
262
263 /* 7.18.4.2. Macros for greatest-width integer constants */
264
265 #if @HAVE_LONG_64BIT@
266 #define INTMAX_C(x) x##L
267 #define UINTMAX_C(x) x##UL
268 #elif @HAVE_LONG_LONG_64BIT@
269 #define INTMAX_C(x) x##LL
270 #define UINTMAX_C(x) x##ULL
271 #elif defined(_MSC_VER)
272 #define INTMAX_C(x) x##i64
273 #define UINTMAX_C(x) x##ui64
274 #else
275 #define INTMAX_C(x) x
276 #define UINTMAX_C(x) x##U
277 #endif
278
279 #endif
280
281 #endif /* !_STDINT_H_HAVE_SYSTEM_INTTYPES */
282
283 #endif /* _STDINT_H */
1 /* Copyright (C) 1991, 1996, 1997, 1998, 2002, 2003, 2004 Free Software
2 Foundation, Inc.
3
4 This file is part of the GNU C Library.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License along
17 with this program; if not, write to the Free Software Foundation,
18 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
19
20 #ifdef HAVE_CONFIG_H
21 # include <config.h>
22 #endif
23
24 #ifndef _LIBC
25 /* Get specification. */
26 # include "strdup.h"
27 #endif
28
29 #include <stdlib.h>
30 #include <string.h>
31
32 #undef __strdup
33 #undef strdup
34
35 #ifndef weak_alias
36 # define __strdup strdup
37 #endif
38
39 /* Duplicate S, returning an identical malloc'd string. */
40 char *
41 __strdup (const char *s)
42 {
43 size_t len = strlen (s) + 1;
44 void *new = malloc (len);
45
46 if (new == NULL)
47 return NULL;
48
49 return (char *) memcpy (new, s, len);
50 }
51 #ifdef libc_hidden_def
52 libc_hidden_def (__strdup)
53 #endif
54 #ifdef weak_alias
55 weak_alias (__strdup, strdup)
56 #endif
1 /* strdup.h -- duplicate a string
2 Copyright (C) 2004 Free Software Foundation, Inc.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
8
9 This program 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
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software Foundation,
16 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
17
18 #ifndef STRDUP_H_
19 #define STRDUP_H_
20
21 /* Get strdup declaration, if available. */
22 #include <string.h>
23
24 #if defined HAVE_DECL_STRDUP && !HAVE_DECL_STRDUP && !defined strdup
25 /* Duplicate S, returning an identical malloc'd string. */
26 extern char *strdup (const char *s);
27 #endif
28
29 #endif /* STRDUP_H_ */