1 /* Function declarations for libiberty.
2 Written by Cygnus Support, 1994.
4 The libiberty library provides a number of functions which are
5 missing on some operating systems. We do not declare those here,
6 to avoid conflicts with the system header files on operating
7 systems that do support those functions. In this file we only
8 declare those functions which are specific to libiberty. */
19 /* Build an argument vector from a string. Allocates memory using
20 malloc. Use freeargv to free the vector. */
22 extern char **buildargv PARAMS ((char *));
24 /* Free a vector returned by buildargv. */
26 extern void freeargv PARAMS ((char **));
28 /* Duplicate an argument vector. Allocates memory using malloc. Use
29 freeargv to free the vector. */
31 extern char **dupargv PARAMS ((char **));
34 /* Return the last component of a path name. Note that we can't use a
35 prototype here because the parameter is declared inconsistently
36 across different systems, sometimes as "char *" and sometimes as
39 #if defined (__GNU_LIBRARY__ ) || defined (__linux__) || defined (__FreeBSD__) || defined (__CYGWIN__) || defined (__CYGWIN32__)
40 extern char *basename PARAMS ((const char *));
42 extern char *basename ();
45 /* Concatenate an arbitrary number of strings, up to (char *) NULL.
46 Allocates memory using xmalloc. */
48 extern char *concat PARAMS ((const char *, ...));
50 /* Check whether two file descriptors refer to the same file. */
52 extern int fdmatch PARAMS ((int fd1, int fd2));
54 /* Get the working directory. The result is cached, so don't call
55 chdir() between calls to getpwd(). */
57 extern char * getpwd PARAMS ((void));
59 /* Get the amount of time the process has run, in microseconds. */
61 extern long get_run_time PARAMS ((void));
63 /* Choose a temporary directory to use for scratch files. */
65 extern char *choose_temp_base PARAMS ((void));
67 /* Allocate memory filled with spaces. Allocates using malloc. */
69 extern const char *spaces PARAMS ((int count));
71 /* Return the maximum error number for which strerror will return a
74 extern int errno_max PARAMS ((void));
76 /* Return the name of an errno value (e.g., strerrno (EINVAL) returns
79 extern const char *strerrno PARAMS ((int));
81 /* Given the name of an errno value, return the value. */
83 extern int strtoerrno PARAMS ((const char *));
85 /* ANSI's strerror(), but more robust. */
87 extern char *xstrerror PARAMS ((int));
89 /* Return the maximum signal number for which strsignal will return a
92 extern int signo_max PARAMS ((void));
94 /* Return a signal message string for a signal number
95 (e.g., strsignal (SIGHUP) returns something like "Hangup"). */
96 /* This is commented out as it can conflict with one in system headers.
97 We still document its existence though. */
99 /*extern const char *strsignal PARAMS ((int));*/
101 /* Return the name of a signal number (e.g., strsigno (SIGHUP) returns
104 extern const char *strsigno PARAMS ((int));
106 /* Given the name of a signal, return its number. */
108 extern int strtosigno PARAMS ((const char *));
110 /* Register a function to be run by xexit. Returns 0 on success. */
112 extern int xatexit PARAMS ((void (*fn) (void)));
114 /* Exit, calling all the functions registered with xatexit. */
117 extern void xexit PARAMS ((int status));
119 void xexit PARAMS ((int status)) __attribute__ ((noreturn));
122 /* Set the program name used by xmalloc. */
124 extern void xmalloc_set_program_name PARAMS ((const char *));
126 /* Allocate memory without fail. If malloc fails, this will print a
127 message to stderr (using the name set by xmalloc_set_program_name,
128 if any) and then call xexit. */
130 #ifdef ANSI_PROTOTYPES
131 /* Get a definition for size_t. */
134 extern PTR xmalloc PARAMS ((size_t));
136 /* Reallocate memory without fail. This works like xmalloc.
138 FIXME: We do not declare the parameter types for the same reason as
141 extern PTR xrealloc PARAMS ((PTR, size_t));
143 /* Allocate memory without fail and set it to zero. This works like
146 extern PTR xcalloc PARAMS ((size_t, size_t));
148 /* Copy a string into a memory buffer without fail. */
150 extern char *xstrdup PARAMS ((const char *));
152 /* hex character manipulation routines */
154 #define _hex_array_size 256
156 extern char _hex_value[_hex_array_size];
157 extern void hex_init PARAMS ((void));
158 #define hex_p(c) (hex_value (c) != _hex_bad)
159 /* If you change this, note well: Some code relies on side effects in
160 the argument being performed exactly once. */
161 #define hex_value(c) (_hex_value[(unsigned char) (c)])
163 /* Definitions used by the pexecute routine. */
165 #define PEXECUTE_FIRST 1
166 #define PEXECUTE_LAST 2
167 #define PEXECUTE_ONE (PEXECUTE_FIRST + PEXECUTE_LAST)
168 #define PEXECUTE_SEARCH 4
169 #define PEXECUTE_VERBOSE 8
171 /* Execute a program. */
173 extern int pexecute PARAMS ((const char *, char * const *, const char *,
174 const char *, char **, char **, int));
176 /* Wait for pexecute to finish. */
178 extern int pwait PARAMS ((int, int *, int));
185 #endif /* ! defined (LIBIBERTY_H) */