Sebastian Kuschel reports that pfd_closing can be called for a socket
[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
219fc523 33 if (fwrite(data, 1, len, pj->fp) < len)
34 /* ignore */;
1709795f 35}
36
37void printer_finish_job(printer_job *pj)
38{
356a1706 39 if (!pj)
40 return;
41
42 pclose(pj->fp);
43 sfree(pj);
1709795f 44}
0f915619 45
46/*
47 * There's no sensible way to enumerate printers under Unix, since
48 * practically any valid Unix command is a valid printer :-) So
49 * these are useless stub functions, and uxcfg.c will disable the
50 * drop-down list in the printer configurer.
51 */
52printer_enum *printer_start_enum(int *nprinters_ptr) {
53 *nprinters_ptr = 0;
54 return NULL;
55}
56char *printer_get_name(printer_enum *pe, int i) { return NULL;
57}
58void printer_finish_enum(printer_enum *pe) { }