12159047fSniklas /* Function declarations for libiberty.
22159047fSniklas    Written by Cygnus Support, 1994.
32159047fSniklas 
42159047fSniklas    The libiberty library provides a number of functions which are
52159047fSniklas    missing on some operating systems.  We do not declare those here,
62159047fSniklas    to avoid conflicts with the system header files on operating
72159047fSniklas    systems that do support those functions.  In this file we only
82159047fSniklas    declare those functions which are specific to libiberty.  */
92159047fSniklas 
102159047fSniklas #ifndef LIBIBERTY_H
112159047fSniklas #define LIBIBERTY_H
122159047fSniklas 
132159047fSniklas #include "ansidecl.h"
142159047fSniklas 
152159047fSniklas /* Build an argument vector from a string.  Allocates memory using
162159047fSniklas    malloc.  Use freeargv to free the vector.  */
172159047fSniklas 
182159047fSniklas extern char **buildargv PARAMS ((char *));
192159047fSniklas 
202159047fSniklas /* Free a vector returned by buildargv.  */
212159047fSniklas 
222159047fSniklas extern void freeargv PARAMS ((char **));
232159047fSniklas 
24*0c6d0228Sniklas /* Return the last component of a path name.  Note that we can't use a
25*0c6d0228Sniklas    prototype here because the parameter is declared inconsistently
26*0c6d0228Sniklas    across different systems, sometimes as "char *" and sometimes as
27*0c6d0228Sniklas    "const char *" */
282159047fSniklas 
292159047fSniklas extern char *basename ();
302159047fSniklas 
312159047fSniklas /* Concatenate an arbitrary number of strings, up to (char *) NULL.
322159047fSniklas    Allocates memory using xmalloc.  */
332159047fSniklas 
342159047fSniklas extern char *concat PARAMS ((const char *, ...));
352159047fSniklas 
362159047fSniklas /* Check whether two file descriptors refer to the same file.  */
372159047fSniklas 
382159047fSniklas extern int fdmatch PARAMS ((int fd1, int fd2));
392159047fSniklas 
402159047fSniklas /* Get the amount of time the process has run, in microseconds.  */
412159047fSniklas 
422159047fSniklas extern long get_run_time PARAMS ((void));
432159047fSniklas 
44c88b1d6cSniklas /* Choose a temporary directory to use for scratch files.  */
45c88b1d6cSniklas 
46c88b1d6cSniklas extern char *choose_temp_base PARAMS ((void));
47c88b1d6cSniklas 
482159047fSniklas /* Allocate memory filled with spaces.  Allocates using malloc.  */
492159047fSniklas 
502159047fSniklas extern const char *spaces PARAMS ((int count));
512159047fSniklas 
522159047fSniklas /* Return the maximum error number for which strerror will return a
532159047fSniklas    string.  */
542159047fSniklas 
552159047fSniklas extern int errno_max PARAMS ((void));
562159047fSniklas 
572159047fSniklas /* Return the name of an errno value (e.g., strerrno (EINVAL) returns
582159047fSniklas    "EINVAL").  */
592159047fSniklas 
602159047fSniklas extern const char *strerrno PARAMS ((int));
612159047fSniklas 
622159047fSniklas /* Given the name of an errno value, return the value.  */
632159047fSniklas 
642159047fSniklas extern int strtoerrno PARAMS ((const char *));
652159047fSniklas 
662159047fSniklas /* ANSI's strerror(), but more robust.  */
672159047fSniklas 
682159047fSniklas extern char *xstrerror PARAMS ((int));
692159047fSniklas 
702159047fSniklas /* Return the maximum signal number for which strsignal will return a
712159047fSniklas    string.  */
722159047fSniklas 
732159047fSniklas extern int signo_max PARAMS ((void));
742159047fSniklas 
752159047fSniklas /* Return a signal message string for a signal number
762159047fSniklas    (e.g., strsignal (SIGHUP) returns something like "Hangup").  */
772159047fSniklas /* This is commented out as it can conflict with one in system headers.
782159047fSniklas    We still document its existence though.  */
792159047fSniklas 
802159047fSniklas /*extern const char *strsignal PARAMS ((int));*/
812159047fSniklas 
822159047fSniklas /* Return the name of a signal number (e.g., strsigno (SIGHUP) returns
832159047fSniklas    "SIGHUP").  */
842159047fSniklas 
852159047fSniklas extern const char *strsigno PARAMS ((int));
862159047fSniklas 
872159047fSniklas /* Given the name of a signal, return its number.  */
882159047fSniklas 
892159047fSniklas extern int strtosigno PARAMS ((const char *));
902159047fSniklas 
912159047fSniklas /* Register a function to be run by xexit.  Returns 0 on success.  */
922159047fSniklas 
932159047fSniklas extern int xatexit PARAMS ((void (*fn) (void)));
942159047fSniklas 
952159047fSniklas /* Exit, calling all the functions registered with xatexit.  */
962159047fSniklas 
972159047fSniklas #ifndef __GNUC__
982159047fSniklas extern void xexit PARAMS ((int status));
992159047fSniklas #else
1002159047fSniklas typedef void libiberty_voidfn PARAMS ((int status));
1012159047fSniklas __volatile__ libiberty_voidfn xexit;
1022159047fSniklas #endif
1032159047fSniklas 
104*0c6d0228Sniklas #ifndef PRIVATE_XMALLOC
105*0c6d0228Sniklas 
1062159047fSniklas /* Set the program name used by xmalloc.  */
1072159047fSniklas 
1082159047fSniklas extern void xmalloc_set_program_name PARAMS ((const char *));
1092159047fSniklas 
1102159047fSniklas /* Allocate memory without fail.  If malloc fails, this will print a
1112159047fSniklas    message to stderr (using the name set by xmalloc_set_program_name,
1122159047fSniklas    if any) and then call xexit.
1132159047fSniklas 
1142159047fSniklas    FIXME: We do not declare the parameter type (size_t) in order to
1152159047fSniklas    avoid conflicts with other declarations of xmalloc that exist in
1162159047fSniklas    programs which use libiberty.  */
1172159047fSniklas 
1182159047fSniklas extern PTR xmalloc ();
1192159047fSniklas 
1202159047fSniklas /* Reallocate memory without fail.  This works like xmalloc.
1212159047fSniklas 
1222159047fSniklas    FIXME: We do not declare the parameter types for the same reason as
1232159047fSniklas    xmalloc.  */
1242159047fSniklas 
1252159047fSniklas extern PTR xrealloc ();
1262159047fSniklas 
127*0c6d0228Sniklas #endif	/* PRIVATE_XMALLOC */
128*0c6d0228Sniklas 
129c88b1d6cSniklas /* Copy a string into a memory buffer without fail.  */
130c88b1d6cSniklas 
131c88b1d6cSniklas extern char *xstrdup PARAMS ((const char *));
132c88b1d6cSniklas 
1332159047fSniklas /* hex character manipulation routines */
1342159047fSniklas 
1352159047fSniklas #define _hex_array_size 256
1362159047fSniklas #define _hex_bad	99
1372159047fSniklas extern char _hex_value[_hex_array_size];
1382159047fSniklas extern void hex_init PARAMS ((void));
1392159047fSniklas #define hex_p(c)	(hex_value (c) != _hex_bad)
1402159047fSniklas /* If you change this, note well: Some code relies on side effects in
1412159047fSniklas    the argument being performed exactly once.  */
1422159047fSniklas #define hex_value(c)	(_hex_value[(unsigned char) (c)])
1432159047fSniklas 
1442159047fSniklas #endif /* ! defined (LIBIBERTY_H) */
145