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