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. */
15 /* Build an argument vector from a string. Allocates memory using
16 malloc. Use freeargv to free the vector. */
18 extern char **buildargv PARAMS ((char *));
20 /* Free a vector returned by buildargv. */
22 extern void freeargv PARAMS ((char **));
24 /* Return the last component of a path name. Note that we can't use a
25 prototype here because the parameter is declared inconsistently
26 across different systems, sometimes as "char *" and sometimes as
29 extern char *basename ();
31 /* Concatenate an arbitrary number of strings, up to (char *) NULL.
32 Allocates memory using xmalloc. */
34 extern char *concat PARAMS ((const char *, ...));
36 /* Check whether two file descriptors refer to the same file. */
38 extern int fdmatch PARAMS ((int fd1, int fd2));
40 /* Get the amount of time the process has run, in microseconds. */
42 extern long get_run_time PARAMS ((void));
44 /* Choose a temporary directory to use for scratch files. */
46 extern char *choose_temp_base PARAMS ((void));
48 /* Allocate memory filled with spaces. Allocates using malloc. */
50 extern const char *spaces PARAMS ((int count));
52 /* Return the maximum error number for which strerror will return a
55 extern int errno_max PARAMS ((void));
57 /* Return the name of an errno value (e.g., strerrno (EINVAL) returns
60 extern const char *strerrno PARAMS ((int));
62 /* Given the name of an errno value, return the value. */
64 extern int strtoerrno PARAMS ((const char *));
66 /* ANSI's strerror(), but more robust. */
68 extern char *xstrerror PARAMS ((int));
70 /* Return the maximum signal number for which strsignal will return a
73 extern int signo_max PARAMS ((void));
75 /* Return a signal message string for a signal number
76 (e.g., strsignal (SIGHUP) returns something like "Hangup"). */
77 /* This is commented out as it can conflict with one in system headers.
78 We still document its existence though. */
80 /*extern const char *strsignal PARAMS ((int));*/
82 /* Return the name of a signal number (e.g., strsigno (SIGHUP) returns
85 extern const char *strsigno PARAMS ((int));
87 /* Given the name of a signal, return its number. */
89 extern int strtosigno PARAMS ((const char *));
91 /* Register a function to be run by xexit. Returns 0 on success. */
93 extern int xatexit PARAMS ((void (*fn) (void)));
95 /* Exit, calling all the functions registered with xatexit. */
98 extern void xexit PARAMS ((int status));
100 typedef void libiberty_voidfn PARAMS ((int status));
101 __volatile__ libiberty_voidfn xexit;
104 /* Set the program name used by xmalloc. */
106 extern void xmalloc_set_program_name PARAMS ((const char *));
108 /* Allocate memory without fail. If malloc fails, this will print a
109 message to stderr (using the name set by xmalloc_set_program_name,
110 if any) and then call xexit.
112 FIXME: We do not declare the parameter type (size_t) in order to
113 avoid conflicts with other declarations of xmalloc that exist in
114 programs which use libiberty. */
116 extern PTR xmalloc ();
118 /* Reallocate memory without fail. This works like xmalloc.
120 FIXME: We do not declare the parameter types for the same reason as
123 extern PTR xrealloc ();
125 /* Copy a string into a memory buffer without fail. */
127 extern char *xstrdup PARAMS ((const char *));
129 /* hex character manipulation routines */
131 #define _hex_array_size 256
133 extern char _hex_value[_hex_array_size];
134 extern void hex_init PARAMS ((void));
135 #define hex_p(c) (hex_value (c) != _hex_bad)
136 /* If you change this, note well: Some code relies on side effects in
137 the argument being performed exactly once. */
138 #define hex_value(c) (_hex_value[(unsigned char) (c)])
140 #endif /* ! defined (LIBIBERTY_H) */