2002-10-09 18:09:42 +00:00
|
|
|
/*
|
|
|
|
* Printing interface for PuTTY.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <assert.h>
|
2002-10-15 17:38:04 +00:00
|
|
|
#include <stdio.h>
|
2002-10-09 18:09:42 +00:00
|
|
|
#include "putty.h"
|
|
|
|
|
2002-10-15 17:38:04 +00:00
|
|
|
struct printer_job_tag {
|
|
|
|
FILE *fp;
|
|
|
|
};
|
|
|
|
|
2002-10-09 18:09:42 +00:00
|
|
|
printer_job *printer_start_job(char *printer)
|
|
|
|
{
|
2002-10-15 17:38:04 +00:00
|
|
|
printer_job *ret = smalloc(sizeof(printer_job));
|
|
|
|
/*
|
2003-01-12 14:50:34 +00:00
|
|
|
* On Unix, we treat the printer string as the name of a
|
|
|
|
* command to pipe to - typically lpr, of course.
|
2002-10-15 17:38:04 +00:00
|
|
|
*/
|
2003-01-12 14:50:34 +00:00
|
|
|
ret->fp = popen(printer, "w");
|
2002-10-15 17:38:04 +00:00
|
|
|
if (!ret->fp) {
|
|
|
|
sfree(ret);
|
|
|
|
ret = NULL;
|
|
|
|
}
|
|
|
|
return ret;
|
2002-10-09 18:09:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void printer_job_data(printer_job *pj, void *data, int len)
|
|
|
|
{
|
2002-10-15 17:38:04 +00:00
|
|
|
if (!pj)
|
|
|
|
return;
|
|
|
|
|
|
|
|
fwrite(data, 1, len, pj->fp);
|
2002-10-09 18:09:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void printer_finish_job(printer_job *pj)
|
|
|
|
{
|
2002-10-15 17:38:04 +00:00
|
|
|
if (!pj)
|
|
|
|
return;
|
|
|
|
|
|
|
|
pclose(pj->fp);
|
|
|
|
sfree(pj);
|
2002-10-09 18:09:42 +00:00
|
|
|
}
|