1 /*
2  * Copyright (c) 2003, 2007-14 Matteo Frigo
3  * Copyright (c) 2003, 2007-14 Massachusetts Institute of Technology
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
18  *
19  */
20 
21 #include "api/api.h"
22 
23 typedef struct {
24      printer super;
25      void (*write_char)(char c, void *);
26      void *data;
27 } P;
28 
putchr_generic(printer * p_,char c)29 static void putchr_generic(printer * p_, char c)
30 {
31      P *p = (P *) p_;
32      (p->write_char)(c, p->data);
33 }
34 
X(export_wisdom)35 void X(export_wisdom)(void (*write_char)(char c, void *), void *data)
36 {
37      P *p = (P *) X(mkprinter)(sizeof(P), putchr_generic, 0);
38      planner *plnr = X(the_planner)();
39 
40      p->write_char = write_char;
41      p->data = data;
42      plnr->adt->exprt(plnr, (printer *) p);
43      X(printer_destroy)((printer *) p);
44 }
45