annotate kpathsea/fn.h @ 2837:aa3630ffbd8e

[project @ 1997-03-26 21:19:26 by jwe]
author jwe
date Wed, 26 Mar 1997 21:19:38 +0000
parents 611d403c7f3d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1267
69501f98669d [project @ 1995-04-20 19:10:05 by jwe]
jwe
parents:
diff changeset
1 /* fn.h: arbitrarily long filenames (or just strings).
69501f98669d [project @ 1995-04-20 19:10:05 by jwe]
jwe
parents:
diff changeset
2
69501f98669d [project @ 1995-04-20 19:10:05 by jwe]
jwe
parents:
diff changeset
3 Copyright (C) 1993 Karl Berry.
69501f98669d [project @ 1995-04-20 19:10:05 by jwe]
jwe
parents:
diff changeset
4
69501f98669d [project @ 1995-04-20 19:10:05 by jwe]
jwe
parents:
diff changeset
5 This program is free software; you can redistribute it and/or modify
69501f98669d [project @ 1995-04-20 19:10:05 by jwe]
jwe
parents:
diff changeset
6 it under the terms of the GNU General Public License as published by
69501f98669d [project @ 1995-04-20 19:10:05 by jwe]
jwe
parents:
diff changeset
7 the Free Software Foundation; either version 2, or (at your option)
69501f98669d [project @ 1995-04-20 19:10:05 by jwe]
jwe
parents:
diff changeset
8 any later version.
69501f98669d [project @ 1995-04-20 19:10:05 by jwe]
jwe
parents:
diff changeset
9
69501f98669d [project @ 1995-04-20 19:10:05 by jwe]
jwe
parents:
diff changeset
10 This program is distributed in the hope that it will be useful,
69501f98669d [project @ 1995-04-20 19:10:05 by jwe]
jwe
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
69501f98669d [project @ 1995-04-20 19:10:05 by jwe]
jwe
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
69501f98669d [project @ 1995-04-20 19:10:05 by jwe]
jwe
parents:
diff changeset
13 GNU General Public License for more details.
69501f98669d [project @ 1995-04-20 19:10:05 by jwe]
jwe
parents:
diff changeset
14
69501f98669d [project @ 1995-04-20 19:10:05 by jwe]
jwe
parents:
diff changeset
15 You should have received a copy of the GNU General Public License
69501f98669d [project @ 1995-04-20 19:10:05 by jwe]
jwe
parents:
diff changeset
16 along with this program; if not, write to the Free Software
1315
611d403c7f3d [project @ 1995-06-25 19:56:32 by jwe]
jwe
parents: 1267
diff changeset
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
1267
69501f98669d [project @ 1995-04-20 19:10:05 by jwe]
jwe
parents:
diff changeset
18
69501f98669d [project @ 1995-04-20 19:10:05 by jwe]
jwe
parents:
diff changeset
19 #ifndef KPATHSEA_FN_H
69501f98669d [project @ 1995-04-20 19:10:05 by jwe]
jwe
parents:
diff changeset
20 #define KPATHSEA_FN_H
69501f98669d [project @ 1995-04-20 19:10:05 by jwe]
jwe
parents:
diff changeset
21
69501f98669d [project @ 1995-04-20 19:10:05 by jwe]
jwe
parents:
diff changeset
22 #include <kpathsea/c-proto.h>
69501f98669d [project @ 1995-04-20 19:10:05 by jwe]
jwe
parents:
diff changeset
23 #include <kpathsea/types.h>
69501f98669d [project @ 1995-04-20 19:10:05 by jwe]
jwe
parents:
diff changeset
24
69501f98669d [project @ 1995-04-20 19:10:05 by jwe]
jwe
parents:
diff changeset
25 /* Arbitrarily long filenames; it's inconvenient to use obstacks here,
69501f98669d [project @ 1995-04-20 19:10:05 by jwe]
jwe
parents:
diff changeset
26 because we want to maintain a null terminator. Also used for
69501f98669d [project @ 1995-04-20 19:10:05 by jwe]
jwe
parents:
diff changeset
27 dynamically growing strings even when the null byte isn't necessary,
69501f98669d [project @ 1995-04-20 19:10:05 by jwe]
jwe
parents:
diff changeset
28 e.g., in `variable.c', since I don't want to pass obstacks around
69501f98669d [project @ 1995-04-20 19:10:05 by jwe]
jwe
parents:
diff changeset
29 everywhere, and one can't free parts of an obstack arbitrarily. */
69501f98669d [project @ 1995-04-20 19:10:05 by jwe]
jwe
parents:
diff changeset
30
69501f98669d [project @ 1995-04-20 19:10:05 by jwe]
jwe
parents:
diff changeset
31 typedef struct
69501f98669d [project @ 1995-04-20 19:10:05 by jwe]
jwe
parents:
diff changeset
32 {
69501f98669d [project @ 1995-04-20 19:10:05 by jwe]
jwe
parents:
diff changeset
33 string str;
69501f98669d [project @ 1995-04-20 19:10:05 by jwe]
jwe
parents:
diff changeset
34 unsigned allocated;
69501f98669d [project @ 1995-04-20 19:10:05 by jwe]
jwe
parents:
diff changeset
35 unsigned length; /* includes the terminating null byte, if any */
69501f98669d [project @ 1995-04-20 19:10:05 by jwe]
jwe
parents:
diff changeset
36 } fn_type;
69501f98669d [project @ 1995-04-20 19:10:05 by jwe]
jwe
parents:
diff changeset
37
69501f98669d [project @ 1995-04-20 19:10:05 by jwe]
jwe
parents:
diff changeset
38 #define FN_STRING(fn) ((fn).str)
69501f98669d [project @ 1995-04-20 19:10:05 by jwe]
jwe
parents:
diff changeset
39 #define FN_ALLOCATED(fn) ((fn).allocated)
69501f98669d [project @ 1995-04-20 19:10:05 by jwe]
jwe
parents:
diff changeset
40 #define FN_LENGTH(fn) ((fn).length)
69501f98669d [project @ 1995-04-20 19:10:05 by jwe]
jwe
parents:
diff changeset
41
69501f98669d [project @ 1995-04-20 19:10:05 by jwe]
jwe
parents:
diff changeset
42
69501f98669d [project @ 1995-04-20 19:10:05 by jwe]
jwe
parents:
diff changeset
43 /* Create a new empty fn. */
69501f98669d [project @ 1995-04-20 19:10:05 by jwe]
jwe
parents:
diff changeset
44 extern fn_type fn_init P1H(void);
69501f98669d [project @ 1995-04-20 19:10:05 by jwe]
jwe
parents:
diff changeset
45
69501f98669d [project @ 1995-04-20 19:10:05 by jwe]
jwe
parents:
diff changeset
46 /* Create a new fn from the first LEN characters from S and a null. */
69501f98669d [project @ 1995-04-20 19:10:05 by jwe]
jwe
parents:
diff changeset
47 extern fn_type fn_copy0 P2H(const_string s, unsigned len);
69501f98669d [project @ 1995-04-20 19:10:05 by jwe]
jwe
parents:
diff changeset
48
69501f98669d [project @ 1995-04-20 19:10:05 by jwe]
jwe
parents:
diff changeset
49 /* Free what's been allocated. Can also just free the string if it's
69501f98669d [project @ 1995-04-20 19:10:05 by jwe]
jwe
parents:
diff changeset
50 been extracted out. Fatal error if nothing allocated in F. */
69501f98669d [project @ 1995-04-20 19:10:05 by jwe]
jwe
parents:
diff changeset
51 extern void fn_free P1H(fn_type *f);
69501f98669d [project @ 1995-04-20 19:10:05 by jwe]
jwe
parents:
diff changeset
52
69501f98669d [project @ 1995-04-20 19:10:05 by jwe]
jwe
parents:
diff changeset
53 /* Append the character C to the fn F. Don't append trailing null. */
69501f98669d [project @ 1995-04-20 19:10:05 by jwe]
jwe
parents:
diff changeset
54 extern void fn_1grow P2H(fn_type *f, char c);
69501f98669d [project @ 1995-04-20 19:10:05 by jwe]
jwe
parents:
diff changeset
55
69501f98669d [project @ 1995-04-20 19:10:05 by jwe]
jwe
parents:
diff changeset
56 /* Append LENGTH bytes from SOURCE to F. */
69501f98669d [project @ 1995-04-20 19:10:05 by jwe]
jwe
parents:
diff changeset
57 extern void fn_grow P3H(fn_type *f, address source, unsigned length);
69501f98669d [project @ 1995-04-20 19:10:05 by jwe]
jwe
parents:
diff changeset
58
69501f98669d [project @ 1995-04-20 19:10:05 by jwe]
jwe
parents:
diff changeset
59 /* Concatenate the component S to the fn F. Assumes string currently in
69501f98669d [project @ 1995-04-20 19:10:05 by jwe]
jwe
parents:
diff changeset
60 F is null terminated. */
69501f98669d [project @ 1995-04-20 19:10:05 by jwe]
jwe
parents:
diff changeset
61 extern void fn_str_grow P2H(fn_type *f, const_string s);
69501f98669d [project @ 1995-04-20 19:10:05 by jwe]
jwe
parents:
diff changeset
62
69501f98669d [project @ 1995-04-20 19:10:05 by jwe]
jwe
parents:
diff changeset
63 /* Add a null to F's string at position LOC, and update its length.
69501f98669d [project @ 1995-04-20 19:10:05 by jwe]
jwe
parents:
diff changeset
64 Fatal error if LOC is past the end of the string. */
69501f98669d [project @ 1995-04-20 19:10:05 by jwe]
jwe
parents:
diff changeset
65 extern void fn_shrink_to P2H(fn_type *f, unsigned loc);
69501f98669d [project @ 1995-04-20 19:10:05 by jwe]
jwe
parents:
diff changeset
66
69501f98669d [project @ 1995-04-20 19:10:05 by jwe]
jwe
parents:
diff changeset
67 #endif /* not KPATHSEA_FN_H */