CUPS rastertoql filter  1.0.4
Filter for the Brother QL family of label printers
Functions | Variables
cupsfrontend.c File Reference

Functions to act as a CUPS filter. More...

Functions

static void handle_sigterm (int signal)
 
static int prepare_signals (void)
 
static int cups_ql_input_raster_file_open (struct qldriver *ql)
 
static int cups_ql_ppd_file_open (struct qldriver *ql, int option_cnt, cups_option_t options[option_cnt])
 
int main (int argc, const char *argv[])
 

Variables

int terminate
 
static struct sigaction signal_pipe [2]
 
static struct sigaction signal_term [2]
 

Detailed Description

Functions to act as a CUPS filter.

Author
Jürgen Borleis

Function Documentation

◆ cups_ql_input_raster_file_open()

static int cups_ql_input_raster_file_open ( struct qldriver ql)
static

'Take a look' into the CUPS raster file

Parameters
[in,out]qlFull job description
Return values
0On succes
-EINVALFailed to open the raster input file

◆ cups_ql_ppd_file_open()

static int cups_ql_ppd_file_open ( struct qldriver ql,
int  option_cnt,
cups_option_t  options[option_cnt] 
)
static

Get access to the printer's PPD file and its settings for this job

Parameters
[in]qlFull job description
[in]option_cntCount of elements in options
[in]optionsOptional parameters
Return values
-EINVALMissing PPD environment variable
-ENODATABad PPD content
0On success

◆ handle_sigterm()

static void handle_sigterm ( int  signal)
static

◆ main()

int main ( int  argc,
const char *  argv[] 
)

Main entry function.

Parameters
argcnumber of command line arguments plus one
argvcommand line arguments
Returns
0 if success, nonzero otherwise

https://opensource.apple.com/source/cups/cups-327/cups/doc/help/api-filter.html

We get:

  • argv[1] The job ID
  • argv[2] The user printing the job
  • argv[3] The job name/title
  • argv[4] The number of copies to print (only valid if argv[6] is given!)
  • argv[5] The options that were provided when the job was submitted
  • argv[6] The file to print (optional)

◆ prepare_signals()

static int prepare_signals ( void  )
static

Prepare for signal handling

Return values
0On success
Negativeon failure

Signals handled are:

  • SIGTERM: when a printing job is canceled or held
  • SIGPIPE: when an upstream or downstream filter/backend exits with a non-zero status

Note: SIGPIPE should be ignored in any case in this environment.

Variable Documentation

◆ signal_pipe

struct sigaction signal_pipe[2]
static
Initial value:
= {
{
.sa_handler = SIG_IGN,
.sa_flags = 0,
},
}

◆ signal_term

struct sigaction signal_term[2]
static
Initial value:
= {
{
.sa_handler = handle_sigterm,
.sa_flags = 0,
},
}

◆ terminate

int terminate

Change to '1' to signal the program should stop

handle_sigterm
static void handle_sigterm(int signal)
Definition: cupsfrontend.c:45