parser: Remove the unused attribute alignment from struct declaration_specifiers_t.
[cparser] / printer.h
1 /*
2  * This file is part of cparser.
3  * Copyright (C) 2012 Matthias Braun <matze@braunis.de>
4  */
5
6 /**
7  * @file
8  * @brief  Abstracts away printing strings to a stream so we can reuse our
9  *         printing routines for printing to files or into memory
10  */
11 #ifndef PRINTER_H
12 #define PRINTER_H
13
14 #include <stdio.h>
15 #include <stdarg.h>
16
17 #include "adt/obst.h"
18
19 /** print a string into current output */
20 extern void (*print_string)(const char *str);
21 extern void (*print_vformat)(const char *format, va_list ap);
22 extern void (*print_char)(const char c);
23
24 /** print a printf style format string to current output */
25 static inline void __attribute__((format(printf,1,2))) print_format(const char *format, ...)
26 {
27         va_list ap;
28         va_start(ap, format);
29         print_vformat(format, ap);
30         va_end(ap);
31 }
32
33 /** Set current output to be a FILE* stream */
34 void print_to_file(FILE *out);
35
36 /** Set current output to an obstack (grows an object on the obstack) */
37 void print_to_obstack(struct obstack *obst);
38
39 /** Set current output to be a buffer with limited size */
40 void print_to_buffer(char *buffer, size_t buffer_size);
41
42 /** Assures that the string in the buffer is 0 terminated */
43 void finish_print_to_buffer(void);
44
45 /** push current printer output to the (printer output) stack */
46 void printer_push(void);
47
48 /** pop a printer output from the stack */
49 void printer_pop(void);
50
51 #endif