Remove
Showing
81 changed files
with
0 additions
and
4889 deletions
mailbox/alloca.c
deleted
100644 → 0
This diff is collapsed.
Click to expand it.
mailbox/alloca_.h
deleted
100644 → 0
1 | /* Memory allocation on the stack. | ||
2 | |||
3 | Copyright (C) 1995, 1999, 2001, 2002, 2003, 2004, 2006 Free Software | ||
4 | Foundation, Inc. | ||
5 | |||
6 | This program is free software; you can redistribute it and/or modify it | ||
7 | under the terms of the GNU General Public License as published | ||
8 | by 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 GNU | ||
14 | General Public License for more details. | ||
15 | |||
16 | You should have received a copy of the GNU General Public | ||
17 | License along with this program; if not, write to the Free Software | ||
18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | ||
19 | USA. */ | ||
20 | |||
21 | /* Avoid using the symbol _ALLOCA_H here, as Bison assumes _ALLOCA_H | ||
22 | means there is a real alloca function. */ | ||
23 | #ifndef _GNULIB_ALLOCA_H | ||
24 | # define _GNULIB_ALLOCA_H | ||
25 | |||
26 | /* alloca (N) returns a pointer to N bytes of memory | ||
27 | allocated on the stack, which will last until the function returns. | ||
28 | Use of alloca should be avoided: | ||
29 | - inside arguments of function calls - undefined behaviour, | ||
30 | - in inline functions - the allocation may actually last until the | ||
31 | calling function returns, | ||
32 | - for huge N (say, N >= 65536) - you never know how large (or small) | ||
33 | the stack is, and when the stack cannot fulfill the memory allocation | ||
34 | request, the program just crashes. | ||
35 | */ | ||
36 | |||
37 | #ifndef alloca | ||
38 | # ifdef __GNUC__ | ||
39 | # define alloca __builtin_alloca | ||
40 | # elif defined _AIX | ||
41 | # define alloca __alloca | ||
42 | # elif defined _MSC_VER | ||
43 | # include <malloc.h> | ||
44 | # define alloca _alloca | ||
45 | # else | ||
46 | # include <stddef.h> | ||
47 | # ifdef __cplusplus | ||
48 | extern "C" | ||
49 | # endif | ||
50 | void *alloca (size_t); | ||
51 | # endif | ||
52 | #endif | ||
53 | |||
54 | #endif /* _GNULIB_ALLOCA_H */ |
mailbox/argp-ba.c
deleted
100644 → 0
1 | /* Default definition for ARGP_PROGRAM_BUG_ADDRESS. | ||
2 | Copyright (C) 1996, 1997, 1999 Free Software Foundation, Inc. | ||
3 | This file is part of the GNU C Library. | ||
4 | Written by Miles Bader <miles@gnu.ai.mit.edu>. | ||
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 | /* If set by the user program, it should point to string that is the | ||
21 | bug-reporting address for the program. It will be printed by argp_help if | ||
22 | the ARGP_HELP_BUG_ADDR flag is set (as it is by various standard help | ||
23 | messages), embedded in a sentence that says something like `Report bugs to | ||
24 | ADDR.'. */ | ||
25 | const char *argp_program_bug_address; |
mailbox/argp-eexst.c
deleted
100644 → 0
1 | /* Default definition for ARGP_ERR_EXIT_STATUS | ||
2 | Copyright (C) 1997 Free Software Foundation, Inc. | ||
3 | This file is part of the GNU C Library. | ||
4 | Written by Miles Bader <miles@gnu.ai.mit.edu>. | ||
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 | #include <sysexits.h> | ||
25 | |||
26 | #include "argp.h" | ||
27 | |||
28 | /* The exit status that argp will use when exiting due to a parsing error. | ||
29 | If not defined or set by the user program, this defaults to EX_USAGE from | ||
30 | <sysexits.h>. */ | ||
31 | error_t argp_err_exit_status = EX_USAGE; |
mailbox/argp-fmtstream.c
deleted
100644 → 0
This diff is collapsed.
Click to expand it.
mailbox/argp-fmtstream.h
deleted
100644 → 0
This diff is collapsed.
Click to expand it.
mailbox/argp-fs-xinl.c
deleted
100644 → 0
1 | /* Real definitions for extern inline functions in argp-fmtstream.h | ||
2 | Copyright (C) 1997, 2003, 2004 Free Software Foundation, Inc. | ||
3 | This file is part of the GNU C Library. | ||
4 | Written by Miles Bader <miles@gnu.ai.mit.edu>. | ||
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 | #define ARGP_FS_EI | ||
25 | #undef __OPTIMIZE__ | ||
26 | #define __OPTIMIZE__ 1 | ||
27 | #include "argp-fmtstream.h" | ||
28 | |||
29 | #if 0 | ||
30 | /* Not exported. */ | ||
31 | /* Add weak aliases. */ | ||
32 | #if _LIBC - 0 && !defined (ARGP_FMTSTREAM_USE_LINEWRAP) && defined (weak_alias) | ||
33 | |||
34 | weak_alias (__argp_fmtstream_putc, argp_fmtstream_putc) | ||
35 | weak_alias (__argp_fmtstream_puts, argp_fmtstream_puts) | ||
36 | weak_alias (__argp_fmtstream_write, argp_fmtstream_write) | ||
37 | weak_alias (__argp_fmtstream_set_lmargin, argp_fmtstream_set_lmargin) | ||
38 | weak_alias (__argp_fmtstream_set_rmargin, argp_fmtstream_set_rmargin) | ||
39 | weak_alias (__argp_fmtstream_set_wmargin, argp_fmtstream_set_wmargin) | ||
40 | weak_alias (__argp_fmtstream_point, argp_fmtstream_point) | ||
41 | |||
42 | #endif | ||
43 | #endif |
mailbox/argp-help.c
deleted
100644 → 0
This diff is collapsed.
Click to expand it.
mailbox/argp-namefrob.h
deleted
100644 → 0
1 | /* Name frobnication for compiling argp outside of glibc | ||
2 | Copyright (C) 1997, 2003 Free Software Foundation, Inc. | ||
3 | This file is part of the GNU C Library. | ||
4 | Written by Miles Bader <miles@gnu.ai.mit.edu>. | ||
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 | #if !_LIBC | ||
21 | /* This code is written for inclusion in gnu-libc, and uses names in the | ||
22 | namespace reserved for libc. If we're not compiling in libc, define those | ||
23 | names to be the normal ones instead. */ | ||
24 | |||
25 | /* argp-parse functions */ | ||
26 | #undef __argp_parse | ||
27 | #define __argp_parse argp_parse | ||
28 | #undef __option_is_end | ||
29 | #define __option_is_end _option_is_end | ||
30 | #undef __option_is_short | ||
31 | #define __option_is_short _option_is_short | ||
32 | #undef __argp_input | ||
33 | #define __argp_input _argp_input | ||
34 | |||
35 | /* argp-help functions */ | ||
36 | #undef __argp_help | ||
37 | #define __argp_help argp_help | ||
38 | #undef __argp_error | ||
39 | #define __argp_error argp_error | ||
40 | #undef __argp_failure | ||
41 | #define __argp_failure argp_failure | ||
42 | #undef __argp_state_help | ||
43 | #define __argp_state_help argp_state_help | ||
44 | #undef __argp_usage | ||
45 | #define __argp_usage argp_usage | ||
46 | |||
47 | /* argp-fmtstream functions */ | ||
48 | #undef __argp_make_fmtstream | ||
49 | #define __argp_make_fmtstream argp_make_fmtstream | ||
50 | #undef __argp_fmtstream_free | ||
51 | #define __argp_fmtstream_free argp_fmtstream_free | ||
52 | #undef __argp_fmtstream_putc | ||
53 | #define __argp_fmtstream_putc argp_fmtstream_putc | ||
54 | #undef __argp_fmtstream_puts | ||
55 | #define __argp_fmtstream_puts argp_fmtstream_puts | ||
56 | #undef __argp_fmtstream_write | ||
57 | #define __argp_fmtstream_write argp_fmtstream_write | ||
58 | #undef __argp_fmtstream_printf | ||
59 | #define __argp_fmtstream_printf argp_fmtstream_printf | ||
60 | #undef __argp_fmtstream_set_lmargin | ||
61 | #define __argp_fmtstream_set_lmargin argp_fmtstream_set_lmargin | ||
62 | #undef __argp_fmtstream_set_rmargin | ||
63 | #define __argp_fmtstream_set_rmargin argp_fmtstream_set_rmargin | ||
64 | #undef __argp_fmtstream_set_wmargin | ||
65 | #define __argp_fmtstream_set_wmargin argp_fmtstream_set_wmargin | ||
66 | #undef __argp_fmtstream_point | ||
67 | #define __argp_fmtstream_point argp_fmtstream_point | ||
68 | #undef __argp_fmtstream_update | ||
69 | #define __argp_fmtstream_update _argp_fmtstream_update | ||
70 | #undef __argp_fmtstream_ensure | ||
71 | #define __argp_fmtstream_ensure _argp_fmtstream_ensure | ||
72 | #undef __argp_fmtstream_lmargin | ||
73 | #define __argp_fmtstream_lmargin argp_fmtstream_lmargin | ||
74 | #undef __argp_fmtstream_rmargin | ||
75 | #define __argp_fmtstream_rmargin argp_fmtstream_rmargin | ||
76 | #undef __argp_fmtstream_wmargin | ||
77 | #define __argp_fmtstream_wmargin argp_fmtstream_wmargin | ||
78 | |||
79 | #include "mempcpy.h" | ||
80 | #include "strcase.h" | ||
81 | #include "strchrnul.h" | ||
82 | #include "strndup.h" | ||
83 | |||
84 | /* normal libc functions we call */ | ||
85 | #undef __flockfile | ||
86 | #define __flockfile flockfile | ||
87 | #undef __funlockfile | ||
88 | #define __funlockfile funlockfile | ||
89 | #undef __mempcpy | ||
90 | #define __mempcpy mempcpy | ||
91 | #undef __sleep | ||
92 | #define __sleep sleep | ||
93 | #undef __strcasecmp | ||
94 | #define __strcasecmp strcasecmp | ||
95 | #undef __strchrnul | ||
96 | #define __strchrnul strchrnul | ||
97 | #undef __strerror_r | ||
98 | #define __strerror_r strerror_r | ||
99 | #undef __strndup | ||
100 | #define __strndup strndup | ||
101 | #undef __vsnprintf | ||
102 | #define __vsnprintf vsnprintf | ||
103 | |||
104 | #if defined(HAVE_DECL_CLEARERR_UNLOCKED) && !HAVE_DECL_CLEARERR_UNLOCKED | ||
105 | # define clearerr_unlocked(x) clearerr (x) | ||
106 | #endif | ||
107 | #if defined(HAVE_DECL_FEOF_UNLOCKED) && !HAVE_DECL_FEOF_UNLOCKED | ||
108 | # define feof_unlocked(x) feof (x) | ||
109 | # endif | ||
110 | #if defined(HAVE_DECL_FERROR_UNLOCKED) && !HAVE_DECL_FERROR_UNLOCKED | ||
111 | # define ferror_unlocked(x) ferror (x) | ||
112 | # endif | ||
113 | #if defined(HAVE_DECL_FFLUSH_UNLOCKED) && !HAVE_DECL_FFLUSH_UNLOCKED | ||
114 | # define fflush_unlocked(x) fflush (x) | ||
115 | # endif | ||
116 | #if defined(HAVE_DECL_FGETS_UNLOCKED) && !HAVE_DECL_FGETS_UNLOCKED | ||
117 | # define fgets_unlocked(x,y,z) fgets (x,y,z) | ||
118 | # endif | ||
119 | #if defined(HAVE_DECL_FPUTC_UNLOCKED) && !HAVE_DECL_FPUTC_UNLOCKED | ||
120 | # define fputc_unlocked(x,y) fputc (x,y) | ||
121 | # endif | ||
122 | #if defined(HAVE_DECL_FPUTS_UNLOCKED) && !HAVE_DECL_FPUTS_UNLOCKED | ||
123 | # define fputs_unlocked(x,y) fputs (x,y) | ||
124 | # endif | ||
125 | #if defined(HAVE_DECL_FREAD_UNLOCKED) && !HAVE_DECL_FREAD_UNLOCKED | ||
126 | # define fread_unlocked(w,x,y,z) fread (w,x,y,z) | ||
127 | # endif | ||
128 | #if defined(HAVE_DECL_FWRITE_UNLOCKED) && !HAVE_DECL_FWRITE_UNLOCKED | ||
129 | # define fwrite_unlocked(w,x,y,z) fwrite (w,x,y,z) | ||
130 | # endif | ||
131 | #if defined(HAVE_DECL_GETC_UNLOCKED) && !HAVE_DECL_GETC_UNLOCKED | ||
132 | # define getc_unlocked(x) getc (x) | ||
133 | # endif | ||
134 | #if defined(HAVE_DECL_GETCHAR_UNLOCKED) && !HAVE_DECL_GETCHAR_UNLOCKED | ||
135 | # define getchar_unlocked() getchar () | ||
136 | # endif | ||
137 | #if defined(HAVE_DECL_PUTC_UNLOCKED) && !HAVE_DECL_PUTC_UNLOCKED | ||
138 | # define putc_unlocked(x,y) putc (x,y) | ||
139 | # endif | ||
140 | #if defined(HAVE_DECL_PUTCHAR_UNLOCKED) && !HAVE_DECL_PUTCHAR_UNLOCKED | ||
141 | # define putchar_unlocked(x) putchar (x) | ||
142 | # endif | ||
143 | |||
144 | #endif /* !_LIBC */ | ||
145 | |||
146 | #ifndef __set_errno | ||
147 | #define __set_errno(e) (errno = (e)) | ||
148 | #endif | ||
149 | |||
150 | #if defined GNULIB_ARGP_DISABLE_DIRNAME | ||
151 | # define __argp_base_name(arg) arg | ||
152 | #elif defined GNULIB_ARGP_EXTERN_BASENAME | ||
153 | extern char *__argp_base_name(const char *arg); | ||
154 | #else | ||
155 | # include "dirname.h" | ||
156 | # define __argp_base_name base_name | ||
157 | #endif | ||
158 | |||
159 | #if defined _LIBC || HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME | ||
160 | # define __argp_short_program_name() (program_invocation_short_name) | ||
161 | #else | ||
162 | extern char *__argp_short_program_name (void); | ||
163 | #endif |
mailbox/argp-parse.c
deleted
100644 → 0
This diff is collapsed.
Click to expand it.
mailbox/argp-pin.c
deleted
100644 → 0
1 | /* Full and short program names for argp module | ||
2 | Copyright (C) 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 along | ||
15 | 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 | #ifdef HAVE_CONFIG_H | ||
19 | # include <config.h> | ||
20 | #endif | ||
21 | |||
22 | #ifndef HAVE_PROGRAM_INVOCATION_SHORT_NAME | ||
23 | char *program_invocation_short_name = 0; | ||
24 | #endif | ||
25 | #ifndef HAVE_PROGRAM_INVOCATION_NAME | ||
26 | char *program_invocation_name = 0; | ||
27 | #endif | ||
28 |
mailbox/argp-pv.c
deleted
100644 → 0
1 | /* Default definition for ARGP_PROGRAM_VERSION. | ||
2 | Copyright (C) 1996, 1997, 1999, 2006 Free Software Foundation, Inc. | ||
3 | This file is part of the GNU C Library. | ||
4 | Written by Miles Bader <miles@gnu.ai.mit.edu>. | ||
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 | /* If set by the user program to a non-zero value, then a default option | ||
21 | --version is added (unless the ARGP_NO_HELP flag is used), which will | ||
22 | print this string followed by a newline and exit (unless the | ||
23 | ARGP_NO_EXIT flag is used). Overridden by ARGP_PROGRAM_VERSION_HOOK. */ | ||
24 | const char *argp_program_version; |
mailbox/argp-pvh.c
deleted
100644 → 0
1 | /* Default definition for ARGP_PROGRAM_VERSION_HOOK. | ||
2 | Copyright (C) 1996, 1997, 1999, 2004 Free Software Foundation, Inc. | ||
3 | This file is part of the GNU C Library. | ||
4 | Written by Miles Bader <miles@gnu.ai.mit.edu>. | ||
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 | #include "argp.h" | ||
25 | |||
26 | /* If set by the user program to a non-zero value, then a default option | ||
27 | --version is added (unless the ARGP_NO_HELP flag is used), which calls | ||
28 | this function with a stream to print the version to and a pointer to the | ||
29 | current parsing state, and then exits (unless the ARGP_NO_EXIT flag is | ||
30 | used). This variable takes precedent over ARGP_PROGRAM_VERSION. */ | ||
31 | void (*argp_program_version_hook) (FILE *stream, struct argp_state *state) = NULL; |
mailbox/argp-xinl.c
deleted
100644 → 0
1 | /* Real definitions for extern inline functions in argp.h | ||
2 | Copyright (C) 1997, 1998, 2004 Free Software Foundation, Inc. | ||
3 | This file is part of the GNU C Library. | ||
4 | Written by Miles Bader <miles@gnu.ai.mit.edu>. | ||
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 | #if defined _LIBC || defined HAVE_FEATURES_H | ||
25 | # include <features.h> | ||
26 | #endif | ||
27 | |||
28 | #ifndef __USE_EXTERN_INLINES | ||
29 | # define __USE_EXTERN_INLINES 1 | ||
30 | #endif | ||
31 | #define ARGP_EI | ||
32 | #undef __OPTIMIZE__ | ||
33 | #define __OPTIMIZE__ 1 | ||
34 | #include "argp.h" | ||
35 | |||
36 | /* Add weak aliases. */ | ||
37 | #if _LIBC - 0 && defined (weak_alias) | ||
38 | |||
39 | weak_alias (__argp_usage, argp_usage) | ||
40 | weak_alias (__option_is_short, _option_is_short) | ||
41 | weak_alias (__option_is_end, _option_is_end) | ||
42 | |||
43 | #endif |
mailbox/argp.h
deleted
100644 → 0
This diff is collapsed.
Click to expand it.
mailbox/asnprintf.c
deleted
100644 → 0
1 | /* Formatted output to strings. | ||
2 | Copyright (C) 1999, 2002 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 along | ||
15 | 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 | #ifdef HAVE_CONFIG_H | ||
19 | # include <config.h> | ||
20 | #endif | ||
21 | |||
22 | /* Specification. */ | ||
23 | #include "vasnprintf.h" | ||
24 | |||
25 | #include <stdarg.h> | ||
26 | |||
27 | char * | ||
28 | asnprintf (char *resultbuf, size_t *lengthp, const char *format, ...) | ||
29 | { | ||
30 | va_list args; | ||
31 | char *result; | ||
32 | |||
33 | va_start (args, format); | ||
34 | result = vasnprintf (resultbuf, lengthp, format, args); | ||
35 | va_end (args); | ||
36 | return result; | ||
37 | } |
mailbox/fnmatch.c
deleted
100644 → 0
This diff is collapsed.
Click to expand it.
mailbox/fnmatch_.h
deleted
100644 → 0
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 */ |
mailbox/fnmatch_loop.c
deleted
100644 → 0
This diff is collapsed.
Click to expand it.
mailbox/getdelim.c
deleted
100644 → 0
1 | /* getdelim.c --- Implementation of replacement getdelim function. | ||
2 | Copyright (C) 1994, 1996, 1997, 1998, 2001, 2003, 2005 Free | ||
3 | Software Foundation, Inc. | ||
4 | |||
5 | This program is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU General Public License as | ||
7 | published by the Free Software Foundation; either version 2, or (at | ||
8 | your option) any later version. | ||
9 | |||
10 | This program is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | 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 | ||
17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
18 | 02110-1301, USA. */ | ||
19 | |||
20 | /* Ported from glibc by Simon Josefsson. */ | ||
21 | |||
22 | #ifdef HAVE_CONFIG_H | ||
23 | # include <config.h> | ||
24 | #endif | ||
25 | |||
26 | #include "getdelim.h" | ||
27 | |||
28 | #include <limits.h> | ||
29 | #include <stdlib.h> | ||
30 | #include <errno.h> | ||
31 | |||
32 | #ifndef SIZE_MAX | ||
33 | # define SIZE_MAX ((size_t) -1) | ||
34 | #endif | ||
35 | #ifndef SSIZE_MAX | ||
36 | # define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2)) | ||
37 | #endif | ||
38 | #if !HAVE_FLOCKFILE | ||
39 | # undef flockfile | ||
40 | # define flockfile(x) ((void) 0) | ||
41 | #endif | ||
42 | #if !HAVE_FUNLOCKFILE | ||
43 | # undef funlockfile | ||
44 | # define funlockfile(x) ((void) 0) | ||
45 | #endif | ||
46 | |||
47 | /* Read up to (and including) a DELIMITER from FP into *LINEPTR (and | ||
48 | NUL-terminate it). *LINEPTR is a pointer returned from malloc (or | ||
49 | NULL), pointing to *N characters of space. It is realloc'ed as | ||
50 | necessary. Returns the number of characters read (not including | ||
51 | the null terminator), or -1 on error or EOF. */ | ||
52 | |||
53 | ssize_t | ||
54 | getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp) | ||
55 | { | ||
56 | ssize_t result; | ||
57 | size_t cur_len = 0; | ||
58 | |||
59 | if (lineptr == NULL || n == NULL || fp == NULL) | ||
60 | { | ||
61 | errno = EINVAL; | ||
62 | return -1; | ||
63 | } | ||
64 | |||
65 | flockfile (fp); | ||
66 | |||
67 | if (*lineptr == NULL || *n == 0) | ||
68 | { | ||
69 | *n = 120; | ||
70 | *lineptr = (char *) malloc (*n); | ||
71 | if (*lineptr == NULL) | ||
72 | { | ||
73 | result = -1; | ||
74 | goto unlock_return; | ||
75 | } | ||
76 | } | ||
77 | |||
78 | for (;;) | ||
79 | { | ||
80 | int i; | ||
81 | |||
82 | i = getc (fp); | ||
83 | if (i == EOF) | ||
84 | { | ||
85 | result = -1; | ||
86 | break; | ||
87 | } | ||
88 | |||
89 | /* Make enough space for len+1 (for final NUL) bytes. */ | ||
90 | if (cur_len + 1 >= *n) | ||
91 | { | ||
92 | size_t needed_max = | ||
93 | SSIZE_MAX < SIZE_MAX ? (size_t) SSIZE_MAX + 1 : SIZE_MAX; | ||
94 | size_t needed = 2 * *n + 1; /* Be generous. */ | ||
95 | char *new_lineptr; | ||
96 | |||
97 | if (needed_max < needed) | ||
98 | needed = needed_max; | ||
99 | if (cur_len + 1 >= needed) | ||
100 | { | ||
101 | result = -1; | ||
102 | goto unlock_return; | ||
103 | } | ||
104 | |||
105 | new_lineptr = (char *) realloc (*lineptr, needed); | ||
106 | if (new_lineptr == NULL) | ||
107 | { | ||
108 | result = -1; | ||
109 | goto unlock_return; | ||
110 | } | ||
111 | |||
112 | *lineptr = new_lineptr; | ||
113 | *n = needed; | ||
114 | } | ||
115 | |||
116 | (*lineptr)[cur_len] = i; | ||
117 | cur_len++; | ||
118 | |||
119 | if (i == delimiter) | ||
120 | break; | ||
121 | } | ||
122 | (*lineptr)[cur_len] = '\0'; | ||
123 | result = cur_len ? cur_len : result; | ||
124 | |||
125 | unlock_return: | ||
126 | funlockfile (fp); | ||
127 | return result; | ||
128 | } |
mailbox/getdelim.h
deleted
100644 → 0
1 | /* getdelim.h --- Prototype for replacement getdelim function. | ||
2 | Copyright (C) 2005 Free Software Foundation, Inc. | ||
3 | |||
4 | This program is free software; you can redistribute it and/or | ||
5 | modify it under the terms of the GNU General Public License as | ||
6 | published by the Free Software Foundation; either version 2, or (at | ||
7 | your option) any later version. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, but | ||
10 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | 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 | ||
16 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
17 | 02110-1301, USA. */ | ||
18 | |||
19 | /* Written by Simon Josefsson. */ | ||
20 | |||
21 | /* Get size_t, FILE, ssize_t. And getdelim, if available. */ | ||
22 | # include <stddef.h> | ||
23 | # include <stdio.h> | ||
24 | # include <sys/types.h> | ||
25 | |||
26 | #if !HAVE_DECL_GETDELIM | ||
27 | ssize_t getdelim (char **lineptr, size_t *n, int delimiter, FILE *stream); | ||
28 | #endif /* !HAVE_GETDELIM */ |
mailbox/getline.c
deleted
100644 → 0
1 | /* getline.c --- Implementation of replacement getline function. | ||
2 | Copyright (C) 2005 Free Software Foundation, Inc. | ||
3 | |||
4 | This program is free software; you can redistribute it and/or | ||
5 | modify it under the terms of the GNU General Public License as | ||
6 | published by the Free Software Foundation; either version 2, or (at | ||
7 | your option) any later version. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, but | ||
10 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | 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 | ||
16 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
17 | 02110-1301, USA. */ | ||
18 | |||
19 | /* Written by Simon Josefsson. */ | ||
20 | |||
21 | #ifdef HAVE_CONFIG_H | ||
22 | # include <config.h> | ||
23 | #endif | ||
24 | |||
25 | #include "getdelim.h" | ||
26 | #include "getline.h" | ||
27 | |||
28 | ssize_t | ||
29 | getline (char **lineptr, size_t *n, FILE *stream) | ||
30 | { | ||
31 | return getdelim (lineptr, n, '\n', stream); | ||
32 | } |
mailbox/getline.h
deleted
100644 → 0
1 | /* getline.h --- Prototype for replacement getline function. | ||
2 | Copyright (C) 2005 Free Software Foundation, Inc. | ||
3 | |||
4 | This program is free software; you can redistribute it and/or | ||
5 | modify it under the terms of the GNU General Public License as | ||
6 | published by the Free Software Foundation; either version 2, or (at | ||
7 | your option) any later version. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, but | ||
10 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | 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 | ||
16 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
17 | 02110-1301, USA. */ | ||
18 | |||
19 | /* Written by Simon Josefsson. */ | ||
20 | |||
21 | /* Get size_t, FILE, ssize_t. And getline, if available. */ | ||
22 | # include <stddef.h> | ||
23 | # include <stdio.h> | ||
24 | # include <sys/types.h> | ||
25 | |||
26 | #if !HAVE_DECL_GETLINE | ||
27 | ssize_t getline (char **lineptr, size_t *n, FILE *stream); | ||
28 | #endif /* !HAVE_GETLINE */ |
mailbox/getlogin_r.c
deleted
100644 → 0
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 | #include <unistd.h> | ||
30 | |||
31 | #if !HAVE_DECL_GETLOGIN | ||
32 | char *getlogin (void); | ||
33 | #endif | ||
34 | |||
35 | /* See getlogin_r.h for documentation. */ | ||
36 | int | ||
37 | getlogin_r (char *name, size_t size) | ||
38 | { | ||
39 | char *n; | ||
40 | size_t nlen; | ||
41 | |||
42 | errno = 0; | ||
43 | n = getlogin (); | ||
44 | |||
45 | /* A system function like getlogin_r is never supposed to set errno | ||
46 | to zero, so make sure errno is nonzero here. ENOENT is a | ||
47 | reasonable errno value if getlogin returns NULL. */ | ||
48 | if (!errno) | ||
49 | errno = ENOENT; | ||
50 | |||
51 | if (!n) | ||
52 | return errno; | ||
53 | nlen = strlen (n); | ||
54 | if (size <= nlen) | ||
55 | return ERANGE; | ||
56 | memcpy (name, n, nlen + 1); | ||
57 | return 0; | ||
58 | } |
mailbox/getlogin_r.h
deleted
100644 → 0
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 | #include <unistd.h> | ||
23 | |||
24 | /* Copies the user's login name to NAME. | ||
25 | The array pointed to by NAME has room for SIZE bytes. | ||
26 | |||
27 | Returns 0 if successful. Upon error, an error number is returned, or -1 in | ||
28 | the case that the login name cannot be found but no specific error is | ||
29 | provided (this case is hopefully rare but is left open by the POSIX spec). | ||
30 | |||
31 | See <http://www.opengroup.org/susv3xsh/getlogin.html>. | ||
32 | */ | ||
33 | #if !HAVE_DECL_GETLOGIN_R | ||
34 | int getlogin_r (char *name, size_t size); | ||
35 | #endif |
mailbox/getndelim2.c
deleted
100644 → 0
1 | /* getndelim2 - Read a line from a stream, stopping at one of 2 delimiters, | ||
2 | with bounded memory allocation. | ||
3 | |||
4 | Copyright (C) 1993, 1996, 1997, 1998, 2000, 2003, 2004 Free Software | ||
5 | Foundation, Inc. | ||
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 | ||
18 | License along with this program; if not, write to the Free | ||
19 | Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
20 | Boston, MA 02110-1301 USA. */ | ||
21 | |||
22 | /* Originally written by Jan Brittenson, bson@gnu.ai.mit.edu. */ | ||
23 | |||
24 | #if HAVE_CONFIG_H | ||
25 | # include <config.h> | ||
26 | #endif | ||
27 | |||
28 | #include "getndelim2.h" | ||
29 | |||
30 | #include <stdlib.h> | ||
31 | #include <stddef.h> | ||
32 | |||
33 | #if USE_UNLOCKED_IO | ||
34 | # include "unlocked-io.h" | ||
35 | #endif | ||
36 | |||
37 | #include <limits.h> | ||
38 | #if HAVE_INTTYPES_H | ||
39 | # include <inttypes.h> | ||
40 | #endif | ||
41 | #if HAVE_STDINT_H | ||
42 | # include <stdint.h> | ||
43 | #endif | ||
44 | #ifndef PTRDIFF_MAX | ||
45 | # define PTRDIFF_MAX ((ptrdiff_t) (SIZE_MAX / 2)) | ||
46 | #endif | ||
47 | #ifndef SIZE_MAX | ||
48 | # define SIZE_MAX ((size_t) -1) | ||
49 | #endif | ||
50 | #ifndef SSIZE_MAX | ||
51 | # define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2)) | ||
52 | #endif | ||
53 | |||
54 | /* The maximum value that getndelim2 can return without suffering from | ||
55 | overflow problems, either internally (because of pointer | ||
56 | subtraction overflow) or due to the API (because of ssize_t). */ | ||
57 | #define GETNDELIM2_MAXIMUM (PTRDIFF_MAX < SSIZE_MAX ? PTRDIFF_MAX : SSIZE_MAX) | ||
58 | |||
59 | /* Try to add at least this many bytes when extending the buffer. | ||
60 | MIN_CHUNK must be no greater than GETNDELIM2_MAXIMUM. */ | ||
61 | #define MIN_CHUNK 64 | ||
62 | |||
63 | ssize_t | ||
64 | getndelim2 (char **lineptr, size_t *linesize, size_t offset, size_t nmax, | ||
65 | int delim1, int delim2, FILE *stream) | ||
66 | { | ||
67 | size_t nbytes_avail; /* Allocated but unused bytes in *LINEPTR. */ | ||
68 | char *read_pos; /* Where we're reading into *LINEPTR. */ | ||
69 | ssize_t bytes_stored = -1; | ||
70 | char *ptr = *lineptr; | ||
71 | size_t size = *linesize; | ||
72 | |||
73 | if (!ptr) | ||
74 | { | ||
75 | size = nmax < MIN_CHUNK ? nmax : MIN_CHUNK; | ||
76 | ptr = malloc (size); | ||
77 | if (!ptr) | ||
78 | return -1; | ||
79 | } | ||
80 | |||
81 | if (size < offset) | ||
82 | goto done; | ||
83 | |||
84 | nbytes_avail = size - offset; | ||
85 | read_pos = ptr + offset; | ||
86 | |||
87 | if (nbytes_avail == 0 && nmax <= size) | ||
88 | goto done; | ||
89 | |||
90 | for (;;) | ||
91 | { | ||
92 | /* Here always ptr + size == read_pos + nbytes_avail. */ | ||
93 | |||
94 | int c; | ||
95 | |||
96 | /* We always want at least one byte left in the buffer, since we | ||
97 | always (unless we get an error while reading the first byte) | ||
98 | NUL-terminate the line buffer. */ | ||
99 | |||
100 | if (nbytes_avail < 2 && size < nmax) | ||
101 | { | ||
102 | size_t newsize = size < MIN_CHUNK ? size + MIN_CHUNK : 2 * size; | ||
103 | char *newptr; | ||
104 | |||
105 | if (! (size < newsize && newsize <= nmax)) | ||
106 | newsize = nmax; | ||
107 | |||
108 | if (GETNDELIM2_MAXIMUM < newsize - offset) | ||
109 | { | ||
110 | size_t newsizemax = offset + GETNDELIM2_MAXIMUM + 1; | ||
111 | if (size == newsizemax) | ||
112 | goto done; | ||
113 | newsize = newsizemax; | ||
114 | } | ||
115 | |||
116 | nbytes_avail = newsize - (read_pos - ptr); | ||
117 | newptr = realloc (ptr, newsize); | ||
118 | if (!newptr) | ||
119 | goto done; | ||
120 | ptr = newptr; | ||
121 | size = newsize; | ||
122 | read_pos = size - nbytes_avail + ptr; | ||
123 | } | ||
124 | |||
125 | c = getc (stream); | ||
126 | if (c == EOF) | ||
127 | { | ||
128 | /* Return partial line, if any. */ | ||
129 | if (read_pos == ptr) | ||
130 | goto done; | ||
131 | else | ||
132 | break; | ||
133 | } | ||
134 | |||
135 | if (nbytes_avail >= 2) | ||
136 | { | ||
137 | *read_pos++ = c; | ||
138 | nbytes_avail--; | ||
139 | } | ||
140 | |||
141 | if (c == delim1 || c == delim2) | ||
142 | /* Return the line. */ | ||
143 | break; | ||
144 | } | ||
145 | |||
146 | /* Done - NUL terminate and return the number of bytes read. | ||
147 | At this point we know that nbytes_avail >= 1. */ | ||
148 | *read_pos = '\0'; | ||
149 | |||
150 | bytes_stored = read_pos - (ptr + offset); | ||
151 | |||
152 | done: | ||
153 | *lineptr = ptr; | ||
154 | *linesize = size; | ||
155 | return bytes_stored; | ||
156 | } |
mailbox/getndelim2.h
deleted
100644 → 0
1 | /* getndelim2 - Read a line from a stream, stopping at one of 2 delimiters, | ||
2 | with bounded memory allocation. | ||
3 | |||
4 | Copyright (C) 2003, 2004 Free Software Foundation, Inc. | ||
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 | ||
17 | License along with this program; if not, write to the Free | ||
18 | Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
19 | Boston, MA 02110-1301 USA. */ | ||
20 | |||
21 | #ifndef GETNDELIM2_H | ||
22 | #define GETNDELIM2_H 1 | ||
23 | |||
24 | #include <stdio.h> | ||
25 | #include <sys/types.h> | ||
26 | |||
27 | #define GETNLINE_NO_LIMIT ((size_t) -1) | ||
28 | |||
29 | /* Read into a buffer *LINEPTR returned from malloc (or NULL), | ||
30 | pointing to *LINESIZE bytes of space. Store the input bytes | ||
31 | starting at *LINEPTR + OFFSET, and null-terminate them. Reallocate | ||
32 | the buffer as necessary, but if NMAX is not GETNLINE_NO_LIMIT | ||
33 | then do not allocate more than NMAX bytes; if the line is longer | ||
34 | than that, read and discard the extra bytes. Stop reading after | ||
35 | after the first occurrence of DELIM1 or DELIM2, whichever comes | ||
36 | first; a delimiter equal to EOF stands for no delimiter. Read the | ||
37 | input bytes from STREAM. | ||
38 | Return the number of bytes read and stored at *LINEPTR + OFFSET (not | ||
39 | including the NUL terminator), or -1 on error or EOF. */ | ||
40 | extern ssize_t getndelim2 (char **lineptr, size_t *linesize, size_t offset, | ||
41 | size_t nmax, int delim1, int delim2, | ||
42 | FILE *stream); | ||
43 | |||
44 | #endif /* GETNDELIM2_H */ |
mailbox/getopt.c
deleted
100644 → 0
This diff is collapsed.
Click to expand it.
mailbox/getopt.h
deleted
100644 → 0
1 | /* Declarations for getopt. | ||
2 | Copyright (C) 1989-1994,1996-1999,2001,2003,2004,2005 | ||
3 | Free Software Foundation, Inc. | ||
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 | #ifndef _GETOPT_H | ||
21 | |||
22 | #ifndef __need_getopt | ||
23 | # define _GETOPT_H 1 | ||
24 | #endif | ||
25 | |||
26 | /* Standalone applications should #define __GETOPT_PREFIX to an | ||
27 | identifier that prefixes the external functions and variables | ||
28 | defined in this header. When this happens, include the | ||
29 | headers that might declare getopt so that they will not cause | ||
30 | confusion if included after this file. Then systematically rename | ||
31 | identifiers so that they do not collide with the system functions | ||
32 | and variables. Renaming avoids problems with some compilers and | ||
33 | linkers. */ | ||
34 | #if defined __GETOPT_PREFIX && !defined __need_getopt | ||
35 | # include <stdlib.h> | ||
36 | # include <stdio.h> | ||
37 | # include <unistd.h> | ||
38 | # undef __need_getopt | ||
39 | # undef getopt | ||
40 | # undef getopt_long | ||
41 | # undef getopt_long_only | ||
42 | # undef optarg | ||
43 | # undef opterr | ||
44 | # undef optind | ||
45 | # undef optopt | ||
46 | # define __GETOPT_CONCAT(x, y) x ## y | ||
47 | # define __GETOPT_XCONCAT(x, y) __GETOPT_CONCAT (x, y) | ||
48 | # define __GETOPT_ID(y) __GETOPT_XCONCAT (__GETOPT_PREFIX, y) | ||
49 | # define getopt __GETOPT_ID (getopt) | ||
50 | # define getopt_long __GETOPT_ID (getopt_long) | ||
51 | # define getopt_long_only __GETOPT_ID (getopt_long_only) | ||
52 | # define optarg __GETOPT_ID (optarg) | ||
53 | # define opterr __GETOPT_ID (opterr) | ||
54 | # define optind __GETOPT_ID (optind) | ||
55 | # define optopt __GETOPT_ID (optopt) | ||
56 | #endif | ||
57 | |||
58 | /* Standalone applications get correct prototypes for getopt_long and | ||
59 | getopt_long_only; they declare "char **argv". libc uses prototypes | ||
60 | with "char *const *argv" that are incorrect because getopt_long and | ||
61 | getopt_long_only can permute argv; this is required for backward | ||
62 | compatibility (e.g., for LSB 2.0.1). | ||
63 | |||
64 | This used to be `#if defined __GETOPT_PREFIX && !defined __need_getopt', | ||
65 | but it caused redefinition warnings if both unistd.h and getopt.h were | ||
66 | included, since unistd.h includes getopt.h having previously defined | ||
67 | __need_getopt. | ||
68 | |||
69 | The only place where __getopt_argv_const is used is in definitions | ||
70 | of getopt_long and getopt_long_only below, but these are visible | ||
71 | only if __need_getopt is not defined, so it is quite safe to rewrite | ||
72 | the conditional as follows: | ||
73 | */ | ||
74 | #if !defined __need_getopt | ||
75 | # if defined __GETOPT_PREFIX | ||
76 | # define __getopt_argv_const /* empty */ | ||
77 | # else | ||
78 | # define __getopt_argv_const const | ||
79 | # endif | ||
80 | #endif | ||
81 | |||
82 | /* If __GNU_LIBRARY__ is not already defined, either we are being used | ||
83 | standalone, or this is the first header included in the source file. | ||
84 | If we are being used with glibc, we need to include <features.h>, but | ||
85 | that does not exist if we are standalone. So: if __GNU_LIBRARY__ is | ||
86 | not defined, include <ctype.h>, which will pull in <features.h> for us | ||
87 | if it's from glibc. (Why ctype.h? It's guaranteed to exist and it | ||
88 | doesn't flood the namespace with stuff the way some other headers do.) */ | ||
89 | #if !defined __GNU_LIBRARY__ | ||
90 | # include <ctype.h> | ||
91 | #endif | ||
92 | |||
93 | #ifndef __THROW | ||
94 | # ifndef __GNUC_PREREQ | ||
95 | # define __GNUC_PREREQ(maj, min) (0) | ||
96 | # endif | ||
97 | # if defined __cplusplus && __GNUC_PREREQ (2,8) | ||
98 | # define __THROW throw () | ||
99 | # else | ||
100 | # define __THROW | ||
101 | # endif | ||
102 | #endif | ||
103 | |||
104 | #ifdef __cplusplus | ||
105 | extern "C" { | ||
106 | #endif | ||
107 | |||
108 | /* For communication from `getopt' to the caller. | ||
109 | When `getopt' finds an option that takes an argument, | ||
110 | the argument value is returned here. | ||
111 | Also, when `ordering' is RETURN_IN_ORDER, | ||
112 | each non-option ARGV-element is returned here. */ | ||
113 | |||
114 | extern char *optarg; | ||
115 | |||
116 | /* Index in ARGV of the next element to be scanned. | ||
117 | This is used for communication to and from the caller | ||
118 | and for communication between successive calls to `getopt'. | ||
119 | |||
120 | On entry to `getopt', zero means this is the first call; initialize. | ||
121 | |||
122 | When `getopt' returns -1, this is the index of the first of the | ||
123 | non-option elements that the caller should itself scan. | ||
124 | |||
125 | Otherwise, `optind' communicates from one call to the next | ||
126 | how much of ARGV has been scanned so far. */ | ||
127 | |||
128 | extern int optind; | ||
129 | |||
130 | /* Callers store zero here to inhibit the error message `getopt' prints | ||
131 | for unrecognized options. */ | ||
132 | |||
133 | extern int opterr; | ||
134 | |||
135 | /* Set to an option character which was unrecognized. */ | ||
136 | |||
137 | extern int optopt; | ||
138 | |||
139 | #ifndef __need_getopt | ||
140 | /* Describe the long-named options requested by the application. | ||
141 | The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector | ||
142 | of `struct option' terminated by an element containing a name which is | ||
143 | zero. | ||
144 | |||
145 | The field `has_arg' is: | ||
146 | no_argument (or 0) if the option does not take an argument, | ||
147 | required_argument (or 1) if the option requires an argument, | ||
148 | optional_argument (or 2) if the option takes an optional argument. | ||
149 | |||
150 | If the field `flag' is not NULL, it points to a variable that is set | ||
151 | to the value given in the field `val' when the option is found, but | ||
152 | left unchanged if the option is not found. | ||
153 | |||
154 | To have a long-named option do something other than set an `int' to | ||
155 | a compiled-in constant, such as set a value from `optarg', set the | ||
156 | option's `flag' field to zero and its `val' field to a nonzero | ||
157 | value (the equivalent single-letter option character, if there is | ||
158 | one). For long options that have a zero `flag' field, `getopt' | ||
159 | returns the contents of the `val' field. */ | ||
160 | |||
161 | struct option | ||
162 | { | ||
163 | const char *name; | ||
164 | /* has_arg can't be an enum because some compilers complain about | ||
165 | type mismatches in all the code that assumes it is an int. */ | ||
166 | int has_arg; | ||
167 | int *flag; | ||
168 | int val; | ||
169 | }; | ||
170 | |||
171 | /* Names for the values of the `has_arg' field of `struct option'. */ | ||
172 | |||
173 | # define no_argument 0 | ||
174 | # define required_argument 1 | ||
175 | # define optional_argument 2 | ||
176 | #endif /* need getopt */ | ||
177 | |||
178 | |||
179 | /* Get definitions and prototypes for functions to process the | ||
180 | arguments in ARGV (ARGC of them, minus the program name) for | ||
181 | options given in OPTS. | ||
182 | |||
183 | Return the option character from OPTS just read. Return -1 when | ||
184 | there are no more options. For unrecognized options, or options | ||
185 | missing arguments, `optopt' is set to the option letter, and '?' is | ||
186 | returned. | ||
187 | |||
188 | The OPTS string is a list of characters which are recognized option | ||
189 | letters, optionally followed by colons, specifying that that letter | ||
190 | takes an argument, to be placed in `optarg'. | ||
191 | |||
192 | If a letter in OPTS is followed by two colons, its argument is | ||
193 | optional. This behavior is specific to the GNU `getopt'. | ||
194 | |||
195 | The argument `--' causes premature termination of argument | ||
196 | scanning, explicitly telling `getopt' that there are no more | ||
197 | options. | ||
198 | |||
199 | If OPTS begins with `--', then non-option arguments are treated as | ||
200 | arguments to the option '\0'. This behavior is specific to the GNU | ||
201 | `getopt'. */ | ||
202 | |||
203 | extern int getopt (int ___argc, char *const *___argv, const char *__shortopts) | ||
204 | __THROW; | ||
205 | |||
206 | #ifndef __need_getopt | ||
207 | extern int getopt_long (int ___argc, char *__getopt_argv_const *___argv, | ||
208 | const char *__shortopts, | ||
209 | const struct option *__longopts, int *__longind) | ||
210 | __THROW; | ||
211 | extern int getopt_long_only (int ___argc, char *__getopt_argv_const *___argv, | ||
212 | const char *__shortopts, | ||
213 | const struct option *__longopts, int *__longind) | ||
214 | __THROW; | ||
215 | |||
216 | #endif | ||
217 | |||
218 | #ifdef __cplusplus | ||
219 | } | ||
220 | #endif | ||
221 | |||
222 | /* Make sure we later can get all the definitions and declarations. */ | ||
223 | #undef __need_getopt | ||
224 | |||
225 | #endif /* getopt.h */ |
mailbox/getopt1.c
deleted
100644 → 0
1 | /* getopt_long and getopt_long_only entry points for GNU getopt. | ||
2 | Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98,2004 | ||
3 | Free Software Foundation, Inc. | ||
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 | #ifdef _LIBC | ||
25 | # include <getopt.h> | ||
26 | #else | ||
27 | # include "getopt.h" | ||
28 | #endif | ||
29 | #include "getopt_int.h" | ||
30 | |||
31 | #include <stdio.h> | ||
32 | |||
33 | /* This needs to come after some library #include | ||
34 | to get __GNU_LIBRARY__ defined. */ | ||
35 | #ifdef __GNU_LIBRARY__ | ||
36 | #include <stdlib.h> | ||
37 | #endif | ||
38 | |||
39 | #ifndef NULL | ||
40 | #define NULL 0 | ||
41 | #endif | ||
42 | |||
43 | int | ||
44 | getopt_long (int argc, char *__getopt_argv_const *argv, const char *options, | ||
45 | const struct option *long_options, int *opt_index) | ||
46 | { | ||
47 | return _getopt_internal (argc, (char **) argv, options, long_options, | ||
48 | opt_index, 0, 0); | ||
49 | } | ||
50 | |||
51 | int | ||
52 | _getopt_long_r (int argc, char **argv, const char *options, | ||
53 | const struct option *long_options, int *opt_index, | ||
54 | struct _getopt_data *d) | ||
55 | { | ||
56 | return _getopt_internal_r (argc, argv, options, long_options, opt_index, | ||
57 | 0, 0, d); | ||
58 | } | ||
59 | |||
60 | /* Like getopt_long, but '-' as well as '--' can indicate a long option. | ||
61 | If an option that starts with '-' (not '--') doesn't match a long option, | ||
62 | but does match a short option, it is parsed as a short option | ||
63 | instead. */ | ||
64 | |||
65 | int | ||
66 | getopt_long_only (int argc, char *__getopt_argv_const *argv, | ||
67 | const char *options, | ||
68 | const struct option *long_options, int *opt_index) | ||
69 | { | ||
70 | return _getopt_internal (argc, (char **) argv, options, long_options, | ||
71 | opt_index, 1, 0); | ||
72 | } | ||
73 | |||
74 | int | ||
75 | _getopt_long_only_r (int argc, char **argv, const char *options, | ||
76 | const struct option *long_options, int *opt_index, | ||
77 | struct _getopt_data *d) | ||
78 | { | ||
79 | return _getopt_internal_r (argc, argv, options, long_options, opt_index, | ||
80 | 1, 0, d); | ||
81 | } | ||
82 | |||
83 | |||
84 | #ifdef TEST | ||
85 | |||
86 | #include <stdio.h> | ||
87 | |||
88 | int | ||
89 | main (int argc, char **argv) | ||
90 | { | ||
91 | int c; | ||
92 | int digit_optind = 0; | ||
93 | |||
94 | while (1) | ||
95 | { | ||
96 | int this_option_optind = optind ? optind : 1; | ||
97 | int option_index = 0; | ||
98 | static struct option long_options[] = | ||
99 | { | ||
100 | {"add", 1, 0, 0}, | ||
101 | {"append", 0, 0, 0}, | ||
102 | {"delete", 1, 0, 0}, | ||
103 | {"verbose", 0, 0, 0}, | ||
104 | {"create", 0, 0, 0}, | ||
105 | {"file", 1, 0, 0}, | ||
106 | {0, 0, 0, 0} | ||
107 | }; | ||
108 | |||
109 | c = getopt_long (argc, argv, "abc:d:0123456789", | ||
110 | long_options, &option_index); | ||
111 | if (c == -1) | ||
112 | break; | ||
113 | |||
114 | switch (c) | ||
115 | { | ||
116 | case 0: | ||
117 | printf ("option %s", long_options[option_index].name); | ||
118 | if (optarg) | ||
119 | printf (" with arg %s", optarg); | ||
120 | printf ("\n"); | ||
121 | break; | ||
122 | |||
123 | case '0': | ||
124 | case '1': | ||
125 | case '2': | ||
126 | case '3': | ||
127 | case '4': | ||
128 | case '5': | ||
129 | case '6': | ||
130 | case '7': | ||
131 | case '8': | ||
132 | case '9': | ||
133 | if (digit_optind != 0 && digit_optind != this_option_optind) | ||
134 | printf ("digits occur in two different argv-elements.\n"); | ||
135 | digit_optind = this_option_optind; | ||
136 | printf ("option %c\n", c); | ||
137 | break; | ||
138 | |||
139 | case 'a': | ||
140 | printf ("option a\n"); | ||
141 | break; | ||
142 | |||
143 | case 'b': | ||
144 | printf ("option b\n"); | ||
145 | break; | ||
146 | |||
147 | case 'c': | ||
148 | printf ("option c with value `%s'\n", optarg); | ||
149 | break; | ||
150 | |||
151 | case 'd': | ||
152 | printf ("option d with value `%s'\n", optarg); | ||
153 | break; | ||
154 | |||
155 | case '?': | ||
156 | break; | ||
157 | |||
158 | default: | ||
159 | printf ("?? getopt returned character code 0%o ??\n", c); | ||
160 | } | ||
161 | } | ||
162 | |||
163 | if (optind < argc) | ||
164 | { | ||
165 | printf ("non-option ARGV-elements: "); | ||
166 | while (optind < argc) | ||
167 | printf ("%s ", argv[optind++]); | ||
168 | printf ("\n"); | ||
169 | } | ||
170 | |||
171 | exit (0); | ||
172 | } | ||
173 | |||
174 | #endif /* TEST */ |
mailbox/getopt_.h
deleted
100644 → 0
1 | /* Declarations for getopt. | ||
2 | Copyright (C) 1989-1994,1996-1999,2001,2003,2004,2005 | ||
3 | Free Software Foundation, Inc. | ||
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 | #ifndef _GETOPT_H | ||
21 | |||
22 | #ifndef __need_getopt | ||
23 | # define _GETOPT_H 1 | ||
24 | #endif | ||
25 | |||
26 | /* Standalone applications should #define __GETOPT_PREFIX to an | ||
27 | identifier that prefixes the external functions and variables | ||
28 | defined in this header. When this happens, include the | ||
29 | headers that might declare getopt so that they will not cause | ||
30 | confusion if included after this file. Then systematically rename | ||
31 | identifiers so that they do not collide with the system functions | ||
32 | and variables. Renaming avoids problems with some compilers and | ||
33 | linkers. */ | ||
34 | #if defined __GETOPT_PREFIX && !defined __need_getopt | ||
35 | # include <stdlib.h> | ||
36 | # include <stdio.h> | ||
37 | # include <unistd.h> | ||
38 | # undef __need_getopt | ||
39 | # undef getopt | ||
40 | # undef getopt_long | ||
41 | # undef getopt_long_only | ||
42 | # undef optarg | ||
43 | # undef opterr | ||
44 | # undef optind | ||
45 | # undef optopt | ||
46 | # define __GETOPT_CONCAT(x, y) x ## y | ||
47 | # define __GETOPT_XCONCAT(x, y) __GETOPT_CONCAT (x, y) | ||
48 | # define __GETOPT_ID(y) __GETOPT_XCONCAT (__GETOPT_PREFIX, y) | ||
49 | # define getopt __GETOPT_ID (getopt) | ||
50 | # define getopt_long __GETOPT_ID (getopt_long) | ||
51 | # define getopt_long_only __GETOPT_ID (getopt_long_only) | ||
52 | # define optarg __GETOPT_ID (optarg) | ||
53 | # define opterr __GETOPT_ID (opterr) | ||
54 | # define optind __GETOPT_ID (optind) | ||
55 | # define optopt __GETOPT_ID (optopt) | ||
56 | #endif | ||
57 | |||
58 | /* Standalone applications get correct prototypes for getopt_long and | ||
59 | getopt_long_only; they declare "char **argv". libc uses prototypes | ||
60 | with "char *const *argv" that are incorrect because getopt_long and | ||
61 | getopt_long_only can permute argv; this is required for backward | ||
62 | compatibility (e.g., for LSB 2.0.1). | ||
63 | |||
64 | This used to be `#if defined __GETOPT_PREFIX && !defined __need_getopt', | ||
65 | but it caused redefinition warnings if both unistd.h and getopt.h were | ||
66 | included, since unistd.h includes getopt.h having previously defined | ||
67 | __need_getopt. | ||
68 | |||
69 | The only place where __getopt_argv_const is used is in definitions | ||
70 | of getopt_long and getopt_long_only below, but these are visible | ||
71 | only if __need_getopt is not defined, so it is quite safe to rewrite | ||
72 | the conditional as follows: | ||
73 | */ | ||
74 | #if !defined __need_getopt | ||
75 | # if defined __GETOPT_PREFIX | ||
76 | # define __getopt_argv_const /* empty */ | ||
77 | # else | ||
78 | # define __getopt_argv_const const | ||
79 | # endif | ||
80 | #endif | ||
81 | |||
82 | /* If __GNU_LIBRARY__ is not already defined, either we are being used | ||
83 | standalone, or this is the first header included in the source file. | ||
84 | If we are being used with glibc, we need to include <features.h>, but | ||
85 | that does not exist if we are standalone. So: if __GNU_LIBRARY__ is | ||
86 | not defined, include <ctype.h>, which will pull in <features.h> for us | ||
87 | if it's from glibc. (Why ctype.h? It's guaranteed to exist and it | ||
88 | doesn't flood the namespace with stuff the way some other headers do.) */ | ||
89 | #if !defined __GNU_LIBRARY__ | ||
90 | # include <ctype.h> | ||
91 | #endif | ||
92 | |||
93 | #ifndef __THROW | ||
94 | # ifndef __GNUC_PREREQ | ||
95 | # define __GNUC_PREREQ(maj, min) (0) | ||
96 | # endif | ||
97 | # if defined __cplusplus && __GNUC_PREREQ (2,8) | ||
98 | # define __THROW throw () | ||
99 | # else | ||
100 | # define __THROW | ||
101 | # endif | ||
102 | #endif | ||
103 | |||
104 | #ifdef __cplusplus | ||
105 | extern "C" { | ||
106 | #endif | ||
107 | |||
108 | /* For communication from `getopt' to the caller. | ||
109 | When `getopt' finds an option that takes an argument, | ||
110 | the argument value is returned here. | ||
111 | Also, when `ordering' is RETURN_IN_ORDER, | ||
112 | each non-option ARGV-element is returned here. */ | ||
113 | |||
114 | extern char *optarg; | ||
115 | |||
116 | /* Index in ARGV of the next element to be scanned. | ||
117 | This is used for communication to and from the caller | ||
118 | and for communication between successive calls to `getopt'. | ||
119 | |||
120 | On entry to `getopt', zero means this is the first call; initialize. | ||
121 | |||
122 | When `getopt' returns -1, this is the index of the first of the | ||
123 | non-option elements that the caller should itself scan. | ||
124 | |||
125 | Otherwise, `optind' communicates from one call to the next | ||
126 | how much of ARGV has been scanned so far. */ | ||
127 | |||
128 | extern int optind; | ||
129 | |||
130 | /* Callers store zero here to inhibit the error message `getopt' prints | ||
131 | for unrecognized options. */ | ||
132 | |||
133 | extern int opterr; | ||
134 | |||
135 | /* Set to an option character which was unrecognized. */ | ||
136 | |||
137 | extern int optopt; | ||
138 | |||
139 | #ifndef __need_getopt | ||
140 | /* Describe the long-named options requested by the application. | ||
141 | The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector | ||
142 | of `struct option' terminated by an element containing a name which is | ||
143 | zero. | ||
144 | |||
145 | The field `has_arg' is: | ||
146 | no_argument (or 0) if the option does not take an argument, | ||
147 | required_argument (or 1) if the option requires an argument, | ||
148 | optional_argument (or 2) if the option takes an optional argument. | ||
149 | |||
150 | If the field `flag' is not NULL, it points to a variable that is set | ||
151 | to the value given in the field `val' when the option is found, but | ||
152 | left unchanged if the option is not found. | ||
153 | |||
154 | To have a long-named option do something other than set an `int' to | ||
155 | a compiled-in constant, such as set a value from `optarg', set the | ||
156 | option's `flag' field to zero and its `val' field to a nonzero | ||
157 | value (the equivalent single-letter option character, if there is | ||
158 | one). For long options that have a zero `flag' field, `getopt' | ||
159 | returns the contents of the `val' field. */ | ||
160 | |||
161 | struct option | ||
162 | { | ||
163 | const char *name; | ||
164 | /* has_arg can't be an enum because some compilers complain about | ||
165 | type mismatches in all the code that assumes it is an int. */ | ||
166 | int has_arg; | ||
167 | int *flag; | ||
168 | int val; | ||
169 | }; | ||
170 | |||
171 | /* Names for the values of the `has_arg' field of `struct option'. */ | ||
172 | |||
173 | # define no_argument 0 | ||
174 | # define required_argument 1 | ||
175 | # define optional_argument 2 | ||
176 | #endif /* need getopt */ | ||
177 | |||
178 | |||
179 | /* Get definitions and prototypes for functions to process the | ||
180 | arguments in ARGV (ARGC of them, minus the program name) for | ||
181 | options given in OPTS. | ||
182 | |||
183 | Return the option character from OPTS just read. Return -1 when | ||
184 | there are no more options. For unrecognized options, or options | ||
185 | missing arguments, `optopt' is set to the option letter, and '?' is | ||
186 | returned. | ||
187 | |||
188 | The OPTS string is a list of characters which are recognized option | ||
189 | letters, optionally followed by colons, specifying that that letter | ||
190 | takes an argument, to be placed in `optarg'. | ||
191 | |||
192 | If a letter in OPTS is followed by two colons, its argument is | ||
193 | optional. This behavior is specific to the GNU `getopt'. | ||
194 | |||
195 | The argument `--' causes premature termination of argument | ||
196 | scanning, explicitly telling `getopt' that there are no more | ||
197 | options. | ||
198 | |||
199 | If OPTS begins with `--', then non-option arguments are treated as | ||
200 | arguments to the option '\0'. This behavior is specific to the GNU | ||
201 | `getopt'. */ | ||
202 | |||
203 | extern int getopt (int ___argc, char *const *___argv, const char *__shortopts) | ||
204 | __THROW; | ||
205 | |||
206 | #ifndef __need_getopt | ||
207 | extern int getopt_long (int ___argc, char *__getopt_argv_const *___argv, | ||
208 | const char *__shortopts, | ||
209 | const struct option *__longopts, int *__longind) | ||
210 | __THROW; | ||
211 | extern int getopt_long_only (int ___argc, char *__getopt_argv_const *___argv, | ||
212 | const char *__shortopts, | ||
213 | const struct option *__longopts, int *__longind) | ||
214 | __THROW; | ||
215 | |||
216 | #endif | ||
217 | |||
218 | #ifdef __cplusplus | ||
219 | } | ||
220 | #endif | ||
221 | |||
222 | /* Make sure we later can get all the definitions and declarations. */ | ||
223 | #undef __need_getopt | ||
224 | |||
225 | #endif /* getopt.h */ |
mailbox/getopt_int.h
deleted
100644 → 0
1 | /* Internal declarations for getopt. | ||
2 | Copyright (C) 1989-1994,1996-1999,2001,2003,2004 | ||
3 | Free Software Foundation, Inc. | ||
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 | #ifndef _GETOPT_INT_H | ||
21 | #define _GETOPT_INT_H 1 | ||
22 | |||
23 | extern int _getopt_internal (int ___argc, char **___argv, | ||
24 | const char *__shortopts, | ||
25 | const struct option *__longopts, int *__longind, | ||
26 | int __long_only, int __posixly_correct); | ||
27 | |||
28 | |||
29 | /* Reentrant versions which can handle parsing multiple argument | ||
30 | vectors at the same time. */ | ||
31 | |||
32 | /* Data type for reentrant functions. */ | ||
33 | struct _getopt_data | ||
34 | { | ||
35 | /* These have exactly the same meaning as the corresponding global | ||
36 | variables, except that they are used for the reentrant | ||
37 | versions of getopt. */ | ||
38 | int optind; | ||
39 | int opterr; | ||
40 | int optopt; | ||
41 | char *optarg; | ||
42 | |||
43 | /* Internal members. */ | ||
44 | |||
45 | /* True if the internal members have been initialized. */ | ||
46 | int __initialized; | ||
47 | |||
48 | /* The next char to be scanned in the option-element | ||
49 | in which the last option character we returned was found. | ||
50 | This allows us to pick up the scan where we left off. | ||
51 | |||
52 | If this is zero, or a null string, it means resume the scan | ||
53 | by advancing to the next ARGV-element. */ | ||
54 | char *__nextchar; | ||
55 | |||
56 | /* Describe how to deal with options that follow non-option ARGV-elements. | ||
57 | |||
58 | If the caller did not specify anything, | ||
59 | the default is REQUIRE_ORDER if the environment variable | ||
60 | POSIXLY_CORRECT is defined, PERMUTE otherwise. | ||
61 | |||
62 | REQUIRE_ORDER means don't recognize them as options; | ||
63 | stop option processing when the first non-option is seen. | ||
64 | This is what Unix does. | ||
65 | This mode of operation is selected by either setting the environment | ||
66 | variable POSIXLY_CORRECT, or using `+' as the first character | ||
67 | of the list of option characters, or by calling getopt. | ||
68 | |||
69 | PERMUTE is the default. We permute the contents of ARGV as we | ||
70 | scan, so that eventually all the non-options are at the end. | ||
71 | This allows options to be given in any order, even with programs | ||
72 | that were not written to expect this. | ||
73 | |||
74 | RETURN_IN_ORDER is an option available to programs that were | ||
75 | written to expect options and other ARGV-elements in any order | ||
76 | and that care about the ordering of the two. We describe each | ||
77 | non-option ARGV-element as if it were the argument of an option | ||
78 | with character code 1. Using `-' as the first character of the | ||
79 | list of option characters selects this mode of operation. | ||
80 | |||
81 | The special argument `--' forces an end of option-scanning regardless | ||
82 | of the value of `ordering'. In the case of RETURN_IN_ORDER, only | ||
83 | `--' can cause `getopt' to return -1 with `optind' != ARGC. */ | ||
84 | |||
85 | enum | ||
86 | { | ||
87 | REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER | ||
88 | } __ordering; | ||
89 | |||
90 | /* If the POSIXLY_CORRECT environment variable is set | ||
91 | or getopt was called. */ | ||
92 | int __posixly_correct; | ||
93 | |||
94 | |||
95 | /* Handle permutation of arguments. */ | ||
96 | |||
97 | /* Describe the part of ARGV that contains non-options that have | ||
98 | been skipped. `first_nonopt' is the index in ARGV of the first | ||
99 | of them; `last_nonopt' is the index after the last of them. */ | ||
100 | |||
101 | int __first_nonopt; | ||
102 | int __last_nonopt; | ||
103 | |||
104 | #if defined _LIBC && defined USE_NONOPTION_FLAGS | ||
105 | int __nonoption_flags_max_len; | ||
106 | int __nonoption_flags_len; | ||
107 | # endif | ||
108 | }; | ||
109 | |||
110 | /* The initializer is necessary to set OPTIND and OPTERR to their | ||
111 | default values and to clear the initialization flag. */ | ||
112 | #define _GETOPT_DATA_INITIALIZER { 1, 1 } | ||
113 | |||
114 | extern int _getopt_internal_r (int ___argc, char **___argv, | ||
115 | const char *__shortopts, | ||
116 | const struct option *__longopts, int *__longind, | ||
117 | int __long_only, int __posixly_correct, | ||
118 | struct _getopt_data *__data); | ||
119 | |||
120 | extern int _getopt_long_r (int ___argc, char **___argv, | ||
121 | const char *__shortopts, | ||
122 | const struct option *__longopts, int *__longind, | ||
123 | struct _getopt_data *__data); | ||
124 | |||
125 | extern int _getopt_long_only_r (int ___argc, char **___argv, | ||
126 | const char *__shortopts, | ||
127 | const struct option *__longopts, | ||
128 | int *__longind, | ||
129 | struct _getopt_data *__data); | ||
130 | |||
131 | #endif /* getopt_int.h */ |
mailbox/gettext.h
deleted
100644 → 0
1 | /* Convenience header for conditional use of GNU <libintl.h>. | ||
2 | Copyright (C) 1995-1998, 2000-2002, 2004-2006 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 along | ||
15 | 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 _LIBGETTEXT_H | ||
19 | #define _LIBGETTEXT_H 1 | ||
20 | |||
21 | /* NLS can be disabled through the configure --disable-nls option. */ | ||
22 | #if ENABLE_NLS | ||
23 | |||
24 | /* Get declarations of GNU message catalog functions. */ | ||
25 | # include <libintl.h> | ||
26 | |||
27 | #else | ||
28 | |||
29 | /* Solaris /usr/include/locale.h includes /usr/include/libintl.h, which | ||
30 | chokes if dcgettext is defined as a macro. So include it now, to make | ||
31 | later inclusions of <locale.h> a NOP. We don't include <libintl.h> | ||
32 | as well because people using "gettext.h" will not include <libintl.h>, | ||
33 | and also including <libintl.h> would fail on SunOS 4, whereas <locale.h> | ||
34 | is OK. */ | ||
35 | #if defined(__sun) | ||
36 | # include <locale.h> | ||
37 | #endif | ||
38 | |||
39 | /* Many header files from the libstdc++ coming with g++ 3.3 or newer include | ||
40 | <libintl.h>, which chokes if dcgettext is defined as a macro. So include | ||
41 | it now, to make later inclusions of <libintl.h> a NOP. */ | ||
42 | #if defined(__cplusplus) && defined(__GNUG__) && (__GNUC__ >= 3) | ||
43 | # include <cstdlib> | ||
44 | # if (__GLIBC__ >= 2) || _GLIBCXX_HAVE_LIBINTL_H | ||
45 | # include <libintl.h> | ||
46 | # endif | ||
47 | #endif | ||
48 | |||
49 | /* Disabled NLS. | ||
50 | The casts to 'const char *' serve the purpose of producing warnings | ||
51 | for invalid uses of the value returned from these functions. | ||
52 | On pre-ANSI systems without 'const', the config.h file is supposed to | ||
53 | contain "#define const". */ | ||
54 | # define gettext(Msgid) ((const char *) (Msgid)) | ||
55 | # define dgettext(Domainname, Msgid) ((const char *) (Msgid)) | ||
56 | # define dcgettext(Domainname, Msgid, Category) ((const char *) (Msgid)) | ||
57 | # define ngettext(Msgid1, Msgid2, N) \ | ||
58 | ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2)) | ||
59 | # define dngettext(Domainname, Msgid1, Msgid2, N) \ | ||
60 | ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2)) | ||
61 | # define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \ | ||
62 | ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2)) | ||
63 | # define textdomain(Domainname) ((const char *) (Domainname)) | ||
64 | # define bindtextdomain(Domainname, Dirname) ((const char *) (Dirname)) | ||
65 | # define bind_textdomain_codeset(Domainname, Codeset) ((const char *) (Codeset)) | ||
66 | |||
67 | #endif | ||
68 | |||
69 | /* A pseudo function call that serves as a marker for the automated | ||
70 | extraction of messages, but does not call gettext(). The run-time | ||
71 | translation is done at a different place in the code. | ||
72 | The argument, String, should be a literal string. Concatenated strings | ||
73 | and other string expressions won't work. | ||
74 | The macro's expansion is not parenthesized, so that it is suitable as | ||
75 | initializer for static 'char[]' or 'const char[]' variables. */ | ||
76 | #define gettext_noop(String) String | ||
77 | |||
78 | /* The separator between msgctxt and msgid in a .mo file. */ | ||
79 | #define GETTEXT_CONTEXT_GLUE "\004" | ||
80 | |||
81 | /* Pseudo function calls, taking a MSGCTXT and a MSGID instead of just a | ||
82 | MSGID. MSGCTXT and MSGID must be string literals. MSGCTXT should be | ||
83 | short and rarely need to change. | ||
84 | The letter 'p' stands for 'particular' or 'special'. */ | ||
85 | #define pgettext(Msgctxt, Msgid) \ | ||
86 | pgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES) | ||
87 | #define dpgettext(Domainname, Msgctxt, Msgid) \ | ||
88 | pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES) | ||
89 | #define dcpgettext(Domainname, Msgctxt, Msgid, Category) \ | ||
90 | pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, Category) | ||
91 | #define npgettext(Msgctxt, Msgid, MsgidPlural, N) \ | ||
92 | npgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES) | ||
93 | #define dnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N) \ | ||
94 | npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES) | ||
95 | #define dcnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N, Category) \ | ||
96 | npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, Category) | ||
97 | |||
98 | #ifdef __GNUC__ | ||
99 | __inline | ||
100 | #else | ||
101 | #ifdef __cplusplus | ||
102 | inline | ||
103 | #endif | ||
104 | #endif | ||
105 | static const char * | ||
106 | pgettext_aux (const char *domain, | ||
107 | const char *msg_ctxt_id, const char *msgid, | ||
108 | int category) | ||
109 | { | ||
110 | const char *translation = dcgettext (domain, msg_ctxt_id, category); | ||
111 | if (translation == msg_ctxt_id) | ||
112 | return msgid; | ||
113 | else | ||
114 | return translation; | ||
115 | } | ||
116 | |||
117 | #ifdef __GNUC__ | ||
118 | __inline | ||
119 | #else | ||
120 | #ifdef __cplusplus | ||
121 | inline | ||
122 | #endif | ||
123 | #endif | ||
124 | static const char * | ||
125 | npgettext_aux (const char *domain, | ||
126 | const char *msg_ctxt_id, const char *msgid, | ||
127 | const char *msgid_plural, unsigned long int n, | ||
128 | int category) | ||
129 | { | ||
130 | const char *translation = | ||
131 | dcngettext (domain, msg_ctxt_id, msgid_plural, n, category); | ||
132 | if (translation == msg_ctxt_id || translation == msgid_plural) | ||
133 | return (n == 1 ? msgid : msgid_plural); | ||
134 | else | ||
135 | return translation; | ||
136 | } | ||
137 | |||
138 | /* The same thing extended for non-constant arguments. Here MSGCTXT and MSGID | ||
139 | can be arbitrary expressions. But for string literals these macros are | ||
140 | less efficient than those above. */ | ||
141 | |||
142 | #include <string.h> | ||
143 | |||
144 | #define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS \ | ||
145 | (__GNUC__ >= 3 || defined __cplusplus) | ||
146 | |||
147 | #if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS | ||
148 | #include <stdlib.h> | ||
149 | #endif | ||
150 | |||
151 | #define pgettext_expr(Msgctxt, Msgid) \ | ||
152 | dcpgettext_expr (NULL, Msgctxt, Msgid, LC_MESSAGES) | ||
153 | #define dpgettext_expr(Domainname, Msgctxt, Msgid) \ | ||
154 | dcpgettext_expr (Domainname, Msgctxt, Msgid, LC_MESSAGES) | ||
155 | |||
156 | #ifdef __GNUC__ | ||
157 | __inline | ||
158 | #else | ||
159 | #ifdef __cplusplus | ||
160 | inline | ||
161 | #endif | ||
162 | #endif | ||
163 | static const char * | ||
164 | dcpgettext_expr (const char *domain, | ||
165 | const char *msgctxt, const char *msgid, | ||
166 | int category) | ||
167 | { | ||
168 | size_t msgctxt_len = strlen (msgctxt) + 1; | ||
169 | size_t msgid_len = strlen (msgid) + 1; | ||
170 | const char *translation; | ||
171 | #if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS | ||
172 | char msg_ctxt_id[msgctxt_len + msgid_len]; | ||
173 | #else | ||
174 | char buf[1024]; | ||
175 | char *msg_ctxt_id = | ||
176 | (msgctxt_len + msgid_len <= sizeof (buf) | ||
177 | ? buf | ||
178 | : (char *) malloc (msgctxt_len + msgid_len)); | ||
179 | if (msg_ctxt_id != NULL) | ||
180 | #endif | ||
181 | { | ||
182 | memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1); | ||
183 | msg_ctxt_id[msgctxt_len - 1] = '\004'; | ||
184 | memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len); | ||
185 | translation = dcgettext (domain, msg_ctxt_id, category); | ||
186 | #if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS | ||
187 | if (msg_ctxt_id != buf) | ||
188 | free (msg_ctxt_id); | ||
189 | #endif | ||
190 | if (translation != msg_ctxt_id) | ||
191 | return translation; | ||
192 | } | ||
193 | return msgid; | ||
194 | } | ||
195 | |||
196 | #define npgettext_expr(Msgctxt, Msgid, MsgidPlural, N) \ | ||
197 | dcnpgettext_expr (NULL, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES) | ||
198 | #define dnpgettext_expr(Domainname, Msgctxt, Msgid, MsgidPlural, N) \ | ||
199 | dcnpgettext_expr (Domainname, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES) | ||
200 | |||
201 | #ifdef __GNUC__ | ||
202 | __inline | ||
203 | #else | ||
204 | #ifdef __cplusplus | ||
205 | inline | ||
206 | #endif | ||
207 | #endif | ||
208 | static const char * | ||
209 | dcnpgettext_expr (const char *domain, | ||
210 | const char *msgctxt, const char *msgid, | ||
211 | const char *msgid_plural, unsigned long int n, | ||
212 | int category) | ||
213 | { | ||
214 | size_t msgctxt_len = strlen (msgctxt) + 1; | ||
215 | size_t msgid_len = strlen (msgid) + 1; | ||
216 | const char *translation; | ||
217 | #if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS | ||
218 | char msg_ctxt_id[msgctxt_len + msgid_len]; | ||
219 | #else | ||
220 | char buf[1024]; | ||
221 | char *msg_ctxt_id = | ||
222 | (msgctxt_len + msgid_len <= sizeof (buf) | ||
223 | ? buf | ||
224 | : (char *) malloc (msgctxt_len + msgid_len)); | ||
225 | if (msg_ctxt_id != NULL) | ||
226 | #endif | ||
227 | { | ||
228 | memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1); | ||
229 | msg_ctxt_id[msgctxt_len - 1] = '\004'; | ||
230 | memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len); | ||
231 | translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n, category); | ||
232 | #if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS | ||
233 | if (msg_ctxt_id != buf) | ||
234 | free (msg_ctxt_id); | ||
235 | #endif | ||
236 | if (!(translation == msg_ctxt_id || translation == msgid_plural)) | ||
237 | return translation; | ||
238 | } | ||
239 | return (n == 1 ? msgid : msgid_plural); | ||
240 | } | ||
241 | |||
242 | #endif /* _LIBGETTEXT_H */ |
mailbox/glob-libc.h
deleted
100644 → 0
1 | /* Copyright (C) 1991,92,95-98,2000,2001,2004-2006 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 */ |
mailbox/glob.c
deleted
100644 → 0
This diff is collapsed.
Click to expand it.
mailbox/glob_.h
deleted
100644 → 0
1 | /* glob_.h -- Find a path matching a pattern. | ||
2 | |||
3 | Copyright (C) 2005, 2006 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 __restrict | ||
42 | # define __restrict restrict | ||
43 | #endif | ||
44 | #ifndef __USE_GNU | ||
45 | # define __USE_GNU 1 | ||
46 | #endif | ||
47 | |||
48 | |||
49 | #define glob rpl_glob | ||
50 | #define globfree rpl_globfree | ||
51 | #define glob_pattern_p rpl_glob_pattern_p | ||
52 | |||
53 | #define __GLOB_GNULIB 1 | ||
54 | |||
55 | /* Now the standard GNU C Library header should work. */ | ||
56 | #include "glob-libc.h" | ||
57 | |||
58 | #endif /* GLOB_H */ |
mailbox/malloc.c
deleted
100644 → 0
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 | } |
mailbox/mbchar.c
deleted
100644 → 0
1 | /* Copyright (C) 2001 Free Software Foundation, Inc. | ||
2 | |||
3 | This program is free software; you can redistribute it and/or modify | ||
4 | it under the terms of the GNU General Public License as published by | ||
5 | the Free Software Foundation; either version 2, or (at your option) | ||
6 | any later version. | ||
7 | |||
8 | This program 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 | ||
11 | GNU General Public License for more details. | ||
12 | |||
13 | You should have received a copy of the GNU General Public License | ||
14 | along with this program; if not, write to the Free Software Foundation, | ||
15 | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | ||
16 | |||
17 | |||
18 | #ifdef HAVE_CONFIG_H | ||
19 | # include <config.h> | ||
20 | #endif | ||
21 | |||
22 | #include <limits.h> | ||
23 | |||
24 | #include "mbchar.h" | ||
25 | |||
26 | #if IS_BASIC_ASCII | ||
27 | |||
28 | /* Bit table of characters in the ISO C "basic character set". */ | ||
29 | unsigned int is_basic_table [UCHAR_MAX / 32 + 1] = | ||
30 | { | ||
31 | 0x00001a00, /* '\t' '\v' '\f' */ | ||
32 | 0xffffffef, /* ' '...'#' '%'...'?' */ | ||
33 | 0xfffffffe, /* 'A'...'Z' '[' '\\' ']' '^' '_' */ | ||
34 | 0x7ffffffe /* 'a'...'z' '{' '|' '}' '~' */ | ||
35 | /* The remaining bits are 0. */ | ||
36 | }; | ||
37 | |||
38 | #endif /* IS_BASIC_ASCII */ |
mailbox/mbchar.h
deleted
100644 → 0
This diff is collapsed.
Click to expand it.
mailbox/mbuiter.h
deleted
100644 → 0
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 */ |
mailbox/memchr.c
deleted
100644 → 0
1 | /* Copyright (C) 1991, 1993, 1996, 1997, 1999, 2000, 2003, 2004 Free | ||
2 | Software Foundation, Inc. | ||
3 | |||
4 | Based on strlen implementation by Torbjorn Granlund (tege@sics.se), | ||
5 | with help from Dan Sahlin (dan@sics.se) and | ||
6 | commentary by Jim Blandy (jimb@ai.mit.edu); | ||
7 | adaptation to memchr suggested by Dick Karpinski (dick@cca.ucsf.edu), | ||
8 | and implemented by Roland McGrath (roland@ai.mit.edu). | ||
9 | |||
10 | NOTE: The canonical source of this file is maintained with the GNU C Library. | ||
11 | Bugs can be reported to bug-glibc@prep.ai.mit.edu. | ||
12 | |||
13 | This program is free software; you can redistribute it and/or modify it | ||
14 | under the terms of the GNU General Public License as published by the | ||
15 | Free Software Foundation; either version 2, or (at your option) any | ||
16 | later version. | ||
17 | |||
18 | This program is distributed in the hope that it will be useful, | ||
19 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
20 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
21 | GNU General Public License for more details. | ||
22 | |||
23 | You should have received a copy of the GNU General Public License | ||
24 | along with this program; if not, write to the Free Software Foundation, | ||
25 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ | ||
26 | |||
27 | #ifdef HAVE_CONFIG_H | ||
28 | # include <config.h> | ||
29 | #endif | ||
30 | |||
31 | #include <string.h> | ||
32 | |||
33 | #include <stddef.h> | ||
34 | |||
35 | #if defined _LIBC | ||
36 | # include <memcopy.h> | ||
37 | #else | ||
38 | # define reg_char char | ||
39 | #endif | ||
40 | |||
41 | #include <limits.h> | ||
42 | |||
43 | #if HAVE_BP_SYM_H || defined _LIBC | ||
44 | # include <bp-sym.h> | ||
45 | #else | ||
46 | # define BP_SYM(sym) sym | ||
47 | #endif | ||
48 | |||
49 | #undef memchr | ||
50 | #undef __memchr | ||
51 | |||
52 | /* Search no more than N bytes of S for C. */ | ||
53 | void * | ||
54 | __memchr (void const *s, int c_in, size_t n) | ||
55 | { | ||
56 | const unsigned char *char_ptr; | ||
57 | const unsigned long int *longword_ptr; | ||
58 | unsigned long int longword, magic_bits, charmask; | ||
59 | unsigned reg_char c; | ||
60 | int i; | ||
61 | |||
62 | c = (unsigned char) c_in; | ||
63 | |||
64 | /* Handle the first few characters by reading one character at a time. | ||
65 | Do this until CHAR_PTR is aligned on a longword boundary. */ | ||
66 | for (char_ptr = (const unsigned char *) s; | ||
67 | n > 0 && (size_t) char_ptr % sizeof longword != 0; | ||
68 | --n, ++char_ptr) | ||
69 | if (*char_ptr == c) | ||
70 | return (void *) char_ptr; | ||
71 | |||
72 | /* All these elucidatory comments refer to 4-byte longwords, | ||
73 | but the theory applies equally well to any size longwords. */ | ||
74 | |||
75 | longword_ptr = (const unsigned long int *) char_ptr; | ||
76 | |||
77 | /* Bits 31, 24, 16, and 8 of this number are zero. Call these bits | ||
78 | the "holes." Note that there is a hole just to the left of | ||
79 | each byte, with an extra at the end: | ||
80 | |||
81 | bits: 01111110 11111110 11111110 11111111 | ||
82 | bytes: AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDD | ||
83 | |||
84 | The 1-bits make sure that carries propagate to the next 0-bit. | ||
85 | The 0-bits provide holes for carries to fall into. */ | ||
86 | |||
87 | /* Set MAGIC_BITS to be this pattern of 1 and 0 bits. | ||
88 | Set CHARMASK to be a longword, each of whose bytes is C. */ | ||
89 | |||
90 | magic_bits = 0xfefefefe; | ||
91 | charmask = c | (c << 8); | ||
92 | charmask |= charmask << 16; | ||
93 | #if 0xffffffffU < ULONG_MAX | ||
94 | magic_bits |= magic_bits << 32; | ||
95 | charmask |= charmask << 32; | ||
96 | if (8 < sizeof longword) | ||
97 | for (i = 64; i < sizeof longword * 8; i *= 2) | ||
98 | { | ||
99 | magic_bits |= magic_bits << i; | ||
100 | charmask |= charmask << i; | ||
101 | } | ||
102 | #endif | ||
103 | magic_bits = (ULONG_MAX >> 1) & (magic_bits | 1); | ||
104 | |||
105 | /* Instead of the traditional loop which tests each character, | ||
106 | we will test a longword at a time. The tricky part is testing | ||
107 | if *any of the four* bytes in the longword in question are zero. */ | ||
108 | while (n >= sizeof longword) | ||
109 | { | ||
110 | /* We tentatively exit the loop if adding MAGIC_BITS to | ||
111 | LONGWORD fails to change any of the hole bits of LONGWORD. | ||
112 | |||
113 | 1) Is this safe? Will it catch all the zero bytes? | ||
114 | Suppose there is a byte with all zeros. Any carry bits | ||
115 | propagating from its left will fall into the hole at its | ||
116 | least significant bit and stop. Since there will be no | ||
117 | carry from its most significant bit, the LSB of the | ||
118 | byte to the left will be unchanged, and the zero will be | ||
119 | detected. | ||
120 | |||
121 | 2) Is this worthwhile? Will it ignore everything except | ||
122 | zero bytes? Suppose every byte of LONGWORD has a bit set | ||
123 | somewhere. There will be a carry into bit 8. If bit 8 | ||
124 | is set, this will carry into bit 16. If bit 8 is clear, | ||
125 | one of bits 9-15 must be set, so there will be a carry | ||
126 | into bit 16. Similarly, there will be a carry into bit | ||
127 | 24. If one of bits 24-30 is set, there will be a carry | ||
128 | into bit 31, so all of the hole bits will be changed. | ||
129 | |||
130 | The one misfire occurs when bits 24-30 are clear and bit | ||
131 | 31 is set; in this case, the hole at bit 31 is not | ||
132 | changed. If we had access to the processor carry flag, | ||
133 | we could close this loophole by putting the fourth hole | ||
134 | at bit 32! | ||
135 | |||
136 | So it ignores everything except 128's, when they're aligned | ||
137 | properly. | ||
138 | |||
139 | 3) But wait! Aren't we looking for C, not zero? | ||
140 | Good point. So what we do is XOR LONGWORD with a longword, | ||
141 | each of whose bytes is C. This turns each byte that is C | ||
142 | into a zero. */ | ||
143 | |||
144 | longword = *longword_ptr++ ^ charmask; | ||
145 | |||
146 | /* Add MAGIC_BITS to LONGWORD. */ | ||
147 | if ((((longword + magic_bits) | ||
148 | |||
149 | /* Set those bits that were unchanged by the addition. */ | ||
150 | ^ ~longword) | ||
151 | |||
152 | /* Look at only the hole bits. If any of the hole bits | ||
153 | are unchanged, most likely one of the bytes was a | ||
154 | zero. */ | ||
155 | & ~magic_bits) != 0) | ||
156 | { | ||
157 | /* Which of the bytes was C? If none of them were, it was | ||
158 | a misfire; continue the search. */ | ||
159 | |||
160 | const unsigned char *cp = (const unsigned char *) (longword_ptr - 1); | ||
161 | |||
162 | if (cp[0] == c) | ||
163 | return (void *) cp; | ||
164 | if (cp[1] == c) | ||
165 | return (void *) &cp[1]; | ||
166 | if (cp[2] == c) | ||
167 | return (void *) &cp[2]; | ||
168 | if (cp[3] == c) | ||
169 | return (void *) &cp[3]; | ||
170 | if (4 < sizeof longword && cp[4] == c) | ||
171 | return (void *) &cp[4]; | ||
172 | if (5 < sizeof longword && cp[5] == c) | ||
173 | return (void *) &cp[5]; | ||
174 | if (6 < sizeof longword && cp[6] == c) | ||
175 | return (void *) &cp[6]; | ||
176 | if (7 < sizeof longword && cp[7] == c) | ||
177 | return (void *) &cp[7]; | ||
178 | if (8 < sizeof longword) | ||
179 | for (i = 8; i < sizeof longword; i++) | ||
180 | if (cp[i] == c) | ||
181 | return (void *) &cp[i]; | ||
182 | } | ||
183 | |||
184 | n -= sizeof longword; | ||
185 | } | ||
186 | |||
187 | char_ptr = (const unsigned char *) longword_ptr; | ||
188 | |||
189 | while (n-- > 0) | ||
190 | { | ||
191 | if (*char_ptr == c) | ||
192 | return (void *) char_ptr; | ||
193 | else | ||
194 | ++char_ptr; | ||
195 | } | ||
196 | |||
197 | return 0; | ||
198 | } | ||
199 | #ifdef weak_alias | ||
200 | weak_alias (__memchr, BP_SYM (memchr)) | ||
201 | #endif |
mailbox/mempcpy.c
deleted
100644 → 0
1 | /* Copy memory area and return pointer after last written byte. | ||
2 | Copyright (C) 2003 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 | /* Specification. */ | ||
19 | #include "mempcpy.h" | ||
20 | |||
21 | #include <string.h> | ||
22 | |||
23 | /* Copy N bytes of SRC to DEST, return pointer to bytes after the | ||
24 | last written byte. */ | ||
25 | void * | ||
26 | mempcpy (void *dest, const void *src, size_t n) | ||
27 | { | ||
28 | return (char *) memcpy (dest, src, n) + n; | ||
29 | } |
mailbox/mempcpy.h
deleted
100644 → 0
1 | /* Copy memory area and return pointer after last written byte. | ||
2 | Copyright (C) 2003, 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 mempcpy | ||
19 | |||
20 | # if HAVE_MEMPCPY | ||
21 | |||
22 | /* Get mempcpy() declaration. */ | ||
23 | # include <string.h> | ||
24 | |||
25 | # else | ||
26 | |||
27 | /* Get size_t */ | ||
28 | # include <stddef.h> | ||
29 | |||
30 | /* Copy N bytes of SRC to DEST, return pointer to bytes after the | ||
31 | last written byte. */ | ||
32 | extern void *mempcpy (void *dest, const void *src, size_t n); | ||
33 | |||
34 | # endif | ||
35 | |||
36 | #endif |
mailbox/minmax.h
deleted
100644 → 0
1 | /* MIN, MAX macros. | ||
2 | Copyright (C) 1995, 1998, 2001, 2003, 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 _MINMAX_H | ||
19 | #define _MINMAX_H | ||
20 | |||
21 | /* Note: MIN, MAX are also defined in <sys/param.h> on some systems | ||
22 | (glibc, IRIX, HP-UX, OSF/1). Therefore you might get warnings about | ||
23 | MIN, MAX macro redefinitions on some systems; the workaround is to | ||
24 | #include this file as the last one among the #include list. */ | ||
25 | |||
26 | /* Before we define the following symbols we get the <limits.h> file | ||
27 | since otherwise we get redefinitions on some systems if <limits.h> is | ||
28 | included after this file. Likewise for <sys/param.h>. | ||
29 | If more than one of these system headers define MIN and MAX, pick just | ||
30 | one of the headers (because the definitions most likely are the same). */ | ||
31 | #if HAVE_MINMAX_IN_LIMITS_H | ||
32 | # include <limits.h> | ||
33 | #elif HAVE_MINMAX_IN_SYS_PARAM_H | ||
34 | # include <sys/param.h> | ||
35 | #endif | ||
36 | |||
37 | /* Note: MIN and MAX should be used with two arguments of the | ||
38 | same type. They might not return the minimum and maximum of their two | ||
39 | arguments, if the arguments have different types or have unusual | ||
40 | floating-point values. For example, on a typical host with 32-bit 'int', | ||
41 | 64-bit 'long long', and 64-bit IEEE 754 'double' types: | ||
42 | |||
43 | MAX (-1, 2147483648) returns 4294967295. | ||
44 | MAX (9007199254740992.0, 9007199254740993) returns 9007199254740992.0. | ||
45 | MAX (NaN, 0.0) returns 0.0. | ||
46 | MAX (+0.0, -0.0) returns -0.0. | ||
47 | |||
48 | and in each case the answer is in some sense bogus. */ | ||
49 | |||
50 | /* MAX(a,b) returns the maximum of A and B. */ | ||
51 | #ifndef MAX | ||
52 | # define MAX(a,b) ((a) > (b) ? (a) : (b)) | ||
53 | #endif | ||
54 | |||
55 | /* MIN(a,b) returns the minimum of A and B. */ | ||
56 | #ifndef MIN | ||
57 | # define MIN(a,b) ((a) < (b) ? (a) : (b)) | ||
58 | #endif | ||
59 | |||
60 | #endif /* _MINMAX_H */ |
mailbox/pin.c
deleted
100644 → 0
1 | /* Declaration of program_invocation_name and program_invocation_short_name | ||
2 | for those libc's that don't already have it. These variable are needed | ||
3 | by the argp_ functions. */ | ||
4 | |||
5 | #ifdef HAVE_CONFIG_H | ||
6 | # include <config.h> | ||
7 | #endif | ||
8 | |||
9 | #ifndef HAVE_PROGRAM_INVOCATION_NAME | ||
10 | char *program_invocation_short_name = 0; | ||
11 | char *program_invocation_name = 0; | ||
12 | #endif |
mailbox/printf-args.c
deleted
100644 → 0
1 | /* Decomposed printf argument list. | ||
2 | Copyright (C) 1999, 2002-2003, 2005-2006 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 along | ||
15 | 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 | #ifdef HAVE_CONFIG_H | ||
19 | # include <config.h> | ||
20 | #endif | ||
21 | |||
22 | /* Specification. */ | ||
23 | #include "printf-args.h" | ||
24 | |||
25 | #ifdef STATIC | ||
26 | STATIC | ||
27 | #endif | ||
28 | int | ||
29 | printf_fetchargs (va_list args, arguments *a) | ||
30 | { | ||
31 | size_t i; | ||
32 | argument *ap; | ||
33 | |||
34 | for (i = 0, ap = &a->arg[0]; i < a->count; i++, ap++) | ||
35 | switch (ap->type) | ||
36 | { | ||
37 | case TYPE_SCHAR: | ||
38 | ap->a.a_schar = va_arg (args, /*signed char*/ int); | ||
39 | break; | ||
40 | case TYPE_UCHAR: | ||
41 | ap->a.a_uchar = va_arg (args, /*unsigned char*/ int); | ||
42 | break; | ||
43 | case TYPE_SHORT: | ||
44 | ap->a.a_short = va_arg (args, /*short*/ int); | ||
45 | break; | ||
46 | case TYPE_USHORT: | ||
47 | ap->a.a_ushort = va_arg (args, /*unsigned short*/ int); | ||
48 | break; | ||
49 | case TYPE_INT: | ||
50 | ap->a.a_int = va_arg (args, int); | ||
51 | break; | ||
52 | case TYPE_UINT: | ||
53 | ap->a.a_uint = va_arg (args, unsigned int); | ||
54 | break; | ||
55 | case TYPE_LONGINT: | ||
56 | ap->a.a_longint = va_arg (args, long int); | ||
57 | break; | ||
58 | case TYPE_ULONGINT: | ||
59 | ap->a.a_ulongint = va_arg (args, unsigned long int); | ||
60 | break; | ||
61 | #ifdef HAVE_LONG_LONG | ||
62 | case TYPE_LONGLONGINT: | ||
63 | ap->a.a_longlongint = va_arg (args, long long int); | ||
64 | break; | ||
65 | case TYPE_ULONGLONGINT: | ||
66 | ap->a.a_ulonglongint = va_arg (args, unsigned long long int); | ||
67 | break; | ||
68 | #endif | ||
69 | case TYPE_DOUBLE: | ||
70 | ap->a.a_double = va_arg (args, double); | ||
71 | break; | ||
72 | #ifdef HAVE_LONG_DOUBLE | ||
73 | case TYPE_LONGDOUBLE: | ||
74 | ap->a.a_longdouble = va_arg (args, long double); | ||
75 | break; | ||
76 | #endif | ||
77 | case TYPE_CHAR: | ||
78 | ap->a.a_char = va_arg (args, int); | ||
79 | break; | ||
80 | #ifdef HAVE_WINT_T | ||
81 | case TYPE_WIDE_CHAR: | ||
82 | /* Although ISO C 99 7.24.1.(2) says that wint_t is "unchanged by | ||
83 | default argument promotions", this is not the case in mingw32, | ||
84 | where wint_t is 'unsigned short'. */ | ||
85 | ap->a.a_wide_char = | ||
86 | (sizeof (wint_t) < sizeof (int) | ||
87 | ? va_arg (args, int) | ||
88 | : va_arg (args, wint_t)); | ||
89 | break; | ||
90 | #endif | ||
91 | case TYPE_STRING: | ||
92 | ap->a.a_string = va_arg (args, const char *); | ||
93 | /* A null pointer is an invalid argument for "%s", but in practice | ||
94 | it occurs quite frequently in printf statements that produce | ||
95 | debug output. Use a fallback in this case. */ | ||
96 | if (ap->a.a_string == NULL) | ||
97 | ap->a.a_string = "(NULL)"; | ||
98 | break; | ||
99 | #ifdef HAVE_WCHAR_T | ||
100 | case TYPE_WIDE_STRING: | ||
101 | ap->a.a_wide_string = va_arg (args, const wchar_t *); | ||
102 | /* A null pointer is an invalid argument for "%ls", but in practice | ||
103 | it occurs quite frequently in printf statements that produce | ||
104 | debug output. Use a fallback in this case. */ | ||
105 | if (ap->a.a_wide_string == NULL) | ||
106 | { | ||
107 | static const wchar_t wide_null_string[] = | ||
108 | { | ||
109 | (wchar_t)'(', | ||
110 | (wchar_t)'N', (wchar_t)'U', (wchar_t)'L', (wchar_t)'L', | ||
111 | (wchar_t)')', | ||
112 | (wchar_t)0 | ||
113 | }; | ||
114 | ap->a.a_wide_string = wide_null_string; | ||
115 | } | ||
116 | break; | ||
117 | #endif | ||
118 | case TYPE_POINTER: | ||
119 | ap->a.a_pointer = va_arg (args, void *); | ||
120 | break; | ||
121 | case TYPE_COUNT_SCHAR_POINTER: | ||
122 | ap->a.a_count_schar_pointer = va_arg (args, signed char *); | ||
123 | break; | ||
124 | case TYPE_COUNT_SHORT_POINTER: | ||
125 | ap->a.a_count_short_pointer = va_arg (args, short *); | ||
126 | break; | ||
127 | case TYPE_COUNT_INT_POINTER: | ||
128 | ap->a.a_count_int_pointer = va_arg (args, int *); | ||
129 | break; | ||
130 | case TYPE_COUNT_LONGINT_POINTER: | ||
131 | ap->a.a_count_longint_pointer = va_arg (args, long int *); | ||
132 | break; | ||
133 | #ifdef HAVE_LONG_LONG | ||
134 | case TYPE_COUNT_LONGLONGINT_POINTER: | ||
135 | ap->a.a_count_longlongint_pointer = va_arg (args, long long int *); | ||
136 | break; | ||
137 | #endif | ||
138 | default: | ||
139 | /* Unknown type. */ | ||
140 | return -1; | ||
141 | } | ||
142 | return 0; | ||
143 | } |
mailbox/printf-args.h
deleted
100644 → 0
1 | /* Decomposed printf argument list. | ||
2 | Copyright (C) 1999, 2002-2003 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 along | ||
15 | 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 _PRINTF_ARGS_H | ||
19 | #define _PRINTF_ARGS_H | ||
20 | |||
21 | /* Get size_t. */ | ||
22 | #include <stddef.h> | ||
23 | |||
24 | /* Get wchar_t. */ | ||
25 | #ifdef HAVE_WCHAR_T | ||
26 | # include <stddef.h> | ||
27 | #endif | ||
28 | |||
29 | /* Get wint_t. */ | ||
30 | #ifdef HAVE_WINT_T | ||
31 | # include <wchar.h> | ||
32 | #endif | ||
33 | |||
34 | /* Get va_list. */ | ||
35 | #include <stdarg.h> | ||
36 | |||
37 | |||
38 | /* Argument types */ | ||
39 | typedef enum | ||
40 | { | ||
41 | TYPE_NONE, | ||
42 | TYPE_SCHAR, | ||
43 | TYPE_UCHAR, | ||
44 | TYPE_SHORT, | ||
45 | TYPE_USHORT, | ||
46 | TYPE_INT, | ||
47 | TYPE_UINT, | ||
48 | TYPE_LONGINT, | ||
49 | TYPE_ULONGINT, | ||
50 | #ifdef HAVE_LONG_LONG | ||
51 | TYPE_LONGLONGINT, | ||
52 | TYPE_ULONGLONGINT, | ||
53 | #endif | ||
54 | TYPE_DOUBLE, | ||
55 | #ifdef HAVE_LONG_DOUBLE | ||
56 | TYPE_LONGDOUBLE, | ||
57 | #endif | ||
58 | TYPE_CHAR, | ||
59 | #ifdef HAVE_WINT_T | ||
60 | TYPE_WIDE_CHAR, | ||
61 | #endif | ||
62 | TYPE_STRING, | ||
63 | #ifdef HAVE_WCHAR_T | ||
64 | TYPE_WIDE_STRING, | ||
65 | #endif | ||
66 | TYPE_POINTER, | ||
67 | TYPE_COUNT_SCHAR_POINTER, | ||
68 | TYPE_COUNT_SHORT_POINTER, | ||
69 | TYPE_COUNT_INT_POINTER, | ||
70 | TYPE_COUNT_LONGINT_POINTER | ||
71 | #ifdef HAVE_LONG_LONG | ||
72 | , TYPE_COUNT_LONGLONGINT_POINTER | ||
73 | #endif | ||
74 | } arg_type; | ||
75 | |||
76 | /* Polymorphic argument */ | ||
77 | typedef struct | ||
78 | { | ||
79 | arg_type type; | ||
80 | union | ||
81 | { | ||
82 | signed char a_schar; | ||
83 | unsigned char a_uchar; | ||
84 | short a_short; | ||
85 | unsigned short a_ushort; | ||
86 | int a_int; | ||
87 | unsigned int a_uint; | ||
88 | long int a_longint; | ||
89 | unsigned long int a_ulongint; | ||
90 | #ifdef HAVE_LONG_LONG | ||
91 | long long int a_longlongint; | ||
92 | unsigned long long int a_ulonglongint; | ||
93 | #endif | ||
94 | float a_float; | ||
95 | double a_double; | ||
96 | #ifdef HAVE_LONG_DOUBLE | ||
97 | long double a_longdouble; | ||
98 | #endif | ||
99 | int a_char; | ||
100 | #ifdef HAVE_WINT_T | ||
101 | wint_t a_wide_char; | ||
102 | #endif | ||
103 | const char* a_string; | ||
104 | #ifdef HAVE_WCHAR_T | ||
105 | const wchar_t* a_wide_string; | ||
106 | #endif | ||
107 | void* a_pointer; | ||
108 | signed char * a_count_schar_pointer; | ||
109 | short * a_count_short_pointer; | ||
110 | int * a_count_int_pointer; | ||
111 | long int * a_count_longint_pointer; | ||
112 | #ifdef HAVE_LONG_LONG | ||
113 | long long int * a_count_longlongint_pointer; | ||
114 | #endif | ||
115 | } | ||
116 | a; | ||
117 | } | ||
118 | argument; | ||
119 | |||
120 | typedef struct | ||
121 | { | ||
122 | size_t count; | ||
123 | argument *arg; | ||
124 | } | ||
125 | arguments; | ||
126 | |||
127 | |||
128 | /* Fetch the arguments, putting them into a. */ | ||
129 | #ifdef STATIC | ||
130 | STATIC | ||
131 | #else | ||
132 | extern | ||
133 | #endif | ||
134 | int printf_fetchargs (va_list args, arguments *a); | ||
135 | |||
136 | #endif /* _PRINTF_ARGS_H */ |
mailbox/printf-parse.c
deleted
100644 → 0
This diff is collapsed.
Click to expand it.
mailbox/printf-parse.h
deleted
100644 → 0
1 | /* Parse printf format string. | ||
2 | Copyright (C) 1999, 2002-2003 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 along | ||
15 | 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 _PRINTF_PARSE_H | ||
19 | #define _PRINTF_PARSE_H | ||
20 | |||
21 | #include "printf-args.h" | ||
22 | |||
23 | |||
24 | /* Flags */ | ||
25 | #define FLAG_GROUP 1 /* ' flag */ | ||
26 | #define FLAG_LEFT 2 /* - flag */ | ||
27 | #define FLAG_SHOWSIGN 4 /* + flag */ | ||
28 | #define FLAG_SPACE 8 /* space flag */ | ||
29 | #define FLAG_ALT 16 /* # flag */ | ||
30 | #define FLAG_ZERO 32 | ||
31 | |||
32 | /* arg_index value indicating that no argument is consumed. */ | ||
33 | #define ARG_NONE (~(size_t)0) | ||
34 | |||
35 | /* A parsed directive. */ | ||
36 | typedef struct | ||
37 | { | ||
38 | const char* dir_start; | ||
39 | const char* dir_end; | ||
40 | int flags; | ||
41 | const char* width_start; | ||
42 | const char* width_end; | ||
43 | size_t width_arg_index; | ||
44 | const char* precision_start; | ||
45 | const char* precision_end; | ||
46 | size_t precision_arg_index; | ||
47 | char conversion; /* d i o u x X f e E g G c s p n U % but not C S */ | ||
48 | size_t arg_index; | ||
49 | } | ||
50 | char_directive; | ||
51 | |||
52 | /* A parsed format string. */ | ||
53 | typedef struct | ||
54 | { | ||
55 | size_t count; | ||
56 | char_directive *dir; | ||
57 | size_t max_width_length; | ||
58 | size_t max_precision_length; | ||
59 | } | ||
60 | char_directives; | ||
61 | |||
62 | |||
63 | /* Parses the format string. Fills in the number N of directives, and fills | ||
64 | in directives[0], ..., directives[N-1], and sets directives[N].dir_start | ||
65 | to the end of the format string. Also fills in the arg_type fields of the | ||
66 | arguments and the needed count of arguments. */ | ||
67 | #ifdef STATIC | ||
68 | STATIC | ||
69 | #else | ||
70 | extern | ||
71 | #endif | ||
72 | int printf_parse (const char *format, char_directives *d, arguments *a); | ||
73 | |||
74 | #endif /* _PRINTF_PARSE_H */ |
mailbox/regcomp.c
deleted
100644 → 0
This diff could not be displayed because it is too large.
mailbox/regex.c
deleted
100644 → 0
1 | /* Extended regular expression matching and search library. | ||
2 | Copyright (C) 2002, 2003, 2005, 2006 Free Software Foundation, Inc. | ||
3 | This file is part of the GNU C Library. | ||
4 | Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>. | ||
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 | /* Make sure noone compiles this code with a C++ compiler. */ | ||
25 | #if defined __cplusplus && defined _LIBC | ||
26 | # error "This is C code, use a C compiler" | ||
27 | #endif | ||
28 | |||
29 | #ifdef _LIBC | ||
30 | /* We have to keep the namespace clean. */ | ||
31 | # define regfree(preg) __regfree (preg) | ||
32 | # define regexec(pr, st, nm, pm, ef) __regexec (pr, st, nm, pm, ef) | ||
33 | # define regcomp(preg, pattern, cflags) __regcomp (preg, pattern, cflags) | ||
34 | # define regerror(errcode, preg, errbuf, errbuf_size) \ | ||
35 | __regerror(errcode, preg, errbuf, errbuf_size) | ||
36 | # define re_set_registers(bu, re, nu, st, en) \ | ||
37 | __re_set_registers (bu, re, nu, st, en) | ||
38 | # define re_match_2(bufp, string1, size1, string2, size2, pos, regs, stop) \ | ||
39 | __re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop) | ||
40 | # define re_match(bufp, string, size, pos, regs) \ | ||
41 | __re_match (bufp, string, size, pos, regs) | ||
42 | # define re_search(bufp, string, size, startpos, range, regs) \ | ||
43 | __re_search (bufp, string, size, startpos, range, regs) | ||
44 | # define re_compile_pattern(pattern, length, bufp) \ | ||
45 | __re_compile_pattern (pattern, length, bufp) | ||
46 | # define re_set_syntax(syntax) __re_set_syntax (syntax) | ||
47 | # define re_search_2(bufp, st1, s1, st2, s2, startpos, range, regs, stop) \ | ||
48 | __re_search_2 (bufp, st1, s1, st2, s2, startpos, range, regs, stop) | ||
49 | # define re_compile_fastmap(bufp) __re_compile_fastmap (bufp) | ||
50 | |||
51 | # include "../locale/localeinfo.h" | ||
52 | #endif | ||
53 | |||
54 | /* On some systems, limits.h sets RE_DUP_MAX to a lower value than | ||
55 | GNU regex allows. Include it before <regex.h>, which correctly | ||
56 | #undefs RE_DUP_MAX and sets it to the right value. */ | ||
57 | #include <limits.h> | ||
58 | |||
59 | #include <regex.h> | ||
60 | #include "regex_internal.h" | ||
61 | |||
62 | #include "regex_internal.c" | ||
63 | #include "regcomp.c" | ||
64 | #include "regexec.c" | ||
65 | |||
66 | /* Binary backward compatibility. */ | ||
67 | #if _LIBC | ||
68 | # include <shlib-compat.h> | ||
69 | # if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_3) | ||
70 | link_warning (re_max_failures, "the 're_max_failures' variable is obsolete and will go away.") | ||
71 | int re_max_failures = 2000; | ||
72 | # endif | ||
73 | #endif |
mailbox/regex.h
deleted
100644 → 0
This diff is collapsed.
Click to expand it.
mailbox/regex_internal.c
deleted
100644 → 0
This diff is collapsed.
Click to expand it.
mailbox/regex_internal.h
deleted
100644 → 0
This diff is collapsed.
Click to expand it.
mailbox/regexec.c
deleted
100644 → 0
This diff could not be displayed because it is too large.
mailbox/stat-macros.h
deleted
100644 → 0
1 | /* stat-related macros | ||
2 | |||
3 | Copyright (C) 1993, 1994, 2001, 2002, 2004, 2006 Free Software | ||
4 | Foundation, Inc. | ||
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 | ||
17 | along 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 | /* Written by Paul Eggert and Jim Meyering. */ | ||
21 | |||
22 | #ifndef STAT_MACROS_H | ||
23 | # define STAT_MACROS_H 1 | ||
24 | |||
25 | # if ! defined S_ISREG && ! defined S_IFREG | ||
26 | # error "you must include <sys/stat.h> before including this file" | ||
27 | # endif | ||
28 | |||
29 | # ifndef S_IFMT | ||
30 | # define S_IFMT 0170000 | ||
31 | # endif | ||
32 | |||
33 | # if STAT_MACROS_BROKEN | ||
34 | # undef S_ISBLK | ||
35 | # undef S_ISCHR | ||
36 | # undef S_ISDIR | ||
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 | # define S_ISDOOR(m) 0 | ||
74 | # endif | ||
75 | |||
76 | # ifndef S_ISFIFO | ||
77 | # ifdef S_IFIFO | ||
78 | # define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) | ||
79 | # else | ||
80 | # define S_ISFIFO(m) 0 | ||
81 | # endif | ||
82 | # endif | ||
83 | |||
84 | # ifndef S_ISLNK | ||
85 | # ifdef S_IFLNK | ||
86 | # define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) | ||
87 | # else | ||
88 | # define S_ISLNK(m) 0 | ||
89 | # endif | ||
90 | # endif | ||
91 | |||
92 | # ifndef S_ISMPB /* V7 */ | ||
93 | # ifdef S_IFMPB | ||
94 | # define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB) | ||
95 | # define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC) | ||
96 | # else | ||
97 | # define S_ISMPB(m) 0 | ||
98 | # define S_ISMPC(m) 0 | ||
99 | # endif | ||
100 | # endif | ||
101 | |||
102 | # ifndef S_ISNAM /* Xenix */ | ||
103 | # ifdef S_IFNAM | ||
104 | # define S_ISNAM(m) (((m) & S_IFMT) == S_IFNAM) | ||
105 | # else | ||
106 | # define S_ISNAM(m) 0 | ||
107 | # endif | ||
108 | # endif | ||
109 | |||
110 | # ifndef S_ISNWK /* HP/UX */ | ||
111 | # ifdef S_IFNWK | ||
112 | # define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK) | ||
113 | # else | ||
114 | # define S_ISNWK(m) 0 | ||
115 | # endif | ||
116 | # endif | ||
117 | |||
118 | # ifndef S_ISPORT /* Solaris 10 and up */ | ||
119 | # define S_ISPORT(m) 0 | ||
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 | /* high performance ("contiguous data") */ | ||
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 | /* 4.4BSD whiteout */ | ||
180 | # ifndef S_ISWHT | ||
181 | # define S_ISWHT(m) 0 | ||
182 | # endif | ||
183 | |||
184 | /* If any of the following are undefined, | ||
185 | define them to their de facto standard values. */ | ||
186 | # if !S_ISUID | ||
187 | # define S_ISUID 04000 | ||
188 | # endif | ||
189 | # if !S_ISGID | ||
190 | # define S_ISGID 02000 | ||
191 | # endif | ||
192 | |||
193 | /* S_ISVTX is a common extension to POSIX. */ | ||
194 | # ifndef S_ISVTX | ||
195 | # define S_ISVTX 01000 | ||
196 | # endif | ||
197 | |||
198 | # if !S_IRUSR && S_IREAD | ||
199 | # define S_IRUSR S_IREAD | ||
200 | # endif | ||
201 | # if !S_IRUSR | ||
202 | # define S_IRUSR 00400 | ||
203 | # endif | ||
204 | # if !S_IRGRP | ||
205 | # define S_IRGRP (S_IRUSR >> 3) | ||
206 | # endif | ||
207 | # if !S_IROTH | ||
208 | # define S_IROTH (S_IRUSR >> 6) | ||
209 | # endif | ||
210 | |||
211 | # if !S_IWUSR && S_IWRITE | ||
212 | # define S_IWUSR S_IWRITE | ||
213 | # endif | ||
214 | # if !S_IWUSR | ||
215 | # define S_IWUSR 00200 | ||
216 | # endif | ||
217 | # if !S_IWGRP | ||
218 | # define S_IWGRP (S_IWUSR >> 3) | ||
219 | # endif | ||
220 | # if !S_IWOTH | ||
221 | # define S_IWOTH (S_IWUSR >> 6) | ||
222 | # endif | ||
223 | |||
224 | # if !S_IXUSR && S_IEXEC | ||
225 | # define S_IXUSR S_IEXEC | ||
226 | # endif | ||
227 | # if !S_IXUSR | ||
228 | # define S_IXUSR 00100 | ||
229 | # endif | ||
230 | # if !S_IXGRP | ||
231 | # define S_IXGRP (S_IXUSR >> 3) | ||
232 | # endif | ||
233 | # if !S_IXOTH | ||
234 | # define S_IXOTH (S_IXUSR >> 6) | ||
235 | # endif | ||
236 | |||
237 | # if !S_IRWXU | ||
238 | # define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR) | ||
239 | # endif | ||
240 | # if !S_IRWXG | ||
241 | # define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP) | ||
242 | # endif | ||
243 | # if !S_IRWXO | ||
244 | # define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH) | ||
245 | # endif | ||
246 | |||
247 | /* S_IXUGO is a common extension to POSIX. */ | ||
248 | # if !S_IXUGO | ||
249 | # define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH) | ||
250 | # endif | ||
251 | |||
252 | # ifndef S_IRWXUGO | ||
253 | # define S_IRWXUGO (S_IRWXU | S_IRWXG | S_IRWXO) | ||
254 | # endif | ||
255 | |||
256 | /* All the mode bits that can be affected by chmod. */ | ||
257 | # define CHMOD_MODE_BITS \ | ||
258 | (S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO) | ||
259 | |||
260 | #endif /* STAT_MACROS_H */ |
mailbox/stdbool_.h
deleted
100644 → 0
1 | /* Copyright (C) 2001, 2002, 2003, 2006 Free Software Foundation, Inc. | ||
2 | Written by Bruno Haible <haible@clisp.cons.org>, 2001. | ||
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 _STDBOOL_H | ||
19 | #define _STDBOOL_H | ||
20 | |||
21 | /* ISO C 99 <stdbool.h> for platforms that lack it. */ | ||
22 | |||
23 | /* Usage suggestions: | ||
24 | |||
25 | Programs that use <stdbool.h> should be aware of some limitations | ||
26 | and standards compliance issues. | ||
27 | |||
28 | Standards compliance: | ||
29 | |||
30 | - <stdbool.h> must be #included before 'bool', 'false', 'true' | ||
31 | can be used. | ||
32 | |||
33 | - You cannot assume that sizeof (bool) == 1. | ||
34 | |||
35 | - Programs should not undefine the macros bool, true, and false, | ||
36 | as C99 lists that as an "obsolescent feature". | ||
37 | |||
38 | Limitations of this substitute, when used in a C89 environment: | ||
39 | |||
40 | - <stdbool.h> must be #included before the '_Bool' type can be used. | ||
41 | |||
42 | - You cannot assume that _Bool is a typedef; it might be a macro. | ||
43 | |||
44 | - In C99, casts and automatic conversions to '_Bool' or 'bool' are | ||
45 | performed in such a way that every nonzero value gets converted | ||
46 | to 'true', and zero gets converted to 'false'. This doesn't work | ||
47 | with this substitute. With this substitute, only the values 0 and 1 | ||
48 | give the expected result when converted to _Bool' or 'bool'. | ||
49 | |||
50 | Also, it is suggested that programs use 'bool' rather than '_Bool'; | ||
51 | this isn't required, but 'bool' is more common. */ | ||
52 | |||
53 | |||
54 | /* 7.16. Boolean type and values */ | ||
55 | |||
56 | /* BeOS <sys/socket.h> already #defines false 0, true 1. We use the same | ||
57 | definitions below, but temporarily we have to #undef them. */ | ||
58 | #ifdef __BEOS__ | ||
59 | # include <OS.h> /* defines bool but not _Bool */ | ||
60 | # undef false | ||
61 | # undef true | ||
62 | #endif | ||
63 | |||
64 | /* For the sake of symbolic names in gdb, we define true and false as | ||
65 | enum constants, not only as macros. | ||
66 | It is tempting to write | ||
67 | typedef enum { false = 0, true = 1 } _Bool; | ||
68 | so that gdb prints values of type 'bool' symbolically. But if we do | ||
69 | this, values of type '_Bool' may promote to 'int' or 'unsigned int' | ||
70 | (see ISO C 99 6.7.2.2.(4)); however, '_Bool' must promote to 'int' | ||
71 | (see ISO C 99 6.3.1.1.(2)). So we add a negative value to the | ||
72 | enum; this ensures that '_Bool' promotes to 'int'. */ | ||
73 | #if defined __cplusplus || defined __BEOS__ | ||
74 | /* A compiler known to have 'bool'. */ | ||
75 | /* If the compiler already has both 'bool' and '_Bool', we can assume they | ||
76 | are the same types. */ | ||
77 | # if !@HAVE__BOOL@ | ||
78 | typedef bool _Bool; | ||
79 | # endif | ||
80 | #else | ||
81 | # if !defined __GNUC__ | ||
82 | /* If @HAVE__BOOL@: | ||
83 | Some HP-UX cc and AIX IBM C compiler versions have compiler bugs when | ||
84 | the built-in _Bool type is used. See | ||
85 | http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html | ||
86 | http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html | ||
87 | http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html | ||
88 | Similar bugs are likely with other compilers as well; this file | ||
89 | wouldn't be used if <stdbool.h> was working. | ||
90 | So we override the _Bool type. | ||
91 | If !@HAVE__BOOL@: | ||
92 | Need to define _Bool ourselves. As 'signed char' or as an enum type? | ||
93 | Use of a typedef, with SunPRO C, leads to a stupid | ||
94 | "warning: _Bool is a keyword in ISO C99". | ||
95 | Use of an enum type, with IRIX cc, leads to a stupid | ||
96 | "warning(1185): enumerated type mixed with another type". | ||
97 | The only benefit of the enum type, debuggability, is not important | ||
98 | with these compilers. So use 'signed char' and no typedef. */ | ||
99 | # define _Bool signed char | ||
100 | enum { false = 0, true = 1 }; | ||
101 | # else | ||
102 | /* With this compiler, trust the _Bool type if the compiler has it. */ | ||
103 | # if !@HAVE__BOOL@ | ||
104 | typedef enum { _Bool_must_promote_to_int = -1, false = 0, true = 1 } _Bool; | ||
105 | # endif | ||
106 | # endif | ||
107 | #endif | ||
108 | #define bool _Bool | ||
109 | |||
110 | /* The other macros must be usable in preprocessor directives. */ | ||
111 | #define false 0 | ||
112 | #define true 1 | ||
113 | #define __bool_true_false_are_defined 1 | ||
114 | |||
115 | #endif /* _STDBOOL_H */ |
mailbox/stdint_.h
deleted
100644 → 0
This diff is collapsed.
Click to expand it.
mailbox/strcase.h
deleted
100644 → 0
1 | /* Case-insensitive string comparison functions. | ||
2 | Copyright (C) 1995-1996, 2001, 2003, 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 _STRCASE_H | ||
19 | #define _STRCASE_H | ||
20 | |||
21 | #include <stddef.h> | ||
22 | |||
23 | |||
24 | #ifdef __cplusplus | ||
25 | extern "C" { | ||
26 | #endif | ||
27 | |||
28 | |||
29 | /* Compare strings S1 and S2, ignoring case, returning less than, equal to or | ||
30 | greater than zero if S1 is lexicographically less than, equal to or greater | ||
31 | than S2. | ||
32 | Note: This function may, in multibyte locales, return 0 for strings of | ||
33 | different lengths! */ | ||
34 | extern int strcasecmp (const char *s1, const char *s2); | ||
35 | |||
36 | /* Compare no more than N characters of strings S1 and S2, ignoring case, | ||
37 | returning less than, equal to or greater than zero if S1 is | ||
38 | lexicographically less than, equal to or greater than S2. | ||
39 | Note: This function can not work correctly in multibyte locales. */ | ||
40 | extern int strncasecmp (const char *s1, const char *s2, size_t n); | ||
41 | |||
42 | |||
43 | #ifdef __cplusplus | ||
44 | } | ||
45 | #endif | ||
46 | |||
47 | |||
48 | #endif /* _STRCASE_H */ |
mailbox/strcasecmp.c
deleted
100644 → 0
1 | /* Case-insensitive string comparison function. | ||
2 | Copyright (C) 1998, 1999, 2005 Free Software Foundation, Inc. | ||
3 | Written by Bruno Haible <bruno@clisp.org>, 2005, | ||
4 | based on earlier glibc code. | ||
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 | ||
17 | along 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 | /* Specification. */ | ||
25 | #include "strcase.h" | ||
26 | |||
27 | #include <ctype.h> | ||
28 | #include <limits.h> | ||
29 | |||
30 | #if HAVE_MBRTOWC | ||
31 | # include "mbuiter.h" | ||
32 | #endif | ||
33 | |||
34 | #define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch)) | ||
35 | |||
36 | /* Compare strings S1 and S2, ignoring case, returning less than, equal to or | ||
37 | greater than zero if S1 is lexicographically less than, equal to or greater | ||
38 | than S2. | ||
39 | Note: This function may, in multibyte locales, return 0 for strings of | ||
40 | different lengths! */ | ||
41 | int | ||
42 | strcasecmp (const char *s1, const char *s2) | ||
43 | { | ||
44 | if (s1 == s2) | ||
45 | return 0; | ||
46 | |||
47 | /* Be careful not to look at the entire extent of s1 or s2 until needed. | ||
48 | This is useful because when two strings differ, the difference is | ||
49 | most often already in the very few first characters. */ | ||
50 | #if HAVE_MBRTOWC | ||
51 | if (MB_CUR_MAX > 1) | ||
52 | { | ||
53 | mbui_iterator_t iter1; | ||
54 | mbui_iterator_t iter2; | ||
55 | |||
56 | mbui_init (iter1, s1); | ||
57 | mbui_init (iter2, s2); | ||
58 | |||
59 | while (mbui_avail (iter1) && mbui_avail (iter2)) | ||
60 | { | ||
61 | int cmp = mb_casecmp (mbui_cur (iter1), mbui_cur (iter2)); | ||
62 | |||
63 | if (cmp != 0) | ||
64 | return cmp; | ||
65 | |||
66 | mbui_advance (iter1); | ||
67 | mbui_advance (iter2); | ||
68 | } | ||
69 | if (mbui_avail (iter1)) | ||
70 | /* s2 terminated before s1. */ | ||
71 | return 1; | ||
72 | if (mbui_avail (iter2)) | ||
73 | /* s1 terminated before s2. */ | ||
74 | return -1; | ||
75 | return 0; | ||
76 | } | ||
77 | else | ||
78 | #endif | ||
79 | { | ||
80 | const unsigned char *p1 = (const unsigned char *) s1; | ||
81 | const unsigned char *p2 = (const unsigned char *) s2; | ||
82 | unsigned char c1, c2; | ||
83 | |||
84 | do | ||
85 | { | ||
86 | c1 = TOLOWER (*p1); | ||
87 | c2 = TOLOWER (*p2); | ||
88 | |||
89 | if (c1 == '\0') | ||
90 | break; | ||
91 | |||
92 | ++p1; | ||
93 | ++p2; | ||
94 | } | ||
95 | while (c1 == c2); | ||
96 | |||
97 | if (UCHAR_MAX <= INT_MAX) | ||
98 | return c1 - c2; | ||
99 | else | ||
100 | /* On machines where 'char' and 'int' are types of the same size, the | ||
101 | difference of two 'unsigned char' values - including the sign bit - | ||
102 | doesn't fit in an 'int'. */ | ||
103 | return (c1 > c2 ? 1 : c1 < c2 ? -1 : 0); | ||
104 | } | ||
105 | } |
mailbox/strchrnul.c
deleted
100644 → 0
1 | /* Searching in a string. | ||
2 | Copyright (C) 2003 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 | /* Specification. */ | ||
19 | #include "strchrnul.h" | ||
20 | |||
21 | /* Find the first occurrence of C in S or the final NUL byte. */ | ||
22 | char * | ||
23 | strchrnul (const char *s, int c_in) | ||
24 | { | ||
25 | char c = c_in; | ||
26 | while (*s && (*s != c)) | ||
27 | s++; | ||
28 | |||
29 | return (char *) s; | ||
30 | } |
mailbox/strchrnul.h
deleted
100644 → 0
1 | /* Searching in a string. | ||
2 | Copyright (C) 2003 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 | #if HAVE_STRCHRNUL | ||
19 | |||
20 | /* Get strchrnul() declaration. */ | ||
21 | #include <string.h> | ||
22 | |||
23 | #else | ||
24 | |||
25 | /* Find the first occurrence of C in S or the final NUL byte. */ | ||
26 | extern char *strchrnul (const char *s, int c_in); | ||
27 | |||
28 | #endif |
mailbox/strdup.c
deleted
100644 → 0
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 |
mailbox/strdup.h
deleted
100644 → 0
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_ */ |
mailbox/strncasecmp.c
deleted
100644 → 0
1 | /* strncasecmp.c -- case insensitive string comparator | ||
2 | Copyright (C) 1998, 1999, 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 | #ifdef HAVE_CONFIG_H | ||
19 | # include <config.h> | ||
20 | #endif | ||
21 | |||
22 | /* Specification. */ | ||
23 | #include "strcase.h" | ||
24 | |||
25 | #include <ctype.h> | ||
26 | #include <limits.h> | ||
27 | |||
28 | #define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch)) | ||
29 | |||
30 | /* Compare no more than N bytes of strings S1 and S2, | ||
31 | ignoring case, returning less than, equal to or | ||
32 | greater than zero if S1 is lexicographically less | ||
33 | than, equal to or greater than S2. */ | ||
34 | |||
35 | int | ||
36 | strncasecmp (const char *s1, const char *s2, size_t n) | ||
37 | { | ||
38 | register const unsigned char *p1 = (const unsigned char *) s1; | ||
39 | register const unsigned char *p2 = (const unsigned char *) s2; | ||
40 | unsigned char c1, c2; | ||
41 | |||
42 | if (p1 == p2 || n == 0) | ||
43 | return 0; | ||
44 | |||
45 | do | ||
46 | { | ||
47 | c1 = TOLOWER (*p1); | ||
48 | c2 = TOLOWER (*p2); | ||
49 | |||
50 | if (--n == 0 || c1 == '\0') | ||
51 | break; | ||
52 | |||
53 | ++p1; | ||
54 | ++p2; | ||
55 | } | ||
56 | while (c1 == c2); | ||
57 | |||
58 | if (UCHAR_MAX <= INT_MAX) | ||
59 | return c1 - c2; | ||
60 | else | ||
61 | /* On machines where 'char' and 'int' are types of the same size, the | ||
62 | difference of two 'unsigned char' values - including the sign bit - | ||
63 | doesn't fit in an 'int'. */ | ||
64 | return (c1 > c2 ? 1 : c1 < c2 ? -1 : 0); | ||
65 | } |
mailbox/strndup.c
deleted
100644 → 0
1 | /* Copyright (C) 1996, 1997, 1998, 2001, 2002, 2003, 2005, 2006 Free | ||
2 | Software Foundation, Inc. | ||
3 | |||
4 | NOTE: The canonical source of this file is maintained with the GNU C Library. | ||
5 | Bugs can be reported to bug-glibc@prep.ai.mit.edu. | ||
6 | |||
7 | This program is free software; you can redistribute it and/or modify it | ||
8 | under the terms of the GNU General Public License as published by the | ||
9 | Free Software Foundation; either version 2, or (at your option) any | ||
10 | 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 | #ifdef HAVE_CONFIG_H | ||
22 | # include <config.h> | ||
23 | #endif | ||
24 | #if !_LIBC | ||
25 | # include "strndup.h" | ||
26 | #endif | ||
27 | |||
28 | #include <stdlib.h> | ||
29 | #include <string.h> | ||
30 | |||
31 | #if !_LIBC | ||
32 | # include "strnlen.h" | ||
33 | # ifndef __strnlen | ||
34 | # define __strnlen strnlen | ||
35 | # endif | ||
36 | #endif | ||
37 | |||
38 | #undef __strndup | ||
39 | #if _LIBC | ||
40 | # undef strndup | ||
41 | #endif | ||
42 | |||
43 | #ifndef weak_alias | ||
44 | # define __strndup strndup | ||
45 | #endif | ||
46 | |||
47 | char * | ||
48 | __strndup (s, n) | ||
49 | const char *s; | ||
50 | size_t n; | ||
51 | { | ||
52 | size_t len = __strnlen (s, n); | ||
53 | char *new = malloc (len + 1); | ||
54 | |||
55 | if (new == NULL) | ||
56 | return NULL; | ||
57 | |||
58 | new[len] = '\0'; | ||
59 | return memcpy (new, s, len); | ||
60 | } | ||
61 | #ifdef libc_hidden_def | ||
62 | libc_hidden_def (__strndup) | ||
63 | #endif | ||
64 | #ifdef weak_alias | ||
65 | weak_alias (__strndup, strndup) | ||
66 | #endif |
mailbox/strndup.h
deleted
100644 → 0
1 | /* Duplicate a size-bounded string. | ||
2 | Copyright (C) 2003 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 | #if HAVE_STRNDUP | ||
19 | |||
20 | /* Get strndup() declaration. */ | ||
21 | #include <string.h> | ||
22 | |||
23 | #else | ||
24 | |||
25 | #include <stddef.h> | ||
26 | |||
27 | /* Return a newly allocated copy of at most N bytes of STRING. */ | ||
28 | extern char *strndup (const char *string, size_t n); | ||
29 | |||
30 | #endif |
mailbox/strnlen.c
deleted
100644 → 0
1 | /* Find the length of STRING, but scan at most MAXLEN characters. | ||
2 | Copyright (C) 2005, 2006 Free Software Foundation, Inc. | ||
3 | Written by Simon Josefsson. | ||
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 | #ifdef HAVE_CONFIG_H | ||
20 | # include <config.h> | ||
21 | #endif | ||
22 | |||
23 | #include "strnlen.h" | ||
24 | |||
25 | /* Find the length of STRING, but scan at most MAXLEN characters. | ||
26 | If no '\0' terminator is found in that many characters, return MAXLEN. */ | ||
27 | |||
28 | size_t | ||
29 | strnlen (const char *string, size_t maxlen) | ||
30 | { | ||
31 | const char *end = memchr (string, '\0', maxlen); | ||
32 | return end ? (size_t) (end - string) : maxlen; | ||
33 | } |
mailbox/strnlen.h
deleted
100644 → 0
1 | /* Find the length of STRING, but scan at most MAXLEN characters. | ||
2 | Copyright (C) 2005 Free Software Foundation, Inc. | ||
3 | Written by Simon Josefsson. | ||
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 STRNLEN_H | ||
20 | #define STRNLEN_H | ||
21 | |||
22 | /* Get strnlen declaration, if available. */ | ||
23 | #include <string.h> | ||
24 | |||
25 | #if defined HAVE_DECL_STRNLEN && !HAVE_DECL_STRNLEN | ||
26 | /* Find the length (number of bytes) of STRING, but scan at most | ||
27 | MAXLEN bytes. If no '\0' terminator is found in that many bytes, | ||
28 | return MAXLEN. */ | ||
29 | extern size_t strnlen(const char *string, size_t maxlen); | ||
30 | #endif | ||
31 | |||
32 | #endif /* STRNLEN_H */ |
mailbox/strnlen1.c
deleted
100644 → 0
1 | /* Find the length of STRING + 1, but scan at most MAXLEN bytes. | ||
2 | Copyright (C) 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 | #ifdef HAVE_CONFIG_H | ||
19 | # include <config.h> | ||
20 | #endif | ||
21 | |||
22 | /* Specification. */ | ||
23 | #include "strnlen1.h" | ||
24 | |||
25 | #include <string.h> | ||
26 | |||
27 | /* Find the length of STRING + 1, but scan at most MAXLEN bytes. | ||
28 | If no '\0' terminator is found in that many characters, return MAXLEN. */ | ||
29 | /* This is the same as strnlen (string, maxlen - 1) + 1. */ | ||
30 | size_t | ||
31 | strnlen1 (const char *string, size_t maxlen) | ||
32 | { | ||
33 | const char *end = memchr (string, '\0', maxlen); | ||
34 | if (end != NULL) | ||
35 | return end - string + 1; | ||
36 | else | ||
37 | return maxlen; | ||
38 | } |
mailbox/strnlen1.h
deleted
100644 → 0
1 | /* Find the length of STRING + 1, but scan at most MAXLEN bytes. | ||
2 | Copyright (C) 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 _STRNLEN1_H | ||
19 | #define _STRNLEN1_H | ||
20 | |||
21 | #include <stddef.h> | ||
22 | |||
23 | |||
24 | #ifdef __cplusplus | ||
25 | extern "C" { | ||
26 | #endif | ||
27 | |||
28 | |||
29 | /* Find the length of STRING + 1, but scan at most MAXLEN bytes. | ||
30 | If no '\0' terminator is found in that many characters, return MAXLEN. */ | ||
31 | /* This is the same as strnlen (string, maxlen - 1) + 1. */ | ||
32 | extern size_t strnlen1 (const char *string, size_t maxlen); | ||
33 | |||
34 | |||
35 | #ifdef __cplusplus | ||
36 | } | ||
37 | #endif | ||
38 | |||
39 | |||
40 | #endif /* _STRNLEN1_H */ |
mailbox/strtok_r.c
deleted
100644 → 0
1 | /* Reentrant string tokenizer. Generic version. | ||
2 | Copyright (C) 1991,1996-1999,2001,2004 Free Software Foundation, Inc. | ||
3 | This file is part of the GNU C Library. | ||
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 along | ||
16 | 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 | #ifdef HAVE_CONFIG_H | ||
20 | # include <config.h> | ||
21 | #endif | ||
22 | |||
23 | #include <string.h> | ||
24 | |||
25 | #undef strtok_r | ||
26 | #undef __strtok_r | ||
27 | |||
28 | #ifndef _LIBC | ||
29 | /* Get specification. */ | ||
30 | # include "strtok_r.h" | ||
31 | # define __strtok_r strtok_r | ||
32 | # define __rawmemchr strchr | ||
33 | #endif | ||
34 | |||
35 | /* Parse S into tokens separated by characters in DELIM. | ||
36 | If S is NULL, the saved pointer in SAVE_PTR is used as | ||
37 | the next starting point. For example: | ||
38 | char s[] = "-abc-=-def"; | ||
39 | char *sp; | ||
40 | x = strtok_r(s, "-", &sp); // x = "abc", sp = "=-def" | ||
41 | x = strtok_r(NULL, "-=", &sp); // x = "def", sp = NULL | ||
42 | x = strtok_r(NULL, "=", &sp); // x = NULL | ||
43 | // s = "abc\0-def\0" | ||
44 | */ | ||
45 | char * | ||
46 | __strtok_r (char *s, const char *delim, char **save_ptr) | ||
47 | { | ||
48 | char *token; | ||
49 | |||
50 | if (s == NULL) | ||
51 | s = *save_ptr; | ||
52 | |||
53 | /* Scan leading delimiters. */ | ||
54 | s += strspn (s, delim); | ||
55 | if (*s == '\0') | ||
56 | { | ||
57 | *save_ptr = s; | ||
58 | return NULL; | ||
59 | } | ||
60 | |||
61 | /* Find the end of the token. */ | ||
62 | token = s; | ||
63 | s = strpbrk (token, delim); | ||
64 | if (s == NULL) | ||
65 | /* This token finishes the string. */ | ||
66 | *save_ptr = __rawmemchr (token, '\0'); | ||
67 | else | ||
68 | { | ||
69 | /* Terminate the token and make *SAVE_PTR point past it. */ | ||
70 | *s = '\0'; | ||
71 | *save_ptr = s + 1; | ||
72 | } | ||
73 | return token; | ||
74 | } | ||
75 | #ifdef weak_alias | ||
76 | libc_hidden_def (__strtok_r) | ||
77 | weak_alias (__strtok_r, strtok_r) | ||
78 | #endif |
mailbox/strtok_r.h
deleted
100644 → 0
1 | /* Split string into tokens | ||
2 | Copyright (C) 2004-2005 Free Software Foundation, Inc. | ||
3 | Written by Simon Josefsson. | ||
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 along | ||
16 | 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 STRTOK_R_H | ||
20 | #define STRTOK_R_H | ||
21 | |||
22 | /* Get strtok_r declaration, if available. */ | ||
23 | #include <string.h> | ||
24 | |||
25 | /* Parse S into tokens separated by characters in DELIM. | ||
26 | If S is NULL, the saved pointer in SAVE_PTR is used as | ||
27 | the next starting point. For example: | ||
28 | char s[] = "-abc-=-def"; | ||
29 | char *sp; | ||
30 | x = strtok_r(s, "-", &sp); // x = "abc", sp = "=-def" | ||
31 | x = strtok_r(NULL, "-=", &sp); // x = "def", sp = NULL | ||
32 | x = strtok_r(NULL, "=", &sp); // x = NULL | ||
33 | // s = "abc\0-def\0" | ||
34 | |||
35 | This is a variant of strtok() that is multithread-safe. | ||
36 | |||
37 | For the POSIX documentation for this function, see: | ||
38 | http://www.opengroup.org/susv3xsh/strtok.html | ||
39 | |||
40 | Caveat: It modifies the original string. | ||
41 | Caveat: These functions cannot be used on constant strings. | ||
42 | Caveat: The identity of the delimiting character is lost. | ||
43 | Caveat: It doesn't work with multibyte strings unless all of the delimiter | ||
44 | characters are ASCII characters < 0x30. | ||
45 | |||
46 | See also strsep(). | ||
47 | */ | ||
48 | #if defined HAVE_DECL_STRTOK_R && !HAVE_DECL_STRTOK_R | ||
49 | extern char *strtok_r(char *restrict s, const char *restrict sep, | ||
50 | char **restrict lasts); | ||
51 | #endif | ||
52 | |||
53 | #endif /* STRTOK_R_H */ |
mailbox/sysexit_.h
deleted
100644 → 0
1 | /* exit() exit codes for some BSD system programs. | ||
2 | Copyright (C) 2003, 2006 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 Simon Josefsson based on sysexits(3) man page */ | ||
19 | |||
20 | #ifndef _SYSEXITS_H | ||
21 | #define _SYSEXITS_H | ||
22 | |||
23 | #define EX_OK 0 /* same value as EXIT_SUCCESS */ | ||
24 | |||
25 | #define EX_USAGE 64 | ||
26 | #define EX_DATAERR 65 | ||
27 | #define EX_NOINPUT 66 | ||
28 | #define EX_NOUSER 67 | ||
29 | #define EX_NOHOST 68 | ||
30 | #define EX_UNAVAILABLE 69 | ||
31 | #define EX_SOFTWARE 70 | ||
32 | #define EX_OSERR 71 | ||
33 | #define EX_OSFILE 72 | ||
34 | #define EX_CANTCREAT 73 | ||
35 | #define EX_IOERR 74 | ||
36 | #define EX_TEMPFAIL 75 | ||
37 | #define EX_PROTOCOL 76 | ||
38 | #define EX_NOPERM 77 | ||
39 | #define EX_CONFIG 78 | ||
40 | |||
41 | #endif /* _SYSEXITS_H */ |
mailbox/unlocked-io.h
deleted
100644 → 0
1 | /* Prefer faster, non-thread-safe stdio functions if available. | ||
2 | |||
3 | Copyright (C) 2001, 2002, 2003, 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 along | ||
16 | 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 Jim Meyering. */ | ||
20 | |||
21 | #ifndef UNLOCKED_IO_H | ||
22 | # define UNLOCKED_IO_H 1 | ||
23 | |||
24 | /* These are wrappers for functions/macros from the GNU C library, and | ||
25 | from other C libraries supporting POSIX's optional thread-safe functions. | ||
26 | |||
27 | The standard I/O functions are thread-safe. These *_unlocked ones are | ||
28 | more efficient but not thread-safe. That they're not thread-safe is | ||
29 | fine since all of the applications in this package are single threaded. | ||
30 | |||
31 | Also, some code that is shared with the GNU C library may invoke | ||
32 | the *_unlocked functions directly. On hosts that lack those | ||
33 | functions, invoke the non-thread-safe versions instead. */ | ||
34 | |||
35 | # include <stdio.h> | ||
36 | |||
37 | # if HAVE_DECL_CLEARERR_UNLOCKED | ||
38 | # undef clearerr | ||
39 | # define clearerr(x) clearerr_unlocked (x) | ||
40 | # else | ||
41 | # define clearerr_unlocked(x) clearerr (x) | ||
42 | # endif | ||
43 | |||
44 | # if HAVE_DECL_FEOF_UNLOCKED | ||
45 | # undef feof | ||
46 | # define feof(x) feof_unlocked (x) | ||
47 | # else | ||
48 | # define feof_unlocked(x) feof (x) | ||
49 | # endif | ||
50 | |||
51 | # if HAVE_DECL_FERROR_UNLOCKED | ||
52 | # undef ferror | ||
53 | # define ferror(x) ferror_unlocked (x) | ||
54 | # else | ||
55 | # define ferror_unlocked(x) ferror (x) | ||
56 | # endif | ||
57 | |||
58 | # if HAVE_DECL_FFLUSH_UNLOCKED | ||
59 | # undef fflush | ||
60 | # define fflush(x) fflush_unlocked (x) | ||
61 | # else | ||
62 | # define fflush_unlocked(x) fflush (x) | ||
63 | # endif | ||
64 | |||
65 | # if HAVE_DECL_FGETS_UNLOCKED | ||
66 | # undef fgets | ||
67 | # define fgets(x,y,z) fgets_unlocked (x,y,z) | ||
68 | # else | ||
69 | # define fgets_unlocked(x,y,z) fgets (x,y,z) | ||
70 | # endif | ||
71 | |||
72 | # if HAVE_DECL_FPUTC_UNLOCKED | ||
73 | # undef fputc | ||
74 | # define fputc(x,y) fputc_unlocked (x,y) | ||
75 | # else | ||
76 | # define fputc_unlocked(x,y) fputc (x,y) | ||
77 | # endif | ||
78 | |||
79 | # if HAVE_DECL_FPUTS_UNLOCKED | ||
80 | # undef fputs | ||
81 | # define fputs(x,y) fputs_unlocked (x,y) | ||
82 | # else | ||
83 | # define fputs_unlocked(x,y) fputs (x,y) | ||
84 | # endif | ||
85 | |||
86 | # if HAVE_DECL_FREAD_UNLOCKED | ||
87 | # undef fread | ||
88 | # define fread(w,x,y,z) fread_unlocked (w,x,y,z) | ||
89 | # else | ||
90 | # define fread_unlocked(w,x,y,z) fread (w,x,y,z) | ||
91 | # endif | ||
92 | |||
93 | # if HAVE_DECL_FWRITE_UNLOCKED | ||
94 | # undef fwrite | ||
95 | # define fwrite(w,x,y,z) fwrite_unlocked (w,x,y,z) | ||
96 | # else | ||
97 | # define fwrite_unlocked(w,x,y,z) fwrite (w,x,y,z) | ||
98 | # endif | ||
99 | |||
100 | # if HAVE_DECL_GETC_UNLOCKED | ||
101 | # undef getc | ||
102 | # define getc(x) getc_unlocked (x) | ||
103 | # else | ||
104 | # define getc_unlocked(x) getc (x) | ||
105 | # endif | ||
106 | |||
107 | # if HAVE_DECL_GETCHAR_UNLOCKED | ||
108 | # undef getchar | ||
109 | # define getchar() getchar_unlocked () | ||
110 | # else | ||
111 | # define getchar_unlocked() getchar () | ||
112 | # endif | ||
113 | |||
114 | # if HAVE_DECL_PUTC_UNLOCKED | ||
115 | # undef putc | ||
116 | # define putc(x,y) putc_unlocked (x,y) | ||
117 | # else | ||
118 | # define putc_unlocked(x,y) putc (x,y) | ||
119 | # endif | ||
120 | |||
121 | # if HAVE_DECL_PUTCHAR_UNLOCKED | ||
122 | # undef putchar | ||
123 | # define putchar(x) putchar_unlocked (x) | ||
124 | # else | ||
125 | # define putchar_unlocked(x) putchar (x) | ||
126 | # endif | ||
127 | |||
128 | # undef flockfile | ||
129 | # define flockfile(x) ((void) 0) | ||
130 | |||
131 | # undef ftrylockfile | ||
132 | # define ftrylockfile(x) 0 | ||
133 | |||
134 | # undef funlockfile | ||
135 | # define funlockfile(x) ((void) 0) | ||
136 | |||
137 | #endif /* UNLOCKED_IO_H */ |
mailbox/vasnprintf.c
deleted
100644 → 0
This diff is collapsed.
Click to expand it.
mailbox/vasnprintf.h
deleted
100644 → 0
1 | /* vsprintf with automatic memory allocation. | ||
2 | Copyright (C) 2002-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 along | ||
15 | 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 _VASNPRINTF_H | ||
19 | #define _VASNPRINTF_H | ||
20 | |||
21 | /* Get va_list. */ | ||
22 | #include <stdarg.h> | ||
23 | |||
24 | /* Get size_t. */ | ||
25 | #include <stddef.h> | ||
26 | |||
27 | #ifndef __attribute__ | ||
28 | /* This feature is available in gcc versions 2.5 and later. */ | ||
29 | # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__ | ||
30 | # define __attribute__(Spec) /* empty */ | ||
31 | # endif | ||
32 | /* The __-protected variants of `format' and `printf' attributes | ||
33 | are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */ | ||
34 | # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) | ||
35 | # define __format__ format | ||
36 | # define __printf__ printf | ||
37 | # endif | ||
38 | #endif | ||
39 | |||
40 | #ifdef __cplusplus | ||
41 | extern "C" { | ||
42 | #endif | ||
43 | |||
44 | /* Write formatted output to a string dynamically allocated with malloc(). | ||
45 | You can pass a preallocated buffer for the result in RESULTBUF and its | ||
46 | size in *LENGTHP; otherwise you pass RESULTBUF = NULL. | ||
47 | If successful, return the address of the string (this may be = RESULTBUF | ||
48 | if no dynamic memory allocation was necessary) and set *LENGTHP to the | ||
49 | number of resulting bytes, excluding the trailing NUL. Upon error, set | ||
50 | errno and return NULL. | ||
51 | |||
52 | When dynamic memory allocation occurs, the preallocated buffer is left | ||
53 | alone (with possibly modified contents). This makes it possible to use | ||
54 | a statically allocated or stack-allocated buffer, like this: | ||
55 | |||
56 | char buf[100]; | ||
57 | size_t len = sizeof (buf); | ||
58 | char *output = vasnprintf (buf, &len, format, args); | ||
59 | if (output == NULL) | ||
60 | ... error handling ...; | ||
61 | else | ||
62 | { | ||
63 | ... use the output string ...; | ||
64 | if (output != buf) | ||
65 | free (output); | ||
66 | } | ||
67 | */ | ||
68 | extern char * asnprintf (char *resultbuf, size_t *lengthp, const char *format, ...) | ||
69 | __attribute__ ((__format__ (__printf__, 3, 4))); | ||
70 | extern char * vasnprintf (char *resultbuf, size_t *lengthp, const char *format, va_list args) | ||
71 | __attribute__ ((__format__ (__printf__, 3, 0))); | ||
72 | |||
73 | #ifdef __cplusplus | ||
74 | } | ||
75 | #endif | ||
76 | |||
77 | #endif /* _VASNPRINTF_H */ |
mailbox/vsnprintf.c
deleted
100644 → 0
1 | /* Formatted output to strings. | ||
2 | Copyright (C) 2004, 2006 Free Software Foundation, Inc. | ||
3 | Written by Simon Josefsson and Yoann Vandoorselaere <yoann@prelude-ids.org>. | ||
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 along | ||
16 | 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 | #ifdef HAVE_CONFIG_H | ||
20 | # include <config.h> | ||
21 | #endif | ||
22 | |||
23 | /* Specification. */ | ||
24 | #include "vsnprintf.h" | ||
25 | |||
26 | #include <errno.h> | ||
27 | #include <limits.h> | ||
28 | #include <stdarg.h> | ||
29 | #include <stdio.h> | ||
30 | #include <stdlib.h> | ||
31 | #include <string.h> | ||
32 | |||
33 | #include "vasnprintf.h" | ||
34 | |||
35 | /* Some systems, like OSF/1 4.0 and Woe32, don't have EOVERFLOW. */ | ||
36 | #ifndef EOVERFLOW | ||
37 | # define EOVERFLOW E2BIG | ||
38 | #endif | ||
39 | |||
40 | /* Print formatted output to string STR. Similar to vsprintf, but | ||
41 | additional length SIZE limit how much is written into STR. Returns | ||
42 | string length of formatted string (which may be larger than SIZE). | ||
43 | STR may be NULL, in which case nothing will be written. On error, | ||
44 | return a negative value. */ | ||
45 | int | ||
46 | vsnprintf (char *str, size_t size, const char *format, va_list args) | ||
47 | { | ||
48 | char *output; | ||
49 | size_t len; | ||
50 | size_t lenbuf = size; | ||
51 | |||
52 | output = vasnprintf (str, &lenbuf, format, args); | ||
53 | len = lenbuf; | ||
54 | |||
55 | if (!output) | ||
56 | return -1; | ||
57 | |||
58 | if (output != str) | ||
59 | { | ||
60 | if (size) | ||
61 | { | ||
62 | size_t pruned_len = (len < size ? len : size - 1); | ||
63 | memcpy (str, output, pruned_len); | ||
64 | str[pruned_len] = '\0'; | ||
65 | } | ||
66 | |||
67 | free (output); | ||
68 | } | ||
69 | |||
70 | if (len > INT_MAX) | ||
71 | { | ||
72 | errno = EOVERFLOW; | ||
73 | return -1; | ||
74 | } | ||
75 | |||
76 | return len; | ||
77 | } |
mailbox/vsnprintf.h
deleted
100644 → 0
1 | /* Formatted output to strings. | ||
2 | Copyright (C) 2004 Free Software Foundation, Inc. | ||
3 | Written by Simon Josefsson and Yoann Vandoorselaere <yoann@prelude-ids.org>. | ||
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 along | ||
16 | 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 VSNPRINTF_H | ||
20 | #define VSNPRINTF_H | ||
21 | |||
22 | #include <stdarg.h> | ||
23 | |||
24 | /* Get vsnprintf declaration, if available. */ | ||
25 | #include <stdio.h> | ||
26 | |||
27 | #if defined HAVE_DECL_VSNPRINTF && !HAVE_DECL_VSNPRINTF | ||
28 | int vsnprintf (char *str, size_t size, const char *format, va_list args); | ||
29 | #endif | ||
30 | |||
31 | #endif /* VSNPRINTF_H */ |
mailbox/wcwidth.h
deleted
100644 → 0
1 | /* Determine the number of screen columns needed for a character. | ||
2 | Copyright (C) 2006 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 _gl_WCWIDTH_H | ||
19 | #define _gl_WCWIDTH_H | ||
20 | |||
21 | #if HAVE_WCHAR_T | ||
22 | |||
23 | /* Get wcwidth if available, along with wchar_t. */ | ||
24 | # if HAVE_WCHAR_H | ||
25 | /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before | ||
26 | <wchar.h>. | ||
27 | BSD/OS 4.1 has a bug: <stdio.h> and <time.h> must be included before | ||
28 | <wchar.h>. */ | ||
29 | # include <stdio.h> | ||
30 | # include <time.h> | ||
31 | # include <wchar.h> | ||
32 | # endif | ||
33 | |||
34 | /* Get iswprint. */ | ||
35 | # if HAVE_WCTYPE_H | ||
36 | # include <wctype.h> | ||
37 | # endif | ||
38 | # if !defined iswprint && !HAVE_ISWPRINT | ||
39 | static inline int | ||
40 | iswprint (wint_t wc) | ||
41 | { | ||
42 | return (wc >= 0 && wc < 128 | ||
43 | ? wc >= ' ' && wc <= '~' | ||
44 | : 1); | ||
45 | } | ||
46 | # define iswprint iswprint | ||
47 | # endif | ||
48 | |||
49 | # ifndef HAVE_DECL_WCWIDTH | ||
50 | "this configure-time declaration test was not run" | ||
51 | # endif | ||
52 | # ifndef wcwidth | ||
53 | # if !HAVE_WCWIDTH | ||
54 | |||
55 | /* wcwidth doesn't exist, so assume all printable characters have | ||
56 | width 1. */ | ||
57 | static inline int | ||
58 | wcwidth (wchar_t wc) | ||
59 | { | ||
60 | return wc == 0 ? 0 : iswprint (wc) ? 1 : -1; | ||
61 | } | ||
62 | |||
63 | # elif !HAVE_DECL_WCWIDTH | ||
64 | |||
65 | /* wcwidth exists but is not declared. */ | ||
66 | extern | ||
67 | # ifdef __cplusplus | ||
68 | "C" | ||
69 | # endif | ||
70 | int wcwidth (int /* actually wchar_t */); | ||
71 | |||
72 | # endif | ||
73 | # endif | ||
74 | |||
75 | #endif /* HAVE_WCHAR_H */ | ||
76 | |||
77 | #endif /* _gl_WCWIDTH_H */ |
mailbox/xsize.h
deleted
100644 → 0
This diff is collapsed.
Click to expand it.
-
Please register or sign in to post a comment