├── NEWS ├── ChangeLog ├── mime ├── cupsfilters-mupdf.convs ├── cupsfilters-poppler.convs ├── cupsfilters-ghostscript.convs ├── cupsfilters.convs ├── cupsfilters-universal-postscript.convs ├── cupsfilters-universal.convs ├── cupsfilters-individual.convs.in └── cupsfilters.types ├── CONTRIBUTING.md ├── filter ├── foomatic-rip │ ├── renderer.h │ ├── postscript.h │ ├── pdf.h │ ├── spooler.h │ ├── process.h │ ├── foomaticrip.h │ ├── foomatic-hash.1 │ ├── options.h │ ├── process.c │ ├── spooler.c │ ├── foomatic-rip.1.in │ └── pdf.c ├── test.sh ├── escp.h ├── pcl.h ├── texttops ├── pclmtoraster.c ├── pdftopdf.c ├── pcl-common.h ├── rastertopwg.c ├── pdftoraster.c ├── rastertops.c ├── texttotext.c ├── gstoraster.c ├── pwgtoraster.c ├── mupdftopwg.c ├── pdftops.c ├── pstops.c ├── pwgtopdf.c ├── imagetops.c ├── pwgtopclm.c ├── gstopdf.c ├── imagetopdf.c ├── gstopxl.c ├── imagetoraster.c ├── bannertopdf.c ├── texttopdf.c ├── universal.c ├── test-external.c ├── commandtopclx.c ├── commandtoescpx.c └── pcl-common.c ├── utils ├── driverless-fax.in └── driverless.1 ├── .github └── ISSUE_TEMPLATE │ ├── feature_request.md │ └── bug_report.md ├── AUTHORS ├── ln-srf ├── m4 ├── ac_define_dir.m4 ├── basic-directories.m4 ├── ac_ln_srf.m4 └── ax_compare_version.m4 ├── autogen.sh ├── drv └── custom-media-lines ├── .gitignore ├── NOTICE ├── COPYING ├── INSTALL ├── install-sh ├── CHANGES.md ├── ppdfiles ├── pxlmono.ppd └── pxlcolor.ppd └── backend └── beh.c /NEWS: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mime/cupsfilters-mupdf.convs: -------------------------------------------------------------------------------- 1 | # 2 | # MIME conversions file for OpenPrinting CUPS Filters. 3 | # 4 | # Copyright 2007-2011 by Apple Inc. 5 | # Copyright 1997-2007 by Easy Software Products. 6 | # Copyright 2012-2016 by Till Kamppeter. 7 | # 8 | # Licensed under Apache License v2.0. See the file "LICENSE" for more 9 | # information. 10 | # 11 | 12 | # 13 | # MuPDF-based filters... 14 | # 15 | 16 | application/vnd.cups-pdf image/pwg-raster 101 mupdftopwg 17 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Contributing to CUPS Filters 2 | ============================ 3 | 4 | CUPS Filters is developed by OpenPrinting and distributed as open source 5 | software under the Apache License, Version 2.0 with exceptions to allow linking 6 | to GPL2/LGPL2 code (same license as for CUPS). 7 | 8 | Contributions should be submitted either as pull requests or as attachments 9 | (unified diffs) to bug reports on the OpenPrinting CUPS GitHub project at 10 | . 11 | -------------------------------------------------------------------------------- /filter/foomatic-rip/renderer.h: -------------------------------------------------------------------------------- 1 | // 2 | // renderer.h 3 | // 4 | // Copyright (C) 2008 Till Kamppeter 5 | // Copyright (C) 2008 Lars Karlitski (formerly Uebernickel) 6 | // 7 | // This file is part of foomatic-rip. 8 | // 9 | // Licensed under Apache License v2.0. See the file "LICENSE" for more 10 | // information. 11 | // 12 | 13 | #ifndef renderer_h 14 | #define renderer_h 15 | 16 | void massage_gs_commandline(dstr_t *cmd); 17 | int exec_kid3(FILE *in, FILE *out, void *user_arg); 18 | 19 | #endif // !renderer_h 20 | -------------------------------------------------------------------------------- /filter/foomatic-rip/postscript.h: -------------------------------------------------------------------------------- 1 | // 2 | // postscript.h 3 | // 4 | // Copyright (C) 2008 Till Kamppeter 5 | // Copyright (C) 2008 Lars Karlitski (formerly Uebernickel) 6 | // 7 | // This file is part of foomatic-rip. 8 | // 9 | // Licensed under Apache License v2.0. See the file "LICENSE" for more 10 | // information. 11 | // 12 | 13 | #ifndef postscript_h 14 | #define postscript_h 15 | 16 | int print_ps(FILE *s, const char *alreadyread, size_t len, 17 | const char *filename); 18 | 19 | #endif // !postscript_h 20 | -------------------------------------------------------------------------------- /filter/foomatic-rip/pdf.h: -------------------------------------------------------------------------------- 1 | // 2 | // pdf.h 3 | // 4 | // Copyright (C) 2008 Till Kamppeter 5 | // Copyright (C) 2008 Lars Karlitski (formerly Uebernickel) 6 | // 7 | // This file is part of foomatic-rip. 8 | // 9 | // Licensed under Apache License v2.0. See the file "LICENSE" for more 10 | // information. 11 | // 12 | 13 | #ifndef pdf_h 14 | #define pdf_h 15 | 16 | int print_pdf(FILE *s, const char *alreadyread, size_t len, 17 | const char *filename, size_t startpos); 18 | int pdf_count_pages(const char *filename); 19 | 20 | #endif // !pdf_h 21 | -------------------------------------------------------------------------------- /mime/cupsfilters-poppler.convs: -------------------------------------------------------------------------------- 1 | # 2 | # MIME conversions file for OpenPrinting CUPS Filters. 3 | # 4 | # Copyright 2007-2011 by Apple Inc. 5 | # Copyright 1997-2007 by Easy Software Products. 6 | # Copyright 2012-2016 by Till Kamppeter. 7 | # 8 | # Licensed under Apache License v2.0. See the file "LICENSE" for more 9 | # information. 10 | # 11 | 12 | # 13 | # Poppler-based filters... 14 | # 15 | 16 | application/vnd.cups-pdf application/vnd.cups-raster 100 pdftoraster 17 | application/vnd.cups-pdf image/pwg-raster 100 pdftoraster 18 | application/vnd.cups-pdf image/urf 100 pdftoraster 19 | -------------------------------------------------------------------------------- /filter/foomatic-rip/spooler.h: -------------------------------------------------------------------------------- 1 | // 2 | // spooler.h 3 | // 4 | // Copyright (C) 2008 Till Kamppeter 5 | // Copyright (C) 2008 Lars Karlitski (formerly Uebernickel) 6 | // 7 | // This file is part of foomatic-rip. 8 | // 9 | // Licensed under Apache License v2.0. See the file "LICENSE" for more 10 | // information. 11 | // 12 | 13 | #ifndef SPOOLER_H 14 | #define SPOOLER_H 15 | 16 | #include "foomaticrip.h" 17 | #include "util.h" 18 | 19 | const char *spooler_name(int spooler); 20 | void init_cups(list_t *arglist, dstr_t *filelist, jobparams_t *job); 21 | void init_direct(list_t *arglist, dstr_t *filelist, jobparams_t *job); 22 | 23 | #endif // !SPOOLER_H 24 | 25 | -------------------------------------------------------------------------------- /utils/driverless-fax.in: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Note: This is only a wrapper for driverless-fax, the real work is done by 4 | # driverless 5 | # 6 | # (C) 2020 Nidhi Jain 7 | # (C) 2012-2020 Till Kamppeter 8 | # 9 | # Licensed under Apache License v2.0. See the file "LICENSE" for more 10 | # information. 11 | # 12 | 13 | if [ $# -eq "0" ]; then 14 | DEVICE_TYPE=FAX @CUPS_SERVERBIN@/backend/driverless 15 | elif [ $# -eq "1" ]; then 16 | DEVICE_TYPE=FAX @CUPS_SERVERBIN@/driver/driverless "$1" 17 | elif [ $# -eq "2" ]; then 18 | DEVICE_TYPE=FAX @CUPS_SERVERBIN@/driver/driverless "$1" "$2" 19 | else 20 | echo "ERROR: Too many arguments" 21 | fi 22 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /filter/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # just for comparison 4 | /usr/lib/cups/filter/texttops 1 hi_user there_title 1 "" Makefile > test1.ps || : 5 | 6 | # for the next to work, you'll have to make a subdirectory fonts/ here, containing the fonts 7 | # and a subdirectory charsets/ with a file pdf.utf-8 8 | export CUPS_DATADIR=`pwd`/ 9 | 10 | ./texttopdf 1 hi_user there_title 1 "" Makefile > test1.pdf 11 | ./texttopdf 1 hi_user there_title 1 "PrettyPrint=1" Makefile > test2.pdf 12 | (export CONTENT_TYPE=application/x-csource; ./texttopdf 1 hi_user there_title 1 "PrettyPrint=1" test_pdf1.c > test3.pdf) 13 | (export CHARSET=utf-8; ./texttopdf 1 hi_user there_title 1 "PrettyPrint=1" Makefile > test4.pdf) 14 | (export CHARSET=utf-8; ./texttopdf 1 hi_user there_title 1 "" testin > test5.pdf) 15 | -------------------------------------------------------------------------------- /mime/cupsfilters-ghostscript.convs: -------------------------------------------------------------------------------- 1 | # 2 | # MIME conversions file for OpenPrinting CUPS Filters. 3 | # 4 | # Copyright 2007-2011 by Apple Inc. 5 | # Copyright 1997-2007 by Easy Software Products. 6 | # Copyright 2012-2016 by Till Kamppeter. 7 | # 8 | # Licensed under Apache License v2.0. See the file "LICENSE" for more 9 | # information. 10 | # 11 | 12 | # 13 | # Ghostscript-based filters... 14 | # 15 | 16 | application/postscript application/pdf 0 gstopdf 17 | application/vnd.cups-pdf application/vnd.cups-raster 99 gstoraster 18 | application/vnd.cups-pdf image/pwg-raster 99 gstoraster 19 | application/vnd.cups-pdf image/urf 99 gstoraster 20 | application/vnd.cups-pdf application/PCLm 99 gstoraster 21 | application/vnd.cups-postscript application/vnd.cups-raster 175 gstoraster 22 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **System Information:** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Additional context** 32 | Add any other context about the problem here. 33 | -------------------------------------------------------------------------------- /filter/escp.h: -------------------------------------------------------------------------------- 1 | // 2 | // This file contains model number definitions for the unified 3 | // ESC/P driver of cups-filters. 4 | // 5 | // Copyright 2007 by Apple Inc. 6 | // Copyright 1997-2005 by Easy Software Products. 7 | // 8 | // Licensed under Apache License v2.0. See the file "LICENSE" for more 9 | // information. 10 | // 11 | 12 | // General ESC/P Support 13 | #define ESCP_DOTMATRIX 0x1 // Dot matrix printer? 14 | #define ESCP_MICROWEAVE 0x2 // Use microweave command? 15 | #define ESCP_STAGGER 0x4 // Are color jets staggered? 16 | #define ESCP_ESCK 0x8 // Use print mode command? 17 | #define ESCP_EXT_UNITS 0x10 // Use extended unit commands? 18 | #define ESCP_EXT_MARGINS 0x20 // Use extended margin command 19 | #define ESCP_USB 0x40 // Send USB packet mode escape? 20 | #define ESCP_PAGE_SIZE 0x80 // Use page size command 21 | #define ESCP_RASTER_ESCI 0x100 // Use ESC i graphics command 22 | 23 | // Remote mode support 24 | #define ESCP_REMOTE 0x1000 // Use remote mode commands? 25 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Till Kamppeter, OpenPrinting/Canonical (till.kamppeter@gmail.com) 2 | Michael Sweet, Apple (msweet@apple.com) 3 | Tim Waugh (twaugh@redhat.com) 4 | Koji Otani, BBR Inc. (sho@bbr.jp) 5 | Tobias Hoffmann (th55@gmx.de) 6 | Lars Karlitski (formerly Übernickel), Red Hat (lars@karlitski.net) 7 | Neil 'Superna' Armstrong (superna9999@gmail.com) 8 | Richard Hughes (hughsient@gmail.com) 9 | Franz Pförtsch (Franz.Pfoertsch@brose.com) 10 | Tomáš Chvátal (tomas.chvatal@gmail.com) 11 | Andrew V. Stepanov (stanv@altlinux.com) 12 | Joseph Simon (jsimon383@gmail.com) 13 | Samuel Thibault (samuel.thibault@ens-lyon.org) 14 | Pranjal Bhor (bhor.pranjal@gmail.com) 15 | Sahil Arora (sahilarora.535@gmail.com) 16 | Deepak Patankar (patankardeepak04@gmail.com) 17 | Tanmay Anand (tanand@iitk.ac.in) 18 | Mohit Mohan (mohitmo@cse.iitk.ac.in) 19 | Suraj Kulriya (surajkulriya@gmail.com) 20 | Pratyush Ranjan (pratyush.ranjan911@gmail.com) 21 | Pranshu Kharkwal (b19136@students.iitmandi.ac.in) 22 | Chandresh Soni (chandresh2702@gmail.com) 23 | Sachin Thakan (sachinthakan001@gmail.com) 24 | -------------------------------------------------------------------------------- /filter/pcl.h: -------------------------------------------------------------------------------- 1 | // 2 | // This file contains model number definitions for the unified 3 | // PCL driver of cups-filters. 4 | // 5 | // Copyright 2007 by Apple Inc. 6 | // Copyright 1997-2005 by Easy Software Products. 7 | // 8 | // Licensed under Apache License v2.0. See the file "LICENSE" for more 9 | // information. 10 | // 11 | 12 | // General PCL Support 13 | #define PCL_PAPER_SIZE 0x1 // Use ESC&l#A 14 | #define PCL_INKJET 0x2 // Use inkjet commands 15 | 16 | // Raster Support 17 | #define PCL_RASTER_END_COLOR 0x100 // Use ESC*rC 18 | #define PCL_RASTER_CID 0x200 // Use ESC*v#W 19 | #define PCL_RASTER_CRD 0x400 // Use ESC*g#W 20 | #define PCL_RASTER_SIMPLE 0x800 // Use ESC*r#U 21 | #define PCL_RASTER_RGB24 0x1000 // Use 24-bit RGB mode 22 | 23 | // PJL Support 24 | #define PCL_PJL 0x10000 // Use PJL Commands 25 | #define PCL_PJL_PAPERWIDTH 0x20000 // Use PJL PAPERWIDTH/LENGTH 26 | #define PCL_PJL_HPGL2 0x40000 // Enter HPGL2 27 | #define PCL_PJL_PCL3GUI 0x80000 // Enter PCL3GUI 28 | #define PCL_PJL_RESOLUTION 0x100000 // Use PJL SET RESOLUTION 29 | -------------------------------------------------------------------------------- /ln-srf: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Author: Carlos Santos 4 | # This file is in public domain. 5 | # 6 | 7 | error() { 8 | echo "$@" 1>&2 9 | exit 1 10 | } 11 | 12 | src="$1" 13 | dst="$2" 14 | 15 | check_path() { 16 | case "$2" in 17 | */../*|*/./*|*/.|*/..) error "$1 path '$2' must be absolute";; 18 | */) error "$1 path '$2' must not end with '/'";; 19 | /?*) ;; 20 | *) error "$1 path '$2' must start with '/'";; 21 | esac 22 | } 23 | 24 | check_path "source" "$src" 25 | check_path "destination" "$dst" 26 | 27 | # strip leading '/' 28 | src=${src#/*} 29 | tmp=${dst#/*} 30 | 31 | s_prefix=${src%%/*} 32 | d_prefix=${tmp%%/*} 33 | 34 | # strip leading common 35 | while [ "$s_prefix" = "$d_prefix" ]; do 36 | src="${src#$s_prefix/}" 37 | tmp="${tmp#$d_prefix/}" 38 | s_prefix=${src%%/*} 39 | d_prefix=${tmp%%/*} 40 | done 41 | 42 | s_prefix="../" 43 | while [ -n "$d_prefix" ] && [ "$tmp" != "$d_prefix" ]; do 44 | s_prefix="../$s_prefix" 45 | tmp="${tmp#$d_prefix/}" 46 | d_prefix=${tmp%%/*} 47 | done 48 | 49 | ln -s -f "$s_prefix$src" "$dst" 50 | -------------------------------------------------------------------------------- /filter/texttops: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # texttops - This is a Text-to-PostScript filter for cups-filters 4 | # 5 | # Note: This wrapper filter is only included for backward compatibility with 6 | # certan custom configurations. It is not mentioned in any of the .convs 7 | # files included in this package and therefore never used with the default 8 | # configuration. It makes sure that third-party PPD files referring to 9 | # texttops explicitly or custom configurations (in /etc/cups/*.convs files) 10 | # will not break. 11 | # 12 | # DO NOT create new PPD or .convs files using this filter! texttops is 13 | # DEPRECATED! 14 | # 15 | # (C) 2012 Till Kamppeter 16 | # 17 | # Licensed under Apache License v2.0. See the file "LICENSE" for more 18 | # information. 19 | # 20 | 21 | PDF2PS=`which pdf2ps` 22 | 23 | echo "DEBUG: texttops argv[$#] = $@" >&2 24 | echo "DEBUG: PPD: $PPD" >&2 25 | 26 | if [ $# -lt 5 -o $# -gt 6 ]; then 27 | echo "ERROR: $0 job-id user title copies options [file]" >&2 28 | exit 1 29 | fi 30 | 31 | # Read from given file. 32 | if [ -n "$6" ]; then 33 | exec <"$6" 34 | fi 35 | 36 | $CUPS_SERVERBIN/filter/texttopdf "$1" "$2" "$3" "$4" "$5" | $PDF2PS - - 37 | -------------------------------------------------------------------------------- /filter/foomatic-rip/process.h: -------------------------------------------------------------------------------- 1 | // 2 | // process.h 3 | // 4 | // Copyright (C) 2008 Till Kamppeter 5 | // Copyright (C) 2008 Lars Karlitski (formerly Uebernickel) 6 | // 7 | // This file is part of foomatic-rip. 8 | // 9 | // Licensed under Apache License v2.0. See the file "LICENSE" for more 10 | // information. 11 | // 12 | 13 | #ifndef process_h 14 | #define process_h 15 | 16 | #include 17 | #include 18 | #include 19 | 20 | 21 | extern char *modern_shell; 22 | 23 | pid_t start_process(const char *name, int (*proc_func)(FILE*, FILE*, void*), void *user_arg, 24 | FILE **fdin, FILE **fdout); 25 | pid_t start_system_process(const char *name, const char *command, FILE **fdin, 26 | FILE **fdout); 27 | 28 | const char *get_modern_shell(); 29 | // returns command's return status (see waitpid(2)) 30 | int run_system_process(const char *name, const char *command); 31 | 32 | pid_t create_pipe_process(const char *name, FILE *src, FILE *dest, 33 | const char *alreadyread, size_t alreadyread_len); 34 | 35 | int wait_for_process(int pid); 36 | 37 | void kill_all_processes(); 38 | 39 | #endif // !process_h 40 | -------------------------------------------------------------------------------- /filter/pclmtoraster.c: -------------------------------------------------------------------------------- 1 | // 2 | // Legacy CUPS filter wrapper for cfFilterPCLmToRaster() for cups-filters. 3 | // 4 | // Copyright © 2020-2022 by OpenPrinting. 5 | // 6 | // Licensed under Apache License v2.0. See the file "LICENSE" for more 7 | // information. 8 | // 9 | 10 | // 11 | // Include necessary headers... 12 | // 13 | 14 | #include 15 | #include 16 | 17 | 18 | // 19 | // Local globals... 20 | // 21 | 22 | static int JobCanceled = 0;// Set to 1 on SIGTERM 23 | 24 | 25 | int main(int argc, char **argv) 26 | { 27 | int ret; 28 | 29 | // 30 | // Fire up the cfFilterPCLmToRaster() filter function 31 | // 32 | 33 | cf_filter_out_format_t outformat = CF_FILTER_OUT_FORMAT_PWG_RASTER; 34 | char *t = getenv("FINAL_CONTENT_TYPE"); 35 | if (t) 36 | { 37 | if (strcasestr(t, "urf")) 38 | outformat = CF_FILTER_OUT_FORMAT_APPLE_RASTER; 39 | else if (strcasestr(t, "cups-raster")) 40 | outformat = CF_FILTER_OUT_FORMAT_CUPS_RASTER; 41 | } 42 | 43 | ret = ppdFilterCUPSWrapper(argc, argv, cfFilterPCLmToRaster, &outformat, 44 | &JobCanceled); 45 | 46 | if (ret) 47 | fprintf(stderr, "ERROR: pclmtoraster filter function failed.\n"); 48 | 49 | return (ret); 50 | } 51 | -------------------------------------------------------------------------------- /m4/ac_define_dir.m4: -------------------------------------------------------------------------------- 1 | dnl @synopsis AC_DEFINE_DIR(VARNAME, DIR [, DESCRIPTION]) 2 | dnl 3 | dnl This macro sets VARNAME to the expansion of the DIR variable, 4 | dnl taking care of fixing up ${prefix} and such. 5 | dnl 6 | dnl VARNAME is then offered as both an output variable and a C 7 | dnl preprocessor symbol. 8 | dnl 9 | dnl Example: 10 | dnl 11 | dnl AC_DEFINE_DIR([DATADIR], [datadir], [Where data are placed to.]) 12 | dnl 13 | dnl @category Misc 14 | dnl @author Stepan Kasal 15 | dnl @author Andreas Schwab 16 | dnl @author Guido U. Draheim 17 | dnl @author Alexandre Oliva 18 | dnl @version 2006-10-13 19 | dnl @license AllPermissive 20 | 21 | AC_DEFUN([AC_DEFINE_DIR], [ 22 | prefix_NONE= 23 | exec_prefix_NONE= 24 | test "x$prefix" = xNONE && prefix_NONE=yes && prefix=$ac_default_prefix 25 | test "x$exec_prefix" = xNONE && exec_prefix_NONE=yes && exec_prefix=$prefix 26 | dnl In Autoconf 2.60, ${datadir} refers to ${datarootdir}, which in turn 27 | dnl refers to ${prefix}. Thus we have to use `eval' twice. 28 | eval ac_define_dir="\"[$]$2\"" 29 | eval ac_define_dir="\"$ac_define_dir\"" 30 | AC_SUBST($1, "$ac_define_dir") 31 | AC_DEFINE_UNQUOTED($1, "$ac_define_dir", [$3]) 32 | test "$prefix_NONE" && prefix=NONE 33 | test "$exec_prefix_NONE" && exec_prefix=NONE 34 | ]) 35 | -------------------------------------------------------------------------------- /mime/cupsfilters.convs: -------------------------------------------------------------------------------- 1 | # 2 | # MIME conversions file for OpenPrinting CUPS Filters. 3 | # 4 | # Copyright 2007-2011 by Apple Inc. 5 | # Copyright 1997-2007 by Easy Software Products. 6 | # Copyright 2012-2021 by Till Kamppeter. 7 | # Copyright 2017 by Sahil Arora. 8 | # 9 | # Licensed under Apache License v2.0. See the file "LICENSE" for more 10 | # information. 11 | # 12 | 13 | ######################################################################## 14 | # 15 | # Format of Lines: 16 | # 17 | # source/type destination/type cost filter 18 | # 19 | # General Notes: 20 | # 21 | # The "cost" field is used to find the least costly filters to run 22 | # when converting a job file to a printable format. 23 | # 24 | # All filters *must* accept the standard command-line arguments 25 | # (job-id, user, title, copies, options, [filename or stdin]) to 26 | # work with CUPS. 27 | # 28 | 29 | ######################################################################## 30 | # 31 | # Text rules (for text-only printers with texttotext filter in PPD and 32 | # for texttopdf, both individual or in universal filter)... 33 | # 34 | 35 | application/x-cshell text/plain 0 - 36 | application/x-csource text/plain 0 - 37 | application/x-perl text/plain 0 - 38 | application/x-shell text/plain 0 - 39 | text/html text/plain 0 - 40 | text/css text/plain 0 - 41 | -------------------------------------------------------------------------------- /mime/cupsfilters-universal-postscript.convs: -------------------------------------------------------------------------------- 1 | # 2 | # MIME conversions file for OpenPrinting CUPS Filters. 3 | # 4 | # Copyright 2007-2011 by Apple Inc. 5 | # Copyright 1997-2007 by Easy Software Products. 6 | # Copyright 2012-2016 by Till Kamppeter. 7 | # Copyright 2017 by Sahil Arora. 8 | # 9 | # Licensed under Apache License v2.0. See the file "LICENSE" for more 10 | # information. 11 | # 12 | 13 | ######################################################################## 14 | # 15 | # Format of Lines: 16 | # 17 | # source/type destination/type cost filter 18 | # 19 | # General Notes: 20 | # 21 | # The "cost" field is used to find the least costly filters to run 22 | # when converting a job file to a printable format. 23 | # 24 | # All filters *must* accept the standard command-line arguments 25 | # (job-id, user, title, copies, options, [filename or stdin]) to 26 | # work with CUPS. 27 | # 28 | 29 | ######################################################################## 30 | # 31 | # Input formats 32 | # 33 | 34 | application/postscript application/vnd.universal-input 0 - 35 | application/vnd.cups-postscript application/vnd.universal-input 0 - 36 | 37 | # CUPS file conversion rules for PostScript input when we are working 38 | # with the PDF printing workflow: General PostScript input should be 39 | # converted to PDF, so that pdftopdf() is doing the page management on 40 | # PDF data and the renderer/driver part renders PDF. An exception is 41 | # made for PostScript coming from the Adobe Reader. As this PostScript 42 | # cannot be converted to PDF if it comes from an encrypted PDF file, 43 | # we simply override pstopdf() and the PDF workflow. 44 | 45 | application/vnd.adobe-reader-postscript application/vnd.universal-input 0 - 46 | 47 | -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | TESTLIBTOOLIZE="glibtoolize libtoolize" 3 | 4 | LIBTOOLIZEFOUND="0" 5 | 6 | srcdir=`dirname $0` 7 | test -z "$srcdir" && srcdir=. 8 | 9 | olddir=`pwd` 10 | cd $srcdir 11 | 12 | aclocal --version > /dev/null 2> /dev/null || { 13 | echo "error: aclocal not found" 14 | exit 1 15 | } 16 | 17 | automake --version > /dev/null 2> /dev/null || { 18 | echo "error: automake not found" 19 | exit 1 20 | } 21 | 22 | autopoint --version > /dev/null 2> /dev/null || { 23 | echo "error: autopoint not found" 24 | exit 1 25 | } 26 | 27 | gettext --version > /dev/null 2> /dev/null || { 28 | echo "error: gettext not found" 29 | exit 1 30 | } 31 | 32 | for i in $TESTLIBTOOLIZE; do 33 | if which $i > /dev/null 2>&1; then 34 | LIBTOOLIZE=$i 35 | LIBTOOLIZEFOUND="1" 36 | break 37 | fi 38 | done 39 | 40 | if [ "$LIBTOOLIZEFOUND" = "0" ]; then 41 | echo "$0: need libtoolize tool to build cups-filters" >&2 42 | exit 1 43 | fi 44 | 45 | amcheck=`automake --version | grep 'automake (GNU automake) 1.5'` 46 | if test "x$amcheck" = "xautomake (GNU automake) 1.5"; then 47 | echo "warning: you appear to be using automake 1.5" 48 | echo " this version has a bug - GNUmakefile.am dependencies are not generated" 49 | fi 50 | 51 | rm -rf autom4te*.cache 52 | 53 | autopoint --force || { 54 | echo "error: autopoint failed" 55 | exit 1 56 | } 57 | # autopoint is for libiconv discovery; we don't want the po directory 58 | rm -rf po 59 | $LIBTOOLIZE --force --copy || { 60 | echo "error: libtoolize failed" 61 | exit 1 62 | } 63 | aclocal $ACLOCAL_FLAGS || { 64 | echo "error: aclocal $ACLOCAL_FLAGS failed" 65 | exit 1 66 | } 67 | autoheader || { 68 | echo "error: autoheader failed" 69 | exit 1 70 | } 71 | automake -a -c --gnu --add-missing || { 72 | echo "warning: automake failed" 73 | } 74 | autoconf || { 75 | echo "error: autoconf failed" 76 | exit 1 77 | } 78 | -------------------------------------------------------------------------------- /drv/custom-media-lines: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Licensed under Apache License v2.0. See the file "LICENSE" for more 4 | # information. 5 | 6 | # This script generates the CustomMedia lines for the Generic IPP 7 | # Everywhere Printer PPD file in cupsfilters.drv based on the paper 8 | # size info in cups/pwg-media.c of the CUPS source code. 9 | 10 | # The script needs sed and bc 11 | 12 | while read line; do 13 | if printf "%s" "$line" | grep -q '^_PWG_MEDIA_'; then 14 | eval "$(printf "%s" "$line" | sed -nre 's/^_PWG_MEDIA_(\S+)\((\S+),\s*(\S+),\s*(\S+),\s*(\S+),\s*(\S+)\s*\)\s*,?\s*$/unit="\1"; pwgname="\2"; ippname="\3"; ppdname="\4"; width="\5"; height="\6"/p')" 15 | if [ "$unit" = "IN" ]; then 16 | widthpt="$(printf "scale=8; (%s)*72.0\n" "$width" | bc)" 17 | heightpt="$(printf "scale=8; (%s)*72.0\n" "$height" | bc)" 18 | fi 19 | if [ "$unit" = "MM" ]; then 20 | widthpt="$(printf "scale=8; (%s)*72.0/25.4\n" "$width" | bc)" 21 | heightpt="$(printf "scale=8; (%s)*72.0/25.4\n" "$height" | bc)" 22 | fi 23 | if [ "$ppdname" != "NULL" ]; then 24 | shortname="$ppdname" 25 | elif [ "$ippname" != "NULL" ]; then 26 | shortname="$ippname" 27 | elif [ "$pwgname" != "NULL" ]; then 28 | shortname="$pwgname" 29 | else 30 | continue 31 | fi 32 | if [ "$ppdname" != "NULL" ]; then 33 | longname="$ppdname" 34 | elif [ "$ippname" != "NULL" ]; then 35 | longname="$ippname" 36 | elif [ "$pwgname" != "NULL" ]; then 37 | longname="$pwgname" 38 | else 39 | continue 40 | fi 41 | #printf "%s %s %s %f %f %s %.0f %.0f PT %s/%s\n" $pwgname $ippname $ppdname $width $height $unit $widthpt $heightpt $shortname $longname 42 | printf " CustomMedia \"%s/%s\" %.2f %.2f 0 0 0 0 \"<>setpagedevice\"\n\t\"<>setpagedevice\"\n" $shortname $longname $widthpt $heightpt $widthpt $heightpt $widthpt $heightpt 43 | fi 44 | done 45 | -------------------------------------------------------------------------------- /filter/pdftopdf.c: -------------------------------------------------------------------------------- 1 | // 2 | // Legacy CUPS filter wrapper for ppdFilterPDFToPDF() for cups-filters. 3 | // 4 | // Copyright © 2020-2022 by OpenPrinting. 5 | // 6 | // Licensed under Apache License v2.0. See the file "LICENSE" for more 7 | // information. 8 | // 9 | 10 | // 11 | // Include necessary headers... 12 | // 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | 19 | // 20 | // Local globals... 21 | // 22 | 23 | static int JobCanceled = 0; // Set to 1 on SIGTERM 24 | 25 | 26 | // 27 | // Local functions... 28 | // 29 | 30 | static void cancel_job(int sig); 31 | 32 | 33 | // 34 | // 'main()' - Main entry. 35 | // 36 | 37 | int // O - Exit status 38 | main(int argc, // I - Number of command-line args 39 | char *argv[]) // I - Command-line arguments 40 | { 41 | int ret; 42 | #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) 43 | struct sigaction action; // Actions for POSIX signals 44 | #endif // HAVE_SIGACTION && !HAVE_SIGSET 45 | 46 | // 47 | // Register a signal handler to cleanly cancel a job. 48 | // 49 | 50 | #ifdef HAVE_SIGSET // Use System V signals over POSIX to avoid bugs 51 | sigset(SIGTERM, cancel_job); 52 | #elif defined(HAVE_SIGACTION) 53 | memset(&action, 0, sizeof(action)); 54 | 55 | sigemptyset(&action.sa_mask); 56 | action.sa_handler = cancel_job; 57 | sigaction(SIGTERM, &action, NULL); 58 | #else 59 | signal(SIGTERM, cancel_job); 60 | #endif // HAVE_SIGSET 61 | 62 | // 63 | // Fire up the ppdFilterPDFToPDF() filter function 64 | // 65 | 66 | ret = ppdFilterCUPSWrapper(argc, argv, ppdFilterPDFToPDF, NULL, &JobCanceled); 67 | 68 | if (ret) 69 | fprintf(stderr, "ERROR: pdftopdf filter function failed.\n"); 70 | 71 | return (ret); 72 | } 73 | 74 | 75 | // 76 | // 'cancel_job()' - Flag the job as canceled. 77 | // 78 | 79 | static void 80 | cancel_job(int sig) // I - Signal number (unused) 81 | { 82 | (void)sig; 83 | 84 | JobCanceled = 1; 85 | } 86 | -------------------------------------------------------------------------------- /filter/pcl-common.h: -------------------------------------------------------------------------------- 1 | // 2 | // Common HP-PCL definitions for cups-filters. 3 | // 4 | // Copyright 2007-2011 by Apple Inc. 5 | // Copyright 1993-2005 by Easy Software Products, All Rights Reserved. 6 | // 7 | // Licensed under Apache License v2.0. See the file "LICENSE" for more 8 | // information. 9 | // 10 | 11 | // 12 | // Include necessary headers... 13 | // 14 | 15 | #include 16 | #include 17 | #include 18 | #include "pcl.h" 19 | 20 | 21 | // 22 | // Functions/macros... 23 | // 24 | 25 | #define pcl_reset()\ 26 | printf("\033E") 27 | #define pcl_set_copies(copies)\ 28 | printf("\033&l%dX", (copies)) 29 | #define pcl_set_pcl_mode(m)\ 30 | printf("\033%%%dA", (m)) 31 | #define pcl_set_hpgl_mode(m)\ 32 | printf("\033%%%dB", (m)) 33 | #define pcl_set_negative_motion()\ 34 | printf("\033&a1N") 35 | #define pcl_set_media_source(source)\ 36 | printf("\033&l%dH", source) 37 | #define pcl_set_media_type(type)\ 38 | printf("\033&l%dM", type) 39 | #define pcl_set_duplex(duplex,landscape)\ 40 | if (duplex) printf("\033&l%dS", (duplex) + (landscape)) 41 | #define pcl_set_simple_black()\ 42 | printf("\033*r-1U") 43 | #define pcl_set_simple_color()\ 44 | printf("\033*r3U") 45 | #define pcl_set_simple_cmy()\ 46 | printf("\033*r-3U") 47 | #define pcl_set_simple_kcmy()\ 48 | printf("\033*r-4U") 49 | #define pcl_set_simple_resolution(r)\ 50 | printf("\033*t%dR", (r)) 51 | 52 | #define pjl_escape()\ 53 | printf("\033%%-12345X@PJL\r\n") 54 | #define pjl_set_job(job_id,user,title)\ 55 | printf("@PJL JOB NAME = \"%s\" DISPLAY = \"%d %s %s\"\r\n", \ 56 | (title), (job_id), (user), (title)) 57 | #define pjl_enter_language(lang)\ 58 | printf("@PJL ENTER LANGUAGE=%s\r\n", (lang)) 59 | 60 | extern void pcl_set_media_size(ppd_file_t *ppd, float width, float length); 61 | extern void pjl_write(const char *format, 62 | const char *value, int job_id, 63 | const char *user, const char *title, 64 | int num_options, cups_option_t *options); 65 | 66 | -------------------------------------------------------------------------------- /filter/rastertopwg.c: -------------------------------------------------------------------------------- 1 | // 2 | // Legacy CUPS filter wrapper for cfFilterRasterToPWG() for cups-filters. 3 | // 4 | // Copyright © 2020-2022 by OpenPrinting. 5 | // 6 | // Licensed under Apache License v2.0. See the file "LICENSE" for more 7 | // information. 8 | // 9 | 10 | // 11 | // Include necessary headers... 12 | // 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | 19 | // 20 | // Local globals... 21 | // 22 | 23 | static int JobCanceled = 0; // Set to 1 on SIGTERM 24 | 25 | 26 | // 27 | // Local functions... 28 | // 29 | 30 | static void cancel_job(int sig); 31 | 32 | 33 | // 34 | // 'main()' - Main entry and processing of driver. 35 | // 36 | 37 | int // O - Exit status 38 | main(int argc, // I - Number of command-line arguments 39 | char *argv[]) // I - Command-line arguments 40 | { 41 | int ret; 42 | #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) 43 | struct sigaction action; // Actions for POSIX signals 44 | #endif // HAVE_SIGACTION && !HAVE_SIGSET 45 | 46 | // 47 | // Register a signal handler to cleanly cancel a job. 48 | // 49 | 50 | #ifdef HAVE_SIGSET // Use System V signals over POSIX to avoid bugs 51 | sigset(SIGTERM, cancel_job); 52 | #elif defined(HAVE_SIGACTION) 53 | memset(&action, 0, sizeof(action)); 54 | 55 | sigemptyset(&action.sa_mask); 56 | action.sa_handler = cancel_job; 57 | sigaction(SIGTERM, &action, NULL); 58 | #else 59 | signal(SIGTERM, cancel_job); 60 | #endif // HAVE_SIGSET 61 | 62 | // 63 | // Fire up the cfFilterRasterToPWG() filter function 64 | // 65 | 66 | ret = ppdFilterCUPSWrapper(argc, argv, cfFilterRasterToPWG, NULL, &JobCanceled); 67 | 68 | if (ret) 69 | fprintf(stderr, "ERROR: rastertopwg filter function failed.\n"); 70 | 71 | return (ret); 72 | } 73 | 74 | 75 | // 76 | // 'cancel_job()' - Flag the job as canceled. 77 | // 78 | 79 | static void 80 | cancel_job(int sig) // I - Signal number (unused) 81 | { 82 | (void)sig; 83 | 84 | JobCanceled = 1; 85 | } 86 | -------------------------------------------------------------------------------- /filter/pdftoraster.c: -------------------------------------------------------------------------------- 1 | // 2 | // Legacy CUPS filter wrapper for cfFilterPDFToRaster() for cups-filters. 3 | // 4 | // Copyright © 2020-2022 by OpenPrinting. 5 | // 6 | // Licensed under Apache License v2.0. See the file "LICENSE" for more 7 | // information. 8 | // 9 | 10 | // 11 | // Include necessary headers... 12 | // 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | // 19 | // Local globals... 20 | // 21 | 22 | static int JobCanceled = 0; // Set to 1 on SIGTERM 23 | 24 | 25 | // 26 | // Local functions... 27 | // 28 | 29 | static void cancel_job(int sig); 30 | 31 | 32 | // 33 | // 'main()' - Main entry and processing of driver. 34 | // 35 | 36 | int // O - Exit status 37 | main(int argc, // I - Number of command-line arguments 38 | char *argv[]) // I - Command-line arguments 39 | { 40 | int ret; 41 | #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) 42 | struct sigaction action; // Actions for POSIX signals 43 | #endif // HAVE_SIGACTION && !HAVE_SIGSET 44 | 45 | // 46 | // Register a signal handler to cleanly cancel a job. 47 | // 48 | 49 | #ifdef HAVE_SIGSET // Use System V signals over POSIX to avoid bugs 50 | sigset(SIGTERM, cancel_job); 51 | #elif defined(HAVE_SIGACTION) 52 | memset(&action, 0, sizeof(action)); 53 | 54 | sigemptyset(&action.sa_mask); 55 | action.sa_handler = cancel_job; 56 | sigaction(SIGTERM, &action, NULL); 57 | #else 58 | signal(SIGTERM, cancel_job); 59 | #endif // HAVE_SIGSET 60 | 61 | // 62 | // Fire up the cfFilterPDFToRaster() filter function 63 | // 64 | 65 | ret = ppdFilterCUPSWrapper(argc, argv, cfFilterPDFToRaster, NULL, 66 | &JobCanceled); 67 | 68 | if (ret) 69 | fprintf(stderr, "ERROR: pdftoraster filter function failed.\n"); 70 | 71 | return (ret); 72 | } 73 | 74 | 75 | // 76 | // 'cancel_job()' - Flag the job as canceled. 77 | // 78 | 79 | static void 80 | cancel_job(int sig) // I - Signal number (unused) 81 | { 82 | (void)sig; 83 | 84 | JobCanceled = 1; 85 | } 86 | -------------------------------------------------------------------------------- /filter/rastertops.c: -------------------------------------------------------------------------------- 1 | // 2 | // Legacy CUPS filter wrapper for ppdFilterRasterToPS() for cups-filters. 3 | // 4 | // Copyright © 2020-2022 by OpenPrinting. 5 | // 6 | // Licensed under Apache License v2.0. See the file "LICENSE" for more 7 | // information. 8 | // 9 | 10 | // 11 | // Include necessary headers... 12 | // 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | 19 | // 20 | // Local globals... 21 | // 22 | 23 | static int JobCanceled = 0; // Set to 1 on SIGTERM 24 | 25 | 26 | // 27 | // Local functions... 28 | // 29 | 30 | static void cancel_job(int sig); 31 | 32 | 33 | // 34 | // 'main()' - Main entry and processing of driver. 35 | // 36 | 37 | int // O - Exit status 38 | main(int argc, // I - Number of command-line arguments 39 | char *argv[]) // I - Command-line arguments 40 | { 41 | int ret; 42 | #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) 43 | struct sigaction action; // Actions for POSIX signals 44 | #endif // HAVE_SIGACTION && !HAVE_SIGSET 45 | 46 | // 47 | // Register a signal handler to cleanly cancel a job. 48 | // 49 | 50 | #ifdef HAVE_SIGSET // Use System V signals over POSIX to avoid bugs 51 | sigset(SIGTERM, cancel_job); 52 | #elif defined(HAVE_SIGACTION) 53 | memset(&action, 0, sizeof(action)); 54 | 55 | sigemptyset(&action.sa_mask); 56 | action.sa_handler = cancel_job; 57 | sigaction(SIGTERM, &action, NULL); 58 | #else 59 | signal(SIGTERM, cancel_job); 60 | #endif // HAVE_SIGSET 61 | 62 | // 63 | // Fire up the ppdFilterRasterToPS() filter function 64 | // 65 | 66 | ret = ppdFilterCUPSWrapper(argc, argv, ppdFilterRasterToPS, NULL, 67 | &JobCanceled); 68 | 69 | if (ret) 70 | fprintf(stderr, "ERROR: rastertops filter function failed.\n"); 71 | 72 | return (ret); 73 | } 74 | 75 | 76 | // 77 | // 'cancel_job()' - Flag the job as canceled. 78 | // 79 | 80 | static void 81 | cancel_job(int sig) // I - Signal number (unused) 82 | { 83 | (void)sig; 84 | 85 | JobCanceled = 1; 86 | } 87 | -------------------------------------------------------------------------------- /filter/texttotext.c: -------------------------------------------------------------------------------- 1 | // 2 | // Legacy CUPS filter wrapper for cfFilterTextToText() for cups-filters. 3 | // 4 | // Copyright © 2020-2022 by OpenPrinting. 5 | // 6 | // Licensed under Apache License v2.0. See the file "LICENSE" for more 7 | // information. 8 | // 9 | 10 | // 11 | // Include necessary headers... 12 | // 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | 19 | // 20 | // Local globals... 21 | // 22 | 23 | static int JobCanceled = 0; // Set to 1 on SIGTERM 24 | 25 | 26 | // 27 | // Local functions... 28 | // 29 | 30 | static void cancel_job(int sig); 31 | 32 | 33 | // 34 | // 'main()' - Main entry and processing of driver. 35 | // 36 | 37 | int // O - Exit status 38 | main(int argc, // I - Number of command-line arguments 39 | char *argv[]) // I - Command-line arguments 40 | { 41 | int ret; 42 | #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) 43 | struct sigaction action; // Actions for POSIX signals 44 | #endif // HAVE_SIGACTION && !HAVE_SIGSET 45 | 46 | // 47 | // Register a signal handler to cleanly cancel a job. 48 | // 49 | 50 | #ifdef HAVE_SIGSET // Use System V signals over POSIX to avoid bugs 51 | sigset(SIGTERM, cancel_job); 52 | #elif defined(HAVE_SIGACTION) 53 | memset(&action, 0, sizeof(action)); 54 | 55 | sigemptyset(&action.sa_mask); 56 | action.sa_handler = cancel_job; 57 | sigaction(SIGTERM, &action, NULL); 58 | #else 59 | signal(SIGTERM, cancel_job); 60 | #endif // HAVE_SIGSET 61 | 62 | // 63 | // Fire up the cfFilterTextToText() filter function 64 | // 65 | 66 | ret = ppdFilterCUPSWrapper(argc, argv, cfFilterTextToText, NULL, 67 | &JobCanceled); 68 | 69 | if (ret) 70 | fprintf(stderr, "ERROR: texttotext filter function failed.\n"); 71 | 72 | return (ret); 73 | } 74 | 75 | 76 | // 77 | // 'cancel_job()' - Flag the job as canceled. 78 | // 79 | 80 | static void 81 | cancel_job(int sig) // I - Signal number (unused) 82 | { 83 | (void)sig; 84 | 85 | JobCanceled = 1; 86 | } 87 | -------------------------------------------------------------------------------- /filter/gstoraster.c: -------------------------------------------------------------------------------- 1 | // 2 | // Legacy CUPS filter wrapper for cfFilterGhostscript() for cups-filters. 3 | // 4 | // PostScript/PDF to Raster filter. 5 | // 6 | // Copyright © 2020-2022 by OpenPrinting. 7 | // 8 | // Licensed under Apache License v2.0. See the file "LICENSE" for more 9 | // information. 10 | // 11 | 12 | // 13 | // Include necessary headers... 14 | // 15 | 16 | #include 17 | #include 18 | #include 19 | 20 | 21 | // 22 | // Local globals... 23 | // 24 | 25 | static int JobCanceled = 0; // Set to 1 on SIGTERM 26 | 27 | 28 | // 29 | // Local functions... 30 | // 31 | 32 | static void cancel_job(int sig); 33 | 34 | 35 | // 36 | // 'main()' - Main entry. 37 | // 38 | 39 | int // O - Exit status 40 | main(int argc, // I - Number of command-line args 41 | char *argv[]) // I - Command-line arguments 42 | { 43 | int ret; 44 | #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) 45 | struct sigaction action; // Actions for POSIX signals 46 | #endif // HAVE_SIGACTION && !HAVE_SIGSET 47 | 48 | // 49 | // Register a signal handler to cleanly cancel a job. 50 | // 51 | 52 | #ifdef HAVE_SIGSET // Use System V signals over POSIX to avoid bugs 53 | sigset(SIGTERM, cancel_job); 54 | #elif defined(HAVE_SIGACTION) 55 | memset(&action, 0, sizeof(action)); 56 | 57 | sigemptyset(&action.sa_mask); 58 | action.sa_handler = cancel_job; 59 | sigaction(SIGTERM, &action, NULL); 60 | #else 61 | signal(SIGTERM, cancel_job); 62 | #endif // HAVE_SIGSET 63 | 64 | // 65 | // Fire up the cfFilterGhostscript() filter function. 66 | // 67 | 68 | ret = ppdFilterCUPSWrapper(argc, argv, cfFilterGhostscript, NULL, 69 | &JobCanceled); 70 | 71 | if (ret) 72 | fprintf(stderr, "ERROR: gstoraster filter failed.\n"); 73 | 74 | return (ret); 75 | } 76 | 77 | // 78 | // 'cancel_job()' - Flag the job as canceled. 79 | // 80 | 81 | static void 82 | cancel_job(int sig) // I - Signal number (unused) 83 | { 84 | (void)sig; 85 | 86 | JobCanceled = 1; 87 | } 88 | -------------------------------------------------------------------------------- /filter/pwgtoraster.c: -------------------------------------------------------------------------------- 1 | // 2 | // Legacy CUPS filter wrapper for cfFilterPWGToRaster() for cups-filters. 3 | // 4 | // Copyright © 2020-2022 by OpenPrinting. 5 | // 6 | // Licensed under Apache License v2.0. See the file "LICENSE" for more 7 | // information. 8 | // 9 | 10 | // 11 | // Include necessary headers... 12 | // 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | 19 | // 20 | // Local globals... 21 | // 22 | 23 | static int JobCanceled = 0; // Set to 1 on SIGTERM 24 | 25 | 26 | // 27 | // Local functions... 28 | // 29 | 30 | static void cancel_job(int sig); 31 | 32 | 33 | // 34 | // 'main()' - Main entry and processing of driver. 35 | // 36 | 37 | int // O - Exit status 38 | main(int argc, // I - Number of command-line arguments 39 | char *argv[]) // I - Command-line arguments 40 | { 41 | int ret; 42 | #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) 43 | struct sigaction action; // Actions for POSIX signals 44 | #endif // HAVE_SIGACTION && !HAVE_SIGSET 45 | 46 | // 47 | // Register a signal handler to cleanly cancel a job. 48 | // 49 | 50 | #ifdef HAVE_SIGSET // Use System V signals over POSIX to avoid bugs 51 | sigset(SIGTERM, cancel_job); 52 | #elif defined(HAVE_SIGACTION) 53 | memset(&action, 0, sizeof(action)); 54 | 55 | sigemptyset(&action.sa_mask); 56 | action.sa_handler = cancel_job; 57 | sigaction(SIGTERM, &action, NULL); 58 | #else 59 | signal(SIGTERM, cancel_job); 60 | #endif // HAVE_SIGSET 61 | 62 | // 63 | // Fire up the cfFilterPWGToRaster() filter function 64 | // 65 | 66 | ret = ppdFilterCUPSWrapper(argc, argv, cfFilterPWGToRaster, NULL, 67 | &JobCanceled); 68 | 69 | if (ret) 70 | fprintf(stderr, "ERROR: pwgtoraster filter function failed.\n"); 71 | 72 | return (ret); 73 | } 74 | 75 | 76 | // 77 | // 'cancel_job()' - Flag the job as canceled. 78 | // 79 | 80 | static void 81 | cancel_job(int sig) // I - Signal number (unused) 82 | { 83 | (void)sig; 84 | 85 | JobCanceled = 1; 86 | } 87 | -------------------------------------------------------------------------------- /filter/foomatic-rip/foomaticrip.h: -------------------------------------------------------------------------------- 1 | // 2 | // foomaticrip.h 3 | // 4 | // Copyright (C) 2008 Till Kamppeter 5 | // Copyright (C) 2008 Lars Karlitski (formerly Uebernickel) 6 | // 7 | // This file is part of foomatic-rip. 8 | // 9 | // Licensed under Apache License v2.0. See the file "LICENSE" for more 10 | // information. 11 | // 12 | 13 | #ifndef foomatic_h 14 | #define foomatic_h 15 | 16 | #ifndef _GNU_SOURCE 17 | #define _GNU_SOURCE 18 | #endif 19 | 20 | #include "config.h" 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | // This is the location of the debug logfile (and also the copy of the 28 | // processed PostScript data) in case you have enabled debugging above. 29 | // The logfile will get the extension ".log", the PostScript data ".ps". 30 | 31 | #ifndef LOG_FILE 32 | #define LOG_FILE "/tmp/foomatic-rip" 33 | #endif 34 | 35 | // Supported spoolers are currently: 36 | // 37 | // cups - CUPS - Common Unix Printing System 38 | // direct - Direct, spooler-less printing 39 | 40 | #define SPOOLER_CUPS 1 41 | #define SPOOLER_DIRECT 2 42 | 43 | // The spooler from which foomatic-rip was called. set in main() 44 | extern int spooler; 45 | 46 | typedef struct 47 | { 48 | char printer[256]; 49 | char id[128]; 50 | char user[128]; 51 | char host[128]; 52 | char title[2048]; 53 | char ppdfile[2048]; 54 | char copies[128]; 55 | int rbinumcopies; 56 | struct dstr *optstr; 57 | time_t time; 58 | } jobparams_t; 59 | 60 | 61 | jobparams_t *get_current_job(); 62 | 63 | FILE *open_postpipe(); 64 | 65 | extern struct dstr *currentcmd; 66 | extern struct dstr *jclappend; 67 | extern char **jclprepend; 68 | extern int jobhasjcl; 69 | extern char cupsfilterpath[PATH_MAX]; 70 | extern int debug; 71 | extern int do_docs; 72 | extern char printer_model[]; 73 | extern int dontparse; 74 | extern int pdfconvertedtops; 75 | extern char gspath[PATH_MAX]; 76 | extern char echopath[PATH_MAX]; 77 | 78 | #endif 79 | 80 | -------------------------------------------------------------------------------- /filter/mupdftopwg.c: -------------------------------------------------------------------------------- 1 | // 2 | // Legacy CUPS filter wrapper for cfFilterMuPDFToPWG() for cups-filters. 3 | // 4 | // Copyright © 2020-2022 by OpenPrinting. 5 | // 6 | // Licensed under Apache License v2.0. See the file "LICENSE" for more 7 | // information. 8 | // 9 | 10 | // 11 | // Include necessary headers... 12 | // 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | 19 | // 20 | // Local globals... 21 | // 22 | 23 | static int JobCanceled = 0;// Set to 1 on SIGTERM 24 | 25 | 26 | // 27 | // Local functions... 28 | // 29 | 30 | static void cancel_job(int sig); 31 | 32 | 33 | // 34 | // 'main()' - Main entry and processing of driver. 35 | // 36 | 37 | int // O - Exit status 38 | main(int argc, // I - Number of command-line arguments 39 | char *argv[], 40 | char *envp[]) // I - Command-line arguments 41 | { 42 | int ret; 43 | #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) 44 | struct sigaction action; // Actions for POSIX signals 45 | #endif // HAVE_SIGACTION && !HAVE_SIGSET 46 | 47 | // 48 | // Register a signal handler to cleanly cancel a job. 49 | // 50 | 51 | #ifdef HAVE_SIGSET // Use System V signals over POSIX to avoid bugs 52 | sigset(SIGTERM, cancel_job); 53 | #elif defined(HAVE_SIGACTION) 54 | memset(&action, 0, sizeof(action)); 55 | 56 | sigemptyset(&action.sa_mask); 57 | action.sa_handler = cancel_job; 58 | sigaction(SIGTERM, &action, NULL); 59 | #else 60 | signal(SIGTERM, cancel_job); 61 | #endif // HAVE_SIGSET 62 | 63 | // 64 | // Fire up the cfFilterMuPDFToPWG() filter function 65 | // 66 | 67 | ret = ppdFilterCUPSWrapper(argc, argv, cfFilterMuPDFToPWG, NULL, 68 | &JobCanceled); 69 | 70 | if (ret) 71 | fprintf(stderr, "ERROR: mupdftopwg filter function failed.\n"); 72 | 73 | return (ret); 74 | } 75 | 76 | 77 | // 78 | // 'cancel_job()' - Flag the job as canceled. 79 | // 80 | 81 | static void 82 | cancel_job(int sig) // I - Signal number (unused) 83 | { 84 | (void)sig; 85 | 86 | JobCanceled = 1; 87 | } 88 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.la 3 | *.lo 4 | *.so 5 | *.so.* 6 | #* 7 | .#* 8 | *~ 9 | *.pc 10 | *.tar.* 11 | core 12 | core.* 13 | aclocal.m4 14 | autom4te.cache 15 | build 16 | compile 17 | config.guess 18 | config.h 19 | config.h.in 20 | config.log 21 | config.sub 22 | config.status 23 | configure 24 | depcomp 25 | libtool 26 | ltmain.sh 27 | Makefile.in 28 | Makefile 29 | missing 30 | stamp-h1 31 | test-driver 32 | test 33 | .deps 34 | .libs 35 | tmp/ 36 | m4/libtool.m4 37 | m4/ltoptions.m4 38 | m4/ltsugar.m4 39 | m4/ltversion.m4 40 | m4/lt~obsolete.m4 41 | mime/cupsfilters.convs 42 | mime/cupsfilters-individual.convs 43 | utils/driverless-fax 44 | beh 45 | parallel 46 | serial 47 | bannertopdf 48 | commandtoescpx 49 | commandtopclx 50 | foomatic-rip 51 | !foomatic-rip/ 52 | gstopdf 53 | gstopxl 54 | gstoraster 55 | imagetopdf 56 | imagetops 57 | imagetoraster 58 | mupdftopwg 59 | pclmtoraster 60 | pdftoijs 61 | pdftoopvp 62 | pdftopdf 63 | pdftops 64 | pdftoraster 65 | pstops 66 | pwgtopclm 67 | pwgtopdf 68 | pwgtoraster 69 | rastertoescpx 70 | rastertopclx 71 | rastertops 72 | rastertopwg 73 | texttopdf 74 | texttotext 75 | universal 76 | driverless 77 | test-external 78 | .vscode/ 79 | 80 | #files generated by ./autogen.sh ./configure && make 81 | ABOUT-NLS 82 | config.rpath 83 | backend/.dirstamp 84 | filter/.dirstamp 85 | ppdfiles/.dirstamp 86 | utils/.dirstamp 87 | m4/codeset.m4 88 | m4/extern-inline.m4 89 | m4/fcntl-o.m4 90 | m4/gettext.m4 91 | m4/glibc2.m4 92 | m4/glibc21.m4 93 | m4/iconv.m4 94 | m4/intdiv0.m4 95 | m4/intl.m4 96 | m4/intldir.m4 97 | m4/intlmacosx.m4 98 | m4/intmax.m4 99 | m4/inttypes-pri.m4 100 | m4/inttypes_h.m4 101 | m4/lcmessage.m4 102 | m4/lib-ld.m4 103 | m4/lib-link.m4 104 | m4/lib-prefix.m4 105 | m4/lock.m4 106 | m4/longlong.m4 107 | m4/nls.m4 108 | m4/po.m4 109 | m4/printf-posix.m4 110 | m4/progtest.m4 111 | m4/size_max.m4 112 | m4/stdint_h.m4 113 | m4/threadlib.m4 114 | m4/uintmax_t.m4 115 | m4/visibility.m4 116 | m4/wchar_t.m4 117 | m4/wint_t.m4 118 | m4/xsize.m4 119 | -------------------------------------------------------------------------------- /filter/pdftops.c: -------------------------------------------------------------------------------- 1 | // 2 | // Legacy CUPS filter wrapper for ppdFilterPDFToPS() for cups-filters. 3 | // 4 | // Copyright © 2020 by Till Kamppeter 5 | // Copyright © 2007-2018 by Apple Inc. 6 | // Copyright © 1993-2007 by Easy Software Products. 7 | // 8 | // Licensed under Apache License v2.0. See the file "LICENSE" for more 9 | // information. 10 | // 11 | 12 | // 13 | // Include necessary headers... 14 | // 15 | 16 | #include 17 | #include 18 | #include 19 | 20 | 21 | // 22 | // Local globals... 23 | // 24 | 25 | static int JobCanceled = 0; // Set to 1 on SIGTERM 26 | 27 | 28 | // 29 | // Local functions... 30 | // 31 | 32 | static void cancel_job(int sig); 33 | 34 | 35 | // 36 | // 'main()' - Main entry. 37 | // 38 | 39 | int // O - Exit status 40 | main(int argc, // I - Number of command-line args 41 | char *argv[]) // I - Command-line arguments 42 | { 43 | int ret; 44 | #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) 45 | struct sigaction action; // Actions for POSIX signals 46 | #endif // HAVE_SIGACTION && !HAVE_SIGSET 47 | 48 | // 49 | // Register a signal handler to cleanly cancel a job. 50 | // 51 | 52 | #ifdef HAVE_SIGSET // Use System V signals over POSIX to avoid bugs 53 | sigset(SIGTERM, cancel_job); 54 | #elif defined(HAVE_SIGACTION) 55 | memset(&action, 0, sizeof(action)); 56 | 57 | sigemptyset(&action.sa_mask); 58 | action.sa_handler = cancel_job; 59 | sigaction(SIGTERM, &action, NULL); 60 | #else 61 | signal(SIGTERM, cancel_job); 62 | #endif // HAVE_SIGSET 63 | 64 | // 65 | // Fire up the ppdFilterPDFToPS() filter function 66 | // 67 | 68 | ret = ppdFilterCUPSWrapper(argc, argv, ppdFilterPDFToPS, NULL, &JobCanceled); 69 | 70 | if (ret) 71 | fprintf(stderr, "ERROR: pdftops filter function failed.\n"); 72 | 73 | return (ret); 74 | } 75 | 76 | 77 | // 78 | // 'cancel_job()' - Flag the job as canceled. 79 | // 80 | 81 | static void 82 | cancel_job(int sig) // I - Signal number (unused) 83 | { 84 | (void)sig; 85 | 86 | JobCanceled = 1; 87 | } 88 | -------------------------------------------------------------------------------- /filter/pstops.c: -------------------------------------------------------------------------------- 1 | // 2 | // Legacy CUPS filter wrapper for ppdFilterPSToPS() for cups-filters. 3 | // 4 | // Copyright © 2020 by Till Kamppeter 5 | // Copyright © 2007-2018 by Apple Inc. 6 | // Copyright © 1993-2007 by Easy Software Products. 7 | // 8 | // Licensed under Apache License v2.0. See the file "LICENSE" for more 9 | // information. 10 | // 11 | 12 | // 13 | // Include necessary headers... 14 | // 15 | 16 | #include 17 | #include 18 | #include 19 | 20 | 21 | // 22 | // Local globals... 23 | // 24 | 25 | static int JobCanceled = 0; // Set to 1 on SIGTERM 26 | 27 | 28 | // 29 | // Local functions... 30 | // 31 | 32 | static void cancel_job(int sig); 33 | 34 | 35 | // 36 | // 'main()' - Main entry. 37 | // 38 | 39 | int // O - Exit status 40 | main(int argc, // I - Number of command-line args 41 | char *argv[]) // I - Command-line arguments 42 | { 43 | int ret; 44 | #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) 45 | struct sigaction action; // Actions for POSIX signals 46 | #endif // HAVE_SIGACTION && !HAVE_SIGSET 47 | 48 | // 49 | // Register a signal handler to cleanly cancel a job. 50 | // 51 | 52 | #ifdef HAVE_SIGSET // Use System V signals over POSIX to avoid bugs 53 | sigset(SIGTERM, cancel_job); 54 | #elif defined(HAVE_SIGACTION) 55 | memset(&action, 0, sizeof(action)); 56 | 57 | sigemptyset(&action.sa_mask); 58 | action.sa_handler = cancel_job; 59 | sigaction(SIGTERM, &action, NULL); 60 | #else 61 | signal(SIGTERM, cancel_job); 62 | #endif // HAVE_SIGSET 63 | 64 | // 65 | // Fire up the ppdFilterPSToPS() filter function 66 | // 67 | 68 | ret = ppdFilterCUPSWrapper(argc, argv, ppdFilterPSToPS, NULL, &JobCanceled); 69 | 70 | if (ret) 71 | fprintf(stderr, "ERROR: pstops filter function failed.\n"); 72 | 73 | return (ret); 74 | } 75 | 76 | 77 | // 78 | // 'cancel_job()' - Flag the job as canceled. 79 | // 80 | 81 | static void 82 | cancel_job(int sig) // I - Signal number (unused) 83 | { 84 | (void)sig; 85 | 86 | JobCanceled = 1; 87 | } 88 | -------------------------------------------------------------------------------- /filter/pwgtopdf.c: -------------------------------------------------------------------------------- 1 | // 2 | // Legacy CUPS filter wrapper for cfFilterPWGToPDF() for cups-filters. 3 | // 4 | // PWG Raster to PDF filter. 5 | // 6 | // Copyright © 2020-2022 by OpenPrinting. 7 | // 8 | // Licensed under Apache License v2.0. See the file "LICENSE" for more 9 | // information. 10 | // 11 | 12 | // 13 | // Include necessary headers... 14 | // 15 | 16 | #include 17 | #include 18 | #include 19 | 20 | 21 | // 22 | // Local globals... 23 | // 24 | 25 | static int JobCanceled = 0; // Set to 1 on SIGTERM 26 | 27 | 28 | // 29 | // Local functions... 30 | // 31 | 32 | static void cancel_job(int sig); 33 | 34 | 35 | // 36 | // 'main()' - Main entry. 37 | // 38 | 39 | int // O - Exit status 40 | main(int argc, // I - Number of command-line args 41 | char *argv[]) // I - Command-line arguments 42 | { 43 | int ret; 44 | #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) 45 | struct sigaction action; // Actions for POSIX signals 46 | #endif // HAVE_SIGACTION && !HAVE_SIGSET 47 | 48 | // 49 | // Register a signal handler to cleanly cancel a job. 50 | // 51 | 52 | #ifdef HAVE_SIGSET // Use System V signals over POSIX to avoid bugs 53 | sigset(SIGTERM, cancel_job); 54 | #elif defined(HAVE_SIGACTION) 55 | memset(&action, 0, sizeof(action)); 56 | 57 | sigemptyset(&action.sa_mask); 58 | action.sa_handler = cancel_job; 59 | sigaction(SIGTERM, &action, NULL); 60 | #else 61 | signal(SIGTERM, cancel_job); 62 | #endif // HAVE_SIGSET 63 | 64 | // 65 | // Fire up the cfFilterPWGToPDF() filter function. 66 | // 67 | 68 | cf_filter_out_format_t outformat = CF_FILTER_OUT_FORMAT_PDF; 69 | ret = ppdFilterCUPSWrapper(argc, argv, cfFilterPWGToPDF, &outformat, 70 | &JobCanceled); 71 | 72 | if (ret) 73 | fprintf(stderr, "ERROR: pwgtopdf filter failed.\n"); 74 | 75 | return (ret); 76 | } 77 | 78 | // 79 | // 'cancel_job()' - Flag the job as canceled. 80 | // 81 | 82 | static void 83 | cancel_job(int sig) // I - Signal number (unused) 84 | { 85 | (void)sig; 86 | 87 | JobCanceled = 1; 88 | } 89 | -------------------------------------------------------------------------------- /filter/imagetops.c: -------------------------------------------------------------------------------- 1 | // 2 | // Legacy CUPS filter wrapper for ppdFilterImageToPS() for cups-filters. 3 | // 4 | // Copyright © 2020 by Till Kamppeter 5 | // Copyright © 2007-2018 by Apple Inc. 6 | // Copyright © 1993-2007 by Easy Software Products. 7 | // 8 | // Licensed under Apache License v2.0. See the file "LICENSE" for more 9 | // information. 10 | // 11 | 12 | // 13 | // Include necessary headers... 14 | // 15 | 16 | #include 17 | #include 18 | #include 19 | 20 | 21 | // 22 | // Local globals... 23 | // 24 | 25 | static int JobCanceled = 0; // Set to 1 on SIGTERM 26 | 27 | 28 | // 29 | // Local functions... 30 | // 31 | 32 | static void cancel_job(int sig); 33 | 34 | 35 | // 36 | // 'main()' - Main entry. 37 | // 38 | 39 | int // O - Exit status 40 | main(int argc, // I - Number of command-line args 41 | char *argv[]) // I - Command-line arguments 42 | { 43 | int ret; 44 | #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) 45 | struct sigaction action; // Actions for POSIX signals 46 | #endif // HAVE_SIGACTION && !HAVE_SIGSET 47 | 48 | // 49 | // Register a signal handler to cleanly cancel a job. 50 | // 51 | 52 | #ifdef HAVE_SIGSET // Use System V signals over POSIX to avoid bugs 53 | sigset(SIGTERM, cancel_job); 54 | #elif defined(HAVE_SIGACTION) 55 | memset(&action, 0, sizeof(action)); 56 | 57 | sigemptyset(&action.sa_mask); 58 | action.sa_handler = cancel_job; 59 | sigaction(SIGTERM, &action, NULL); 60 | #else 61 | signal(SIGTERM, cancel_job); 62 | #endif // HAVE_SIGSET 63 | 64 | // 65 | // Fire up the ppdFilterImageToPS() filter function 66 | // 67 | 68 | ret = ppdFilterCUPSWrapper(argc, argv, ppdFilterImageToPS, NULL, 69 | &JobCanceled); 70 | 71 | if (ret) 72 | fprintf(stderr, "ERROR: imagetops filter function failed.\n"); 73 | 74 | return (ret); 75 | } 76 | 77 | 78 | // 79 | // 'cancel_job()' - Flag the job as canceled. 80 | // 81 | 82 | static void 83 | cancel_job(int sig) // I - Signal number (unused) 84 | { 85 | (void)sig; 86 | 87 | JobCanceled = 1; 88 | } 89 | -------------------------------------------------------------------------------- /filter/pwgtopclm.c: -------------------------------------------------------------------------------- 1 | // 2 | // Legacy CUPS filter wrapper for cfFilterPWGToPDF() for cups-filters. 3 | // 4 | // PWG Raster to PCLm filter. 5 | // 6 | // Copyright © 2020-2022 by OpenPrinting. 7 | // 8 | // Licensed under Apache License v2.0. See the file "LICENSE" for more 9 | // information. 10 | // 11 | 12 | // 13 | // Include necessary headers... 14 | // 15 | 16 | #include 17 | #include 18 | #include 19 | 20 | 21 | // 22 | // Local globals... 23 | // 24 | 25 | static int JobCanceled = 0; // Set to 1 on SIGTERM 26 | 27 | 28 | // 29 | // Local functions... 30 | // 31 | 32 | static void cancel_job(int sig); 33 | 34 | 35 | // 36 | // 'main()' - Main entry. 37 | // 38 | 39 | int // O - Exit status 40 | main(int argc, // I - Number of command-line args 41 | char *argv[]) // I - Command-line arguments 42 | { 43 | int ret; 44 | #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) 45 | struct sigaction action; // Actions for POSIX signals 46 | #endif // HAVE_SIGACTION && !HAVE_SIGSET 47 | 48 | // 49 | // Register a signal handler to cleanly cancel a job. 50 | // 51 | 52 | #ifdef HAVE_SIGSET // Use System V signals over POSIX to avoid bugs 53 | sigset(SIGTERM, cancel_job); 54 | #elif defined(HAVE_SIGACTION) 55 | memset(&action, 0, sizeof(action)); 56 | 57 | sigemptyset(&action.sa_mask); 58 | action.sa_handler = cancel_job; 59 | sigaction(SIGTERM, &action, NULL); 60 | #else 61 | signal(SIGTERM, cancel_job); 62 | #endif // HAVE_SIGSET 63 | 64 | // 65 | // Fire up the cfFilterPWGToPDF() filter function. 66 | // 67 | 68 | cf_filter_out_format_t outformat = CF_FILTER_OUT_FORMAT_PCLM; 69 | ret = ppdFilterCUPSWrapper(argc, argv, cfFilterPWGToPDF, &outformat, 70 | &JobCanceled); 71 | 72 | if (ret) 73 | fprintf(stderr, "ERROR: pwgtopclm filter failed.\n"); 74 | 75 | return (ret); 76 | } 77 | 78 | // 79 | // 'cancel_job()' - Flag the job as canceled. 80 | // 81 | 82 | static void 83 | cancel_job(int sig) // I - Signal number (unused) 84 | { 85 | (void)sig; 86 | 87 | JobCanceled = 1; 88 | } 89 | -------------------------------------------------------------------------------- /filter/gstopdf.c: -------------------------------------------------------------------------------- 1 | // 2 | // Legacy CUPS filter wrapper for cfFilterGhostscript() for cups-filters. 3 | // 4 | // PostScript to PDF filter. 5 | // 6 | // Copyright © 2020-2022 by OpenPrinting. 7 | // 8 | // Licensed under Apache License v2.0. See the file "LICENSE" for more 9 | // information. 10 | // 11 | 12 | // 13 | // Include necessary headers... 14 | // 15 | 16 | #include 17 | #include 18 | #include 19 | 20 | 21 | // 22 | // Local globals... 23 | // 24 | 25 | static int JobCanceled = 0; // Set to 1 on SIGTERM 26 | 27 | // 28 | // Local functions... 29 | // 30 | 31 | static void cancel_job(int sig); 32 | 33 | 34 | // 35 | // 'main()' - Main entry. 36 | // 37 | 38 | int // O - Exit status 39 | main(int argc, // I - Number of command-line args 40 | char *argv[]) // I - Command-line arguments 41 | { 42 | int ret; 43 | #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) 44 | struct sigaction action; // Actions for POSIX signals 45 | #endif // HAVE_SIGACTION && !HAVE_SIGSET 46 | 47 | // 48 | // Register a signal handler to cleanly cancel a job. 49 | // 50 | 51 | #ifdef HAVE_SIGSET // Use System V signals over POSIX to avoid bugs 52 | sigset(SIGTERM, cancel_job); 53 | #elif defined(HAVE_SIGACTION) 54 | memset(&action, 0, sizeof(action)); 55 | 56 | sigemptyset(&action.sa_mask); 57 | action.sa_handler = cancel_job; 58 | sigaction(SIGTERM, &action, NULL); 59 | #else 60 | signal(SIGTERM, cancel_job); 61 | #endif // HAVE_SIGSET 62 | 63 | // 64 | // Fire up the cfFilterGhostscript() filter function. 65 | // 66 | 67 | cf_filter_out_format_t outformat = CF_FILTER_OUT_FORMAT_PDF; 68 | ret = ppdFilterCUPSWrapper(argc, argv, cfFilterGhostscript, &outformat, 69 | &JobCanceled); 70 | 71 | if (ret) 72 | fprintf(stderr, "ERROR: gstopdf filter failed.\n"); 73 | 74 | return (ret); 75 | } 76 | 77 | 78 | // 79 | // 'cancel_job()' - Flag the job as canceled. 80 | // 81 | 82 | static void 83 | cancel_job(int sig) // I - Signal number (unused) 84 | { 85 | (void)sig; 86 | 87 | JobCanceled = 1; 88 | } 89 | -------------------------------------------------------------------------------- /filter/imagetopdf.c: -------------------------------------------------------------------------------- 1 | // 2 | // Legacy CUPS filter wrapper for ppdFilterImageToPDF() for cups-filters. 3 | // 4 | // Copyright © 2020 by Till Kamppeter 5 | // Copyright © 2007-2018 by Apple Inc. 6 | // Copyright © 1993-2007 by Easy Software Products. 7 | // 8 | // Licensed under Apache License v2.0. See the file "LICENSE" for more 9 | // information. 10 | // 11 | 12 | // 13 | // Include necessary headers... 14 | // 15 | 16 | #include 17 | #include 18 | #include 19 | 20 | 21 | // 22 | // Local globals... 23 | // 24 | 25 | static int JobCanceled = 0;// Set to 1 on SIGTERM 26 | 27 | 28 | // 29 | // Local functions... 30 | // 31 | 32 | static void cancel_job(int sig); 33 | 34 | 35 | // 36 | // 'main()' - Main entry. 37 | // 38 | 39 | int // O - Exit status 40 | main(int argc, // I - Number of command-line args 41 | char *argv[]) // I - Command-line arguments 42 | { 43 | int ret; 44 | #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) 45 | struct sigaction action; // Actions for POSIX signals 46 | #endif // HAVE_SIGACTION && !HAVE_SIGSET 47 | 48 | // 49 | // Register a signal handler to cleanly cancel a job. 50 | // 51 | 52 | #ifdef HAVE_SIGSET // Use System V signals over POSIX to avoid bugs 53 | sigset(SIGTERM, cancel_job); 54 | #elif defined(HAVE_SIGACTION) 55 | memset(&action, 0, sizeof(action)); 56 | 57 | sigemptyset(&action.sa_mask); 58 | action.sa_handler = cancel_job; 59 | sigaction(SIGTERM, &action, NULL); 60 | #else 61 | signal(SIGTERM, cancel_job); 62 | #endif // HAVE_SIGSET 63 | 64 | // 65 | // Fire up the ppdFilterImageToPDF() filter function 66 | // 67 | 68 | ret = ppdFilterCUPSWrapper(argc, argv, ppdFilterImageToPDF, NULL, 69 | &JobCanceled); 70 | 71 | if (ret) 72 | fprintf(stderr, "ERROR: imagetopdf filter function failed.\n"); 73 | 74 | return (ret); 75 | } 76 | 77 | 78 | // 79 | // 'cancel_job()' - Flag the job as canceled. 80 | // 81 | 82 | static void 83 | cancel_job(int sig) // I - Signal number (unused) 84 | { 85 | (void)sig; 86 | 87 | JobCanceled = 1; 88 | } 89 | -------------------------------------------------------------------------------- /filter/gstopxl.c: -------------------------------------------------------------------------------- 1 | // 2 | // Legacy CUPS filter wrapper for cfFilterGhostscript() for cups-filters. 3 | // 4 | // PostScript/PDF to PCL-XL filter. 5 | // 6 | // Copyright © 2020-2022 by OpenPrinting. 7 | // 8 | // Licensed under Apache License v2.0. See the file "LICENSE" for more 9 | // information. 10 | // 11 | 12 | // 13 | // Include necessary headers... 14 | // 15 | 16 | #include 17 | #include 18 | #include 19 | 20 | 21 | // 22 | // Local globals... 23 | // 24 | 25 | static int JobCanceled = 0; // Set to 1 on SIGTERM 26 | 27 | 28 | // 29 | // Local functions... 30 | // 31 | 32 | static void cancel_job(int sig); 33 | 34 | 35 | // 36 | // 'main()' - Main entry. 37 | // 38 | 39 | int // O - Exit status 40 | main(int argc, // I - Number of command-line args 41 | char *argv[]) // I - Command-line arguments 42 | { 43 | int ret; 44 | #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) 45 | struct sigaction action; // Actions for POSIX signals 46 | #endif // HAVE_SIGACTION && !HAVE_SIGSET 47 | 48 | // 49 | // Register a signal handler to cleanly cancel a job. 50 | // 51 | 52 | #ifdef HAVE_SIGSET // Use System V signals over POSIX to avoid bugs 53 | sigset(SIGTERM, cancel_job); 54 | #elif defined(HAVE_SIGACTION) 55 | memset(&action, 0, sizeof(action)); 56 | 57 | sigemptyset(&action.sa_mask); 58 | action.sa_handler = cancel_job; 59 | sigaction(SIGTERM, &action, NULL); 60 | #else 61 | signal(SIGTERM, cancel_job); 62 | #endif // HAVE_SIGSET 63 | 64 | // 65 | // Fire up the cfFilterGhostscript() filter function. 66 | // 67 | 68 | cf_filter_out_format_t outformat = CF_FILTER_OUT_FORMAT_PXL; 69 | ret = ppdFilterCUPSWrapper(argc, argv, cfFilterGhostscript, &outformat, 70 | &JobCanceled); 71 | 72 | if (ret) 73 | fprintf(stderr, "ERROR: gstopxl filter failed.\n"); 74 | 75 | return (ret); 76 | } 77 | 78 | // 79 | // 'cancel_job()' - Flag the job as canceled. 80 | // 81 | 82 | static void 83 | cancel_job(int sig) // I - Signal number (unused) 84 | { 85 | (void)sig; 86 | 87 | JobCanceled = 1; 88 | } 89 | -------------------------------------------------------------------------------- /filter/imagetoraster.c: -------------------------------------------------------------------------------- 1 | // 2 | // Legacy CUPS filter wrapper for cfFilterImageToRaster() for cups-filters. 3 | // 4 | // Copyright © 2020 by Till Kamppeter 5 | // Copyright © 2007-2018 by Apple Inc. 6 | // Copyright © 1993-2007 by Easy Software Products. 7 | // 8 | // Licensed under Apache License v2.0. See the file "LICENSE" for more 9 | // information. 10 | // 11 | 12 | // 13 | // Include necessary headers... 14 | // 15 | 16 | #include 17 | #include 18 | #include 19 | 20 | 21 | // 22 | // Local globals... 23 | // 24 | 25 | static int JobCanceled = 0;// Set to 1 on SIGTERM 26 | 27 | 28 | // 29 | // Local functions... 30 | // 31 | 32 | static void cancel_job(int sig); 33 | 34 | 35 | // 36 | // 'main()' - Main entry. 37 | // 38 | 39 | int // O - Exit status 40 | main(int argc, // I - Number of command-line args 41 | char *argv[]) // I - Command-line arguments 42 | { 43 | int ret; 44 | #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) 45 | struct sigaction action; // Actions for POSIX signals 46 | #endif // HAVE_SIGACTION && !HAVE_SIGSET 47 | 48 | // 49 | // Register a signal handler to cleanly cancel a job. 50 | // 51 | 52 | #ifdef HAVE_SIGSET // Use System V signals over POSIX to avoid bugs 53 | sigset(SIGTERM, cancel_job); 54 | #elif defined(HAVE_SIGACTION) 55 | memset(&action, 0, sizeof(action)); 56 | 57 | sigemptyset(&action.sa_mask); 58 | action.sa_handler = cancel_job; 59 | sigaction(SIGTERM, &action, NULL); 60 | #else 61 | signal(SIGTERM, cancel_job); 62 | #endif // HAVE_SIGSET 63 | 64 | // 65 | // Fire up the cfFilterImageToRaster() filter function 66 | // 67 | 68 | ret = ppdFilterCUPSWrapper(argc, argv, cfFilterImageToRaster, NULL, 69 | &JobCanceled); 70 | 71 | if (ret) 72 | fprintf(stderr, "ERROR: imagetoraster filter function failed.\n"); 73 | 74 | return (ret); 75 | } 76 | 77 | 78 | // 79 | // 'cancel_job()' - Flag the job as canceled. 80 | // 81 | 82 | static void 83 | cancel_job(int sig) // I - Signal number (unused) 84 | { 85 | (void)sig; 86 | 87 | JobCanceled = 1; 88 | } 89 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | cups-filters 2 | 3 | Copyright © 2011-2022 OpenPrinting 4 | Copyright © 1993-2007 Easy Software Products 5 | Copyright © 1996-2023 Free Software Foundation, Inc. 6 | Copyright © 2003-2015 Tim Waugh 7 | Copyright © 2003-2006 Red Hat, Inc. 8 | Copyright © 2006-2012 BBR Inc. 9 | Copyright © 2007-2019 Apple Inc. 10 | Copyright © 2008-2022 Till Kamppeter 11 | Copyright © 2008-2012 Tobias Hoffmann 12 | Copyright © 2008 Lars Karlitski (formerly Übernickel) 13 | Copyright © 2010 Neil 'Superna' Armstrong 14 | Copyright © 2011-2013 Richard Hughes 15 | Copyright © 2012 Canonical Ltd. 16 | Copyright © 2012 Franz Pförtsch 17 | Copyright © 2012 Tomáš Chvátal 18 | Copyright © 2013 ALT Linux, Andrew V. Stepanov 19 | Copyright © 2014 Joseph Simon 20 | Copyright © 2015-2022 Samuel Thibault 21 | Copyright © 2016 Pranjal Bhor 22 | Copyright © 2017-2018 Sahil Arora 23 | Copyright © 2018-2019 Deepak Patankar 24 | Copyright © 2019 Tanmay Anand 25 | Copyright © 2020 Mohit Mohan 26 | Copyright © 2021 Suraj Kulriya 27 | Copyright © 2021 Pratyush Ranjan 28 | Copyright © 2021 Pranshu Kharkwal 29 | Copyright © 2022 Chandresh Soni 30 | Copyright © 2022 Sachin Thakan 31 | 32 | Licensed under Apache License v2.0 with CUPS Exceptions. See the file 33 | "LICENSE" for the Apache License v2.0. 34 | 35 | -- CUPS Exceptions to the Apache 2.0 License -- 36 | 37 | As an exception, if, as a result of your compiling your source code, portions 38 | of this Software are embedded into an Object form of such source code, you 39 | may redistribute such embedded portions in such Object form without complying 40 | with the conditions of Sections 4(a), 4(b) and 4(d) of the License. 41 | 42 | In addition, if you combine or link compiled forms of this Software with 43 | software that is licensed under the GPLv2 ("Combined Software") and if a 44 | court of competent jurisdiction determines that the patent provision (Section 45 | 3), the indemnity provision (Section 9) or other Section of the License 46 | conflicts with the conditions of the GPLv2, you may retroactively and 47 | prospectively choose to deem waived or otherwise exclude such Section(s) of 48 | the License, but only in their entirety and only with respect to the Combined 49 | Software. 50 | -------------------------------------------------------------------------------- /filter/bannertopdf.c: -------------------------------------------------------------------------------- 1 | // 2 | // Legacy CUPS filter wrapper for cfFilterBannerToPDF() for cups-filters. 3 | // 4 | // Copyright © 2020-2022 by OpenPrinting. 5 | // 6 | // Licensed under Apache License v2.0. See the file "LICENSE" for more 7 | // information. 8 | // 9 | 10 | // 11 | // Include necessary headers... 12 | // 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | // 20 | // Local globals... 21 | // 22 | 23 | static int JobCanceled = 0; // Set to 1 on SIGTERM 24 | 25 | 26 | // 27 | // Local functions... 28 | // 29 | 30 | static void cancel_job(int sig); 31 | 32 | 33 | // 34 | // 'main()' - Main entry and processing of driver. 35 | // 36 | 37 | int // O - Exit status 38 | main(int argc, // I - Number of command-line arguments 39 | char *argv[]) // I - Command-line arguments 40 | { 41 | int ret; 42 | #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) 43 | struct sigaction action; // Actions for POSIX signals 44 | #endif // HAVE_SIGACTION && !HAVE_SIGSET 45 | 46 | // 47 | // Register a signal handler to cleanly cancel a job. 48 | // 49 | 50 | #ifdef HAVE_SIGSET // Use System V signals over POSIX to avoid bugs 51 | sigset(SIGTERM, cancel_job); 52 | #elif defined(HAVE_SIGACTION) 53 | memset(&action, 0, sizeof(action)); 54 | 55 | sigemptyset(&action.sa_mask); 56 | action.sa_handler = cancel_job; 57 | sigaction(SIGTERM, &action, NULL); 58 | #else 59 | signal(SIGTERM, cancel_job); 60 | #endif // HAVE_SIGSET 61 | 62 | // 63 | // Fire up the cfFilterBannerToPDF() filter function 64 | // 65 | 66 | char buf[1024]; 67 | const char *datadir = getenv("CUPS_DATADIR"); 68 | if (!datadir) 69 | datadir = CUPS_DATADIR; 70 | snprintf(buf, sizeof(buf), "%s/data", datadir); 71 | 72 | ret = ppdFilterCUPSWrapper(argc, argv, cfFilterBannerToPDF, buf, 73 | &JobCanceled); 74 | 75 | if (ret) 76 | fprintf(stderr, "ERROR: bannertopdf filter function failed.\n"); 77 | 78 | return (ret); 79 | } 80 | 81 | 82 | // 83 | // 'cancel_job()' - Flag the job as canceled. 84 | // 85 | 86 | static void 87 | cancel_job(int sig) // I - Signal number (unused) 88 | { 89 | (void)sig; 90 | 91 | JobCanceled = 1; 92 | } 93 | -------------------------------------------------------------------------------- /filter/foomatic-rip/foomatic-hash.1: -------------------------------------------------------------------------------- 1 | .\" 2 | .\" foomatic-hash man page. 3 | .\" 4 | .\" Copyright @ 2025 by Zdenek Dohnal. 5 | .\" 6 | .\" Licensed under Apache License v2.0. See the file "LICENSE" for more 7 | .\" information. 8 | .\" 9 | 10 | 11 | .TH "foomatic-hash" "1" "2025-06-18" "User Commands" 12 | 13 | .SH "NAME" 14 | 15 | foomatic-hash - tool for scanning provided drivers for problematic PPD options and hash them using SHA-256 16 | 17 | .SH "SYNOPSIS" 18 | 19 | .BI \fBfoomatic-hash\fR\ \fB--ppd\fR\ \fI\fR\ \fI\fR\ \fI\fR 20 | 21 | .BI \fBfoomatic-hash\fR\ \fB--ppd-paths\fR\ \fI\fR\ \fI\fR\ \fI\fR 22 | 23 | 24 | .SH "DESCRIPTION" 25 | 26 | The tool scans the provided drivers for values of PPD keywords \fBFoomaticRIPCommandLine\fR, \fBFoomaticRIPCommandLinePDF\fR, and \fBFoomaticRIPOptionSetting\fR, puts the found values into a file for review, and prints out values hashes in hexadecimal format. The hashes are required for allowing the filter \fBfoomatic-rip\fR to process those values. 27 | 28 | 29 | .SH "OPTIONS" 30 | 31 | The tool \fBfoomatic-hash\fR supports two options: 32 | 33 | .TP 10 34 | .BI \fB--ppd\fR\ \fI\fR 35 | The tool scans the specific PPD file. 36 | 37 | .TP 10 38 | .BI \fB--ppd-paths\fR\ \fI\fR 39 | The tool scans directories \fIpath1\fR, \fIpath2\fR until \fIpathN\fR for values of desired PPD keyword. Paths are absolute, symlinks are ignored. Each path is divided by comma. LibPPD support is required for the functionality. 40 | 41 | .SH "EXAMPLES" 42 | Scans PPD file \fBtest.ppd\fR, prints found values into \fBfound_values\fR, hash them and save them into \fBhashed_values\fR. 43 | .nf 44 | 45 | foomatic-hash --ppd test.ppd found_values hashed_values 46 | 47 | .fi 48 | 49 | Scans path \fB/etc/cups/ppd\fR for drivers, finds values if any, puts them into \fBfound_values\fR, and hashes them into \fBhashed_values\fR. 50 | .nf 51 | 52 | sudo foomatic-hash --ppd-paths /etc/cups/ppd found_value hashed_values 53 | .fi 54 | 55 | .SH "EXIT STATUS" 56 | 57 | Returns zero if scan happens successfully, non-zero return value for any error during the process. 58 | 59 | 60 | .SH "SEE ALSO" 61 | 62 | .BR foomatic-rip (1) 63 | 64 | 65 | .BR 66 | .EL 67 | -------------------------------------------------------------------------------- /mime/cupsfilters-universal.convs: -------------------------------------------------------------------------------- 1 | # 2 | # MIME conversions file for OpenPrinting CUPS Filters. 3 | # 4 | # Copyright 2007-2011 by Apple Inc. 5 | # Copyright 1997-2007 by Easy Software Products. 6 | # Copyright 2012-2016 by Till Kamppeter. 7 | # Copyright 2017 by Sahil Arora. 8 | # 9 | # Licensed under Apache License v2.0. See the file "LICENSE" for more 10 | # information. 11 | # 12 | 13 | ######################################################################## 14 | # 15 | # Format of Lines: 16 | # 17 | # source/type destination/type cost filter 18 | # 19 | # General Notes: 20 | # 21 | # The "cost" field is used to find the least costly filters to run 22 | # when converting a job file to a printable format. 23 | # 24 | # All filters *must* accept the standard command-line arguments 25 | # (job-id, user, title, copies, options, [filename or stdin]) to 26 | # work with CUPS. 27 | # 28 | 29 | ######################################################################## 30 | # 31 | # Input formats 32 | # 33 | 34 | image/jpeg application/vnd.universal-input 0 - 35 | @HAVE_LIBJXL_TRUE@image/jxl application/vnd.universal-input 0 - 36 | image/png application/vnd.universal-input 0 - 37 | image/tiff application/vnd.universal-input 0 - 38 | image/pwg-raster application/vnd.universal-input 0 - 39 | application/vnd.cups-pdf application/vnd.universal-input 0 - 40 | image/urf application/vnd.universal-input 0 - 41 | application/pdf application/vnd.universal-input 0 - 42 | text/plain application/vnd.universal-input 0 - 43 | application/PCLm application/vnd.universal-input 0 - 44 | application/vnd.cups-pdf-banner application/vnd.universal-input 0 - 45 | 46 | ######################################################################## 47 | # 48 | # Output formats 49 | # 50 | 51 | application/vnd.universal-input application/pdf 0 universal 52 | application/vnd.universal-input application/vnd.cups-pdf 0 universal 53 | application/vnd.universal-input application/vnd.cups-postscript 0 universal 54 | application/vnd.universal-input application/postscript 0 universal 55 | application/vnd.universal-input application/vnd.cups-raster 0 universal 56 | application/vnd.universal-input image/pwg-raster 0 universal 57 | application/vnd.universal-input image/urf 0 universal 58 | application/vnd.universal-input application/PCLm 0 universal 59 | -------------------------------------------------------------------------------- /filter/texttopdf.c: -------------------------------------------------------------------------------- 1 | // 2 | // Legacy CUPS filter wrapper for cfFilterTextToPDF() for cups-filters. 3 | // 4 | // Copyright © 2020-2022 by OpenPrinting. 5 | // 6 | // Licensed under Apache License v2.0. See the file "LICENSE" for more 7 | // information. 8 | // 9 | 10 | // 11 | // Include necessary headers... 12 | // 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | 20 | // 21 | // Local globals... 22 | // 23 | 24 | static int JobCanceled = 0; // Set to 1 on SIGTERM 25 | 26 | 27 | // 28 | // Local functions... 29 | // 30 | 31 | static void cancel_job(int sig); 32 | 33 | 34 | // 35 | // 'main()' - Main entry and processing of driver. 36 | // 37 | 38 | int // O - Exit status 39 | main(int argc, // I - Number of command-line arguments 40 | char *argv[]) // I - Command-line arguments 41 | { 42 | int ret; 43 | #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) 44 | struct sigaction action; // Actions for POSIX signals 45 | #endif // HAVE_SIGACTION && !HAVE_SIGSET 46 | 47 | // 48 | // Register a signal handler to cleanly cancel a job. 49 | // 50 | 51 | #ifdef HAVE_SIGSET // Use System V signals over POSIX to avoid bugs 52 | sigset(SIGTERM, cancel_job); 53 | #elif defined(HAVE_SIGACTION) 54 | memset(&action, 0, sizeof(action)); 55 | 56 | sigemptyset(&action.sa_mask); 57 | action.sa_handler = cancel_job; 58 | sigaction(SIGTERM, &action, NULL); 59 | #else 60 | signal(SIGTERM, cancel_job); 61 | #endif // HAVE_SIGSET 62 | 63 | // 64 | // Fire up the cfFilterTextToPDF() filter function 65 | // 66 | 67 | cf_filter_texttopdf_parameter_t parameters; 68 | char *p; 69 | 70 | if ((p = getenv("CUPS_DATADIR")) != NULL) 71 | parameters.data_dir = p; 72 | else 73 | parameters.data_dir = CUPS_DATADIR; 74 | if ((p = getenv("CHARSET")) != NULL) 75 | parameters.char_set = p; 76 | else 77 | parameters.char_set = NULL; 78 | if ((p = getenv("CONTENT_TYPE")) != NULL) 79 | parameters.content_type = p; 80 | else 81 | parameters.content_type = NULL; 82 | if ((p = getenv("CLASSIFICATION")) != NULL) 83 | parameters.classification = p; 84 | else 85 | parameters.classification = NULL; 86 | 87 | ret = ppdFilterCUPSWrapper(argc, argv, cfFilterTextToPDF, ¶meters, 88 | &JobCanceled); 89 | 90 | if (ret) 91 | fprintf(stderr, "ERROR: texttopdf filter function failed.\n"); 92 | 93 | return (ret); 94 | } 95 | 96 | 97 | // 98 | // 'cancel_job()' - Flag the job as canceled. 99 | // 100 | 101 | static void 102 | cancel_job(int sig) // I - Signal number (unused) 103 | { 104 | (void)sig; 105 | 106 | JobCanceled = 1; 107 | } 108 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ 2 | Upstream-Name: cups-filters 3 | Upstream-Contact: OpenPrinting 4 | Source: http://www.openprinting.org/download/cups-filters/ 5 | 6 | Files: * 7 | Copyright: 2011-2022 OpenPrinting 8 | 1993-2007 Easy Software Products 9 | 1996-2023 Free Software Foundation, Inc. 10 | 2003-2015 Tim Waugh 11 | 2003-2006 Red Hat, Inc. 12 | 2006-2012 BBR Inc. 13 | 2007-2019 Apple Inc. 14 | 2008-2022 Till Kamppeter 15 | 2008-2012 Tobias Hoffmann 16 | 2008 Lars Karlitski (formerly Übernickel) 17 | 2010 Neil 'Superna' Armstrong 18 | 2011-2013 Richard Hughes 19 | 2012 Canonical Ltd. 20 | 2012 Franz Pförtsch 21 | 2012 Tomáš Chvátal 22 | 2013 ALT Linux, Andrew V. Stepanov 23 | 2014 Joseph Simon 24 | 2015-2022 Samuel Thibault 25 | 2016 Pranjal Bhor 26 | 2017-2018 Sahil Arora 27 | 2018-2019 Deepak Patankar 28 | 2019 Tanmay Anand 29 | 2020 Mohit Mohan 30 | 2021 Suraj Kulriya 31 | 2021 Pratyush Ranjan 32 | 2021 Pranshu Kharkwal 33 | 2022 Chandresh Soni 34 | 2022 Sachin Thakan 35 | License: Apache-2.0-with-GPL2-LGPL2-Exception 36 | 37 | License: Apache-2.0-with-GPL2-LGPL2-Exception 38 | Licensed under the Apache License, Version 2.0 (the "License"); 39 | you may not use this file except in compliance with the License. 40 | You may obtain a copy of the License at 41 | http://www.apache.org/licenses/LICENSE-2.0 42 | Unless required by applicable law or agreed to in writing, software 43 | distributed under the License is distributed on an "AS IS"BASIS, 44 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 45 | See the License for the specific language governing permissions and 46 | limitations under the License. 47 | . 48 | On Debian systems, the complete text of the Apache License, 49 | Version 2.0 can be found in '/usr/share/common-licenses/Apache-2.0'. 50 | . 51 | As an exception, if, as a result of your compiling your source code, portions 52 | of this Software are embedded into an Object form of such source code, you 53 | may redistribute such embedded portions in such Object form without complying 54 | with the conditions of Sections 4(a), 4(b) and 4(d) of the License. 55 | . 56 | In addition, if you combine or link compiled forms of this Software with 57 | software that is licensed under the GPLv2 ("Combined Software") and if a 58 | court of competent jurisdiction determines that the patent provision (Section 59 | 3), the indemnity provision (Section 9) or other Section of the License 60 | conflicts with the conditions of the GPLv2, you may retroactively and 61 | prospectively choose to deem waived or otherwise exclude such Section(s) of 62 | the License, but only in their entirety and only with respect to the Combined 63 | Software. 64 | -------------------------------------------------------------------------------- /m4/basic-directories.m4: -------------------------------------------------------------------------------- 1 | dnl 2 | dnl Fix basic directories (Taken from CUPS) 3 | dnl 4 | dnl Copyright 2007-2014 by Apple Inc. 5 | dnl Copyright 1997-2007 by Easy Software Products, all rights reserved. 6 | dnl 7 | dnl Licensed under Apache License v2.0. See the file "LICENSE" for more 8 | dnl information. 9 | dnl 10 | 11 | AC_PREFIX_DEFAULT(/) 12 | 13 | dnl Fix "prefix" variable if it hasn't been specified... 14 | if test "$prefix" = "NONE"; then 15 | prefix="/" 16 | fi 17 | 18 | dnl Fix "exec_prefix" variable if it hasn't been specified... 19 | if test "$exec_prefix" = "NONE"; then 20 | if test "$prefix" = "/"; then 21 | exec_prefix="/usr" 22 | else 23 | exec_prefix="$prefix" 24 | fi 25 | fi 26 | 27 | dnl Fix "bindir" variable... 28 | if test "$bindir" = "\${exec_prefix}/bin"; then 29 | bindir="$exec_prefix/bin" 30 | fi 31 | 32 | dnl Fix "sbindir" variable... 33 | if test "$sbindir" = "\${exec_prefix}/sbin"; then 34 | sbindir="$exec_prefix/sbin" 35 | fi 36 | 37 | dnl Fix "sharedstatedir" variable if it hasn't been specified... 38 | if test "$sharedstatedir" = "\${prefix}/com" -a "$prefix" = "/"; then 39 | sharedstatedir="/usr/com" 40 | fi 41 | 42 | dnl Fix "datarootdir" variable if it hasn't been specified... 43 | if test "$datarootdir" = "\${prefix}/share"; then 44 | if test "$prefix" = "/"; then 45 | datarootdir="/usr/share" 46 | else 47 | datarootdir="$prefix/share" 48 | fi 49 | fi 50 | 51 | dnl Fix "datadir" variable if it hasn't been specified... 52 | if test "$datadir" = "\${prefix}/share"; then 53 | if test "$prefix" = "/"; then 54 | datadir="/usr/share" 55 | else 56 | datadir="$prefix/share" 57 | fi 58 | elif test "$datadir" = "\${datarootdir}"; then 59 | datadir="$datarootdir" 60 | fi 61 | 62 | dnl Fix "includedir" variable if it hasn't been specified... 63 | if test "$includedir" = "\${prefix}/include" -a "$prefix" = "/"; then 64 | includedir="/usr/include" 65 | fi 66 | 67 | dnl Fix "localstatedir" variable if it hasn't been specified... 68 | if test "$localstatedir" = "\${prefix}/var"; then 69 | if test "$prefix" = "/"; then 70 | if test "$uname" = Darwin; then 71 | localstatedir="/private/var" 72 | else 73 | localstatedir="/var" 74 | fi 75 | else 76 | localstatedir="$prefix/var" 77 | fi 78 | fi 79 | 80 | dnl Fix "sysconfdir" variable if it hasn't been specified... 81 | if test "$sysconfdir" = "\${prefix}/etc"; then 82 | if test "$prefix" = "/"; then 83 | if test "$uname" = Darwin; then 84 | sysconfdir="/private/etc" 85 | else 86 | sysconfdir="/etc" 87 | fi 88 | else 89 | sysconfdir="$prefix/etc" 90 | fi 91 | fi 92 | 93 | dnl Fix "libdir" variable... 94 | if test "$libdir" = "\${exec_prefix}/lib"; then 95 | case "$uname" in 96 | Linux*) 97 | if test -d /usr/lib64 -a ! -d /usr/lib64/fakeroot; then 98 | libdir="$exec_prefix/lib64" 99 | fi 100 | ;; 101 | esac 102 | fi 103 | 104 | -------------------------------------------------------------------------------- /utils/driverless.1: -------------------------------------------------------------------------------- 1 | .TH driverless 1 "27 Dec 2016" "" "" 2 | .SH NAME 3 | \fBdriverless \fP- PPD generator utility for driverless printing 4 | \fB 5 | .SH SYNOPSIS 6 | .nf 7 | .fam C 8 | \fBdriverless\fP [\fB-h\fP | \fB--help\fP | \fB--version\fP] [\fB-d\fP | \fB-v\fP | \fB--debug\fP] [\fBlist\fP] [\fB_ipps._tcp\fP] [\fB_ipp._tcp\fP] [\fB--std-ipp-uris\fP] | [\fBcat\fP \fIdriver URI\fP] | [\fIIPP printer URI\fP] 9 | 10 | .fam T 11 | .fi 12 | .fam T 13 | .fi 14 | .SH DESCRIPTION 15 | \fBdriverless\fP generates PPD files for printers which are designed 16 | for driverless IPP printing (currently IPP Everywhere, AirPrint, 17 | Mopria, and Wi-Fi-Direct printers, network printers and also 18 | IPP-over-USB printers with the help of ippusbxd(8)) by polling 19 | capability information from the printers via IPP. it can be either 20 | called for listing suitable printers in the network and for actually 21 | generating the PPD. It can also be called by CUPS when CUPS is listing 22 | available PPDs/drivers or creating print queues, making the setup of 23 | driverless printers with printer setup tools transparently working. 24 | .P 25 | driverless is placed in /usr/lib/cups/driver/ for listing available 26 | driverless-capable printers and generating PPDs for them. It should 27 | also be put in /usr/lib/cups/backend/ (preferably by a symbolic link) 28 | to list IPP device URIs for suitable printers. Printer setup tools 29 | like system-config-printer, the CUPS web interface at 30 | http://localhost:631/, and CUPS' command line utilities can use 31 | driverless with CUPS to list available driverless-capable printers, 32 | determine their IPP device URIs and generate PPDs for them. The 33 | printers will be automatically and correctly set up for driverless 34 | printing. Note that driverless printing requires IPP communication 35 | with the printer. 36 | .P 37 | A second symbolic link to /usr/lib/cups/driver/driverless from 38 | /usr/bin/ allows driverless to be called directly by a user. 39 | .SH OPTIONS 40 | .TP 41 | .B 42 | \fB-h\fP, \fB--help\fP, \fB--version\fP 43 | Show help page, including version number. 44 | .TP 45 | .B 46 | \fB-v\fP, \fB-d\fP, \fB--debug\fP 47 | Debug mode, verbose logging to stderr. 48 | .TP 49 | .B 50 | \fBlist\fP 51 | List the driver URIs and metadata for all available IPP/IPPS printers suitable 52 | for driverless PPD file generation (to be used by CUPS). 53 | .TP 54 | .B 55 | \fB_ipps._tcp\fP 56 | Check for only IPPS printers supporting driverless printing . 57 | .TP 58 | .B 59 | \fB_ipp._tcp\fP 60 | Check for only IPP printers supporting driverless printing . 61 | .TP 62 | .B 63 | \fB--std-ipp-uris\fP 64 | Show URIS in standard form 65 | .TP 66 | .B 67 | \fBcat\fP \fIdriver URI\fP 68 | Generate the PPD file for the supplied \fIdriver URI\fP from the output of "list" 69 | (to be used by CUPS). 70 | .TP 71 | .B 72 | \fIIPP printer URI\fB 73 | Generate the PPD file for the supplied \fIIPP printer URI\fP (suitable URIs are listed when calling driverless without options). 74 | .P 75 | When called without options, the IPP printer URIs of all available 76 | driverless-capable IPP printers will be listed. 77 | .P 78 | .SH SEE ALSO 79 | 80 | \fBcups-browsed\fP(8), \fBippfind\fP(1), \fBippusbxd\fP(8) 81 | .PP 82 | .SH AUTHOR 83 | The authors of \fBdriverless\fP are listed in /usr/share/doc/\fBcups-filters\fP/AUTHORS. 84 | .PP 85 | -------------------------------------------------------------------------------- /filter/universal.c: -------------------------------------------------------------------------------- 1 | // 2 | // Legacy CUPS filter wrapper for cfFilterUniversal() for cups-filters. 3 | // 4 | // Copyright © 2020-2022 by OpenPrinting. 5 | // 6 | // Licensed under Apache License v2.0. See the file "LICENSE" for more 7 | // information. 8 | // 9 | 10 | // 11 | // Include necessary headers... 12 | // 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | 20 | // 21 | // Local globals... 22 | // 23 | 24 | static int JobCanceled = 0; // Set to 1 on SIGTERM 25 | 26 | 27 | // 28 | // Local functions... 29 | // 30 | 31 | static void cancel_job(int sig); 32 | 33 | 34 | // 35 | // 'main()' - Main entry. 36 | // 37 | 38 | int // O - Exit status 39 | main(int argc, // I - Number of command-line args 40 | char *argv[]) // I - Command-line arguments 41 | { 42 | int ret; 43 | char *p; 44 | cf_filter_universal_parameter_t universal_parameters; 45 | char buf[1024]; 46 | const char *datadir; 47 | #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) 48 | struct sigaction action; // Actions for POSIX signals 49 | #endif // HAVE_SIGACTION && !HAVE_SIGSET 50 | 51 | // 52 | // Register a signal handler to cleanly cancel a job. 53 | // 54 | 55 | #ifdef HAVE_SIGSET // Use System V signals over POSIX to avoid bugs 56 | sigset(SIGTERM, cancel_job); 57 | #elif defined(HAVE_SIGACTION) 58 | memset(&action, 0, sizeof(action)); 59 | 60 | sigemptyset(&action.sa_mask); 61 | action.sa_handler = cancel_job; 62 | sigaction(SIGTERM, &action, NULL); 63 | #else 64 | signal(SIGTERM, cancel_job); 65 | #endif // HAVE_SIGSET 66 | 67 | universal_parameters.actual_output_type = NULL; // Determined by PPD file 68 | 69 | if ((p = getenv("CUPS_DATADIR")) != NULL) 70 | universal_parameters.texttopdf_params.data_dir = strdup(p); 71 | else 72 | universal_parameters.texttopdf_params.data_dir = strdup(CUPS_DATADIR); 73 | 74 | if ((p = getenv("CHARSET")) != NULL) 75 | universal_parameters.texttopdf_params.char_set = strdup(p); 76 | else 77 | universal_parameters.texttopdf_params.char_set = NULL; 78 | 79 | if ((p = getenv("CONTENT_TYPE")) != NULL) 80 | universal_parameters.texttopdf_params.content_type = strdup(p); 81 | else 82 | universal_parameters.texttopdf_params.content_type = NULL; 83 | 84 | if ((p = getenv("CLASSIFICATION")) != NULL) 85 | universal_parameters.texttopdf_params.classification = strdup(p); 86 | else 87 | universal_parameters.texttopdf_params.classification = NULL; 88 | 89 | datadir = getenv("CUPS_DATADIR"); 90 | if (!datadir) 91 | datadir = CUPS_DATADIR; 92 | snprintf(buf, sizeof(buf), "%s/data", datadir); 93 | universal_parameters.bannertopdf_template_dir = buf; 94 | 95 | ret = ppdFilterCUPSWrapper(argc, argv, ppdFilterUniversal, 96 | &universal_parameters, &JobCanceled); 97 | 98 | if (ret) 99 | fprintf(stderr, "ERROR: universal filter failed.\n"); 100 | 101 | free(universal_parameters.texttopdf_params.data_dir); 102 | free(universal_parameters.texttopdf_params.char_set); 103 | free(universal_parameters.texttopdf_params.content_type); 104 | free(universal_parameters.texttopdf_params.classification); 105 | 106 | return (ret); 107 | } 108 | 109 | 110 | // 111 | // 'cancel_job()' - Flag the job as canceled. 112 | // 113 | 114 | static void 115 | cancel_job(int sig) // I - Signal number (unused) 116 | { 117 | (void)sig; 118 | 119 | JobCanceled = 1; 120 | } 121 | -------------------------------------------------------------------------------- /mime/cupsfilters-individual.convs.in: -------------------------------------------------------------------------------- 1 | # 2 | # MIME conversions file for OpenPrinting CUPS Filters. 3 | # 4 | # Copyright 2007-2011 by Apple Inc. 5 | # Copyright 1997-2007 by Easy Software Products. 6 | # Copyright 2012-2016 by Till Kamppeter. 7 | # Copyright 2017 by Sahil Arora. 8 | # 9 | # Licensed under Apache License v2.0. See the file "LICENSE" for more 10 | # information. 11 | # 12 | 13 | ######################################################################## 14 | # 15 | # Format of Lines: 16 | # 17 | # source/type destination/type cost filter 18 | # 19 | # General Notes: 20 | # 21 | # The "cost" field is used to find the least costly filters to run 22 | # when converting a job file to a printable format. 23 | # 24 | # All filters *must* accept the standard command-line arguments 25 | # (job-id, user, title, copies, options, [filename or stdin]) to 26 | # work with CUPS. 27 | # 28 | 29 | ######################################################################## 30 | # 31 | # Conversion rules to be used when the filter functions are used as 32 | # individual, classic CUPS filters. Filter chains are generated by 33 | # CUPS 34 | # 35 | 36 | ######################################################################## 37 | # 38 | # PDF filters 39 | # 40 | 41 | application/pdf application/vnd.cups-pdf 66 pdftopdf 42 | @ENABLE_TEXTTOPDF_TRUE@text/plain application/pdf 32 texttopdf 43 | image/pwg-raster application/pdf 32 pwgtopdf 44 | image/png application/vnd.cups-pdf 65 imagetopdf 45 | image/jpeg application/vnd.cups-pdf 65 imagetopdf 46 | @HAVE_LIBJXL_TRUE@image/jxl application/vnd.cups-pdf 65 imagetopdf 47 | image/tiff application/vnd.cups-pdf 65 imagetopdf 48 | application/vnd.cups-pdf-banner application/pdf 32 bannertopdf 49 | image/urf application/pdf 0 pwgtopdf 50 | 51 | ######################################################################## 52 | # 53 | # PostScript filters 54 | # 55 | 56 | #application/pdf application/vnd.cups-postscript 66 pdftops 57 | application/vnd.cups-pdf application/vnd.cups-postscript 100 pdftops 58 | #application/postscript application/vnd.cups-postscript 66 pstops 59 | 60 | # CUPS file conversion rules for PostScript input when we are working with 61 | # the PDF printing workflow: General PostScript input should be converted to 62 | # PDF (see cupsfilters-ghostscript.convs as this is done by Ghostscript), so 63 | # that pdftopdf is doing the page management on PDF data and the 64 | # renderer/driver part renders PDF. An exception is made for PostScript 65 | # coming from the Adobe Reader. As this PostScript cannot be converted to PDF 66 | # if it comes from an encrypted PDF file, we simply override pstopdf and the 67 | # PDF workflow. 68 | 69 | application/vnd.adobe-reader-postscript application/vnd.cups-postscript 66 pstops 70 | 71 | ######################################################################## 72 | # 73 | # Raster filters... 74 | # 75 | 76 | application/PCLm application/vnd.cups-raster 32 pclmtoraster 77 | image/png application/vnd.cups-raster 100 imagetoraster 78 | image/jpeg application/vnd.cups-raster 100 imagetoraster 79 | @HAVE_LIBJXL_TRUE@image/jxl application/vnd.cups-raster 100 imagetoraster 80 | image/tiff application/vnd.cups-raster 100 imagetoraster 81 | image/pwg-raster application/vnd.cups-raster 100 pwgtoraster 82 | image/urf application/vnd.cups-raster 100 pwgtoraster 83 | image/pwg-raster image/urf 100 pwgtoraster 84 | image/urf image/pwg-raster 100 pwgtoraster 85 | image/pwg-raster application/PCLm 100 pwgtopclm 86 | image/urf application/PCLm 100 pwgtopclm 87 | -------------------------------------------------------------------------------- /filter/test-external.c: -------------------------------------------------------------------------------- 1 | // 2 | // Legacy CUPS filter wrapper for cfFilterExternal() and 3 | // ppdFilterExternalCUPS() for cups-filters. 4 | // 5 | // Primarily for testing and debugging. CUPS filters which can be called 6 | // by these filter functions can also be called directly instead of this 7 | // wrapper. 8 | // 9 | // Copyright © 2020-2022 by OpenPrinting. 10 | // 11 | // Licensed under Apache License v2.0. See the file "LICENSE" for more 12 | // information. 13 | // 14 | 15 | // 16 | // Include necessary headers... 17 | // 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | 25 | // 26 | // Local globals... 27 | // 28 | 29 | static int JobCanceled = 0; // Set to 1 on SIGTERM 30 | 31 | 32 | // 33 | // Local functions... 34 | // 35 | 36 | static void cancel_job(int sig); 37 | 38 | 39 | // 40 | // 'main()' - Main entry. 41 | // 42 | 43 | int // O - Exit status 44 | main(int argc, // I - Number of command-line arguments 45 | char *argv[]) // I - Command-line arguments 46 | { 47 | int ret = 1; 48 | #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) 49 | struct sigaction action; // Actions for POSIX signals 50 | #endif // HAVE_SIGACTION && !HAVE_SIGSET 51 | 52 | // 53 | // Register a signal handler to cleanly cancel a job. 54 | // 55 | 56 | #ifdef HAVE_SIGSET // Use System V signals over POSIX to avoid bugs 57 | sigset(SIGTERM, cancel_job); 58 | #elif defined(HAVE_SIGACTION) 59 | memset(&action, 0, sizeof(action)); 60 | 61 | sigemptyset(&action.sa_mask); 62 | action.sa_handler = cancel_job; 63 | sigaction(SIGTERM, &action, NULL); 64 | #else 65 | signal(SIGTERM, cancel_job); 66 | #endif // HAVE_SIGSET 67 | 68 | // 69 | // Fire up the cfFilterExternal()/ppdFilterExternalCUPS() filter function 70 | // 71 | 72 | cf_filter_external_t parameters; 73 | char *val; 74 | 75 | parameters.num_options = 0; 76 | parameters.options = NULL; 77 | parameters.envp = NULL; 78 | if ((val = getenv("INTERFACE")) != NULL) 79 | { 80 | parameters.filter = val; 81 | parameters.exec_mode = -1; 82 | ret = ppdFilterCUPSWrapper(argc, argv, cfFilterExternal, ¶meters, 83 | &JobCanceled); 84 | } 85 | else if ((val = getenv("FILTER")) != NULL) 86 | { 87 | parameters.filter = val; 88 | parameters.exec_mode = 0; 89 | ret = ppdFilterCUPSWrapper(argc, argv, cfFilterExternal, ¶meters, 90 | &JobCanceled); 91 | } 92 | else if ((val = getenv("CUPSFILTER")) != NULL) 93 | { 94 | parameters.filter = val; 95 | parameters.exec_mode = 0; 96 | ret = ppdFilterCUPSWrapper(argc, argv, ppdFilterExternalCUPS, ¶meters, 97 | &JobCanceled); 98 | } 99 | else if ((val = getenv("CUPSBACKEND")) != NULL) 100 | { 101 | parameters.filter = val; 102 | if (argc < 6) 103 | parameters.exec_mode = 2; 104 | else 105 | parameters.exec_mode = 1; 106 | ret = ppdFilterCUPSWrapper(argc, argv, ppdFilterExternalCUPS, ¶meters, 107 | &JobCanceled); 108 | } 109 | else 110 | fprintf(stderr, "ERROR: No filter executable specified. Specify with one of INTERFACE, FILTER, CUPSFILTER, or CUPSBACKEND environment variables.\n"); 111 | 112 | if (ret) 113 | fprintf(stderr, "ERROR: cfFilterExternal()/ppdFilterExternalCUPS() filter function failed.\n"); 114 | 115 | return (ret); 116 | } 117 | 118 | 119 | // 120 | // 'cancel_job()' - Flag the job as canceled. 121 | // 122 | 123 | static void 124 | cancel_job(int sig) // I - Signal number (unused) 125 | { 126 | (void)sig; 127 | 128 | JobCanceled = 1; 129 | } 130 | -------------------------------------------------------------------------------- /filter/commandtopclx.c: -------------------------------------------------------------------------------- 1 | // 2 | // Advanced PCL command filter for cups-filters. 3 | // 4 | // Copyright 2007-2011 by Apple Inc. 5 | // Copyright 1993-2005 by Easy Software Products. 6 | // 7 | // Licensed under Apache License v2.0. See the file "LICENSE" for more 8 | // information. 9 | // 10 | // 11 | // Contents: 12 | // 13 | // main() - Main entry and command processing. 14 | // 15 | 16 | // 17 | // Include necessary headers... 18 | // 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include "pcl.h" 25 | #include 26 | #include 27 | 28 | 29 | // 30 | // 'main()' - Main entry and processing of driver. 31 | // 32 | 33 | int // O - Exit status 34 | main(int argc, // I - Number of command-line 35 | // arguments 36 | char *argv[]) // I - Command-line arguments 37 | { 38 | FILE *fp; // Command file 39 | char line[1024], // Line from file 40 | *lineptr; // Pointer into line 41 | int feedpage; // Feed the page 42 | ppd_file_t *ppd; // PPD file 43 | 44 | 45 | // 46 | // Check for valid arguments... 47 | // 48 | 49 | if (argc < 6 || argc > 7) 50 | { 51 | // 52 | // We don't have the correct number of arguments; write an error message 53 | // and return. 54 | // 55 | 56 | fprintf(stderr, "Usage: %s job-id user title copies options [file]\n", 57 | argv[0]); 58 | return (1); 59 | } 60 | 61 | // 62 | // Open the PPD file... 63 | // 64 | 65 | if ((ppd = ppdOpenFile(getenv("PPD"))) == NULL) 66 | { 67 | fputs("ERROR: Unable to open PPD file!\n", stderr); 68 | return (1); 69 | } 70 | 71 | // 72 | // Open the command file as needed... 73 | // 74 | 75 | if (argc == 7) 76 | { 77 | if ((fp = fopen(argv[6], "r")) == NULL) 78 | { 79 | perror("ERROR: Unable to open command file - "); 80 | return (1); 81 | } 82 | } 83 | else 84 | fp = stdin; 85 | 86 | // 87 | // Reset the printer... 88 | // 89 | 90 | cfWritePrintData("\033E", 2); 91 | 92 | // 93 | // Read the commands from the file and send the appropriate commands... 94 | // 95 | 96 | feedpage = 0; 97 | 98 | while (fgets(line, sizeof(line), fp) != NULL) 99 | { 100 | // 101 | // Drop trailing newline... 102 | // 103 | 104 | lineptr = line + strlen(line) - 1; 105 | if (*lineptr == '\n') 106 | *lineptr = '\0'; 107 | 108 | // 109 | // Skip leading whitespace... 110 | // 111 | 112 | for (lineptr = line; isspace(*lineptr); lineptr ++); 113 | 114 | // 115 | // Skip comments and blank lines... 116 | // 117 | 118 | if (*lineptr == '#' || !*lineptr) 119 | continue; 120 | 121 | // 122 | // Parse the command... 123 | // 124 | 125 | if (strncasecmp(lineptr, "Clean", 5) == 0 && 126 | (ppd->model_number & PCL_INKJET)) 127 | { 128 | // 129 | // Clean heads... 130 | // 131 | 132 | cfWritePrintData("\033&b16WPML \004\000\006\001\004\001\005\001" 133 | "\001\004\001\144", 22); 134 | } 135 | else 136 | fprintf(stderr, "ERROR: Invalid printer command \"%s\"!\n", lineptr); 137 | } 138 | 139 | // 140 | // Eject the page as needed... 141 | // 142 | 143 | if (feedpage) 144 | { 145 | fputs("PAGE: 1 1\n", stderr); 146 | 147 | putchar(12); 148 | } 149 | 150 | // 151 | // Reset the printer... 152 | // 153 | 154 | cfWritePrintData("\033E", 2); 155 | 156 | // 157 | // Close the command file and return... 158 | // 159 | 160 | ppdClose(ppd); 161 | 162 | if (fp != stdin) 163 | fclose(fp); 164 | 165 | return (0); 166 | } 167 | -------------------------------------------------------------------------------- /INSTALL: -------------------------------------------------------------------------------- 1 | INSTALL - OpenPrinting CUPS Filters v2.0.1 - 2024-08-15 2 | ------------------------------------------------------- 3 | 4 | This file describes how to compile and install OpenPrinting CUPS 5 | Filters from source code. For more information on OpenPrinting CUPS 6 | Filters see the file called "README.md". A complete change log can be 7 | found in "CHANGES.md". 8 | 9 | **** IF YOU HAVE A NON-POSTSCRIPT PRINTER AND ARE NOT **** 10 | **** RUNNING MAC OS X, YOU WILL ALSO NEED TO INSTALL **** 11 | **** GHOSTSCRIPT WITH AT LEAST THE "cups", "pwgraster", **** 12 | **** "appleraster", "urf", "pclm", "pclm8", "pdfwrite", **** 13 | **** "pdfimage24", "pdfimage32", "pdfimage8" DRIVERS AFTER **** 14 | **** YOU INSTALL CUPS AND BEFORE YOU INSTALL THIS PACKAGE. **** 15 | 16 | 17 | BEFORE YOU BEGIN 18 | 19 | You'll need ANSI-compliant C, plus a make program and POSIX-compliant shell 20 | (/bin/sh). The GNU compiler tools and Bash work well and we have tested 21 | the current CUPS code against several versions of GCC with excellent results. 22 | 23 | The Makefiles used by the project should work with most versions of make. 24 | We've tested them with GNU make as well as the make programs shipped by 25 | Compaq, HP, SGI, and Sun. BSD users should use GNU make (gmake) since BSD 26 | make does not support "include". 27 | 28 | libcups (of CUPS 2.2.2 or newer), libcupsfilters 2.x, and libppd 29 | must be installed to be able to compile this package. 30 | 31 | COMPILING THE GIT REPOSITORY CODE 32 | 33 | The CUPS Filters GIT repository doesn't hold a copy of the 34 | pre-built configure script. You'll need to run the GNU autoconf 35 | software (2.65 or higher) to create it: 36 | 37 | ./autogen.sh 38 | 39 | 40 | CONFIGURATION 41 | 42 | CUPS Filters uses GNU autoconf, so you should find the usual 43 | "configure" script in the main CUPS Filters source directory. To 44 | configure CUPS Filters for your system, type: 45 | 46 | ./configure 47 | 48 | The default installation will put the CUPS Filters software in the 49 | "/usr" directory on your system. 50 | 51 | Use the "--prefix" option to install the CUPS Filters software in 52 | another location: 53 | 54 | ./configure --prefix=/some/directory 55 | 56 | To see a complete list of configuration options, use the --help 57 | option: 58 | 59 | ./configure --help 60 | 61 | If any of the dependent libraries are not installed in a system 62 | default location (typically "/usr/include" and "/usr/lib") you'll 63 | need to set the CFLAGS, CPPFLAGS, CXXFLAGS, DSOFLAGS, and LDFLAGS 64 | environment variables prior to running configure: 65 | 66 | setenv CFLAGS "-I/some/directory" 67 | setenv CPPFLAGS "-I/some/directory" 68 | setenv CXXFLAGS "-I/some/directory" 69 | setenv DSOFLAGS "-L/some/directory" 70 | setenv LDFLAGS "-L/some/directory" 71 | ./configure ... 72 | 73 | or: 74 | 75 | CFLAGS="-I/some/directory" \ 76 | CPPFLAGS="-I/some/directory" \ 77 | CXXFLAGS="-I/some/directory" \ 78 | DSOFLAGS="-L/some/directory" \ 79 | LDFLAGS="-L/some/directory" \ 80 | ./configure ... 81 | 82 | Once you have configured things, just type: 83 | 84 | make ENTER 85 | 86 | or if you have FreeBSD, NetBSD, or OpenBSD type: 87 | 88 | gmake ENTER 89 | 90 | to build the software. 91 | 92 | 93 | INSTALLING THE SOFTWARE 94 | 95 | Once you have built the software you need to install it. The "install" 96 | target provides a quick way to install the software on your local system: 97 | 98 | make install ENTER 99 | 100 | or for FreeBSD, NetBSD, or OpenBSD: 101 | 102 | gmake install ENTER 103 | 104 | PACKAGING THE SOFTWARE FOR OPERATING SYSTEM DISTRIBUTIONS 105 | 106 | The use of this version of cups-filters is supported for CUPS 2.x 107 | from version 2.2.2 on. For earlier versions of CUPS please use 108 | cups-filters 1.x. For CUPS 3.x this package will not be needed any 109 | more. 110 | -------------------------------------------------------------------------------- /m4/ac_ln_srf.m4: -------------------------------------------------------------------------------- 1 | # Adapted from Autoconf Version 2.63 (GPLv2). 2 | # 3 | # Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 4 | # Free Software Foundation, Inc. 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2, or (at your option) 9 | # any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 19 | # 02110-1301, USA. 20 | # 21 | # As a special exception, the Free Software Foundation gives unlimited 22 | # permission to copy, distribute and modify the configure scripts that 23 | # are the output of Autoconf. You need not follow the terms of the GNU 24 | # General Public License when using or distributing such scripts, even 25 | # though portions of the text of Autoconf appear in them. The GNU 26 | # General Public License (GPL) does govern all other use of the material 27 | # that constitutes the Autoconf program. 28 | # 29 | # Certain portions of the Autoconf source text are designed to be copied 30 | # (in certain cases, depending on the input) into the output of 31 | # Autoconf. We call these the "data" portions. The rest of the Autoconf 32 | # source text consists of comments plus executable code that decides which 33 | # of the data portions to output in any given case. We call these 34 | # comments and executable code the "non-data" portions. Autoconf never 35 | # copies any of the non-data portions into its output. 36 | # 37 | # This special exception to the GPL applies to versions of Autoconf 38 | # released by the Free Software Foundation. When you make and 39 | # distribute a modified version of Autoconf, you may extend this special 40 | # exception to the GPL to apply to your modified version as well, *unless* 41 | # your modified version has the potential to copy into its output some 42 | # of the text that was the non-data portion of the version that you started 43 | # with. (In other words, unless your change moves or copies text from 44 | # the non-data portions to the data portions.) If your modification has 45 | # such potential, you must delete any notice of this special exception 46 | # to the GPL from your modified version. 47 | 48 | # AS_LN_SRF_PREPARE 49 | # ------------------------------------ 50 | m4_defun([AS_LN_SRF_PREPARE], 51 | [rm -f conf$$ conf$$.exe conf$$.file 52 | if test -d conf$$.dir; then 53 | rm -f conf$$.dir/conf$$.file 54 | else 55 | rm -f conf$$.dir 56 | mkdir conf$$.dir 2>/dev/null 57 | fi 58 | if (echo >conf$$.file) 2>/dev/null; then 59 | if ln -s -r conf$$.file conf$$ 2>/dev/null; then 60 | as_ln_srf='ln -s -r -f' 61 | elif ln -s conf$$.file conf$$ 2>/dev/null; then 62 | as_ln_srf='./ln-srf' 63 | # ... but there are two gotchas: 64 | # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. 65 | # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. 66 | # In both cases, we have to default to `cp -pRf'. 67 | ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || 68 | as_ln_srf='cp -pRf' 69 | elif ln conf$$.file conf$$ 2>/dev/null; then 70 | as_ln_srf=ln 71 | else 72 | as_ln_srf='cp -pRf' 73 | fi 74 | else 75 | as_ln_srf='cp -pRf' 76 | fi 77 | rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file 78 | rmdir conf$$.dir 2>/dev/null 79 | ])# AS_LN_SRF_PREPARE 80 | 81 | # AC_PROG_LN_SRF 82 | # -------------------------------- 83 | AC_DEFUN([AC_PROG_LN_SRF], 84 | [AC_MSG_CHECKING([whether ln -s -r -f works]) 85 | AC_SUBST([LN_SRF], [$as_ln_srf])dnl 86 | if test "$LN_SRF" = "ln -s -r -f"; then 87 | AC_MSG_RESULT([yes]) 88 | else 89 | AC_MSG_RESULT([no, using $LN_SRF]) 90 | fi 91 | ])# AC_PROG_LN_SRF 92 | -------------------------------------------------------------------------------- /mime/cupsfilters.types: -------------------------------------------------------------------------------- 1 | # 2 | # MIME types file for OpenPrinting CUPS Filters. 3 | # 4 | # DO NOT EDIT THIS FILE, AS IT IS OVERWRITTEN WHEN YOU INSTALL NEW 5 | # VERSIONS OF OPENPRINTING CUPS FILTERS. Instead, create a "local.types" 6 | # file that reflects your local configuration changes. 7 | # 8 | # Copyright 2007-2011 by Apple Inc. 9 | # Copyright 1997-2007 by Easy Software Products. 10 | # Copyright 2012-2016 by Till Kamppeter. 11 | # Copyright 2017 by Sahil Arora. 12 | # 13 | # Licensed under Apache License v2.0. See the file "LICENSE" for more 14 | # information. 15 | # 16 | 17 | ######################################################################## 18 | # 19 | # Format of Lines: 20 | # 21 | # super/type rules 22 | # 23 | # "rules" can be any combination of: 24 | # 25 | # ( expr ) Parenthesis for expression grouping 26 | # + Logical AND 27 | # , or whitespace Logical OR 28 | # ! Logical NOT 29 | # match("pattern") Pattern match on filename 30 | # extension Pattern match on "*.extension" 31 | # ascii(offset,length) True if bytes are valid printable ASCII 32 | # (CR, NL, TAB, BS, 32-126) 33 | # priority(number) Sets priority of type (0=lowest, 34 | # 100=default, 200=highest) 35 | # printable(offset,length) True if bytes are printable 8-bit chars 36 | # (CR, NL, TAB, BS, 32-126, 128-254) 37 | # string(offset,"string") True if bytes are identical to string 38 | # istring(offset,"string") True if bytes are identical to 39 | # case-insensitive string 40 | # char(offset,value) True if byte is identical 41 | # short(offset,value) True if 16-bit integer is identical 42 | # int(offset,value) True if 32-bit integer is identical 43 | # locale("string") True if current locale matches string 44 | # contains(offset,range,"string") True if the range contains the string 45 | # 46 | # General Notes: 47 | # 48 | # MIME type names are case-insensitive. Internally they are converted 49 | # to lowercase. Multiple occurrences of a type will cause the provided 50 | # rules to be appended to the existing definition. If two types use the same 51 | # rules to resolve a type and have the same priority, e.g. "doc" extension for 52 | # "text/bar" and "text/foo", the returned type will be the first type as 53 | # sorted in alphanumerically ascending order without regard to case. Thus, 54 | # the "text/bar" type will match the "doc" extension first unless the 55 | # "text/foo" type has specified a higher priority. 56 | # 57 | # The "printable" rule differs from the "ascii" rule in that it also 58 | # accepts 8-bit characters in the range 128-255. 59 | # 60 | # String constants must be surrounded by "" if they contain whitespace. 61 | # To insert binary data into a string, use the notation. 62 | # 63 | 64 | ######################################################################## 65 | # 66 | # Application-generated files... 67 | # 68 | 69 | # CUPS file detection rule for PostScript which is generated by the Adobe 70 | # Reader. We distinguish PostScript from the Adobe reader here so that we 71 | # can override pstopdf and the PDF workflow for these PostScript files as the 72 | # conversion of them to PDF does not work if the original PDF file was 73 | # encrypted. 74 | 75 | application/vnd.adobe-reader-postscript priority(150) contains(0,4096,"%%Creator: Adobe Acrobat") + \ 76 | (ai eps ps string(0,%!) string(0,<04>%!) \ 77 | contains(0,128,<1B>%-12345X) + \ 78 | (contains(0,4096,"LANGUAGE=POSTSCRIPT") \ 79 | contains(0,4096,"LANGUAGE = Postscript") \ 80 | contains(0,4096,"LANGUAGE = PostScript") \ 81 | contains(0,4096,"LANGUAGE = POSTSCRIPT") \ 82 | (contains(0,4096,<0a>%!) + \ 83 | !contains(0,4096,"ENTER LANGUAGE")))) 84 | 85 | ######################################################################## 86 | # 87 | # Image files... 88 | # 89 | 90 | image/x-xbitmap xbm string(0,"#define"); 91 | image/x-xpixmap xpm string(3,"XPM") 92 | image/x-xwindowdump xwd string(4,<00000007>) 93 | image/urf urf string(0,UNIRAST<00>) 94 | @HAVE_LIBJXL_TRUE@image/jxl jxl string(0,"<0000000C4A584C20>") string(0,"") 95 | 96 | ######################################################################## 97 | # 98 | # CUPS-specific types... 99 | # 100 | 101 | application/vnd.cups-pdf 102 | application/vnd.cups-pdf-banner string(0,'#PDF-BANNER') 103 | application/PCLm 104 | 105 | ######################################################################## 106 | # 107 | # Auxiliary input type for the universal CUPS filter... 108 | # 109 | 110 | application/vnd.universal-input 111 | -------------------------------------------------------------------------------- /filter/foomatic-rip/options.h: -------------------------------------------------------------------------------- 1 | // 2 | // options.h 3 | // 4 | // Copyright (C) 2008 Till Kamppeter 5 | // Copyright (C) 2008 Lars Karlitski (formerly Uebernickel) 6 | // 7 | // This file is part of foomatic-rip. 8 | // 9 | // Licensed under Apache License v2.0. See the file "LICENSE" for more 10 | // information. 11 | // 12 | 13 | #ifndef options_h 14 | #define options_h 15 | 16 | 17 | #include 18 | #include 19 | #include "util.h" 20 | 21 | // Option types 22 | #define TYPE_NONE 0 23 | #define TYPE_ENUM 1 24 | #define TYPE_PICKMANY 2 25 | #define TYPE_BOOL 3 26 | #define TYPE_INT 4 27 | #define TYPE_FLOAT 5 28 | #define TYPE_STRING 6 29 | #define TYPE_PASSWORD 7 30 | #define TYPE_CURVE 8 31 | #define TYPE_INVCURVE 9 32 | #define TYPE_PASSCODE 10 33 | #define TYPE_POINTS 11 34 | 35 | // Sections 36 | #define SECTION_ANYSETUP 1 37 | #define SECTION_PAGESETUP 2 38 | #define SECTION_PROLOG 3 39 | #define SECTION_DOCUMENTSETUP 4 40 | #define SECTION_JCLSETUP 5 41 | 42 | 43 | 44 | typedef struct choice_s 45 | { 46 | char value [128]; 47 | char text [128]; 48 | char command[65536]; 49 | struct choice_s *next; 50 | } choice_t; 51 | 52 | // Custom option parameter 53 | typedef struct param_s 54 | { 55 | char name [128]; 56 | char text [128]; // formerly comment, changed to 'text' to 57 | // be consistent with cups 58 | int order; 59 | 60 | int type; 61 | char min[20], max[20]; // contents depend on 'type' 62 | 63 | regex_t *allowedchars; 64 | regex_t *allowedregexp; 65 | 66 | struct param_s *next; 67 | } param_t; 68 | 69 | // Option 70 | typedef struct option_s 71 | { 72 | char name [128]; 73 | char text [128]; 74 | char varname [128]; // clean version of 'name' (no spaces etc.) 75 | int type; 76 | int style; 77 | char spot; 78 | double order; 79 | int section; 80 | 81 | int notfirst; // TODO remove 82 | 83 | choice_t *choicelist; 84 | 85 | // Foomatic PPD extensions 86 | char *proto; // *FoomaticRIPOptionPrototype: if this is set 87 | // it will be used with only the first option 88 | // in paramlist (there should be only one) 89 | param_t *foomatic_param; 90 | 91 | // CUPS custom options 92 | char *custom_command; // *CustomFoo 93 | param_t *paramlist; // for custom values, sorted by stack order 94 | size_t param_count; 95 | 96 | struct value_s *valuelist; 97 | 98 | struct option_s *next; 99 | struct option_s *next_by_order; 100 | } option_t; 101 | 102 | // A value for an option 103 | typedef struct value_s 104 | { 105 | int optionset; 106 | char *value; 107 | option_t *fromoption; // This is set when this value is set by a composite 108 | struct value_s *next; 109 | } value_t; 110 | 111 | 112 | extern option_t *optionlist; 113 | extern option_t *optionlist_sorted_by_order; 114 | 115 | extern char jclbegin[256]; 116 | extern char jcltointerpreter[256]; 117 | extern char jclend[256]; 118 | extern char jclprefix[256]; 119 | 120 | extern char cmd[4096]; 121 | extern char cmd_pdf[4096]; 122 | 123 | 124 | int option_is_composite(option_t *opt); 125 | int option_is_ps_command(option_t *opt); 126 | int option_is_jcl_arg(option_t *opt); 127 | int option_is_commandline_arg(option_t *opt); 128 | 129 | 130 | int option_get_section(option_t *opt); // TODO deprecated 131 | 132 | // handles ANYSETUP (for (PAGE|DOCUMENT)SETUP) 133 | int option_is_in_section(option_t *opt, int section); 134 | 135 | void options_init(); 136 | void options_free(); 137 | 138 | size_t option_count(); 139 | option_t *find_option(const char *name); 140 | 141 | void read_ppd_file(const char *filename); 142 | 143 | int ppd_supports_pdf(); 144 | 145 | 146 | int option_set_value(option_t *opt, int optset, const char *value); 147 | const char * option_get_value(option_t *opt, int optset); 148 | 149 | // section == -1 for all sections 150 | int option_get_command(dstr_t *cmd, option_t *opt, int optset, int section); 151 | 152 | int option_accepts_value(option_t *opt, const char *value); 153 | int option_has_choice(option_t *opt, const char *choice); 154 | int option_is_custom_value(option_t *opt, const char *value); 155 | 156 | 157 | const char * optionset_name(int idx); 158 | int optionset(const char * name); 159 | 160 | void optionset_copy_values(int src_optset, int dest_optset); 161 | int optionset_equal(int optset1, int optset2, int exceptPS); 162 | void optionset_delete_values(int optionset); 163 | 164 | void append_prolog_section(dstr_t *str, int optset, int comments); 165 | void append_setup_section(dstr_t *str, int optset, int comments); 166 | void append_page_setup_section(dstr_t *str, int optset, int comments); 167 | int build_commandline(int optset, dstr_t *cmdline, int pdfcmdline); 168 | 169 | void set_options_for_page(int optset, int page); 170 | char *get_icc_profile_for_qualifier(const char **qualifier); 171 | const char **get_ppd_qualifier(void); 172 | 173 | #endif // !options_h 174 | -------------------------------------------------------------------------------- /filter/commandtoescpx.c: -------------------------------------------------------------------------------- 1 | // 2 | // Advanced EPSON ESC/P command filter for cups-filters. 3 | // 4 | // Copyright 2007-2011 by Apple Inc. 5 | // Copyright 1993-2005 by Easy Software Products. 6 | // 7 | // Licensed under Apache License v2.0. See the file "LICENSE" for more 8 | // information. 9 | // 10 | // 11 | // Contents: 12 | // 13 | // main() - Main entry and command processing. 14 | // 15 | 16 | // 17 | // Include necessary headers... 18 | // 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include "escp.h" 25 | #include 26 | #include 27 | 28 | 29 | // 30 | // 'main()' - Main entry and processing of driver. 31 | // 32 | 33 | int // O - Exit status 34 | main(int argc, // I - Number of command-line arguments 35 | char *argv[]) // I - Command-line arguments 36 | { 37 | FILE *fp; // Command file 38 | char line[1024], // Line from file 39 | *lineptr; // Pointer into line 40 | int feedpage; // Feed the page 41 | ppd_file_t *ppd; // PPD file 42 | 43 | 44 | // 45 | // Check for valid arguments... 46 | // 47 | 48 | if (argc < 6 || argc > 7) 49 | { 50 | // 51 | // We don't have the correct number of arguments; write an error message 52 | // and return. 53 | // 54 | 55 | fprintf(stderr, "Usage: %s job-id user title copies options [file]\n", 56 | argv[0]); 57 | return (1); 58 | } 59 | 60 | // 61 | // Open the PPD file... 62 | // 63 | 64 | if ((ppd = ppdOpenFile(getenv("PPD"))) == NULL) 65 | { 66 | fputs("ERROR: Unable to open PPD file!\n", stderr); 67 | return (1); 68 | } 69 | 70 | // 71 | // Open the command file as needed... 72 | // 73 | 74 | if (argc == 7) 75 | { 76 | if ((fp = fopen(argv[6], "r")) == NULL) 77 | { 78 | perror("ERROR: Unable to open command file - "); 79 | return (1); 80 | } 81 | } 82 | else 83 | fp = stdin; 84 | 85 | // 86 | // Some EPSON printers need an additional command issued at the 87 | // beginning of each job to exit from USB "packet" mode... 88 | // 89 | 90 | if (ppd->model_number & ESCP_USB) 91 | cfWritePrintData("\000\000\000\033\001@EJL 1284.4\n@EJL \n\033@", 29); 92 | 93 | // 94 | // Reset the printer... 95 | // 96 | 97 | cfWritePrintData("\033@", 2); 98 | 99 | // 100 | // Enter remote mode... 101 | // 102 | 103 | cfWritePrintData("\033(R\010\000\000REMOTE1", 13); 104 | feedpage = 0; 105 | 106 | // 107 | // Read the commands from the file and send the appropriate commands... 108 | // 109 | 110 | while (fgets(line, sizeof(line), fp) != NULL) 111 | { 112 | // 113 | // Drop trailing newline... 114 | // 115 | 116 | lineptr = line + strlen(line) - 1; 117 | if (*lineptr == '\n') 118 | *lineptr = '\0'; 119 | 120 | // 121 | // Skip leading whitespace... 122 | // 123 | 124 | for (lineptr = line; isspace(*lineptr); lineptr ++); 125 | 126 | // 127 | // Skip comments and blank lines... 128 | // 129 | 130 | if (*lineptr == '#' || !*lineptr) 131 | continue; 132 | 133 | // 134 | // Parse the command... 135 | // 136 | 137 | if (strncasecmp(lineptr, "Clean", 5) == 0) 138 | { 139 | // 140 | // Clean heads... 141 | // 142 | 143 | cfWritePrintData("CH\002\000\000\000", 6); 144 | } 145 | else if (strncasecmp(lineptr, "PrintAlignmentPage", 18) == 0) 146 | { 147 | // 148 | // Print alignment page... 149 | // 150 | 151 | int phase; 152 | 153 | phase = atoi(lineptr + 18); 154 | 155 | cfWritePrintData("DT\003\000\000", 5); 156 | putchar(phase & 255); 157 | putchar(phase >> 8); 158 | feedpage = 1; 159 | } 160 | else if (strncasecmp(lineptr, "PrintSelfTestPage", 17) == 0) 161 | { 162 | // 163 | // Print version info and nozzle check... 164 | // 165 | 166 | cfWritePrintData("VI\002\000\000\000", 6); 167 | cfWritePrintData("NC\002\000\000\000", 6); 168 | feedpage = 1; 169 | } 170 | else if (strncasecmp(lineptr, "ReportLevels", 12) == 0) 171 | { 172 | // 173 | // Report ink levels... 174 | // 175 | 176 | cfWritePrintData("IQ\001\000\001", 5); 177 | } 178 | else if (strncasecmp(lineptr, "SetAlignment", 12) == 0) 179 | { 180 | // 181 | // Set head alignment... 182 | // 183 | 184 | int phase, x; 185 | 186 | if (sscanf(lineptr + 12, "%d%d", &phase, &x) != 2) 187 | { 188 | fprintf(stderr, "ERROR: Invalid printer command \"%s\"!\n", lineptr); 189 | continue; 190 | } 191 | 192 | cfWritePrintData("DA\004\000", 4); 193 | putchar(0); 194 | putchar(phase); 195 | putchar(0); 196 | putchar(x); 197 | cfWritePrintData("SV\000\000", 4); 198 | } 199 | else 200 | fprintf(stderr, "ERROR: Invalid printer command \"%s\"!\n", lineptr); 201 | } 202 | 203 | // 204 | // Exit remote mode... 205 | // 206 | 207 | cfWritePrintData("\033\000\000\000", 4); 208 | 209 | // 210 | // Eject the page as needed... 211 | // 212 | 213 | if (feedpage) 214 | { 215 | fputs("PAGE: 1 1\n", stderr); 216 | 217 | putchar(13); 218 | putchar(10); 219 | putchar(12); 220 | } 221 | 222 | // 223 | // Reset the printer... 224 | // 225 | 226 | cfWritePrintData("\033@", 2); 227 | 228 | // 229 | // Close the command file and return... 230 | // 231 | 232 | ppdClose(ppd); 233 | 234 | if (fp != stdin) 235 | fclose(fp); 236 | 237 | return (0); 238 | } 239 | -------------------------------------------------------------------------------- /install-sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Install a program, script, or datafile. 4 | # 5 | # Copyright 2008-2009 by Apple Inc. 6 | # 7 | # This script is not compatible with BSD (or any other) install program, as it 8 | # allows owner and group changes to fail with a warning and makes sure that the 9 | # destination directory permissions are as specified - BSD install and the 10 | # original X11 install script did not change permissions of existing 11 | # directories. It also does not support the transform options since CUPS does 12 | # not use them... 13 | # 14 | # Original script from X11R5 (mit/util/scripts/install.sh) 15 | # Copyright 1991 by the Massachusetts Institute of Technology 16 | # 17 | # Permission to use, copy, modify, distribute, and sell this software and its 18 | # documentation for any purpose is hereby granted without fee, provided that 19 | # the above copyright notice appear in all copies and that both that 20 | # copyright notice and this permission notice appear in supporting 21 | # documentation, and that the name of M.I.T. not be used in advertising or 22 | # publicity pertaining to distribution of the software without specific, 23 | # written prior permission. M.I.T. makes no representations about the 24 | # suitability of this software for any purpose. It is provided "as is" 25 | # without express or implied warranty. 26 | # 27 | # Calling this script install-sh is preferred over install.sh, to prevent 28 | # `make' implicit rules from creating a file called install from it 29 | # when there is no Makefile. 30 | 31 | # set DOITPROG to echo to test this script 32 | # Don't use :- since 4.3BSD and earlier shells don't like it. 33 | doit="${DOITPROG-}" 34 | 35 | # Force umask to 022... 36 | umask 022 37 | 38 | # put in absolute paths if you don't have them in your path; or use env. vars. 39 | mvprog="${MVPROG-mv}" 40 | cpprog="${CPPROG-cp}" 41 | chmodprog="${CHMODPROG-chmod}" 42 | chownprog="${CHOWNPROG-chown}" 43 | chgrpprog="${CHGRPPROG-chgrp}" 44 | stripprog="${STRIPPROG-strip}" 45 | rmprog="${RMPROG-rm}" 46 | mkdirprog="${MKDIRPROG-mkdir}" 47 | 48 | transformbasename="" 49 | transform_arg="" 50 | instcmd="$mvprog" 51 | chmodcmd="$chmodprog 0755" 52 | chowncmd="" 53 | chgrpcmd="" 54 | stripcmd="" 55 | rmcmd="$rmprog -f" 56 | mvcmd="$mvprog" 57 | src="" 58 | dst="" 59 | dir_arg="" 60 | 61 | while [ x"$1" != x ]; do 62 | case $1 in 63 | -c) 64 | instcmd="$cpprog" 65 | shift 66 | continue 67 | ;; 68 | 69 | -d) 70 | dir_arg=true 71 | shift 72 | continue 73 | ;; 74 | 75 | -m) 76 | chmodcmd="$chmodprog $2" 77 | shift 78 | shift 79 | continue 80 | ;; 81 | 82 | -o) 83 | chowncmd="$chownprog $2" 84 | shift 85 | shift 86 | continue 87 | ;; 88 | 89 | -g) 90 | chgrpcmd="$chgrpprog $2" 91 | shift 92 | shift 93 | continue 94 | ;; 95 | 96 | -s) 97 | stripcmd="$stripprog" 98 | shift 99 | continue 100 | ;; 101 | 102 | *) 103 | if [ x"$src" = x ]; then 104 | src="$1" 105 | else 106 | dst="$1" 107 | fi 108 | shift 109 | continue 110 | ;; 111 | esac 112 | done 113 | 114 | if [ x"$src" = x ]; then 115 | echo "install-sh: No input file specified" 116 | exit 1 117 | fi 118 | 119 | if [ x"$dir_arg" != x ]; then 120 | dst="$src" 121 | src="" 122 | 123 | if [ -d "$dst" ]; then 124 | instcmd=: 125 | else 126 | instcmd=$mkdirprog 127 | fi 128 | else 129 | # Waiting for this to be detected by the "$instcmd $src $dsttmp" command 130 | # might cause directories to be created, which would be especially bad 131 | # if $src (and thus $dsttmp) contains '*'. 132 | if [ ! -f "$src" -a ! -d "$src" ]; then 133 | echo "install: $src does not exist" 134 | exit 1 135 | fi 136 | 137 | if [ x"$dst" = x ]; then 138 | echo "install: No destination specified" 139 | exit 1 140 | fi 141 | 142 | # If destination is a directory, append the input filename. 143 | if [ -d "$dst" ]; then 144 | dst="$dst/`basename $src`" 145 | fi 146 | fi 147 | 148 | ## this sed command emulates the dirname command 149 | dstdir="`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`" 150 | 151 | # Make sure that the destination directory exists. 152 | # This part is taken from Noah Friedman's mkinstalldirs script 153 | 154 | # Skip lots of stat calls in the usual case. 155 | if [ ! -d "$dstdir" ]; then 156 | defaultIFS=' 157 | ' 158 | IFS="${IFS-${defaultIFS}}" 159 | 160 | oIFS="${IFS}" 161 | # Some sh's can't handle IFS=/ for some reason. 162 | IFS='%' 163 | set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` 164 | IFS="${oIFS}" 165 | 166 | pathcomp='' 167 | 168 | while [ $# -ne 0 ] ; do 169 | pathcomp="${pathcomp}${1}" 170 | shift 171 | 172 | if [ ! -d "${pathcomp}" ]; then $doit $mkdirprog "${pathcomp}"; fi 173 | 174 | pathcomp="${pathcomp}/" 175 | done 176 | fi 177 | 178 | if [ x"$dir_arg" != x ]; then 179 | # Make a directory... 180 | $doit $instcmd $dst || exit 1 181 | 182 | # Allow chown/chgrp to fail, but log a warning 183 | if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst || echo "warning: Unable to change owner of $dst!"; fi 184 | if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst || echo "warning: Unable to change group of $dst!"; fi 185 | if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst || exit 1; fi 186 | else 187 | # Install a file... 188 | dstfile="`basename $dst`" 189 | 190 | # Check the destination file - for libraries just use the "-x" option 191 | # to strip... 192 | case "$dstfile" in 193 | *.a | *.dylib | *.sl | *.sl.* | *.so | *.so.*) 194 | stripopt="-x" 195 | ;; 196 | *) 197 | stripopt="" 198 | ;; 199 | esac 200 | 201 | # Make a temp file name in the proper directory. 202 | dsttmp="$dstdir/#inst.$$#" 203 | 204 | # Move or copy the file name to the temp name 205 | $doit $instcmd $src $dsttmp || exit 1 206 | 207 | # Update permissions and strip as needed, then move to the final name. 208 | # If the chmod, strip, rm, or mv commands fail, remove the installed 209 | # file... 210 | if [ x"$stripcmd" != x ]; then $doit $stripcmd $stripopt "$dsttmp" || echo "warning: Unable to strip $dst!"; fi 211 | if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dsttmp" || echo "warning: Unable to change owner of $dst!"; fi 212 | if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dsttmp" || echo "warning: Unable to change group of $dst!"; fi 213 | 214 | trap "rm -f ${dsttmp}" 0 && 215 | if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dsttmp"; fi && 216 | $doit $rmcmd -f "$dstdir/$dstfile" && 217 | $doit $mvcmd "$dsttmp" "$dstdir/$dstfile" 218 | fi 219 | 220 | exit 0 221 | -------------------------------------------------------------------------------- /filter/foomatic-rip/process.c: -------------------------------------------------------------------------------- 1 | // 2 | // process.c 3 | // 4 | // Copyright (C) 2008 Till Kamppeter 5 | // Copyright (C) 2008 Lars Karlitski (formerly Uebernickel) 6 | // 7 | // This file is part of foomatic-rip. 8 | // 9 | // Licensed under Apache License v2.0. See the file "LICENSE" for more 10 | // information. 11 | // 12 | 13 | #include "foomaticrip.h" 14 | #include "process.h" 15 | #include 16 | #include "util.h" 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | 23 | int kidgeneration = 0; 24 | 25 | char *modern_shell; 26 | 27 | struct process 28 | { 29 | char name[64]; 30 | pid_t pid; 31 | int isgroup; 32 | }; 33 | 34 | #define MAX_CHILDS 4 35 | struct process procs[MAX_CHILDS] = 36 | { 37 | { "", -1, 0 }, 38 | { "", -1, 0 }, 39 | { "", -1, 0 }, 40 | { "", -1, 0 } 41 | }; 42 | 43 | 44 | const char * 45 | get_modern_shell() 46 | { 47 | return (modern_shell); 48 | } 49 | 50 | 51 | void 52 | add_process(const char *name, 53 | int pid, 54 | int isgroup) 55 | { 56 | int i; 57 | for (i = 0; i < MAX_CHILDS; i++) 58 | { 59 | if (procs[i].pid == -1) 60 | { 61 | strlcpy(procs[i].name, name, 64); 62 | procs[i].pid = pid; 63 | procs[i].isgroup = isgroup; 64 | return; 65 | } 66 | } 67 | rip_die(EXIT_PRNERR_NORETRY_BAD_SETTINGS, 68 | "Didn't think there would be that many child processes... Exiting.\n"); 69 | } 70 | 71 | 72 | int 73 | find_process(int pid) 74 | { 75 | int i; 76 | for (i = 0; i < MAX_CHILDS; i++) 77 | if (procs[i].pid == pid) 78 | return (i); 79 | return (-1); 80 | } 81 | 82 | 83 | void 84 | clear_proc_list() 85 | { 86 | int i; 87 | for (i = 0; i < MAX_CHILDS; i++) 88 | procs[i].pid = -1; 89 | } 90 | 91 | 92 | void 93 | kill_all_processes() 94 | { 95 | int i; 96 | 97 | for (i = 0; i < MAX_CHILDS; i++) 98 | { 99 | if (procs[i].pid == -1) 100 | continue; 101 | _log("Killing %s\n", procs[i].name); 102 | kill(procs[i].isgroup ? -procs[i].pid : procs[i].pid, 15); 103 | sleep(1 << (3 - kidgeneration)); 104 | kill(procs[i].isgroup ? -procs[i].pid : procs[i].pid, 9); 105 | } 106 | clear_proc_list(); 107 | } 108 | 109 | 110 | static pid_t 111 | _start_process(const char *name, 112 | int (*proc_func)(FILE *, FILE *, void *), 113 | void *user_arg, 114 | FILE **pipe_in, 115 | FILE **pipe_out, 116 | int createprocessgroup) 117 | { 118 | pid_t pid; 119 | int pfdin[2], pfdout[2]; 120 | int ret; 121 | FILE *in, *out; 122 | 123 | if (pipe_in) 124 | if (pipe(pfdin) < 0) 125 | return (-1); 126 | if (pipe_out) 127 | if (pipe(pfdout) < 0) 128 | return (-1); 129 | 130 | _log("Starting process \"%s\" (generation %d)\n", name, kidgeneration +1); 131 | 132 | pid = fork(); 133 | if (pid < 0) 134 | { 135 | _log("Could not fork for %s\n", name); 136 | if (pipe_in) 137 | { 138 | close(pfdin[0]); 139 | close(pfdin[1]); 140 | } 141 | if (pipe_out) 142 | { 143 | close(pfdout[0]); 144 | close(pfdout[1]); 145 | } 146 | return (-1); 147 | } 148 | 149 | if (pid == 0) 150 | { 151 | // Child 152 | 153 | // Reset sigpipe behavior to default for all children 154 | signal(SIGPIPE, SIG_DFL); 155 | 156 | if (pipe_in) 157 | { 158 | close(pfdin[1]); 159 | in = fdopen(pfdin[0], "r"); 160 | } 161 | else 162 | in = NULL; 163 | 164 | if (pipe_out) 165 | { 166 | close(pfdout[0]); 167 | out = fdopen(pfdout[1], "w"); 168 | } 169 | else 170 | out = NULL; 171 | 172 | if (createprocessgroup) 173 | setpgid(0, 0); 174 | 175 | kidgeneration ++; 176 | 177 | // The subprocess list is only valid for the parent. Clear it. 178 | clear_proc_list(); 179 | 180 | ret = proc_func(in, out, user_arg); 181 | exit(ret); 182 | } 183 | 184 | // Parent 185 | if (pipe_in) 186 | { 187 | close(pfdin[0]); 188 | *pipe_in = fdopen(pfdin[1], "w"); 189 | if (!*pipe_in) 190 | _log("fdopen: %s\n", strerror(errno)); 191 | } 192 | if (pipe_out) 193 | { 194 | close(pfdout[1]); 195 | *pipe_out = fdopen(pfdout[0], "r"); 196 | if (!*pipe_out) 197 | _log("fdopen: %s\n", strerror(errno)); 198 | } 199 | 200 | // Add the child process to the list of open processes (to be able to kill 201 | // them in case of a signal. 202 | add_process(name, pid, createprocessgroup); 203 | 204 | return (pid); 205 | } 206 | 207 | 208 | int 209 | exec_command(FILE *in, 210 | FILE *out, 211 | void *cmd) 212 | { 213 | if (in && dup2(fileno(in), fileno(stdin)) < 0) 214 | rip_die(EXIT_PRNERR_NORETRY_BAD_SETTINGS, 215 | "%s: Could not dup stdin\n", (const char *)cmd); 216 | if (out && dup2(fileno(out), fileno(stdout)) < 0) 217 | rip_die(EXIT_PRNERR_NORETRY_BAD_SETTINGS, 218 | "%s: Could not dup stdout\n", (const char *)cmd); 219 | 220 | execl(get_modern_shell(), get_modern_shell(), "-e", "-c", 221 | (const char *)cmd, (char *)NULL); 222 | 223 | _log("Error: Executing \"%s -c %s\" failed (%s).\n", get_modern_shell(), 224 | (const char *)cmd, strerror(errno)); 225 | return (EXIT_PRNERR_NORETRY_BAD_SETTINGS); 226 | } 227 | 228 | 229 | pid_t 230 | start_system_process(const char *name, 231 | const char *command, 232 | FILE **fdin, 233 | FILE **fdout) 234 | { 235 | return (_start_process(name, exec_command, (void*)command, fdin, fdout, 1)); 236 | } 237 | 238 | 239 | pid_t 240 | start_process(const char *name, 241 | int (*proc_func)(FILE *, FILE *, void *), 242 | void *user_arg, 243 | FILE **fdin, 244 | FILE **fdout) 245 | { 246 | return (_start_process(name, proc_func, user_arg, fdin, fdout, 0)); 247 | } 248 | 249 | 250 | int 251 | wait_for_process(int pid) 252 | { 253 | int i; 254 | int status; 255 | 256 | i = find_process(pid); 257 | if (i < 0) 258 | { 259 | _log("No such process \"%d\"", pid); 260 | return (-1); 261 | } 262 | 263 | waitpid(procs[i].pid, &status, 0); 264 | if (WIFEXITED(status)) 265 | _log("%s exited with status %d\n", procs[i].name, WEXITSTATUS(status)); 266 | else if (WIFSIGNALED(status)) 267 | _log("%s received signal %d\n", procs[i].name, WTERMSIG(status)); 268 | 269 | // remove from process list 270 | procs[i].pid = -1; 271 | return (status); 272 | } 273 | 274 | 275 | int 276 | run_system_process(const char *name, 277 | const char *command) 278 | { 279 | int pid = start_system_process(name, command, NULL, NULL); 280 | return (wait_for_process(pid)); 281 | } 282 | -------------------------------------------------------------------------------- /m4/ax_compare_version.m4: -------------------------------------------------------------------------------- 1 | # =========================================================================== 2 | # http://www.gnu.org/software/autoconf-archive/ax_compare_version.html 3 | # =========================================================================== 4 | # 5 | # SYNOPSIS 6 | # 7 | # AX_COMPARE_VERSION(VERSION_A, OP, VERSION_B, [ACTION-IF-TRUE], [ACTION-IF-FALSE]) 8 | # 9 | # DESCRIPTION 10 | # 11 | # This macro compares two version strings. Due to the various number of 12 | # minor-version numbers that can exist, and the fact that string 13 | # comparisons are not compatible with numeric comparisons, this is not 14 | # necessarily trivial to do in a autoconf script. This macro makes doing 15 | # these comparisons easy. 16 | # 17 | # The six basic comparisons are available, as well as checking equality 18 | # limited to a certain number of minor-version levels. 19 | # 20 | # The operator OP determines what type of comparison to do, and can be one 21 | # of: 22 | # 23 | # eq - equal (test A == B) 24 | # ne - not equal (test A != B) 25 | # le - less than or equal (test A <= B) 26 | # ge - greater than or equal (test A >= B) 27 | # lt - less than (test A < B) 28 | # gt - greater than (test A > B) 29 | # 30 | # Additionally, the eq and ne operator can have a number after it to limit 31 | # the test to that number of minor versions. 32 | # 33 | # eq0 - equal up to the length of the shorter version 34 | # ne0 - not equal up to the length of the shorter version 35 | # eqN - equal up to N sub-version levels 36 | # neN - not equal up to N sub-version levels 37 | # 38 | # When the condition is true, shell commands ACTION-IF-TRUE are run, 39 | # otherwise shell commands ACTION-IF-FALSE are run. The environment 40 | # variable 'ax_compare_version' is always set to either 'true' or 'false' 41 | # as well. 42 | # 43 | # Examples: 44 | # 45 | # AX_COMPARE_VERSION([3.15.7],[lt],[3.15.8]) 46 | # AX_COMPARE_VERSION([3.15],[lt],[3.15.8]) 47 | # 48 | # would both be true. 49 | # 50 | # AX_COMPARE_VERSION([3.15.7],[eq],[3.15.8]) 51 | # AX_COMPARE_VERSION([3.15],[gt],[3.15.8]) 52 | # 53 | # would both be false. 54 | # 55 | # AX_COMPARE_VERSION([3.15.7],[eq2],[3.15.8]) 56 | # 57 | # would be true because it is only comparing two minor versions. 58 | # 59 | # AX_COMPARE_VERSION([3.15.7],[eq0],[3.15]) 60 | # 61 | # would be true because it is only comparing the lesser number of minor 62 | # versions of the two values. 63 | # 64 | # Note: The characters that separate the version numbers do not matter. An 65 | # empty string is the same as version 0. OP is evaluated by autoconf, not 66 | # configure, so must be a string, not a variable. 67 | # 68 | # The author would like to acknowledge Guido Draheim whose advice about 69 | # the m4_case and m4_ifvaln functions make this macro only include the 70 | # portions necessary to perform the specific comparison specified by the 71 | # OP argument in the final configure script. 72 | # 73 | # LICENSE 74 | # 75 | # Copyright (c) 2008 Tim Toolan 76 | # 77 | # Copying and distribution of this file, with or without modification, are 78 | # permitted in any medium without royalty provided the copyright notice 79 | # and this notice are preserved. This file is offered as-is, without any 80 | # warranty. 81 | 82 | #serial 11 83 | 84 | dnl ######################################################################### 85 | AC_DEFUN([AX_COMPARE_VERSION], [ 86 | AC_REQUIRE([AC_PROG_AWK]) 87 | 88 | # Used to indicate true or false condition 89 | ax_compare_version=false 90 | 91 | # Convert the two version strings to be compared into a format that 92 | # allows a simple string comparison. The end result is that a version 93 | # string of the form 1.12.5-r617 will be converted to the form 94 | # 0001001200050617. In other words, each number is zero padded to four 95 | # digits, and non digits are removed. 96 | AS_VAR_PUSHDEF([A],[ax_compare_version_A]) 97 | A=`echo "$1" | sed -e 's/\([[0-9]]*\)/Z\1Z/g' \ 98 | -e 's/Z\([[0-9]]\)Z/Z0\1Z/g' \ 99 | -e 's/Z\([[0-9]][[0-9]]\)Z/Z0\1Z/g' \ 100 | -e 's/Z\([[0-9]][[0-9]][[0-9]]\)Z/Z0\1Z/g' \ 101 | -e 's/[[^0-9]]//g'` 102 | 103 | AS_VAR_PUSHDEF([B],[ax_compare_version_B]) 104 | B=`echo "$3" | sed -e 's/\([[0-9]]*\)/Z\1Z/g' \ 105 | -e 's/Z\([[0-9]]\)Z/Z0\1Z/g' \ 106 | -e 's/Z\([[0-9]][[0-9]]\)Z/Z0\1Z/g' \ 107 | -e 's/Z\([[0-9]][[0-9]][[0-9]]\)Z/Z0\1Z/g' \ 108 | -e 's/[[^0-9]]//g'` 109 | 110 | dnl # In the case of le, ge, lt, and gt, the strings are sorted as necessary 111 | dnl # then the first line is used to determine if the condition is true. 112 | dnl # The sed right after the echo is to remove any indented white space. 113 | m4_case(m4_tolower($2), 114 | [lt],[ 115 | ax_compare_version=`echo "x$A 116 | x$B" | sed 's/^ *//' | sort -r | sed "s/x${A}/false/;s/x${B}/true/;1q"` 117 | ], 118 | [gt],[ 119 | ax_compare_version=`echo "x$A 120 | x$B" | sed 's/^ *//' | sort | sed "s/x${A}/false/;s/x${B}/true/;1q"` 121 | ], 122 | [le],[ 123 | ax_compare_version=`echo "x$A 124 | x$B" | sed 's/^ *//' | sort | sed "s/x${A}/true/;s/x${B}/false/;1q"` 125 | ], 126 | [ge],[ 127 | ax_compare_version=`echo "x$A 128 | x$B" | sed 's/^ *//' | sort -r | sed "s/x${A}/true/;s/x${B}/false/;1q"` 129 | ],[ 130 | dnl Split the operator from the subversion count if present. 131 | m4_bmatch(m4_substr($2,2), 132 | [0],[ 133 | # A count of zero means use the length of the shorter version. 134 | # Determine the number of characters in A and B. 135 | ax_compare_version_len_A=`echo "$A" | $AWK '{print(length)}'` 136 | ax_compare_version_len_B=`echo "$B" | $AWK '{print(length)}'` 137 | 138 | # Set A to no more than B's length and B to no more than A's length. 139 | A=`echo "$A" | sed "s/\(.\{$ax_compare_version_len_B\}\).*/\1/"` 140 | B=`echo "$B" | sed "s/\(.\{$ax_compare_version_len_A\}\).*/\1/"` 141 | ], 142 | [[0-9]+],[ 143 | # A count greater than zero means use only that many subversions 144 | A=`echo "$A" | sed "s/\(\([[0-9]]\{4\}\)\{m4_substr($2,2)\}\).*/\1/"` 145 | B=`echo "$B" | sed "s/\(\([[0-9]]\{4\}\)\{m4_substr($2,2)\}\).*/\1/"` 146 | ], 147 | [.+],[ 148 | AC_WARNING( 149 | [illegal OP numeric parameter: $2]) 150 | ],[]) 151 | 152 | # Pad zeros at end of numbers to make same length. 153 | ax_compare_version_tmp_A="$A`echo $B | sed 's/./0/g'`" 154 | B="$B`echo $A | sed 's/./0/g'`" 155 | A="$ax_compare_version_tmp_A" 156 | 157 | # Check for equality or inequality as necessary. 158 | m4_case(m4_tolower(m4_substr($2,0,2)), 159 | [eq],[ 160 | test "x$A" = "x$B" && ax_compare_version=true 161 | ], 162 | [ne],[ 163 | test "x$A" != "x$B" && ax_compare_version=true 164 | ],[ 165 | AC_WARNING([illegal OP parameter: $2]) 166 | ]) 167 | ]) 168 | 169 | AS_VAR_POPDEF([A])dnl 170 | AS_VAR_POPDEF([B])dnl 171 | 172 | dnl # Execute ACTION-IF-TRUE / ACTION-IF-FALSE. 173 | if test "$ax_compare_version" = "true" ; then 174 | m4_ifvaln([$4],[$4],[:])dnl 175 | m4_ifvaln([$5],[else $5])dnl 176 | fi 177 | ]) dnl AX_COMPARE_VERSION 178 | -------------------------------------------------------------------------------- /CHANGES.md: -------------------------------------------------------------------------------- 1 | # CHANGES - OpenPrinting CUPS Filters v2.0.1 - 2024-08-15 2 | 3 | ## CHANGES IN V2.0.1 (15th August 2024) 4 | 5 | - serial backend: Fixed bug in conversion of comments 6 | (Pull request #548) 7 | 8 | - pclmtoraster: Properly set CFLAGS 9 | As this is a C program, set `pclmtoraster_CFLAGS`, not 10 | `pclmtoraster_CXXFLAGS` (Pull request #588). 11 | 12 | - `configure`: Remove `==` bashism 13 | (Pull request #567) 14 | 15 | - `configure.ac`: Remove Avahi check 16 | cups-filters does not use Avahi (Pull request #558) 17 | 18 | 19 | ## CHANGES IN V2.0.0 (22th September 2023) 20 | 21 | - `universal`: Enable `application/vnd.cups-postscript` as input 22 | There are filters which produce this MIME type (such as `hpps` of 23 | HPLIP), and if someone uses such driver on a client and the server 24 | has an IPP Everywhere/driverless printer, the job fails (Pull 25 | request #534). 26 | 27 | 28 | ## CHANGES IN V2.0rc2 (20th June 2023) 29 | 30 | - beh backend: Use `execv()` instead of `system()` - CVE-2023-24805 31 | With `execv()` command line arguments are passed as separate strings 32 | and not the full command line in a single string. This prevents 33 | arbitrary command execution by escaping the quoting of the arguments 34 | in a job with forged job title. 35 | 36 | - beh backend: Extra checks against odd/forged input - CVE-2023-24805 37 | 38 | * Do not allow `/` in the scheme of the URI (= backend executable 39 | name), to assure that only backends inside 40 | `/usr/lib/cups/backend/` are used. 41 | 42 | * Pre-define scheme buffer to empty string, to be defined for case 43 | of URI being NULL. 44 | 45 | * URI must have `:`, to split off scheme, otherwise error. 46 | 47 | * Check return value of `snprintf()` to create call path for 48 | backend, to error out on truncation of a too long scheme or on 49 | complete failure due to a completely odd scheme. 50 | 51 | - beh backend: Further improvements - CVE-2023-24805 52 | 53 | * Use `strncat()` instead of `strncpy()` for getting scheme from 54 | URI, the latter does not require setting terminating zero byte in 55 | case of truncation. 56 | 57 | * Also exclude `.` or `..` as scheme, as directories are not valid 58 | CUPS backends. 59 | 60 | * Do not use `fprintf()` in `sigterm_handler()`, to not interfere 61 | with a `fprintf()` which could be running in the main process when 62 | `sigterm_handler()` is triggered. 63 | 64 | * Use `static volatile int` for global variable job_canceled. 65 | 66 | - `parallel` backend: Added missing `#include` lines 67 | 68 | 69 | ## CHANGES IN V2.0rc1 (12th April 2023) 70 | 71 | - foomatic-rip: Fix a SIGPIPE error when calling gs (Pull request #517) 72 | [Ubuntu's autopkgtest for 73 | foo2zjs](https://autopkgtest.ubuntu.com/packages/f/foo2zjs/lunar/ppc64el) 74 | shows foo2zjs's testsuite failing with cups-filters 2.0beta3 on 75 | ppc64el. This is cause by a timing issue in foomatic-rip which is 76 | fixed now. 77 | 78 | - Coverity check done by Zdenek Dohnal for the inclusion of 79 | cups-filters in Fedora and Red Hat. Zdenek has fixed all the issues: 80 | Missing `free()`, files not closed, potential string overflows, 81 | ... Thanks a lot! (Pull request #510). 82 | 83 | - Dropped all C++ references and obsolete C standards (Pull requests 84 | #504 and #513) 85 | With no C++ compiler needed, there is no need for any checks or 86 | setting for C++ in configure.ac. 87 | 88 | - configure.ac: Change deprecated AC_PROG_LIBTOOL for LT_INIT (Pull 89 | request #508) 90 | 91 | 92 | ## CHANGES IN V2.0b3 (31st January 2023) 93 | 94 | - texttopdf: Do not include fontconfig.h in the CUPS filter wrapper 95 | 96 | - Build system: Do not explicitly check for libpoppler-cpp 97 | The cups-filters package does not contain any code using 98 | libpoppler-cpp, therefore we let ./configure not check for it. 99 | 100 | - COPYING, NOTICE: Simplification for autotools-generated files 101 | autotools-generated files can be included under the license of the 102 | upstream code, and FSF copyright added to upstream copyright 103 | list. Simplified COPYING appropriately. 104 | 105 | - Makefile.am: Include LICENSE in distribution tarball 106 | 107 | - Add templates for issue reports on GitHub. This makes a selection 108 | screen appear when clicking "New Issue" in the web UI, to selct 109 | whether the issue is a regular bug, a feature request, or a security 110 | vulnerability. 111 | 112 | 113 | ## CHANGES IN V2.0b2 (8th January 2023) 114 | 115 | - Corrected installation path for *.h files of *.drv files. The ppdc 116 | (and underlying functions) of libppd searches for include files in 117 | /usr/share/ppdc and not in /usr/share/cups/ppdc any more. 118 | 119 | - configure.ac: Remove unnecessary "AVAHI_GLIB_..." definitions. 120 | 121 | - Makefile.am: Include NOTICE in distribution tarball 122 | 123 | - configure.ac: Added "foreign" to to AM_INIT_AUTOMAKE() call. Makes 124 | automake not require a file named README. 125 | 126 | - Cleaned up .gitignore 127 | 128 | - Tons of fixes in the source code documentation: README.md, INSTALL, 129 | DEVELOPING.md, CONTRIBUTING.md, COPYING, NOTICE, ... Adapted to the 130 | cups-filters component, added links. 131 | 132 | 133 | ## CHANGES IN V2.0b1 (18th November 2022) 134 | 135 | - Converted nearly all filters to filter functions, only exceptions 136 | are `rastertoescpx`, `rastertopclx`, `commandtoescpx`, 137 | `commandtopclx`, and `foomatic-rip`. The latter is deeply involved 138 | with Foomatic PPDs and the others are legacy printer drivers. The 139 | filter functions are mainly in libcupsfilters, the ones which 140 | generate PostScript are in libppd. 141 | 142 | - Replaced all the filters converted to filter functions by simple 143 | wrapper executables using `ppdFilterCUPSWrapper()` of libppd for 144 | backward compatibility with CUPS 2.x. 145 | 146 | - Added new streaming mode triggered by the boolean 147 | "filter-streaming-mode" option. In this mode a filter (function) is 148 | supposed to avoid everything which prevents the job data from 149 | streaming, as loading the whole job (or good part of it) into a 150 | temporary file or into memory, interpreting PDF, pre-checking input 151 | file type or zero-page jobs, ... This is mainly to be used by 152 | Printer Applications when they do raster printing in streaming mode, 153 | to run with lowest resources possible. Currently `foomatic-rip`, 154 | `ghostscript`, and `pdftopdf` got a streaming mode. For the former 155 | two PostScript (not PDF) is assumed as input and no zero-page-job 156 | check is done, in the latter all QPDF processing (page management, 157 | page size adjustment, ...) is skipped and only JCL according to the 158 | PPD added. 159 | 160 | - The CUPS filter `imagetops` uses the `ppdFilterImageToPS()` filter 161 | function of libppd now. 162 | 163 | - `driverless`, `driverless-fax`: Added IPP Fax Out support. Now 164 | printer setup tools list an additional fax "driver". A fax queue is 165 | created by selecting this driver. Jobs have to be sent with "-o 166 | phone=12345" to supply the destination phone number (Pull request 167 | #280, #293, #296, #302, #304, #305, #306, #309, Issue #298, #308). 168 | 169 | - `sys5ippprinter`: Removed `sys5ippprinter`, as CUPS does not support 170 | System V interface scripts any more. This first approach of PPD-less 171 | printing was also not actually made use of. 172 | 173 | - `urftopdf`: Removed as we require CUPS 2.2.2+ now which supports 174 | Apple Raster by itself. 175 | 176 | - Build system, `README.md`: Require CUPS 2.2.2+. Removed now unneeded 177 | `./configure` switches for use of the `urftopdf` filter for old CUPS 178 | versions. 179 | 180 | - Sample PPDs: Renamed source directory from `ppd/` to `ppdfiles/`. 181 | 182 | - Build system: Remove '-D_PPD_DEPRECATED=""' from the compiling 183 | command lines of the source files which use libcups. The flag is not 184 | supported any more for longer times already and all the PPD-related 185 | functions deprecated by CUPS have moved into libppd now. 186 | 187 | - Build system: Add files in `.gitignore` that are generated by 188 | "autogen.sh", "configure", and "make" (Pull request #336). 189 | -------------------------------------------------------------------------------- /filter/foomatic-rip/spooler.c: -------------------------------------------------------------------------------- 1 | // 2 | // spooler.c 3 | // 4 | // Copyright (C) 2008 Till Kamppeter 5 | // Copyright (C) 2008 Lars Karlitski (formerly Uebernickel) 6 | // 7 | // This file is part of foomatic-rip. 8 | // 9 | // Licensed under Apache License v2.0. See the file "LICENSE" for more 10 | // information. 11 | // 12 | 13 | #include "spooler.h" 14 | #include "foomaticrip.h" 15 | #include "util.h" 16 | #include "options.h" 17 | #include 18 | #include 19 | #include 20 | 21 | 22 | const char * 23 | spooler_name(int spooler) 24 | { 25 | switch (spooler) 26 | { 27 | case SPOOLER_CUPS: 28 | return ("cups"); 29 | case SPOOLER_DIRECT: 30 | return ("direct"); 31 | }; 32 | return (""); 33 | } 34 | 35 | 36 | void 37 | init_cups(list_t *arglist, 38 | dstr_t *filelist, 39 | jobparams_t *job) 40 | { 41 | char path [PATH_MAX] = ""; 42 | char cups_jobid [128]; 43 | char cups_user [128]; 44 | char cups_jobtitle [2048]; 45 | char cups_copies [128]; 46 | int cups_options_len; 47 | char *cups_options; 48 | const char *pname; 49 | char cups_filename [256]; 50 | 51 | if (getenv("CUPS_FONTPATH")) 52 | strncpy(path, getenv("CUPS_FONTPATH"), PATH_MAX - 1); 53 | else if (getenv("CUPS_DATADIR")) 54 | { 55 | strncpy(path, getenv("CUPS_DATADIR"), PATH_MAX - 1); 56 | strncat(path, "/fonts", PATH_MAX - strlen(path) - 1); 57 | } 58 | if (getenv("GS_LIB")) 59 | { 60 | strncat(path, ":", PATH_MAX - strlen(path) - 1); 61 | strncat(path, getenv("GS_LIB"), PATH_MAX - strlen(path) - 1); 62 | } 63 | setenv("GS_LIB", path, 1); 64 | 65 | // Get all command line parameters 66 | strncpy_omit(cups_jobid, arglist_get(arglist, 0), 128, omit_shellescapes); 67 | strncpy_omit(cups_user, arglist_get(arglist, 1), 128, omit_shellescapes); 68 | strncpy_omit(cups_jobtitle, arglist_get(arglist, 2), 2048, 69 | omit_shellescapes); 70 | strncpy_omit(cups_copies, arglist_get(arglist, 3), 128, omit_shellescapes); 71 | 72 | cups_options_len = strlen(arglist_get(arglist, 4)); 73 | cups_options = malloc(cups_options_len + 1); 74 | strncpy_omit(cups_options, arglist_get(arglist, 4), cups_options_len + 1, 75 | omit_shellescapes); 76 | 77 | // Common job parameters 78 | strcpy(job->id, cups_jobid); 79 | strcpy(job->title, cups_jobtitle); 80 | strcpy(job->user, cups_user); 81 | strcpy(job->copies, cups_copies); 82 | dstrcatf(job->optstr, " %s", cups_options); 83 | 84 | // Check for and handle inputfile vs stdin 85 | if (list_item_count(arglist) > 4) 86 | { 87 | strncpy_omit(cups_filename, arglist_get(arglist, 5), 256, 88 | omit_shellescapes); 89 | if (cups_filename[0] != '-') 90 | { 91 | // We get input from a file 92 | dstrcatf(filelist, "%s ", cups_filename); 93 | _log("Getting input from file %s\n", cups_filename); 94 | } 95 | } 96 | 97 | // On which queue are we printing? 98 | // CUPS puts the print queue name into the PRINTER environment variable 99 | // when calling filters. 100 | pname = getenv("PRINTER"); 101 | if (pname == NULL) 102 | pname = "unknown"; 103 | strncpy(job->printer, pname, 256); 104 | job->printer[255] = '\0'; 105 | 106 | free(cups_options); 107 | } 108 | 109 | 110 | // used by init_direct to find a ppd file 111 | int 112 | find_ppdfile(const char *user_default_path, 113 | jobparams_t *job) 114 | { 115 | // Search also common spooler-specific locations, this way a printer 116 | // configured under a certain spooler can also be used without spooler 117 | 118 | strcpy(job->ppdfile, job->printer); 119 | if (access(job->ppdfile, R_OK) == 0) 120 | return (1); 121 | 122 | snprintf(job->ppdfile, 2048, "%s.ppd", job->printer); // current dir 123 | if (access(job->ppdfile, R_OK) == 0) 124 | return (1); 125 | snprintf(job->ppdfile, 2048, "%s/%s.ppd", user_default_path, job->printer); 126 | // user dir 127 | if (access(job->ppdfile, R_OK) == 0) 128 | return (1); 129 | snprintf(job->ppdfile, 2048, "%s/direct/%s.ppd", CONFIG_PATH, job->printer); 130 | // system dir 131 | if (access(job->ppdfile, R_OK) == 0) 132 | return (1); 133 | snprintf(job->ppdfile, 2048, "%s/%s.ppd", CONFIG_PATH, job->printer); 134 | // system dir 135 | if (access(job->ppdfile, R_OK) == 0) 136 | return (1); 137 | snprintf(job->ppdfile, 2048, "/etc/cups/ppd/%s.ppd", job->printer); 138 | // CUPS config dir 139 | if (access(job->ppdfile, R_OK) == 0) 140 | return (1); 141 | snprintf(job->ppdfile, 2048, "/usr/local/etc/cups/ppd/%s.ppd", job->printer); 142 | // CUPS config dir 143 | if (access(job->ppdfile, R_OK) == 0) 144 | return (1); 145 | 146 | // nothing found 147 | job->ppdfile[0] = '\0'; 148 | return (0); 149 | } 150 | 151 | 152 | // search 'configfile' for 'key', copy value into dest, return success 153 | int 154 | configfile_find_option(const char *configfile, 155 | const char *key, 156 | char *dest, 157 | size_t destsize) 158 | { 159 | FILE *fh; 160 | char line [1024]; 161 | char *p; 162 | 163 | dest[0] = '\0'; 164 | 165 | if (!(fh = fopen(configfile, "r"))) 166 | return (0); 167 | 168 | while (fgets(line, 1024, fh)) 169 | { 170 | if (!prefixcmp(line, "default")) 171 | { 172 | p = strchr(line, ':'); 173 | if (p) 174 | { 175 | strncpy_omit(dest, p + 1, destsize, omit_whitespace_newline); 176 | if (dest[0]) 177 | break; 178 | } 179 | } 180 | } 181 | fclose(fh); 182 | return (dest[0] != '\0'); 183 | } 184 | 185 | 186 | // tries to find a default printer name in various config files and copies the 187 | // result into the global var 'printer'. Returns success 188 | int 189 | find_default_printer(const char *user_default_path, 190 | jobparams_t *job) 191 | { 192 | char configfile [1024]; 193 | char *key = "default"; 194 | 195 | if (configfile_find_option("./.directconfig", key, job->printer, 256)) 196 | return (1); 197 | if (configfile_find_option("./directconfig", key, job->printer, 256)) 198 | return (1); 199 | if (configfile_find_option("./.config", key, job->printer, 256)) 200 | return (1); 201 | strlcpy(configfile, user_default_path, 1024); 202 | strlcat(configfile, "/direct/.config", 1024); 203 | if (configfile_find_option(configfile, key, job->printer, 256)) 204 | return (1); 205 | strlcpy(configfile, user_default_path, 1024); 206 | strlcat(configfile, "/direct.conf", 1024); 207 | if (configfile_find_option(configfile, key, job->printer, 256)) 208 | return (1); 209 | if (configfile_find_option(CONFIG_PATH "/direct/.config", key, job->printer, 210 | 256)) 211 | return (1); 212 | if (configfile_find_option(CONFIG_PATH "/direct.conf", key, job->printer, 213 | 256)) 214 | return (1); 215 | 216 | return (0); 217 | } 218 | 219 | 220 | void 221 | init_direct(list_t *arglist, 222 | dstr_t *filelist, 223 | jobparams_t *job) 224 | { 225 | char tmp [1024]; 226 | listitem_t *i; 227 | char user_default_path [PATH_MAX]; 228 | 229 | strlcpy(user_default_path, getenv("HOME"), 256); 230 | strlcat(user_default_path, "/.foomatic/", 256); 231 | 232 | // Which files do we want to print? 233 | for (i = arglist->first; i; i = i->next) 234 | { 235 | strncpy_omit(tmp, (char*)i->data, 1024, omit_shellescapes); 236 | dstrcatf(filelist, "%s ", tmp); 237 | } 238 | 239 | if (job->ppdfile[0] == '\0') 240 | { 241 | if (job->printer[0] == '\0') 242 | { 243 | // No printer definition file selected, check whether we have a 244 | // default printer defined 245 | find_default_printer(user_default_path, job); 246 | } 247 | 248 | // Neither in a config file nor on the command line a printer was selected 249 | if (!job->printer[0]) 250 | { 251 | _log("No printer definition (option \"-P \") specified!\n"); 252 | exit(EXIT_PRNERR_NORETRY_BAD_SETTINGS); 253 | } 254 | 255 | // Search for the PPD file 256 | if (!find_ppdfile(user_default_path, job)) 257 | { 258 | _log("There is no readable PPD file for the printer %s, is it configured?\n", 259 | job->printer); 260 | exit(EXIT_PRNERR_NORETRY_BAD_SETTINGS); 261 | } 262 | } 263 | } 264 | -------------------------------------------------------------------------------- /filter/foomatic-rip/foomatic-rip.1.in: -------------------------------------------------------------------------------- 1 | .\" This -*- nroff -*- source file is part of foomatic. 2 | 3 | .hy 0 4 | .TH FOOMATIC-RIP 1 "2013-11-06" "cups-filters" 5 | .SH NAME 6 | foomatic-rip \- Universal print filter/RIP wrapper 7 | .SH SYNOPSIS 8 | 9 | .SS \fRGeneral Options: 10 | .BI \fBfoomatic-rip\fR\ \fB[-v]\ [-q]\fP \fI\ 11 | 12 | .SS \fRSpooler-less printing filter: 13 | .BI \fBfoomatic-rip\fR\ \fB[\fB-P\fR \ \fI\fR \ 14 | | \ \fB--ppd\fR \ \fI\fR \fB]\fR \ [\fB-J\fR\ \fI\fR ] 15 | [\fB-o\fR \ \fI