1/* bucomm.h -- binutils common include file. 2 Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 3 2001, 2002, 2003, 2005, 2006 Free Software Foundation, Inc. 4 5 This file is part of GNU Binutils. 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 of the License, or 10 (at your option) 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 19 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ 20 21#ifndef _BUCOMM_H 22#define _BUCOMM_H 23 24#include "ansidecl.h" 25#include <stdio.h> 26#include <sys/types.h> 27 28#include "config.h" 29#include "bin-bugs.h" 30 31#include <stdarg.h> 32 33#ifdef USE_BINARY_FOPEN 34#include "fopen-bin.h" 35#else 36#include "fopen-same.h" 37#endif 38 39#include <errno.h> 40#ifndef errno 41extern int errno; 42#endif 43 44#ifdef HAVE_UNISTD_H 45#include <unistd.h> 46#endif 47 48#ifdef HAVE_STRING_H 49#include <string.h> 50#else 51#ifdef HAVE_STRINGS_H 52#include <strings.h> 53#else 54extern char *strchr (); 55extern char *strrchr (); 56#endif 57#endif 58 59#ifdef HAVE_STDLIB_H 60#include <stdlib.h> 61#endif 62 63#ifdef HAVE_FCNTL_H 64#include <fcntl.h> 65#else 66#ifdef HAVE_SYS_FILE_H 67#include <sys/file.h> 68#endif 69#endif 70 71#if !HAVE_DECL_STPCPY 72extern char *stpcpy (char *, const char *); 73#endif 74 75#if !HAVE_DECL_STRSTR 76extern char *strstr (); 77#endif 78 79#ifdef HAVE_SBRK 80#if !HAVE_DECL_SBRK 81extern char *sbrk (); 82#endif 83#endif 84 85#if !HAVE_DECL_GETENV 86extern char *getenv (); 87#endif 88 89#if !HAVE_DECL_ENVIRON 90extern char **environ; 91#endif 92 93#if !HAVE_DECL_FPRINTF 94extern int fprintf (FILE *, const char *, ...); 95#endif 96 97#if !HAVE_DECL_SNPRINTF 98extern int snprintf(char *, size_t, const char *, ...); 99#endif 100 101#if !HAVE_DECL_VSNPRINTF 102extern int vsnprintf(char *, size_t, const char *, va_list); 103#endif 104 105#ifndef O_RDONLY 106#define O_RDONLY 0 107#endif 108 109#ifndef O_RDWR 110#define O_RDWR 2 111#endif 112 113#ifndef SEEK_SET 114#define SEEK_SET 0 115#endif 116#ifndef SEEK_CUR 117#define SEEK_CUR 1 118#endif 119#ifndef SEEK_END 120#define SEEK_END 2 121#endif 122 123#if defined(__GNUC__) && !defined(C_ALLOCA) 124# undef alloca 125# define alloca __builtin_alloca 126#else 127# if defined(HAVE_ALLOCA_H) && !defined(C_ALLOCA) 128# include <alloca.h> 129# else 130# ifndef alloca /* predefined by HP cc +Olibcalls */ 131# if !defined (__STDC__) && !defined (__hpux) 132char *alloca (); 133# else 134void *alloca (); 135# endif /* __STDC__, __hpux */ 136# endif /* alloca */ 137# endif /* HAVE_ALLOCA_H */ 138#endif 139 140 141#ifdef HAVE_LOCALE_H 142# ifndef ENABLE_NLS 143 /* The Solaris version of locale.h always includes libintl.h. If we have 144 been configured with --disable-nls then ENABLE_NLS will not be defined 145 and the dummy definitions of bindtextdomain (et al) below will conflict 146 with the defintions in libintl.h. So we define these values to prevent 147 the bogus inclusion of libintl.h. */ 148# define _LIBINTL_H 149# define _LIBGETTEXT_H 150# endif 151# include <locale.h> 152#endif 153 154#ifdef ENABLE_NLS 155# include <libintl.h> 156# define _(String) gettext (String) 157# ifdef gettext_noop 158# define N_(String) gettext_noop (String) 159# else 160# define N_(String) (String) 161# endif 162#else 163# define gettext(Msgid) (Msgid) 164# define dgettext(Domainname, Msgid) (Msgid) 165# define dcgettext(Domainname, Msgid, Category) (Msgid) 166# define textdomain(Domainname) while (0) /* nothing */ 167# define bindtextdomain(Domainname, Dirname) while (0) /* nothing */ 168# define _(String) (String) 169# define N_(String) (String) 170#endif 171 172/* Used by ar.c and objcopy.c. */ 173#define BUFSIZE 8192 174 175/* bucomm.c */ 176 177/* Return the filename in a static buffer. */ 178const char *bfd_get_archive_filename (bfd *); 179 180void bfd_nonfatal (const char *); 181 182void bfd_fatal (const char *) ATTRIBUTE_NORETURN; 183 184void report (const char *, va_list) ATTRIBUTE_PRINTF(1,0); 185 186void fatal (const char *, ...) ATTRIBUTE_PRINTF_1 ATTRIBUTE_NORETURN; 187 188void non_fatal (const char *, ...) ATTRIBUTE_PRINTF_1; 189 190void set_default_bfd_target (void); 191 192void list_matching_formats (char **); 193 194void list_supported_targets (const char *, FILE *); 195 196void list_supported_architectures (const char *, FILE *); 197 198int display_info (void); 199 200void print_arelt_descr (FILE *, bfd *, bfd_boolean); 201 202char *make_tempname (char *); 203char *make_tempdir (char *); 204 205bfd_vma parse_vma (const char *, const char *); 206 207off_t get_file_size (const char *); 208 209extern char *program_name; 210 211/* filemode.c */ 212void mode_string (unsigned long, char *); 213 214/* version.c */ 215extern void print_version (const char *); 216 217/* rename.c */ 218extern void set_times (const char *, const struct stat *); 219 220extern int smart_rename (const char *, const char *, int); 221 222/* libiberty. */ 223void *xmalloc (size_t); 224 225void *xrealloc (void *, size_t); 226 227#endif /* _BUCOMM_H */ 228