fix cases where compoundlits are constant/get an entity
[cparser] / printer.h
1 /*
2  * This file is part of cparser.
3  * Copyright (C) 2007-2009 Matthias Braun <matze@braunis.de>
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
18  * 02111-1307, USA.
19  */
20
21 /**
22  * @file
23  * @brief  Abstracts away printing strings to a stream so we can reuse our
24  *         printing routines for printing to files or into memory
25  */
26 #ifndef PRINTER_H
27 #define PRINTER_H
28
29 #include <stdio.h>
30 #include <stdlib.h>
31 #include <stdarg.h>
32 #include "adt/obst.h"
33 #include "string_rep.h"
34
35 /** print a string into current output */
36 extern void (*print_string)(const char *str);
37 extern void (*print_vformat)(const char *format, va_list ap);
38 extern void (*print_char)(const char c);
39
40 /** print a printf style format string to current output */
41 static inline void __attribute__((format(printf,1,2))) print_format(const char *format, ...)
42 {
43         va_list ap;
44         va_start(ap, format);
45         print_vformat(format, ap);
46         va_end(ap);
47 }
48
49 /** Set current output to be a FILE* stream */
50 void print_to_file(FILE *out);
51
52 /** Set current output to an obstack (grows an object on the obstack) */
53 void print_to_obstack(struct obstack *obst);
54
55 /** Set current output to be a buffer with limited size */
56 void print_to_buffer(char *buffer, size_t buffer_size);
57
58 /** Assures that the string in the buffer is 0 terminated */
59 void finish_print_to_buffer(void);
60
61 /** push current printer output to the (printer output) stack */
62 void printer_push(void);
63
64 /** pop a printer output from the stack */
65 void printer_pop(void);
66
67 #endif