1 rizwank 1.1 /*
2 * Printer interface for popen() / lpr systems.
3 * Copyright (c) 1995-1999 Markku Rossi.
4 *
5 * Author: Markku Rossi <mtr@iki.fi>
6 */
7
8 /*
9 * This file is part of GNU enscript.
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2, or (at your option)
14 * any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 rizwank 1.1 * along with this program; see the file COPYING. If not, write to
23 * the Free Software Foundation, 59 Temple Place - Suite 330,
24 * Boston, MA 02111-1307, USA.
25 */
26
27 #include "gsint.h"
28
29 /*
30 * Global functions.
31 */
32
33 FILE *
34 printer_open(char *cmd, char *options, char *queue_param, char *printer_name,
35 void **context_return)
36 {
37 Buffer pipe_cmd;
38 FILE *fp;
39
40 buffer_init(&pipe_cmd);
41
42 buffer_append(&pipe_cmd, cmd);
43 rizwank 1.1 buffer_append(&pipe_cmd, " ");
44
45 if (options)
46 {
47 buffer_append(&pipe_cmd, options);
48 buffer_append(&pipe_cmd, " ");
49 }
50
51 if (printer_name)
52 {
53 buffer_append(&pipe_cmd, queue_param);
54 buffer_append(&pipe_cmd, printer_name);
55 }
56
57 fp = popen(buffer_ptr(&pipe_cmd), "w");
58
59 buffer_uninit(&pipe_cmd);
60
61 *context_return = fp;
62 return fp;
63 }
64 rizwank 1.1
65
66 void
67 printer_close(void *context)
68 {
69 FILE *fp = (FILE *) context;
70
71 pclose(fp);
72 }
|