1*2159047fSniklas /* Function declarations for libiberty.
2*2159047fSniklas    Written by Cygnus Support, 1994.
3*2159047fSniklas 
4*2159047fSniklas    The libiberty library provides a number of functions which are
5*2159047fSniklas    missing on some operating systems.  We do not declare those here,
6*2159047fSniklas    to avoid conflicts with the system header files on operating
7*2159047fSniklas    systems that do support those functions.  In this file we only
8*2159047fSniklas    declare those functions which are specific to libiberty.  */
9*2159047fSniklas 
10*2159047fSniklas #ifndef LIBIBERTY_H
11*2159047fSniklas #define LIBIBERTY_H
12*2159047fSniklas 
13*2159047fSniklas #include "ansidecl.h"
14*2159047fSniklas 
15*2159047fSniklas /* Build an argument vector from a string.  Allocates memory using
16*2159047fSniklas    malloc.  Use freeargv to free the vector.  */
17*2159047fSniklas 
18*2159047fSniklas extern char **buildargv PARAMS ((char *));
19*2159047fSniklas 
20*2159047fSniklas /* Free a vector returned by buildargv.  */
21*2159047fSniklas 
22*2159047fSniklas extern void freeargv PARAMS ((char **));
23*2159047fSniklas 
24*2159047fSniklas /* Return the last component of a path name.  */
25*2159047fSniklas 
26*2159047fSniklas extern char *basename ();
27*2159047fSniklas 
28*2159047fSniklas /* Concatenate an arbitrary number of strings, up to (char *) NULL.
29*2159047fSniklas    Allocates memory using xmalloc.  */
30*2159047fSniklas 
31*2159047fSniklas extern char *concat PARAMS ((const char *, ...));
32*2159047fSniklas 
33*2159047fSniklas /* Check whether two file descriptors refer to the same file.  */
34*2159047fSniklas 
35*2159047fSniklas extern int fdmatch PARAMS ((int fd1, int fd2));
36*2159047fSniklas 
37*2159047fSniklas /* Get the amount of time the process has run, in microseconds.  */
38*2159047fSniklas 
39*2159047fSniklas extern long get_run_time PARAMS ((void));
40*2159047fSniklas 
41*2159047fSniklas /* Allocate memory filled with spaces.  Allocates using malloc.  */
42*2159047fSniklas 
43*2159047fSniklas extern const char *spaces PARAMS ((int count));
44*2159047fSniklas 
45*2159047fSniklas /* Return the maximum error number for which strerror will return a
46*2159047fSniklas    string.  */
47*2159047fSniklas 
48*2159047fSniklas extern int errno_max PARAMS ((void));
49*2159047fSniklas 
50*2159047fSniklas /* Return the name of an errno value (e.g., strerrno (EINVAL) returns
51*2159047fSniklas    "EINVAL").  */
52*2159047fSniklas 
53*2159047fSniklas extern const char *strerrno PARAMS ((int));
54*2159047fSniklas 
55*2159047fSniklas /* Given the name of an errno value, return the value.  */
56*2159047fSniklas 
57*2159047fSniklas extern int strtoerrno PARAMS ((const char *));
58*2159047fSniklas 
59*2159047fSniklas /* ANSI's strerror(), but more robust.  */
60*2159047fSniklas 
61*2159047fSniklas extern char *xstrerror PARAMS ((int));
62*2159047fSniklas 
63*2159047fSniklas /* Return the maximum signal number for which strsignal will return a
64*2159047fSniklas    string.  */
65*2159047fSniklas 
66*2159047fSniklas extern int signo_max PARAMS ((void));
67*2159047fSniklas 
68*2159047fSniklas /* Return a signal message string for a signal number
69*2159047fSniklas    (e.g., strsignal (SIGHUP) returns something like "Hangup").  */
70*2159047fSniklas /* This is commented out as it can conflict with one in system headers.
71*2159047fSniklas    We still document its existence though.  */
72*2159047fSniklas 
73*2159047fSniklas /*extern const char *strsignal PARAMS ((int));*/
74*2159047fSniklas 
75*2159047fSniklas /* Return the name of a signal number (e.g., strsigno (SIGHUP) returns
76*2159047fSniklas    "SIGHUP").  */
77*2159047fSniklas 
78*2159047fSniklas extern const char *strsigno PARAMS ((int));
79*2159047fSniklas 
80*2159047fSniklas /* Given the name of a signal, return its number.  */
81*2159047fSniklas 
82*2159047fSniklas extern int strtosigno PARAMS ((const char *));
83*2159047fSniklas 
84*2159047fSniklas /* Register a function to be run by xexit.  Returns 0 on success.  */
85*2159047fSniklas 
86*2159047fSniklas extern int xatexit PARAMS ((void (*fn) (void)));
87*2159047fSniklas 
88*2159047fSniklas /* Exit, calling all the functions registered with xatexit.  */
89*2159047fSniklas 
90*2159047fSniklas #ifndef __GNUC__
91*2159047fSniklas extern void xexit PARAMS ((int status));
92*2159047fSniklas #else
93*2159047fSniklas typedef void libiberty_voidfn PARAMS ((int status));
94*2159047fSniklas __volatile__ libiberty_voidfn xexit;
95*2159047fSniklas #endif
96*2159047fSniklas 
97*2159047fSniklas /* Set the program name used by xmalloc.  */
98*2159047fSniklas 
99*2159047fSniklas extern void xmalloc_set_program_name PARAMS ((const char *));
100*2159047fSniklas 
101*2159047fSniklas /* Allocate memory without fail.  If malloc fails, this will print a
102*2159047fSniklas    message to stderr (using the name set by xmalloc_set_program_name,
103*2159047fSniklas    if any) and then call xexit.
104*2159047fSniklas 
105*2159047fSniklas    FIXME: We do not declare the parameter type (size_t) in order to
106*2159047fSniklas    avoid conflicts with other declarations of xmalloc that exist in
107*2159047fSniklas    programs which use libiberty.  */
108*2159047fSniklas 
109*2159047fSniklas extern PTR xmalloc ();
110*2159047fSniklas 
111*2159047fSniklas /* Reallocate memory without fail.  This works like xmalloc.
112*2159047fSniklas 
113*2159047fSniklas    FIXME: We do not declare the parameter types for the same reason as
114*2159047fSniklas    xmalloc.  */
115*2159047fSniklas 
116*2159047fSniklas extern PTR xrealloc ();
117*2159047fSniklas 
118*2159047fSniklas /* hex character manipulation routines */
119*2159047fSniklas 
120*2159047fSniklas #define _hex_array_size 256
121*2159047fSniklas #define _hex_bad	99
122*2159047fSniklas extern char _hex_value[_hex_array_size];
123*2159047fSniklas extern void hex_init PARAMS ((void));
124*2159047fSniklas #define hex_p(c)	(hex_value (c) != _hex_bad)
125*2159047fSniklas /* If you change this, note well: Some code relies on side effects in
126*2159047fSniklas    the argument being performed exactly once.  */
127*2159047fSniklas #define hex_value(c)	(_hex_value[(unsigned char) (c)])
128*2159047fSniklas 
129*2159047fSniklas #endif /* ! defined (LIBIBERTY_H) */
130