annotate kpathsea/lib.h @ 2999:faa5d0421460

[project @ 1997-05-23 03:02:09 by jwe]
author jwe
date Fri, 23 May 1997 03:02:36 +0000
parents
children 1f0b06020e36
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2999
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
1 /* lib.h: declarations for common, low-level routines in kpathsea.
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
2
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
3 Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc.
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
4
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
6 modify it under the terms of the GNU Library General Public
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
7 License as published by the Free Software Foundation; either
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
8 version 2 of the License, or (at your option) any later version.
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
9
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
13 Library General Public License for more details.
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
14
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
15 You should have received a copy of the GNU Library General Public
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
16 License along with this library; if not, write to the Free Software
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
18
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
19 #ifndef KPATHSEA_LIB_H
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
20 #define KPATHSEA_LIB_H
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
21
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
22 #include <kpathsea/types.h>
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
23
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
24 /* Define common sorts of messages. */
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
25
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
26 /* This should be called only after a system call fails. Don't exit
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
27 with status `errno', because that might be 256, which would mean
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
28 success (exit statuses are truncated to eight bits). */
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
29 #define FATAL_PERROR(str) do { \
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
30 fprintf (stderr, "%s: ", program_invocation_name); \
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
31 perror (str); exit (EXIT_FAILURE); } while (0)
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
32
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
33 #define START_FATAL() do { \
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
34 fprintf (stderr, "%s: fatal: ", program_invocation_name);
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
35 #define END_FATAL() fputs (".\n", stderr); exit (1); } while (0)
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
36
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
37 #define FATAL(str) \
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
38 START_FATAL (); fputs (str, stderr); END_FATAL ()
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
39 #define FATAL1(str, e1) \
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
40 START_FATAL (); fprintf (stderr, str, e1); END_FATAL ()
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
41 #define FATAL2(str, e1, e2) \
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
42 START_FATAL (); fprintf (stderr, str, e1, e2); END_FATAL ()
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
43 #define FATAL3(str, e1, e2, e3) \
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
44 START_FATAL (); fprintf (stderr, str, e1, e2, e3); END_FATAL ()
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
45 #define FATAL4(str, e1, e2, e3, e4) \
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
46 START_FATAL (); fprintf (stderr, str, e1, e2, e3, e4); END_FATAL ()
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
47 #define FATAL5(str, e1, e2, e3, e4, e5) \
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
48 START_FATAL (); fprintf (stderr, str, e1, e2, e3, e4, e5); END_FATAL ()
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
49 #define FATAL6(str, e1, e2, e3, e4, e5, e6) \
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
50 START_FATAL (); fprintf (stderr, str, e1, e2, e3, e4, e5, e6); END_FATAL ()
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
51
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
52
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
53 #define START_WARNING() do { fputs ("warning: ", stderr)
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
54 #define END_WARNING() fputs (".\n", stderr); fflush (stderr); } while (0)
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
55
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
56 #define WARNING(str) \
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
57 START_WARNING (); fputs (str, stderr); END_WARNING ()
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
58 #define WARNING1(str, e1) \
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
59 START_WARNING (); fprintf (stderr, str, e1); END_WARNING ()
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
60 #define WARNING2(str, e1, e2) \
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
61 START_WARNING (); fprintf (stderr, str, e1, e2); END_WARNING ()
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
62 #define WARNING3(str, e1, e2, e3) \
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
63 START_WARNING (); fprintf (stderr, str, e1, e2, e3); END_WARNING ()
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
64 #define WARNING4(str, e1, e2, e3, e4) \
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
65 START_WARNING (); fprintf (stderr, str, e1, e2, e3, e4); END_WARNING ()
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
66
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
67
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
68 /* I find this easier to read. */
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
69 #define STREQ(s1, s2) (strcmp (s1, s2) == 0)
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
70
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
71 /* Support for FAT/ISO-9660 filesystems. Theoretically this should be
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
72 done at runtime, per filesystem, but that's painful to program. */
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
73 #ifdef MONOCASE_FILENAMES
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
74 #define FILESTRCASEEQ(s1, s2) (strcasecmp (s1, s2) == 0)
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
75 #define FILECHARCASEEQ(c1, c2) (toupper (c1) == toupper (c2))
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
76 #else
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
77 #define FILESTRCASEEQ STREQ
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
78 #define FILECHARCASEEQ(c1, c2) ((c1) == (c2))
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
79 #endif
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
80
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
81 /* This is the maximum number of numerals that result when a 64-bit
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
82 integer is converted to a string, plus one for a trailing null byte,
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
83 plus one for a sign. */
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
84 #define MAX_INT_LENGTH 21
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
85
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
86 /* If the environment variable TEST is set, return it; otherwise,
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
87 DEFAULT. This is useful for paths that use more than one envvar. */
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
88 #define ENVVAR(test, default) (getenv (test) ? (test) : (default))
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
89
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
90 /* Return a fresh copy of S1 followed by S2, et al. */
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
91 extern DllImport string concat P2H(const_string s1, const_string s2);
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
92 extern DllImport string concat3 P3H(const_string, const_string, const_string);
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
93 /* `concatn' is declared in its own include file, to avoid pulling in
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
94 all the varargs stuff. */
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
95
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
96 /* A fresh copy of just S. */
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
97 extern DllImport string xstrdup P1H(const_string s);
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
98
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
99 /* Convert all lowercase characters in S to uppercase. */
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
100 extern DllImport string uppercasify P1H(const_string s);
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
101
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
102 /* Like `atoi', but disallow negative numbers. */
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
103 extern DllImport unsigned atou P1H(const_string);
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
104
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
105 /* True if FILENAME1 and FILENAME2 are the same file. If stat fails on
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
106 either name, return false, no error message.
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
107 Cf. `SAME_FILE_P' in xstat.h. */
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
108 extern DllImport boolean same_file_p P2H(const_string filename1,
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
109 const_string filename2);
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
110
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
111 #ifndef HAVE_BASENAME
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
112 /* Return NAME with any leading path stripped off. This returns a
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
113 pointer into NAME. */
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
114 extern DllImport const_string basename P1H(const_string name);
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
115 #endif /* not HAVE_BASENAME */
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
116
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
117 #ifndef HAVE_STRSTR
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
118 extern string strstr P2H(const_string haystack, const_string needle);
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
119 #endif
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
120
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
121 /* If NAME has a suffix, return a pointer to its first character (i.e.,
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
122 the one after the `.'); otherwise, return NULL. */
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
123 extern DllImport string find_suffix P1H(const_string name);
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
124
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
125 /* Return NAME with any suffix removed. */
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
126 extern DllImport string remove_suffix P1H(const_string name);
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
127
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
128 /* Return S with the suffix SUFFIX, removing any suffix already present.
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
129 For example, `make_suffix ("/foo/bar.baz", "quux")' returns
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
130 `/foo/bar.quux'. Returns a string allocated with malloc. */
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
131 extern DllImport string make_suffix P2H(const_string s, const_string suffix);
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
132
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
133 /* Return NAME with STEM_PREFIX prepended to the stem. For example,
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
134 `make_prefix ("/foo/bar.baz", "x")' returns `/foo/xbar.baz'.
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
135 Returns a string allocated with malloc. */
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
136 extern DllImport string make_prefix P2H(string stem_prefix, string name);
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
137
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
138 /* If NAME has a suffix, simply return it; otherwise, return
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
139 `NAME.SUFFIX'. */
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
140 extern DllImport string extend_filename P2H(const_string name,
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
141 const_string suffix);
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
142
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
143 /* Call putenv with the string `VAR=VALUE' and abort on error. */
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
144 extern DllImport void xputenv P2H(const_string var, const_string value);
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
145 extern DllImport void xputenv_int P2H(const_string var, int value);
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
146
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
147 /* Return the current working directory. */
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
148 extern DllImport string xgetcwd P1H(void);
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
149
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
150 /* Returns true if FN is a directory or a symlink to a directory. */
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
151 extern DllImport boolean dir_p P1H(const_string fn);
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
152
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
153 /* If FN is a readable directory, return the number of links it has.
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
154 Otherwise, return -1. */
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
155 extern DllImport int dir_links P1H(const_string fn);
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
156
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
157 /* Like their stdio counterparts, but abort on error, after calling
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
158 perror(3) with FILENAME as its argument. */
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
159 extern DllImport FILE *xfopen P2H(const_string filename, const_string mode);
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
160 extern DllImport void xfclose P2H(FILE *, const_string filename);
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
161 extern DllImport void xfseek P4H(FILE *, long, int, string filename);
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
162 extern DllImport unsigned long xftell P2H(FILE *, string filename);
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
163
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
164 /* These call the corresponding function in the standard library, and
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
165 abort if those routines fail. Also, `xrealloc' calls `xmalloc' if
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
166 OLD_ADDRESS is null. */
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
167 extern DllImport address xmalloc P1H(unsigned size);
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
168 extern DllImport address xrealloc P2H(address old_address, unsigned new_size);
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
169 extern DllImport address xcalloc P2H(unsigned nelem, unsigned elsize);
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
170
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
171 /* (Re)Allocate N items of type T using xmalloc/xrealloc. */
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
172 #define XTALLOC(n, t) ((t *) xmalloc ((n) * sizeof (t)))
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
173 #define XTALLOC1(t) XTALLOC (1, t)
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
174 #define XRETALLOC(addr, n, t) ((addr) = (t *) xrealloc (addr, (n) * sizeof(t)))
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
175
faa5d0421460 [project @ 1997-05-23 03:02:09 by jwe]
jwe
parents:
diff changeset
176 #endif /* not KPATHSEA_LIB_H */