xref: /openbsd-src/libexec/tradcpp/macro.h (revision f9343feac8314427583210aa64cbdde958db9030)
1a9b3ff1aSjsg /*-
2a9b3ff1aSjsg  * Copyright (c) 2010 The NetBSD Foundation, Inc.
3a9b3ff1aSjsg  * All rights reserved.
4a9b3ff1aSjsg  *
5a9b3ff1aSjsg  * This code is derived from software contributed to The NetBSD Foundation
6a9b3ff1aSjsg  * by David A. Holland.
7a9b3ff1aSjsg  *
8a9b3ff1aSjsg  * Redistribution and use in source and binary forms, with or without
9a9b3ff1aSjsg  * modification, are permitted provided that the following conditions
10a9b3ff1aSjsg  * are met:
11a9b3ff1aSjsg  * 1. Redistributions of source code must retain the above copyright
12a9b3ff1aSjsg  *    notice, this list of conditions and the following disclaimer.
13a9b3ff1aSjsg  * 2. Redistributions in binary form must reproduce the above copyright
14a9b3ff1aSjsg  *    notice, this list of conditions and the following disclaimer in the
15a9b3ff1aSjsg  *    documentation and/or other materials provided with the distribution.
16a9b3ff1aSjsg  *
17a9b3ff1aSjsg  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
18a9b3ff1aSjsg  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19a9b3ff1aSjsg  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20a9b3ff1aSjsg  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
21a9b3ff1aSjsg  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22a9b3ff1aSjsg  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23a9b3ff1aSjsg  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24a9b3ff1aSjsg  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25a9b3ff1aSjsg  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26a9b3ff1aSjsg  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27a9b3ff1aSjsg  * POSSIBILITY OF SUCH DAMAGE.
28a9b3ff1aSjsg  */
29a9b3ff1aSjsg 
30a9b3ff1aSjsg #include <stddef.h>
31*f9343feaSjsg #include "bool.h"
32a9b3ff1aSjsg 
33a9b3ff1aSjsg struct place;
34a9b3ff1aSjsg 
35a9b3ff1aSjsg void macros_init(void);
36a9b3ff1aSjsg void macros_cleanup(void);
37a9b3ff1aSjsg 
38a9b3ff1aSjsg void macro_define_plain(struct place *, const char *macro,
39a9b3ff1aSjsg 			struct place *, const char *expansion);
40a9b3ff1aSjsg void macro_define_params(struct place *, const char *macro,
41a9b3ff1aSjsg 			 struct place *, const char *params,
42a9b3ff1aSjsg 			 struct place *, const char *expansion);
43*f9343feaSjsg void macro_define_magic(struct place *, const char *macro);
44a9b3ff1aSjsg void macro_undef(const char *macro);
45a9b3ff1aSjsg bool macro_isdefined(const char *macro);
46a9b3ff1aSjsg 
47*f9343feaSjsg char *macroexpand(struct place *, const char *buf, size_t len,
48*f9343feaSjsg 		  bool honordefined);
49a9b3ff1aSjsg 
50*f9343feaSjsg void macro_sendline(struct place *, const char *buf, size_t len);
51a9b3ff1aSjsg void macro_sendeof(struct place *);
52