00001 /* Function declarations for libiberty. 00002 Written by Cygnus Support, 1994. 00003 00004 The libiberty library provides a number of functions which are 00005 missing on some operating systems. We do not declare those here, 00006 to avoid conflicts with the system header files on operating 00007 systems that do support those functions. In this file we only 00008 declare those functions which are specific to libiberty. */ 00009 00010 #ifndef LIBIBERTY_H 00011 #define LIBIBERTY_H 00012 00013 #ifdef __cplusplus 00014 extern "C" { 00015 #endif 00016 00017 #include "ansidecl.h" 00018 00019 /* Build an argument vector from a string. Allocates memory using 00020 malloc. Use freeargv to free the vector. */ 00021 00022 extern char **buildargv PARAMS ((char *)); 00023 00024 /* Free a vector returned by buildargv. */ 00025 00026 extern void freeargv PARAMS ((char **)); 00027 00028 /* Duplicate an argument vector. Allocates memory using malloc. Use 00029 freeargv to free the vector. */ 00030 00031 extern char **dupargv PARAMS ((char **)); 00032 00033 00034 /* Return the last component of a path name. Note that we can't use a 00035 prototype here because the parameter is declared inconsistently 00036 across different systems, sometimes as "char *" and sometimes as 00037 "const char *" */ 00038 00039 #if defined (__GNU_LIBRARY__ ) || defined (__linux__) || defined (__FreeBSD__) 00040 extern char *basename PARAMS ((const char *)); 00041 #else 00042 extern char *basename (); 00043 #endif 00044 00045 /* Concatenate an arbitrary number of strings, up to (char *) NULL. 00046 Allocates memory using xmalloc. */ 00047 00048 extern char *concat PARAMS ((const char *, ...)); 00049 00050 /* Check whether two file descriptors refer to the same file. */ 00051 00052 extern int fdmatch PARAMS ((int fd1, int fd2)); 00053 00054 /* Get the amount of time the process has run, in microseconds. */ 00055 00056 extern long get_run_time PARAMS ((void)); 00057 00058 /* Choose a temporary directory to use for scratch files. */ 00059 00060 extern char *choose_temp_base PARAMS ((void)); 00061 00062 /* Allocate memory filled with spaces. Allocates using malloc. */ 00063 00064 extern const char *spaces PARAMS ((int count)); 00065 00066 /* Return the maximum error number for which strerror will return a 00067 string. */ 00068 00069 extern int errno_max PARAMS ((void)); 00070 00071 /* Return the name of an errno value (e.g., strerrno (EINVAL) returns 00072 "EINVAL"). */ 00073 00074 extern const char *strerrno PARAMS ((int)); 00075 00076 /* Given the name of an errno value, return the value. */ 00077 00078 extern int strtoerrno PARAMS ((const char *)); 00079 00080 /* ANSI's strerror(), but more robust. */ 00081 00082 extern char *xstrerror PARAMS ((int)); 00083 00084 /* Return the maximum signal number for which strsignal will return a 00085 string. */ 00086 00087 extern int signo_max PARAMS ((void)); 00088 00089 /* Return a signal message string for a signal number 00090 (e.g., strsignal (SIGHUP) returns something like "Hangup"). */ 00091 /* This is commented out as it can conflict with one in system headers. 00092 We still document its existence though. */ 00093 00094 /*extern const char *strsignal PARAMS ((int));*/ 00095 00096 /* Return the name of a signal number (e.g., strsigno (SIGHUP) returns 00097 "SIGHUP"). */ 00098 00099 extern const char *strsigno PARAMS ((int)); 00100 00101 /* Given the name of a signal, return its number. */ 00102 00103 extern int strtosigno PARAMS ((const char *)); 00104 00105 /* Register a function to be run by xexit. Returns 0 on success. */ 00106 00107 extern int xatexit PARAMS ((void (*fn) (void))); 00108 00109 /* Exit, calling all the functions registered with xatexit. */ 00110 00111 #ifndef __GNUC__ 00112 extern void xexit PARAMS ((int status)); 00113 #else 00114 void xexit PARAMS ((int status)) __attribute__ ((noreturn)); 00115 #endif 00116 00117 /* Set the program name used by xmalloc. */ 00118 00119 extern void xmalloc_set_program_name PARAMS ((const char *)); 00120 00121 /* Allocate memory without fail. If malloc fails, this will print a 00122 message to stderr (using the name set by xmalloc_set_program_name, 00123 if any) and then call xexit. */ 00124 00125 #ifdef ANSI_PROTOTYPES 00126 /* Get a definition for size_t. */ 00127 #include <stddef.h> 00128 #endif 00129 extern PTR xmalloc PARAMS ((size_t)); 00130 00131 /* Reallocate memory without fail. This works like xmalloc. 00132 00133 FIXME: We do not declare the parameter types for the same reason as 00134 xmalloc. */ 00135 00136 extern PTR xrealloc PARAMS ((PTR, size_t)); 00137 00138 /* Allocate memory without fail and set it to zero. This works like 00139 xmalloc. */ 00140 00141 extern PTR xcalloc PARAMS ((size_t, size_t)); 00142 00143 /* Copy a string into a memory buffer without fail. */ 00144 00145 extern char *xstrdup PARAMS ((const char *)); 00146 00147 /* hex character manipulation routines */ 00148 00149 #define _hex_array_size 256 00150 #define _hex_bad 99 00151 extern char _hex_value[_hex_array_size]; 00152 extern void hex_init PARAMS ((void)); 00153 #define hex_p(c) (hex_value (c) != _hex_bad) 00154 /* If you change this, note well: Some code relies on side effects in 00155 the argument being performed exactly once. */ 00156 #define hex_value(c) (_hex_value[(unsigned char) (c)]) 00157 00158 /* Definitions used by the pexecute routine. */ 00159 00160 #define PEXECUTE_FIRST 1 00161 #define PEXECUTE_LAST 2 00162 #define PEXECUTE_ONE (PEXECUTE_FIRST + PEXECUTE_LAST) 00163 #define PEXECUTE_SEARCH 4 00164 #define PEXECUTE_VERBOSE 8 00165 00166 /* Execute a program. */ 00167 00168 extern int pexecute PARAMS ((const char *, char * const *, const char *, 00169 const char *, char **, char **, int)); 00170 00171 /* Wait for pexecute to finish. */ 00172 00173 extern int pwait PARAMS ((int, int *, int)); 00174 00175 #ifdef __cplusplus 00176 } 00177 #endif 00178 00179 00180 #endif /* ! defined (LIBIBERTY_H) */
1.4.7

