xref: /netbsd-src/external/bsd/tradcpp/dist/place.h (revision 31615c9617fab4df7f5e221552df7da87f14320d)
1*31615c96Sdholland /*-
2*31615c96Sdholland  * Copyright (c) 2010 The NetBSD Foundation, Inc.
3*31615c96Sdholland  * All rights reserved.
4*31615c96Sdholland  *
5*31615c96Sdholland  * This code is derived from software contributed to The NetBSD Foundation
6*31615c96Sdholland  * by David A. Holland.
7*31615c96Sdholland  *
8*31615c96Sdholland  * Redistribution and use in source and binary forms, with or without
9*31615c96Sdholland  * modification, are permitted provided that the following conditions
10*31615c96Sdholland  * are met:
11*31615c96Sdholland  * 1. Redistributions of source code must retain the above copyright
12*31615c96Sdholland  *    notice, this list of conditions and the following disclaimer.
13*31615c96Sdholland  * 2. Redistributions in binary form must reproduce the above copyright
14*31615c96Sdholland  *    notice, this list of conditions and the following disclaimer in the
15*31615c96Sdholland  *    documentation and/or other materials provided with the distribution.
16*31615c96Sdholland  *
17*31615c96Sdholland  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
18*31615c96Sdholland  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19*31615c96Sdholland  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20*31615c96Sdholland  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
21*31615c96Sdholland  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22*31615c96Sdholland  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23*31615c96Sdholland  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24*31615c96Sdholland  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25*31615c96Sdholland  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26*31615c96Sdholland  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27*31615c96Sdholland  * POSSIBILITY OF SUCH DAMAGE.
28*31615c96Sdholland  */
29*31615c96Sdholland 
30*31615c96Sdholland #ifndef PLACE_H
31*31615c96Sdholland #define PLACE_H
32*31615c96Sdholland 
33*31615c96Sdholland #include "bool.h"
34*31615c96Sdholland 
35*31615c96Sdholland enum places {
36*31615c96Sdholland 	P_NOWHERE,
37*31615c96Sdholland 	P_BUILTIN,
38*31615c96Sdholland 	P_COMMANDLINE,
39*31615c96Sdholland 	P_FILE,
40*31615c96Sdholland };
41*31615c96Sdholland struct place {
42*31615c96Sdholland 	enum places type;
43*31615c96Sdholland 	const struct placefile *file;
44*31615c96Sdholland 	unsigned line;
45*31615c96Sdholland 	unsigned column;
46*31615c96Sdholland };
47*31615c96Sdholland 
48*31615c96Sdholland void place_init(void);
49*31615c96Sdholland void place_cleanup(void);
50*31615c96Sdholland 
51*31615c96Sdholland void place_setnowhere(struct place *p);
52*31615c96Sdholland void place_setbuiltin(struct place *p, unsigned num);
53*31615c96Sdholland void place_setcommandline(struct place *p, unsigned word, unsigned column);
54*31615c96Sdholland void place_setfilestart(struct place *p, const struct placefile *pf);
55*31615c96Sdholland 
56*31615c96Sdholland void place_addcolumns(struct place *, unsigned cols);
57*31615c96Sdholland void place_addlines(struct place *, unsigned lines);
58*31615c96Sdholland 
59*31615c96Sdholland const char *place_getname(const struct place *);
60*31615c96Sdholland const char *place_getparsedir(const struct place *incplace);
61*31615c96Sdholland bool place_eq(const struct place *, const struct place *);
62*31615c96Sdholland bool place_samefile(const struct place *, const struct place *);
63*31615c96Sdholland 
64*31615c96Sdholland void place_changefile(struct place *p, const char *name);
65*31615c96Sdholland 
66*31615c96Sdholland const struct placefile *place_addfile(const struct place *incplace,
67*31615c96Sdholland 				      const char *name, bool fromsystemdir);
68*31615c96Sdholland 
69*31615c96Sdholland #endif /* PLACE_H */
70