Null out the socket pointers in X- and port-forwarding channels for
[u/mdw/putty] / unix / uxprint.c
CommitLineData
1709795f 1/*
2 * Printing interface for PuTTY.
3 */
4
5#include <assert.h>
356a1706 6#include <stdio.h>
1709795f 7#include "putty.h"
8
356a1706 9struct printer_job_tag {
10 FILE *fp;
11};
12
1709795f 13printer_job *printer_start_job(char *printer)
14{
3d88e64d 15 printer_job *ret = snew(printer_job);
356a1706 16 /*
169c04c9 17 * On Unix, we treat the printer string as the name of a
18 * command to pipe to - typically lpr, of course.
356a1706 19 */
169c04c9 20 ret->fp = popen(printer, "w");
356a1706 21 if (!ret->fp) {
22 sfree(ret);
23 ret = NULL;
24 }
25 return ret;
1709795f 26}
27
28void printer_job_data(printer_job *pj, void *data, int len)
29{
356a1706 30 if (!pj)
31 return;
32
33 fwrite(data, 1, len, pj->fp);
1709795f 34}
35
36void printer_finish_job(printer_job *pj)
37{
356a1706 38 if (!pj)
39 return;
40
41 pclose(pj->fp);
42 sfree(pj);
1709795f 43}
0f915619 44
45/*
46 * There's no sensible way to enumerate printers under Unix, since
47 * practically any valid Unix command is a valid printer :-) So
48 * these are useless stub functions, and uxcfg.c will disable the
49 * drop-down list in the printer configurer.
50 */
51printer_enum *printer_start_enum(int *nprinters_ptr) {
52 *nprinters_ptr = 0;
53 return NULL;
54}
55char *printer_get_name(printer_enum *pe, int i) { return NULL;
56}
57void printer_finish_enum(printer_enum *pe) { }