d95f48268c772ffdfc320f21d5fad769f0415dde
[gnulib.git] / lib / argp-namefrob.h
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 /* GNULIB makes sure both program_invocation_name and
80    program_invocation_short_name are available */
81 #ifdef GNULIB_PROGRAM_INVOCATION_NAME
82 extern char *program_invocation_name;
83 #undef HAVE_DECL_PROGRAM_INVOCATION_NAME
84 #define HAVE_DECL_PROGRAM_INVOCATION_NAME 1
85 #endif
86
87 #ifdef GNULIB_PROGRAM_INVOCATION_SHORT_NAME
88 extern char *program_invocation_short_name;
89 #undef HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME
90 #define HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME 1
91 #endif
92
93 #include "mempcpy.h"
94 #include "strcase.h"
95 #include "strchrnul.h"
96 #include "strndup.h"
97
98 /* normal libc functions we call */
99 #undef __flockfile
100 #define __flockfile flockfile
101 #undef __funlockfile
102 #define __funlockfile funlockfile
103 #undef __mempcpy
104 #define __mempcpy mempcpy
105 #undef __sleep
106 #define __sleep sleep
107 #undef __strcasecmp
108 #define __strcasecmp strcasecmp
109 #undef __strchrnul
110 #define __strchrnul strchrnul
111 #undef __strerror_r
112 #define __strerror_r strerror_r
113 #undef __strndup
114 #define __strndup strndup
115 #undef __vsnprintf
116 #define __vsnprintf vsnprintf
117
118 #if defined(HAVE_DECL_CLEARERR_UNLOCKED) && !HAVE_DECL_CLEARERR_UNLOCKED
119 # define clearerr_unlocked(x) clearerr (x)
120 #endif
121 #if defined(HAVE_DECL_FEOF_UNLOCKED) && !HAVE_DECL_FEOF_UNLOCKED
122 # define feof_unlocked(x) feof (x)
123 # endif
124 #if defined(HAVE_DECL_FERROR_UNLOCKED) && !HAVE_DECL_FERROR_UNLOCKED
125 # define ferror_unlocked(x) ferror (x)
126 # endif
127 #if defined(HAVE_DECL_FFLUSH_UNLOCKED) && !HAVE_DECL_FFLUSH_UNLOCKED
128 # define fflush_unlocked(x) fflush (x)
129 # endif
130 #if defined(HAVE_DECL_FGETS_UNLOCKED) && !HAVE_DECL_FGETS_UNLOCKED
131 # define fgets_unlocked(x,y,z) fgets (x,y,z)
132 # endif
133 #if defined(HAVE_DECL_FPUTC_UNLOCKED) && !HAVE_DECL_FPUTC_UNLOCKED
134 # define fputc_unlocked(x,y) fputc (x,y)
135 # endif
136 #if defined(HAVE_DECL_FPUTS_UNLOCKED) && !HAVE_DECL_FPUTS_UNLOCKED
137 # define fputs_unlocked(x,y) fputs (x,y)
138 # endif
139 #if defined(HAVE_DECL_FREAD_UNLOCKED) && !HAVE_DECL_FREAD_UNLOCKED
140 # define fread_unlocked(w,x,y,z) fread (w,x,y,z)
141 # endif
142 #if defined(HAVE_DECL_FWRITE_UNLOCKED) && !HAVE_DECL_FWRITE_UNLOCKED
143 # define fwrite_unlocked(w,x,y,z) fwrite (w,x,y,z)
144 # endif
145 #if defined(HAVE_DECL_GETC_UNLOCKED) && !HAVE_DECL_GETC_UNLOCKED
146 # define getc_unlocked(x) getc (x)
147 # endif
148 #if defined(HAVE_DECL_GETCHAR_UNLOCKED) && !HAVE_DECL_GETCHAR_UNLOCKED
149 #  define getchar_unlocked() getchar ()
150 # endif
151 #if defined(HAVE_DECL_PUTC_UNLOCKED) && !HAVE_DECL_PUTC_UNLOCKED
152 # define putc_unlocked(x,y) putc (x,y)
153 # endif
154 #if defined(HAVE_DECL_PUTCHAR_UNLOCKED) && !HAVE_DECL_PUTCHAR_UNLOCKED
155 # define putchar_unlocked(x) putchar (x)
156 # endif
157
158 extern char *__argp_basename (char *name);
159
160 #endif /* !_LIBC */
161
162 #ifndef __set_errno
163 #define __set_errno(e) (errno = (e))
164 #endif
165
166 char * __argp_base_name (char *name);
167
168 #if defined _LIBC || HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME
169 # define __argp_short_program_name()    (program_invocation_short_name)
170 #else
171 extern char *__argp_short_program_name (void);
172 #endif
173