From d53cb1bea7d43f03c41ba9798fb778270f218892 Mon Sep 17 00:00:00 2001 From: Till Kamppeter Date: Fri, 21 Oct 2022 23:56:00 +0200 Subject: [PATCH] CUPS filters: Code clean-up for code in filter/ Cleaned up the code of the legacy CUPS filters/filter function wrappers following the coding style rules in the DEVELOPING.md file of the CUPS source code. Comments are re-formatted to use "// ..." instead of "/* ... */", like in PAPPL, so C and C++ files get the same comment style. Also we get rid of the mix of many different coding styles which came together from the many code contributions received during more than a decade, even before the start of the cups-filters project. In addition, all the file's header comments reflect the new license now, Apache 2.0, the same license as used for CUPS. --- filter/bannertopdf.c | 69 +- filter/braille/drivers/common/fr-braille.po | 23 +- .../braille/drivers/common/media-braille.defs | 21 +- .../braille/drivers/generic/brftoembosser.in | 21 +- .../drivers/index/imageubrltoindexv3.in | 21 +- .../drivers/index/imageubrltoindexv4.in | 21 +- filter/braille/drivers/index/index.defs | 21 +- filter/braille/drivers/index/index.sh.in | 21 +- filter/braille/drivers/index/indexv3.sh.in | 21 +- filter/braille/drivers/index/indexv4.sh.in | 21 +- .../braille/drivers/index/textbrftoindexv3.in | 21 +- filter/braille/drivers/index/ubrlto4dot.c | 56 +- filter/braille/filters/braille.defs | 21 +- filter/braille/filters/brftopagedbrf.in | 25 +- filter/braille/filters/cups-braille.sh.in | 25 +- filter/braille/filters/imagemagick.defs | 27 +- filter/braille/filters/imagetobrf.in | 25 +- filter/braille/filters/liblouis.defs | 27 +- filter/braille/filters/liblouis1.defs.gen.in | 27 +- filter/braille/filters/musicxmltobrf.in | 25 +- filter/braille/filters/texttobrf.in | 25 +- filter/braille/filters/vectortobrf.in | 25 +- filter/braille/filters/vectortopdf.in | 25 +- filter/commandtoescpx.c | 191 ++- filter/commandtopclx.c | 148 ++- filter/escp.h | 47 +- filter/gstopdf.c | 77 +- filter/gstopxl.c | 78 +- filter/gstoraster.c | 78 +- filter/imagetopdf.c | 83 +- filter/imagetops.c | 86 +- filter/imagetoraster.c | 86 +- filter/mupdftopwg.c | 73 +- filter/pcl-common.c | 304 +++-- filter/pcl-common.h | 32 +- filter/pcl.h | 53 +- filter/pclmtoraster.c | 58 +- filter/pdftopdf.c | 74 +- filter/pdftops.c | 83 +- filter/pdftoraster.c | 72 +- filter/pstops.c | 83 +- filter/pwgtopclm.c | 80 +- filter/pwgtopdf.c | 80 +- filter/pwgtoraster.c | 73 +- filter/rastertoescpx.c | 1071 +++++++++-------- filter/rastertopclx.c | 1069 ++++++++-------- filter/rastertops.c | 93 +- filter/rastertopwg.c | 70 +- filter/test-external.c | 18 +- filter/texttopdf.c | 117 +- filter/texttops | 7 +- filter/texttotext.c | 71 +- filter/universal.c | 66 +- 53 files changed, 2434 insertions(+), 2701 deletions(-) diff --git a/filter/bannertopdf.c b/filter/bannertopdf.c index 8b70830a0..7c9e5b841 100644 --- a/filter/bannertopdf.c +++ b/filter/bannertopdf.c @@ -1,44 +1,53 @@ -/* - * Include necessary headers... - */ +// +// Legacy CUPS filter wrapper for cfFilterBannerToPDF() for cups-filters. +// +// Copyright © 2020-2022 by OpenPrinting. +// +// Licensed under Apache License v2.0. See the file "LICENSE" for more +// information. +// + +// +// Include necessary headers... +// #include #include #include #include -/* - * Local globals... - */ +// +// Local globals... +// -static int JobCanceled = 0;/* Set to 1 on SIGTERM */ +static int JobCanceled = 0; // Set to 1 on SIGTERM -/* - * Local functions... - */ +// +// Local functions... +// static void cancel_job(int sig); -/* - * 'main()' - Main entry and processing of driver. - */ +// +// 'main()' - Main entry and processing of driver. +// -int /* O - Exit status */ -main(int argc, /* I - Number of command-line arguments */ - char *argv[]) /* I - Command-line arguments */ +int // O - Exit status +main(int argc, // I - Number of command-line arguments + char *argv[]) // I - Command-line arguments { int ret; #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) - struct sigaction action; /* Actions for POSIX signals */ -#endif /* HAVE_SIGACTION && !HAVE_SIGSET */ + struct sigaction action; // Actions for POSIX signals +#endif // HAVE_SIGACTION && !HAVE_SIGSET - /* - * Register a signal handler to cleanly cancel a job. - */ + // + // Register a signal handler to cleanly cancel a job. + // -#ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */ +#ifdef HAVE_SIGSET // Use System V signals over POSIX to avoid bugs sigset(SIGTERM, cancel_job); #elif defined(HAVE_SIGACTION) memset(&action, 0, sizeof(action)); @@ -48,11 +57,11 @@ main(int argc, /* I - Number of command-line arguments */ sigaction(SIGTERM, &action, NULL); #else signal(SIGTERM, cancel_job); -#endif /* HAVE_SIGSET */ +#endif // HAVE_SIGSET - /* - * Fire up the ppdFilterPDFToRaster() filter function - */ + // + // Fire up the cfFilterBannerToPDF() filter function + // char buf[1024]; const char *datadir = getenv("CUPS_DATADIR"); @@ -70,12 +79,12 @@ main(int argc, /* I - Number of command-line arguments */ } -/* - * 'cancel_job()' - Flag the job as canceled. - */ +// +// 'cancel_job()' - Flag the job as canceled. +// static void -cancel_job(int sig) /* I - Signal number (unused) */ +cancel_job(int sig) // I - Signal number (unused) { (void)sig; diff --git a/filter/braille/drivers/common/fr-braille.po b/filter/braille/drivers/common/fr-braille.po index 81da3c1ec..c73c6a563 100644 --- a/filter/braille/drivers/common/fr-braille.po +++ b/filter/braille/drivers/common/fr-braille.po @@ -1,26 +1,9 @@ # # Copyright (c) 2015, 2017-2018 Samuel Thibault # -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# +# Licensed under Apache License v2.0. See the file "LICENSE" for more +# information. +# msgid "Generic" msgstr "Generique" diff --git a/filter/braille/drivers/common/media-braille.defs b/filter/braille/drivers/common/media-braille.defs index e1179862e..a8ee4faf2 100644 --- a/filter/braille/drivers/common/media-braille.defs +++ b/filter/braille/drivers/common/media-braille.defs @@ -1,25 +1,8 @@ // // Copyright (c) 2015 Samuel Thibault // -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. +// Licensed under Apache License v2.0. See the file "LICENSE" for more +// information. // #media "110x115/11x11.5" 792 828 diff --git a/filter/braille/drivers/generic/brftoembosser.in b/filter/braille/drivers/generic/brftoembosser.in index 029b3ec08..84ae165d7 100755 --- a/filter/braille/drivers/generic/brftoembosser.in +++ b/filter/braille/drivers/generic/brftoembosser.in @@ -3,25 +3,8 @@ # # Copyright (c) 2015, 2017-2018 Samuel Thibault # -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. +# Licensed under Apache License v2.0. See the file "LICENSE" for more +# information. # # Make sure we have enough options diff --git a/filter/braille/drivers/index/imageubrltoindexv3.in b/filter/braille/drivers/index/imageubrltoindexv3.in index 7e14f95a5..f26741bae 100755 --- a/filter/braille/drivers/index/imageubrltoindexv3.in +++ b/filter/braille/drivers/index/imageubrltoindexv3.in @@ -3,25 +3,8 @@ # # Copyright (c) 2015-2018 Samuel Thibault # -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. +# Licensed under Apache License v2.0. See the file "LICENSE" for more +# information. # # Make sure we have enough options diff --git a/filter/braille/drivers/index/imageubrltoindexv4.in b/filter/braille/drivers/index/imageubrltoindexv4.in index 0afc1b230..cc010302d 100755 --- a/filter/braille/drivers/index/imageubrltoindexv4.in +++ b/filter/braille/drivers/index/imageubrltoindexv4.in @@ -3,25 +3,8 @@ # # Copyright (c) 2015-2018 Samuel Thibault # -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. +# Licensed under Apache License v2.0. See the file "LICENSE" for more +# information. # # Make sure we have enough options diff --git a/filter/braille/drivers/index/index.defs b/filter/braille/drivers/index/index.defs index 615b1630a..79349021e 100644 --- a/filter/braille/drivers/index/index.defs +++ b/filter/braille/drivers/index/index.defs @@ -1,25 +1,8 @@ // // Copyright (c) 2015-2016, 2018 Samuel Thibault // -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. +// Licensed under Apache License v2.0. See the file "LICENSE" for more +// information. // Throughput 1 diff --git a/filter/braille/drivers/index/index.sh.in b/filter/braille/drivers/index/index.sh.in index 76163a47a..442242caf 100644 --- a/filter/braille/drivers/index/index.sh.in +++ b/filter/braille/drivers/index/index.sh.in @@ -1,25 +1,8 @@ # # Copyright (c) 2015-2016, 2018 Samuel Thibault # -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. +# Licensed under Apache License v2.0. See the file "LICENSE" for more +# information. # . @CUPS_DATADIR@/braille/cups-braille.sh diff --git a/filter/braille/drivers/index/indexv3.sh.in b/filter/braille/drivers/index/indexv3.sh.in index afc8d79cf..a7528c869 100644 --- a/filter/braille/drivers/index/indexv3.sh.in +++ b/filter/braille/drivers/index/indexv3.sh.in @@ -1,25 +1,8 @@ # # Copyright (c) 2015-2018 Samuel Thibault # -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. +# Licensed under Apache License v2.0. See the file "LICENSE" for more +# information. # . @CUPS_DATADIR@/braille/index.sh diff --git a/filter/braille/drivers/index/indexv4.sh.in b/filter/braille/drivers/index/indexv4.sh.in index 6b01dfc3a..9052ce81d 100644 --- a/filter/braille/drivers/index/indexv4.sh.in +++ b/filter/braille/drivers/index/indexv4.sh.in @@ -1,25 +1,8 @@ # # Copyright (c) 2015-2018 Samuel Thibault # -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. +# Licensed under Apache License v2.0. See the file "LICENSE" for more +# information. # . @CUPS_DATADIR@/braille/index.sh diff --git a/filter/braille/drivers/index/textbrftoindexv3.in b/filter/braille/drivers/index/textbrftoindexv3.in index 56dd50171..ec6665f9e 100755 --- a/filter/braille/drivers/index/textbrftoindexv3.in +++ b/filter/braille/drivers/index/textbrftoindexv3.in @@ -3,25 +3,8 @@ # # Copyright (c) 2015-2018, 2021 Samuel Thibault # -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. +# Licensed under Apache License v2.0. See the file "LICENSE" for more +# information. # # Make sure we have enough options diff --git a/filter/braille/drivers/index/ubrlto4dot.c b/filter/braille/drivers/index/ubrlto4dot.c index 3d3e7dae9..bd85b2601 100644 --- a/filter/braille/drivers/index/ubrlto4dot.c +++ b/filter/braille/drivers/index/ubrlto4dot.c @@ -1,40 +1,28 @@ -/* - Copyright (c) 2015 Samuel Thibault - j - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. -*/ +// +// Character conversion table generator for imageubrltoindexv[34] +// +// Copyright (c) 2015 Samuel Thibault +// +// Licensed under Apache License v2.0. See the file "LICENSE" for more +// information. +// #include #include #include -int main(int argc, char *argv[]) { - int i, j, lo, hi; - setlocale(LC_ALL,""); - for (i = 0; i < 256; i++) - { - j = (i&0x7) | ((i&0x8) << 3) | ((i&0x70) >> 1) | (i&0x80); - lo = i & 0xf; - hi = (i & 0xf0) >> 4; - printf(" -e 's/%lc/%c%c/g' \\\n", 0x2800+j, '@'+lo, '@'+hi); - } - return 0; +int +main(int argc, + char *argv[]) +{ + int i, j, lo, hi; + setlocale(LC_ALL, ""); + for (i = 0; i < 256; i ++) + { + j = (i & 0x7) | ((i & 0x8) << 3) | ((i & 0x70) >> 1) | (i & 0x80); + lo = i & 0xf; + hi = (i & 0xf0) >> 4; + printf(" -e 's/%lc/%c%c/g' \\\n", 0x2800 + j, '@' + lo, '@' + hi); + } + return (0); } diff --git a/filter/braille/filters/braille.defs b/filter/braille/filters/braille.defs index 5047e84ba..9edbd9b67 100644 --- a/filter/braille/filters/braille.defs +++ b/filter/braille/filters/braille.defs @@ -1,25 +1,8 @@ // // Copyright (c) 2015, 2017-2018 Samuel Thibault // -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. +// Licensed under Apache License v2.0. See the file "LICENSE" for more +// information. // Group "Braille/Braille transcription" diff --git a/filter/braille/filters/brftopagedbrf.in b/filter/braille/filters/brftopagedbrf.in index d9873a182..4dafad281 100755 --- a/filter/braille/filters/brftopagedbrf.in +++ b/filter/braille/filters/brftopagedbrf.in @@ -2,27 +2,10 @@ # # Copyright (c) 2015-2018 Samuel Thibault -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# +# +# Licensed under Apache License v2.0. See the file "LICENSE" for more +# information. +# # Make sure we have enough options if [ $# != 5 -a $# != 6 ]; then diff --git a/filter/braille/filters/cups-braille.sh.in b/filter/braille/filters/cups-braille.sh.in index 37f315f71..fac15e7f3 100644 --- a/filter/braille/filters/cups-braille.sh.in +++ b/filter/braille/filters/cups-braille.sh.in @@ -1,26 +1,9 @@ # # Copyright (c) 2015-2018, 2022 Samuel Thibault -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# +# +# Licensed under Apache License v2.0. See the file "LICENSE" for more +# information. +# # Get an attribute from the ppd file getAttribute () { diff --git a/filter/braille/filters/imagemagick.defs b/filter/braille/filters/imagemagick.defs index d209dcc95..79f47843f 100644 --- a/filter/braille/filters/imagemagick.defs +++ b/filter/braille/filters/imagemagick.defs @@ -1,26 +1,9 @@ -// +// // Copyright (c) 2015, 2017 Samuel Thibault -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -// +// +// Licensed under Apache License v2.0. See the file "LICENSE" for more +// information. +// Group "Image/Image conversion" diff --git a/filter/braille/filters/imagetobrf.in b/filter/braille/filters/imagetobrf.in index 9fd303976..2d23610db 100755 --- a/filter/braille/filters/imagetobrf.in +++ b/filter/braille/filters/imagetobrf.in @@ -2,27 +2,10 @@ # # Copyright (c) 2015-2018 Samuel Thibault -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# +# +# Licensed under Apache License v2.0. See the file "LICENSE" for more +# information. +# # Make sure we have enough options if [ $# != 5 -a $# != 6 ]; then diff --git a/filter/braille/filters/liblouis.defs b/filter/braille/filters/liblouis.defs index 265149662..fd46fd9a3 100644 --- a/filter/braille/filters/liblouis.defs +++ b/filter/braille/filters/liblouis.defs @@ -1,26 +1,9 @@ -// +// // Copyright (c) 2015 Samuel Thibault -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -// +// +// Licensed under Apache License v2.0. See the file "LICENSE" for more +// information. +// #include #include diff --git a/filter/braille/filters/liblouis1.defs.gen.in b/filter/braille/filters/liblouis1.defs.gen.in index 75f7cd223..e60a8a88f 100644 --- a/filter/braille/filters/liblouis1.defs.gen.in +++ b/filter/braille/filters/liblouis1.defs.gen.in @@ -1,28 +1,11 @@ #!/bin/bash -# +# # Copyright (c) 2015, 2017-2018, 2020 Samuel Thibault -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# +# +# Licensed under Apache License v2.0. See the file "LICENSE" for more +# information. +# TABLESDIR=@TABLESDIR@ diff --git a/filter/braille/filters/musicxmltobrf.in b/filter/braille/filters/musicxmltobrf.in index f498a5cf0..d41fb9d0b 100644 --- a/filter/braille/filters/musicxmltobrf.in +++ b/filter/braille/filters/musicxmltobrf.in @@ -2,27 +2,10 @@ # # Copyright (c) 2017-2018 Samuel Thibault -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# +# +# Licensed under Apache License v2.0. See the file "LICENSE" for more +# information. +# # Make sure we have enough options if [ $# != 5 -a $# != 6 ]; then diff --git a/filter/braille/filters/texttobrf.in b/filter/braille/filters/texttobrf.in index b0429d3be..832cc3e80 100755 --- a/filter/braille/filters/texttobrf.in +++ b/filter/braille/filters/texttobrf.in @@ -2,27 +2,10 @@ # # Copyright (c) 2015-2018 Samuel Thibault -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# +# +# Licensed under Apache License v2.0. See the file "LICENSE" for more +# information. +# # Make sure we have enough options if [ $# != 5 -a $# != 6 ]; then diff --git a/filter/braille/filters/vectortobrf.in b/filter/braille/filters/vectortobrf.in index feaef086b..0d35705ff 100644 --- a/filter/braille/filters/vectortobrf.in +++ b/filter/braille/filters/vectortobrf.in @@ -2,27 +2,10 @@ # # Copyright (c) 2017-2018 Samuel Thibault -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# +# +# Licensed under Apache License v2.0. See the file "LICENSE" for more +# information. +# # Make sure we have enough options if [ $# != 5 -a $# != 6 ]; then diff --git a/filter/braille/filters/vectortopdf.in b/filter/braille/filters/vectortopdf.in index 6e568c3fe..d1001edab 100644 --- a/filter/braille/filters/vectortopdf.in +++ b/filter/braille/filters/vectortopdf.in @@ -2,27 +2,10 @@ # # Copyright (c) 2017 Samuel Thibault -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# +# +# Licensed under Apache License v2.0. See the file "LICENSE" for more +# information. +# # Make sure we have enough options if [ $# != 5 -a $# != 6 ]; then diff --git a/filter/commandtoescpx.c b/filter/commandtoescpx.c index 7544c3b3e..27e042075 100644 --- a/filter/commandtoescpx.c +++ b/filter/commandtoescpx.c @@ -1,23 +1,21 @@ -/* - * Advanced EPSON ESC/P command filter for CUPS. - * - * Copyright 2007-2011 by Apple Inc. - * Copyright 1993-2005 by Easy Software Products. - * - * These coded instructions, statements, and computer programs are the - * property of Apple Inc. and are protected by Federal copyright - * law. Distribution and use rights are outlined in the file "COPYING" - * which should have been included with this file. - * - * - * Contents: - * - * main() - Main entry and command processing. - */ - -/* - * Include necessary headers... - */ +// +// Advanced EPSON ESC/P command filter for cups-filters. +// +// Copyright 2007-2011 by Apple Inc. +// Copyright 1993-2005 by Easy Software Products. +// +// Licensed under Apache License v2.0. See the file "LICENSE" for more +// information. +// +// +// Contents: +// +// main() - Main entry and command processing. +// + +// +// Include necessary headers... +// #include #include @@ -28,40 +26,40 @@ #include -/* - * 'main()' - Main entry and processing of driver. - */ +// +// 'main()' - Main entry and processing of driver. +// -int /* O - Exit status */ -main(int argc, /* I - Number of command-line arguments */ - char *argv[]) /* I - Command-line arguments */ +int // O - Exit status +main(int argc, // I - Number of command-line arguments + char *argv[]) // I - Command-line arguments { - FILE *fp; /* Command file */ - char line[1024], /* Line from file */ - *lineptr; /* Pointer into line */ - int feedpage; /* Feed the page */ - ppd_file_t *ppd; /* PPD file */ + FILE *fp; // Command file + char line[1024], // Line from file + *lineptr; // Pointer into line + int feedpage; // Feed the page + ppd_file_t *ppd; // PPD file - /* - * Check for valid arguments... - */ + // + // Check for valid arguments... + // if (argc < 6 || argc > 7) { - /* - * We don't have the correct number of arguments; write an error message - * and return. - */ + // + // We don't have the correct number of arguments; write an error message + // and return. + // fprintf(stderr, "Usage: %s job-id user title copies options [file]\n", argv[0]); return (1); } - /* - * Open the PPD file... - */ + // + // Open the PPD file... + // if ((ppd = ppdOpenFile(getenv("PPD"))) == NULL) { @@ -69,9 +67,9 @@ main(int argc, /* I - Number of command-line arguments */ return (1); } - /* - * Open the command file as needed... - */ + // + // Open the command file as needed... + // if (argc == 7) { @@ -84,71 +82,71 @@ main(int argc, /* I - Number of command-line arguments */ else fp = stdin; - /* - * Some EPSON printers need an additional command issued at the - * beginning of each job to exit from USB "packet" mode... - */ + // + // Some EPSON printers need an additional command issued at the + // beginning of each job to exit from USB "packet" mode... + // if (ppd->model_number & ESCP_USB) cfWritePrintData("\000\000\000\033\001@EJL 1284.4\n@EJL \n\033@", 29); - /* - * Reset the printer... - */ + // + // Reset the printer... + // cfWritePrintData("\033@", 2); - /* - * Enter remote mode... - */ + // + // Enter remote mode... + // cfWritePrintData("\033(R\010\000\000REMOTE1", 13); feedpage = 0; - /* - * Read the commands from the file and send the appropriate commands... - */ + // + // Read the commands from the file and send the appropriate commands... + // while (fgets(line, sizeof(line), fp) != NULL) { - /* - * Drop trailing newline... - */ + // + // Drop trailing newline... + // lineptr = line + strlen(line) - 1; if (*lineptr == '\n') *lineptr = '\0'; - /* - * Skip leading whitespace... - */ + // + // Skip leading whitespace... + // for (lineptr = line; isspace(*lineptr); lineptr ++); - /* - * Skip comments and blank lines... - */ + // + // Skip comments and blank lines... + // if (*lineptr == '#' || !*lineptr) continue; - /* - * Parse the command... - */ + // + // Parse the command... + // if (strncasecmp(lineptr, "Clean", 5) == 0) { - /* - * Clean heads... - */ + // + // Clean heads... + // cfWritePrintData("CH\002\000\000\000", 6); } else if (strncasecmp(lineptr, "PrintAlignmentPage", 18) == 0) { - /* - * Print alignment page... - */ + // + // Print alignment page... + // int phase; @@ -161,9 +159,9 @@ main(int argc, /* I - Number of command-line arguments */ } else if (strncasecmp(lineptr, "PrintSelfTestPage", 17) == 0) { - /* - * Print version info and nozzle check... - */ + // + // Print version info and nozzle check... + // cfWritePrintData("VI\002\000\000\000", 6); cfWritePrintData("NC\002\000\000\000", 6); @@ -171,17 +169,17 @@ main(int argc, /* I - Number of command-line arguments */ } else if (strncasecmp(lineptr, "ReportLevels", 12) == 0) { - /* - * Report ink levels... - */ + // + // Report ink levels... + // cfWritePrintData("IQ\001\000\001", 5); } else if (strncasecmp(lineptr, "SetAlignment", 12) == 0) { - /* - * Set head alignment... - */ + // + // Set head alignment... + // int phase, x; @@ -202,15 +200,15 @@ main(int argc, /* I - Number of command-line arguments */ fprintf(stderr, "ERROR: Invalid printer command \"%s\"!\n", lineptr); } - /* - * Exit remote mode... - */ + // + // Exit remote mode... + // cfWritePrintData("\033\000\000\000", 4); - /* - * Eject the page as needed... - */ + // + // Eject the page as needed... + // if (feedpage) { @@ -221,15 +219,15 @@ main(int argc, /* I - Number of command-line arguments */ putchar(12); } - /* - * Reset the printer... - */ + // + // Reset the printer... + // cfWritePrintData("\033@", 2); - /* - * Close the command file and return... - */ + // + // Close the command file and return... + // ppdClose(ppd); @@ -238,4 +236,3 @@ main(int argc, /* I - Number of command-line arguments */ return (0); } - diff --git a/filter/commandtopclx.c b/filter/commandtopclx.c index d4a035285..b0a5d046e 100644 --- a/filter/commandtopclx.c +++ b/filter/commandtopclx.c @@ -1,23 +1,21 @@ -/* - * Advanced PCL command filter for CUPS. - * - * Copyright 2007-2011 by Apple Inc. - * Copyright 1993-2005 by Easy Software Products. - * - * These coded instructions, statements, and computer programs are the - * property of Apple Inc. and are protected by Federal copyright - * law. Distribution and use rights are outlined in the file "COPYING" - * which should have been included with this file. - * - * - * Contents: - * - * main() - Main entry and command processing. - */ - -/* - * Include necessary headers... - */ +// +// Advanced PCL command filter for cups-filters. +// +// Copyright 2007-2011 by Apple Inc. +// Copyright 1993-2005 by Easy Software Products. +// +// Licensed under Apache License v2.0. See the file "LICENSE" for more +// information. +// +// +// Contents: +// +// main() - Main entry and command processing. +// + +// +// Include necessary headers... +// #include #include @@ -28,40 +26,41 @@ #include -/* - * 'main()' - Main entry and processing of driver. - */ +// +// 'main()' - Main entry and processing of driver. +// -int /* O - Exit status */ -main(int argc, /* I - Number of command-line arguments */ - char *argv[]) /* I - Command-line arguments */ +int // O - Exit status +main(int argc, // I - Number of command-line + // arguments + char *argv[]) // I - Command-line arguments { - FILE *fp; /* Command file */ - char line[1024], /* Line from file */ - *lineptr; /* Pointer into line */ - int feedpage; /* Feed the page */ - ppd_file_t *ppd; /* PPD file */ + FILE *fp; // Command file + char line[1024], // Line from file + *lineptr; // Pointer into line + int feedpage; // Feed the page + ppd_file_t *ppd; // PPD file - /* - * Check for valid arguments... - */ + // + // Check for valid arguments... + // if (argc < 6 || argc > 7) { - /* - * We don't have the correct number of arguments; write an error message - * and return. - */ + // + // We don't have the correct number of arguments; write an error message + // and return. + // fprintf(stderr, "Usage: %s job-id user title copies options [file]\n", argv[0]); return (1); } - /* - * Open the PPD file... - */ + // + // Open the PPD file... + // if ((ppd = ppdOpenFile(getenv("PPD"))) == NULL) { @@ -69,9 +68,9 @@ main(int argc, /* I - Number of command-line arguments */ return (1); } - /* - * Open the command file as needed... - */ + // + // Open the command file as needed... + // if (argc == 7) { @@ -84,51 +83,51 @@ main(int argc, /* I - Number of command-line arguments */ else fp = stdin; - /* - * Reset the printer... - */ + // + // Reset the printer... + // cfWritePrintData("\033E", 2); - /* - * Read the commands from the file and send the appropriate commands... - */ + // + // Read the commands from the file and send the appropriate commands... + // feedpage = 0; while (fgets(line, sizeof(line), fp) != NULL) { - /* - * Drop trailing newline... - */ + // + // Drop trailing newline... + // lineptr = line + strlen(line) - 1; if (*lineptr == '\n') *lineptr = '\0'; - /* - * Skip leading whitespace... - */ + // + // Skip leading whitespace... + // for (lineptr = line; isspace(*lineptr); lineptr ++); - /* - * Skip comments and blank lines... - */ + // + // Skip comments and blank lines... + // if (*lineptr == '#' || !*lineptr) continue; - /* - * Parse the command... - */ + // + // Parse the command... + // if (strncasecmp(lineptr, "Clean", 5) == 0 && (ppd->model_number & PCL_INKJET)) { - /* - * Clean heads... - */ + // + // Clean heads... + // cfWritePrintData("\033&b16WPML \004\000\006\001\004\001\005\001" "\001\004\001\144", 22); @@ -137,9 +136,9 @@ main(int argc, /* I - Number of command-line arguments */ fprintf(stderr, "ERROR: Invalid printer command \"%s\"!\n", lineptr); } - /* - * Eject the page as needed... - */ + // + // Eject the page as needed... + // if (feedpage) { @@ -148,15 +147,15 @@ main(int argc, /* I - Number of command-line arguments */ putchar(12); } - /* - * Reset the printer... - */ + // + // Reset the printer... + // cfWritePrintData("\033E", 2); - /* - * Close the command file and return... - */ + // + // Close the command file and return... + // ppdClose(ppd); @@ -165,4 +164,3 @@ main(int argc, /* I - Number of command-line arguments */ return (0); } - diff --git a/filter/escp.h b/filter/escp.h index 0fdedcfd9..a38329695 100644 --- a/filter/escp.h +++ b/filter/escp.h @@ -1,27 +1,24 @@ -/* - * This file contains model number definitions for the CUPS unified - * ESC/P driver. - * - * Copyright 2007 by Apple Inc. - * Copyright 1997-2005 by Easy Software Products. - * - * These coded instructions, statements, and computer programs are the - * property of Apple Inc. and are protected by Federal copyright - * law. Distribution and use rights are outlined in the file "COPYING" - * which should have been included with this file. - */ +// +// This file contains model number definitions for the unified +// ESC/P driver of cups-filters. +// +// Copyright 2007 by Apple Inc. +// Copyright 1997-2005 by Easy Software Products. +// +// Licensed under Apache License v2.0. See the file "LICENSE" for more +// information. +// -/* General ESC/P Support */ -#define ESCP_DOTMATRIX 0x1 /* Dot matrix printer? */ -#define ESCP_MICROWEAVE 0x2 /* Use microweave command? */ -#define ESCP_STAGGER 0x4 /* Are color jets staggered? */ -#define ESCP_ESCK 0x8 /* Use print mode command?*/ -#define ESCP_EXT_UNITS 0x10 /* Use extended unit commands? */ -#define ESCP_EXT_MARGINS 0x20 /* Use extended margin command */ -#define ESCP_USB 0x40 /* Send USB packet mode escape? */ -#define ESCP_PAGE_SIZE 0x80 /* Use page size command */ -#define ESCP_RASTER_ESCI 0x100 /* Use ESC i graphics command */ - -/* Remote mode support */ -#define ESCP_REMOTE 0x1000 /* Use remote mode commands? */ +// General ESC/P Support +#define ESCP_DOTMATRIX 0x1 // Dot matrix printer? +#define ESCP_MICROWEAVE 0x2 // Use microweave command? +#define ESCP_STAGGER 0x4 // Are color jets staggered? +#define ESCP_ESCK 0x8 // Use print mode command? +#define ESCP_EXT_UNITS 0x10 // Use extended unit commands? +#define ESCP_EXT_MARGINS 0x20 // Use extended margin command +#define ESCP_USB 0x40 // Send USB packet mode escape? +#define ESCP_PAGE_SIZE 0x80 // Use page size command +#define ESCP_RASTER_ESCI 0x100 // Use ESC i graphics command +// Remote mode support +#define ESCP_REMOTE 0x1000 // Use remote mode commands? diff --git a/filter/gstopdf.c b/filter/gstopdf.c index ce6d63588..22309a2f8 100644 --- a/filter/gstopdf.c +++ b/filter/gstopdf.c @@ -1,48 +1,54 @@ -/* - * PostScript to PDF filter (based on cfFilterGhostscript() filter function). - */ - - -/* - * Include necessary headers... - */ +// +// Legacy CUPS filter wrapper for cfFilterGhostscript() for cups-filters. +// +// PostScript to PDF filter. +// +// Copyright © 2020-2022 by OpenPrinting. +// +// Licensed under Apache License v2.0. See the file "LICENSE" for more +// information. +// + +// +// Include necessary headers... +// #include #include #include -/* - * Local globals... - */ +// +// Local globals... +// -static int JobCanceled = 0; /* Set to 1 on SIGTERM */ +static int JobCanceled = 0; // Set to 1 on SIGTERM -/* - * Local functions... - */ +// +// Local functions... +// static void cancel_job(int sig); -/* - * 'main()' - Main entry. - */ +// +// 'main()' - Main entry. +// -int /* O - Exit status */ -main(int argc, /* I - Number of command-line args */ - char *argv[]) /* I - Command-line arguments */ +int // O - Exit status +main(int argc, // I - Number of command-line args + char *argv[]) // I - Command-line arguments { int ret; #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) - struct sigaction action; /* Actions for POSIX signals */ -#endif /* HAVE_SIGACTION && !HAVE_SIGSET */ + struct sigaction action; // Actions for POSIX signals +#endif // HAVE_SIGACTION && !HAVE_SIGSET - /* - * Register a signal handler to cleanly cancel a job. - */ + // + // Register a signal handler to cleanly cancel a job. + // -#ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */ +#ifdef HAVE_SIGSET // Use System V signals over POSIX to avoid bugs sigset(SIGTERM, cancel_job); #elif defined(HAVE_SIGACTION) memset(&action, 0, sizeof(action)); @@ -52,11 +58,11 @@ main(int argc, /* I - Number of command-line args */ sigaction(SIGTERM, &action, NULL); #else signal(SIGTERM, cancel_job); -#endif /* HAVE_SIGSET */ +#endif // HAVE_SIGSET - /* - * Fire up the ppdFilterGhostscript() filter function. - */ + // + // Fire up the cfFilterGhostscript() filter function. + // cf_filter_out_format_t outformat = CF_FILTER_OUT_FORMAT_PDF; ret = ppdFilterCUPSWrapper(argc, argv, cfFilterGhostscript, &outformat, @@ -68,12 +74,13 @@ main(int argc, /* I - Number of command-line args */ return (ret); } -/* - * 'cancel_job()' - Flag the job as canceled. - */ + +// +// 'cancel_job()' - Flag the job as canceled. +// static void -cancel_job(int sig) /* I - Signal number (unused) */ +cancel_job(int sig) // I - Signal number (unused) { (void)sig; diff --git a/filter/gstopxl.c b/filter/gstopxl.c index 94954da91..ccafd2265 100644 --- a/filter/gstopxl.c +++ b/filter/gstopxl.c @@ -1,49 +1,55 @@ -/* - * PostScript/PDF to PCL-XL filter (based on cfFilterGhostscript() filter - * function). - */ - - -/* - * Include necessary headers... - */ +// +// Legacy CUPS filter wrapper for cfFilterGhostscript() for cups-filters. +// +// PostScript/PDF to PCL-XL filter. +// +// Copyright © 2020-2022 by OpenPrinting. +// +// Licensed under Apache License v2.0. See the file "LICENSE" for more +// information. +// + +// +// Include necessary headers... +// #include #include #include -/* - * Local globals... - */ +// +// Local globals... +// + +static int JobCanceled = 0; // Set to 1 on SIGTERM -static int JobCanceled = 0; /* Set to 1 on SIGTERM */ -/* - * Local functions... - */ +// +// Local functions... +// static void cancel_job(int sig); -/* - * 'main()' - Main entry. - */ +// +// 'main()' - Main entry. +// -int /* O - Exit status */ -main(int argc, /* I - Number of command-line args */ - char *argv[]) /* I - Command-line arguments */ +int // O - Exit status +main(int argc, // I - Number of command-line args + char *argv[]) // I - Command-line arguments { int ret; #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) - struct sigaction action; /* Actions for POSIX signals */ -#endif /* HAVE_SIGACTION && !HAVE_SIGSET */ + struct sigaction action; // Actions for POSIX signals +#endif // HAVE_SIGACTION && !HAVE_SIGSET - /* - * Register a signal handler to cleanly cancel a job. - */ + // + // Register a signal handler to cleanly cancel a job. + // -#ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */ +#ifdef HAVE_SIGSET // Use System V signals over POSIX to avoid bugs sigset(SIGTERM, cancel_job); #elif defined(HAVE_SIGACTION) memset(&action, 0, sizeof(action)); @@ -53,11 +59,11 @@ main(int argc, /* I - Number of command-line args */ sigaction(SIGTERM, &action, NULL); #else signal(SIGTERM, cancel_job); -#endif /* HAVE_SIGSET */ +#endif // HAVE_SIGSET - /* - * Fire up the ppdFilterGhostscript() filter function. - */ + // + // Fire up the cfFilterGhostscript() filter function. + // cf_filter_out_format_t outformat = CF_FILTER_OUT_FORMAT_PXL; ret = ppdFilterCUPSWrapper(argc, argv, cfFilterGhostscript, &outformat, @@ -69,12 +75,12 @@ main(int argc, /* I - Number of command-line args */ return (ret); } -/* - * 'cancel_job()' - Flag the job as canceled. - */ +// +// 'cancel_job()' - Flag the job as canceled. +// static void -cancel_job(int sig) /* I - Signal number (unused) */ +cancel_job(int sig) // I - Signal number (unused) { (void)sig; diff --git a/filter/gstoraster.c b/filter/gstoraster.c index 0aa5e7066..9d79fac50 100644 --- a/filter/gstoraster.c +++ b/filter/gstoraster.c @@ -1,49 +1,55 @@ -/* - * PostScript/PDF to Raster filter (based on cfFilterGhostscript() filter - * function). - */ - - -/* - * Include necessary headers... - */ +// +// Legacy CUPS filter wrapper for cfFilterGhostscript() for cups-filters. +// +// PostScript/PDF to Raster filter. +// +// Copyright © 2020-2022 by OpenPrinting. +// +// Licensed under Apache License v2.0. See the file "LICENSE" for more +// information. +// + +// +// Include necessary headers... +// #include #include #include -/* - * Local globals... - */ +// +// Local globals... +// + +static int JobCanceled = 0; // Set to 1 on SIGTERM -static int JobCanceled = 0; /* Set to 1 on SIGTERM */ -/* - * Local functions... - */ +// +// Local functions... +// static void cancel_job(int sig); -/* - * 'main()' - Main entry. - */ +// +// 'main()' - Main entry. +// -int /* O - Exit status */ -main(int argc, /* I - Number of command-line args */ - char *argv[]) /* I - Command-line arguments */ +int // O - Exit status +main(int argc, // I - Number of command-line args + char *argv[]) // I - Command-line arguments { int ret; #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) - struct sigaction action; /* Actions for POSIX signals */ -#endif /* HAVE_SIGACTION && !HAVE_SIGSET */ + struct sigaction action; // Actions for POSIX signals +#endif // HAVE_SIGACTION && !HAVE_SIGSET - /* - * Register a signal handler to cleanly cancel a job. - */ + // + // Register a signal handler to cleanly cancel a job. + // -#ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */ +#ifdef HAVE_SIGSET // Use System V signals over POSIX to avoid bugs sigset(SIGTERM, cancel_job); #elif defined(HAVE_SIGACTION) memset(&action, 0, sizeof(action)); @@ -53,11 +59,11 @@ main(int argc, /* I - Number of command-line args */ sigaction(SIGTERM, &action, NULL); #else signal(SIGTERM, cancel_job); -#endif /* HAVE_SIGSET */ +#endif // HAVE_SIGSET - /* - * Fire up the ppdFilterGhostscript() filter function. - */ + // + // Fire up the cfFilterGhostscript() filter function. + // ret = ppdFilterCUPSWrapper(argc, argv, cfFilterGhostscript, NULL, &JobCanceled); @@ -68,12 +74,12 @@ main(int argc, /* I - Number of command-line args */ return (ret); } -/* - * 'cancel_job()' - Flag the job as canceled. - */ +// +// 'cancel_job()' - Flag the job as canceled. +// static void -cancel_job(int sig) /* I - Signal number (unused) */ +cancel_job(int sig) // I - Signal number (unused) { (void)sig; diff --git a/filter/imagetopdf.c b/filter/imagetopdf.c index 88b3d3aea..747101e85 100644 --- a/filter/imagetopdf.c +++ b/filter/imagetopdf.c @@ -1,55 +1,55 @@ -/* - * Image-to-PDF filter for CUPS (based on cfFilterImageToPDF() filter function). - * - * Copyright © 2020 by Till Kamppeter - * Copyright © 2007-2018 by Apple Inc. - * Copyright © 1993-2007 by Easy Software Products. - * - * Licensed under Apache License v2.0. See the file "LICENSE" for more - * information. - */ - -/* - * Include necessary headers... - */ +// +// Legacy CUPS filter wrapper for ppdFilterImageToPDF() for cups-filters. +// +// Copyright © 2020 by Till Kamppeter +// Copyright © 2007-2018 by Apple Inc. +// Copyright © 1993-2007 by Easy Software Products. +// +// Licensed under Apache License v2.0. See the file "LICENSE" for more +// information. +// + +// +// Include necessary headers... +// #include #include #include -/* - * Local globals... - */ +// +// Local globals... +// -static int JobCanceled = 0;/* Set to 1 on SIGTERM */ +static int JobCanceled = 0;// Set to 1 on SIGTERM -/* - * Local functions... - */ +// +// Local functions... +// static void cancel_job(int sig); -/* - * 'main()' - Main entry. - */ +// +// 'main()' - Main entry. +// -int /* O - Exit status */ -main(int argc, /* I - Number of command-line args */ - char *argv[]) /* I - Command-line arguments */ +int // O - Exit status +main(int argc, // I - Number of command-line args + char *argv[]) // I - Command-line arguments { int ret; #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) - struct sigaction action; /* Actions for POSIX signals */ -#endif /* HAVE_SIGACTION && !HAVE_SIGSET */ + struct sigaction action; // Actions for POSIX signals +#endif // HAVE_SIGACTION && !HAVE_SIGSET - /* - * Register a signal handler to cleanly cancel a job. - */ + // + // Register a signal handler to cleanly cancel a job. + // -#ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */ +#ifdef HAVE_SIGSET // Use System V signals over POSIX to avoid bugs sigset(SIGTERM, cancel_job); #elif defined(HAVE_SIGACTION) memset(&action, 0, sizeof(action)); @@ -59,11 +59,11 @@ main(int argc, /* I - Number of command-line args */ sigaction(SIGTERM, &action, NULL); #else signal(SIGTERM, cancel_job); -#endif /* HAVE_SIGSET */ +#endif // HAVE_SIGSET - /* - * Fire up the ppdFilterImageToPDF() filter function - */ + // + // Fire up the ppdFilterImageToPDF() filter function + // ret = ppdFilterCUPSWrapper(argc, argv, ppdFilterImageToPDF, NULL, &JobCanceled); @@ -75,15 +75,14 @@ main(int argc, /* I - Number of command-line args */ } -/* - * 'cancel_job()' - Flag the job as canceled. - */ +// +// 'cancel_job()' - Flag the job as canceled. +// static void -cancel_job(int sig) /* I - Signal number (unused) */ +cancel_job(int sig) // I - Signal number (unused) { (void)sig; JobCanceled = 1; } - diff --git a/filter/imagetops.c b/filter/imagetops.c index 9ad54b12a..f3ca6fb22 100644 --- a/filter/imagetops.c +++ b/filter/imagetops.c @@ -1,55 +1,55 @@ -/* - * Image-to-PostScript filter for CUPS (based on cfFilterImageToPS() filter function) - * - * Copyright © 2020 by Till Kamppeter - * Copyright © 2007-2018 by Apple Inc. - * Copyright © 1993-2007 by Easy Software Products. - * - * Licensed under Apache License v2.0. See the file "LICENSE" for more - * information. - */ - -/* - * Include necessary headers... - */ +// +// Legacy CUPS filter wrapper for ppdFilterImageToPS() for cups-filters. +// +// Copyright © 2020 by Till Kamppeter +// Copyright © 2007-2018 by Apple Inc. +// Copyright © 1993-2007 by Easy Software Products. +// +// Licensed under Apache License v2.0. See the file "LICENSE" for more +// information. +// + +// +// Include necessary headers... +// #include #include #include -/* - * Local globals... - */ +// +// Local globals... +// -static int JobCanceled = 0;/* Set to 1 on SIGTERM */ +static int JobCanceled = 0; // Set to 1 on SIGTERM -/* - * Local functions... - */ +// +// Local functions... +// static void cancel_job(int sig); -/* - * 'main()' - Main entry. - */ +// +// 'main()' - Main entry. +// -int /* O - Exit status */ -main(int argc, /* I - Number of command-line args */ - char *argv[]) /* I - Command-line arguments */ +int // O - Exit status +main(int argc, // I - Number of command-line args + char *argv[]) // I - Command-line arguments { int ret; #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) - struct sigaction action; /* Actions for POSIX signals */ -#endif /* HAVE_SIGACTION && !HAVE_SIGSET */ + struct sigaction action; // Actions for POSIX signals +#endif // HAVE_SIGACTION && !HAVE_SIGSET - /* - * Register a signal handler to cleanly cancel a job. - */ + // + // Register a signal handler to cleanly cancel a job. + // -#ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */ +#ifdef HAVE_SIGSET // Use System V signals over POSIX to avoid bugs sigset(SIGTERM, cancel_job); #elif defined(HAVE_SIGACTION) memset(&action, 0, sizeof(action)); @@ -59,13 +59,14 @@ main(int argc, /* I - Number of command-line args */ sigaction(SIGTERM, &action, NULL); #else signal(SIGTERM, cancel_job); -#endif /* HAVE_SIGSET */ +#endif // HAVE_SIGSET - /* - * Fire up the cfFilterImageToPS() filter function - */ + // + // Fire up the ppdFilterImageToPS() filter function + // - ret = ppdFilterCUPSWrapper(argc, argv, ppdFilterImageToPS, NULL, &JobCanceled); + ret = ppdFilterCUPSWrapper(argc, argv, ppdFilterImageToPS, NULL, + &JobCanceled); if (ret) fprintf(stderr, "ERROR: imagetops filter function failed.\n"); @@ -74,15 +75,14 @@ main(int argc, /* I - Number of command-line args */ } -/* - * 'cancel_job()' - Flag the job as canceled. - */ +// +// 'cancel_job()' - Flag the job as canceled. +// static void -cancel_job(int sig) /* I - Signal number (unused) */ +cancel_job(int sig) // I - Signal number (unused) { (void)sig; JobCanceled = 1; } - diff --git a/filter/imagetoraster.c b/filter/imagetoraster.c index 86c7b8c54..5d1dfc1a1 100644 --- a/filter/imagetoraster.c +++ b/filter/imagetoraster.c @@ -1,55 +1,55 @@ -/* - * Image-to-Raster filter for CUPS (based on cfFilterImageToRaster() filter function). - * - * Copyright © 2020 by Till Kamppeter - * Copyright © 2007-2018 by Apple Inc. - * Copyright © 1993-2007 by Easy Software Products. - * - * Licensed under Apache License v2.0. See the file "LICENSE" for more - * information. - */ - -/* - * Include necessary headers... - */ +// +// Legacy CUPS filter wrapper for cfFilterImageToRaster() for cups-filters. +// +// Copyright © 2020 by Till Kamppeter +// Copyright © 2007-2018 by Apple Inc. +// Copyright © 1993-2007 by Easy Software Products. +// +// Licensed under Apache License v2.0. See the file "LICENSE" for more +// information. +// + +// +// Include necessary headers... +// #include #include #include -/* - * Local globals... - */ +// +// Local globals... +// -static int JobCanceled = 0;/* Set to 1 on SIGTERM */ +static int JobCanceled = 0;// Set to 1 on SIGTERM -/* - * Local functions... - */ +// +// Local functions... +// static void cancel_job(int sig); -/* - * 'main()' - Main entry. - */ +// +// 'main()' - Main entry. +// -int /* O - Exit status */ -main(int argc, /* I - Number of command-line args */ - char *argv[]) /* I - Command-line arguments */ +int // O - Exit status +main(int argc, // I - Number of command-line args + char *argv[]) // I - Command-line arguments { int ret; #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) - struct sigaction action; /* Actions for POSIX signals */ -#endif /* HAVE_SIGACTION && !HAVE_SIGSET */ + struct sigaction action; // Actions for POSIX signals +#endif // HAVE_SIGACTION && !HAVE_SIGSET - /* - * Register a signal handler to cleanly cancel a job. - */ + // + // Register a signal handler to cleanly cancel a job. + // -#ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */ +#ifdef HAVE_SIGSET // Use System V signals over POSIX to avoid bugs sigset(SIGTERM, cancel_job); #elif defined(HAVE_SIGACTION) memset(&action, 0, sizeof(action)); @@ -59,13 +59,14 @@ main(int argc, /* I - Number of command-line args */ sigaction(SIGTERM, &action, NULL); #else signal(SIGTERM, cancel_job); -#endif /* HAVE_SIGSET */ +#endif // HAVE_SIGSET - /* - * Fire up the ppdFilterImageToRaster() filter function - */ + // + // Fire up the cfFilterImageToRaster() filter function + // - ret = ppdFilterCUPSWrapper(argc, argv, cfFilterImageToRaster, NULL, &JobCanceled); + ret = ppdFilterCUPSWrapper(argc, argv, cfFilterImageToRaster, NULL, + &JobCanceled); if (ret) fprintf(stderr, "ERROR: imagetoraster filter function failed.\n"); @@ -74,15 +75,14 @@ main(int argc, /* I - Number of command-line args */ } -/* - * 'cancel_job()' - Flag the job as canceled. - */ +// +// 'cancel_job()' - Flag the job as canceled. +// static void -cancel_job(int sig) /* I - Signal number (unused) */ +cancel_job(int sig) // I - Signal number (unused) { (void)sig; JobCanceled = 1; } - diff --git a/filter/mupdftopwg.c b/filter/mupdftopwg.c index eeac5f19f..df8188dbf 100644 --- a/filter/mupdftopwg.c +++ b/filter/mupdftopwg.c @@ -1,44 +1,54 @@ -/* - * Include necessary headers... - */ +// +// Legacy CUPS filter wrapper for cfFilterMuPDFToPWG() for cups-filters. +// +// Copyright © 2020-2022 by OpenPrinting. +// +// Licensed under Apache License v2.0. See the file "LICENSE" for more +// information. +// + +// +// Include necessary headers... +// #include #include #include -/* - * Local globals... - */ -static int JobCanceled = 0;/* Set to 1 on SIGTERM */ +// +// Local globals... +// +static int JobCanceled = 0;// Set to 1 on SIGTERM -/* - * Local functions... - */ + +// +// Local functions... +// static void cancel_job(int sig); -/* - * 'main()' - Main entry and processing of driver. - */ +// +// 'main()' - Main entry and processing of driver. +// -int /* O - Exit status */ -main(int argc, /* I - Number of command-line arguments */ +int // O - Exit status +main(int argc, // I - Number of command-line arguments char *argv[], - char *envp[]) /* I - Command-line arguments */ + char *envp[]) // I - Command-line arguments { int ret; #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) - struct sigaction action; /* Actions for POSIX signals */ -#endif /* HAVE_SIGACTION && !HAVE_SIGSET */ + struct sigaction action; // Actions for POSIX signals +#endif // HAVE_SIGACTION && !HAVE_SIGSET - /* - * Register a signal handler to cleanly cancel a job. - */ + // + // Register a signal handler to cleanly cancel a job. + // -#ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */ +#ifdef HAVE_SIGSET // Use System V signals over POSIX to avoid bugs sigset(SIGTERM, cancel_job); #elif defined(HAVE_SIGACTION) memset(&action, 0, sizeof(action)); @@ -48,13 +58,14 @@ main(int argc, /* I - Number of command-line arguments */ sigaction(SIGTERM, &action, NULL); #else signal(SIGTERM, cancel_job); -#endif /* HAVE_SIGSET */ +#endif // HAVE_SIGSET - /* - * Fire up the ppdFilterMuPDFToPWG() filter function - */ + // + // Fire up the cfFilterMuPDFToPWG() filter function + // - ret = ppdFilterCUPSWrapper(argc, argv, cfFilterMuPDFToPWG, NULL, &JobCanceled); + ret = ppdFilterCUPSWrapper(argc, argv, cfFilterMuPDFToPWG, NULL, + &JobCanceled); if (ret) fprintf(stderr, "ERROR: mupdftopwg filter function failed.\n"); @@ -63,12 +74,12 @@ main(int argc, /* I - Number of command-line arguments */ } -/* - * 'cancel_job()' - Flag the job as canceled. - */ +// +// 'cancel_job()' - Flag the job as canceled. +// static void -cancel_job(int sig) /* I - Signal number (unused) */ +cancel_job(int sig) // I - Signal number (unused) { (void)sig; diff --git a/filter/pcl-common.c b/filter/pcl-common.c index fd0ae934a..dc162b535 100644 --- a/filter/pcl-common.c +++ b/filter/pcl-common.c @@ -1,24 +1,22 @@ -/* - * Common PCL functions for CUPS. - * - * Copyright 2007 by Apple Inc. - * Copyright 1993-2005 by Easy Software Products - * - * These coded instructions, statements, and computer programs are the - * property of Apple Inc. and are protected by Federal copyright - * law. Distribution and use rights are outlined in the file "COPYING" - * which should have been included with this file. - * - * Contents: - * - * pcl_set_media_size() - Set media size using the page size command. - * pjl_write() - Write a PJL command string, performing - * substitutions as needed. - */ - -/* - * Include necessary headers... - */ +// +// Common PCL functions for cups-filters. +// +// Copyright 2007 by Apple Inc. +// Copyright 1993-2005 by Easy Software Products +// +// Licensed under Apache License v2.0. See the file "LICENSE" for more +// information. +// +// Contents: +// +// pcl_set_media_size() - Set media size using the page size command. +// pjl_write() - Write a PJL command string, performing +// substitutions as needed. +// + +// +// Include necessary headers... +// #include #include @@ -27,14 +25,14 @@ #include -/* - * 'pcl_set_media_size()' - Set media size using the page size command. - */ +// +// 'pcl_set_media_size()' - Set media size using the page size command. +// void -pcl_set_media_size(ppd_file_t *ppd, /* I - PPD file */ - float width, /* I - Width of page */ - float length) /* I - Length of page */ +pcl_set_media_size(ppd_file_t *ppd, // I - PPD file + float width, // I - Width of page + float length) // I - Length of page { float l; int l_int; @@ -47,169 +45,170 @@ pcl_set_media_size(ppd_file_t *ppd, /* I - PPD file */ fprintf (stderr, "DEBUG: Width: %f Length: %f Long Edge: %f\n", width, length, l); - printf("\033&l0O"); /* Set portrait orientation */ + printf("\033&l0O"); // Set portrait orientation if (!ppd || ppd->model_number & PCL_PAPER_SIZE) { - if (l_int >= 418 && l_int <= 420) /* Postcard */ - printf("\033&l71A"); /* Set page size */ - else if (l_int >= 539 && l_int <= 541) /* Monarch Envelope */ - printf("\033&l80A"); /* Set page size */ - else if (l_int >= 566 && l_int <= 568) /* Double Postcard */ - printf("\033&l72A"); /* Set page size */ - else if (l_int >= 594 && l_int <= 596) /* A5 */ - printf("\033&l25A"); /* Set page size */ - else if (l_int >= 611 && l_int <= 613) /* Statement */ - printf("\033&l5A"); /* Set page size */ - else if (l_int >= 623 && l_int <= 625) /* DL Envelope */ - printf("\033&l90A"); /* Set page size */ - else if (l_int >= 648 && l_int <= 650) /* C5 Envelope */ - printf("\033&l91A"); /* Set page size */ - else if (l_int >= 683 && l_int <= 685) /* COM-10 Envelope */ - printf("\033&l81A"); /* Set page size */ - else if (l_int >= 708 && l_int <= 710) /* B5 Envelope */ - printf("\033&l100A"); /* Set page size */ - else if (l_int >= 728 && l_int <= 730) /* B5 */ - printf("\033&l45A"); /* Set page size */ - else if (l_int >= 755 && l_int <= 757) /* Executive */ - printf("\033&l1A"); /* Set page size */ - else if (l_int >= 791 && l_int <= 793) /* Letter */ - printf("\033&l2A"); /* Set page size */ - else if (l_int >= 841 && l_int <= 843) /* A4 */ - printf("\033&l26A"); /* Set page size */ - else if (l_int >= 935 && l_int <= 937) /* Foolscap */ - printf("\033&l23A"); /* Set page size */ - else if (l_int >= 1007 && l_int <= 1009) /* Legal */ - printf("\033&l3A"); /* Set page size */ - else if (l_int >= 1031 && l_int <= 1033) /* B4 */ - printf("\033&l46A"); /* Set page size */ - else if (l_int >= 1190 && l_int <= 1192) /* A3 */ - printf("\033&l27A"); /* Set page size */ - else if (l_int >= 1223 && l_int <= 1225) /* Tabloid */ - printf("\033&l6A"); /* Set page size */ + if (l_int >= 418 && l_int <= 420) // Postcard + printf("\033&l71A"); // Set page size + else if (l_int >= 539 && l_int <= 541) // Monarch Envelope + printf("\033&l80A"); // Set page size + else if (l_int >= 566 && l_int <= 568) // Double Postcard + printf("\033&l72A"); // Set page size + else if (l_int >= 594 && l_int <= 596) // A5 + printf("\033&l25A"); // Set page size + else if (l_int >= 611 && l_int <= 613) // Statement + printf("\033&l5A"); // Set page size + else if (l_int >= 623 && l_int <= 625) // DL Envelope + printf("\033&l90A"); // Set page size + else if (l_int >= 648 && l_int <= 650) // C5 Envelope + printf("\033&l91A"); // Set page size + else if (l_int >= 683 && l_int <= 685) // COM-10 Envelope + printf("\033&l81A"); // Set page size + else if (l_int >= 708 && l_int <= 710) // B5 Envelope + printf("\033&l100A"); // Set page size + else if (l_int >= 728 && l_int <= 730) // B5 + printf("\033&l45A"); // Set page size + else if (l_int >= 755 && l_int <= 757) // Executive + printf("\033&l1A"); // Set page size + else if (l_int >= 791 && l_int <= 793) // Letter + printf("\033&l2A"); // Set page size + else if (l_int >= 841 && l_int <= 843) // A4 + printf("\033&l26A"); // Set page size + else if (l_int >= 935 && l_int <= 937) // Foolscap + printf("\033&l23A"); // Set page size + else if (l_int >= 1007 && l_int <= 1009) // Legal + printf("\033&l3A"); // Set page size + else if (l_int >= 1031 && l_int <= 1033) // B4 + printf("\033&l46A"); // Set page size + else if (l_int >= 1190 && l_int <= 1192) // A3 + printf("\033&l27A"); // Set page size + else if (l_int >= 1223 && l_int <= 1225) // Tabloid + printf("\033&l6A"); // Set page size else { - printf("\033&l101A"); /* Set page size */ - printf("\033&l6D\033&k12H"); /* Set 6 LPI, 10 CPI */ - printf("\033&l%.2fP", l / 12.0); /* Set page length */ - printf("\033&l%.0fF", l / 12.0); /* Set text length to page */ + printf("\033&l101A"); // Set page size + printf("\033&l6D\033&k12H"); // Set 6 LPI, 10 CPI + printf("\033&l%.2fP", l / 12.0); // Set page length + printf("\033&l%.0fF", l / 12.0); // Set text length to page } #if 0 switch ((int)(l + 0.5f)) { - case 419 : /* Postcard */ - printf("\033&l71A"); /* Set page size */ + case 419 : // Postcard + printf("\033&l71A"); // Set page size break; - case 540 : /* Monarch Envelope */ - printf("\033&l80A"); /* Set page size */ + case 540 : // Monarch Envelope + printf("\033&l80A"); // Set page size break; - case 567 : /* Double Postcard */ - printf("\033&l72A"); /* Set page size */ + case 567 : // Double Postcard + printf("\033&l72A"); // Set page size break; - case 595 : /* A5 */ - printf("\033&l25A"); /* Set page size */ + case 595 : // A5 + printf("\033&l25A"); // Set page size break; - case 612 : /* Statement */ - printf("\033&l5A"); /* Set page size */ + case 612 : // Statement + printf("\033&l5A"); // Set page size break; - case 624 : /* DL Envelope */ - printf("\033&l90A"); /* Set page size */ + case 624 : // DL Envelope + printf("\033&l90A"); // Set page size break; - case 649 : /* C5 Envelope */ - printf("\033&l91A"); /* Set page size */ + case 649 : // C5 Envelope + printf("\033&l91A"); // Set page size break; - case 684 : /* COM-10 Envelope */ - printf("\033&l81A"); /* Set page size */ + case 684 : // COM-10 Envelope + printf("\033&l81A"); // Set page size break; - case 709 : /* B5 Envelope */ - printf("\033&l100A"); /* Set page size */ + case 709 : // B5 Envelope + printf("\033&l100A"); // Set page size break; - case 729 : /* B5 */ - printf("\033&l45A"); /* Set page size */ + case 729 : // B5 + printf("\033&l45A"); // Set page size break; - case 756 : /* Executive */ - printf("\033&l1A"); /* Set page size */ + case 756 : // Executive + printf("\033&l1A"); // Set page size break; - case 792 : /* Letter */ - printf("\033&l2A"); /* Set page size */ + case 792 : // Letter + printf("\033&l2A"); // Set page size break; - case 842 : /* A4 */ - printf("\033&l26A"); /* Set page size */ + case 842 : // A4 + printf("\033&l26A"); // Set page size break; - case 936 : /* Foolscap */ - printf("\033&l23A"); /* Set page size */ + case 936 : // Foolscap + printf("\033&l23A"); // Set page size break; - case 1008 : /* Legal */ - printf("\033&l3A"); /* Set page size */ + case 1008 : // Legal + printf("\033&l3A"); // Set page size break; - case 1032 : /* B4 */ - printf("\033&l46A"); /* Set page size */ + case 1032 : // B4 + printf("\033&l46A"); // Set page size break; - case 1191 : /* A3 */ - printf("\033&l27A"); /* Set page size */ + case 1191 : // A3 + printf("\033&l27A"); // Set page size break; - case 1224 : /* Tabloid */ - printf("\033&l6A"); /* Set page size */ + case 1224 : // Tabloid + printf("\033&l6A"); // Set page size break; default : - printf("\033&l101A"); /* Set page size */ - printf("\033&l6D\033&k12H"); /* Set 6 LPI, 10 CPI */ + printf("\033&l101A"); // Set page size + printf("\033&l6D\033&k12H"); // Set 6 LPI, 10 CPI printf("\033&l%.2fP", l / 12.0); - /* Set page length */ + // Set page length printf("\033&l%.0fF", l / 12.0); - /* Set text length to page */ + // Set text length to page break; } #endif } else { - printf("\033&l6D\033&k12H"); /* Set 6 LPI, 10 CPI */ + printf("\033&l6D\033&k12H"); // Set 6 LPI, 10 CPI printf("\033&l%.2fP", l / 12.0); - /* Set page length */ + // Set page length printf("\033&l%.0fF", l / 12.0); - /* Set text length to page */ + // Set text length to page } - printf("\033&l0L"); /* Turn off perforation skip */ - printf("\033&l0E"); /* Reset top margin to 0 */ + printf("\033&l0L"); // Turn off perforation skip + printf("\033&l0E"); // Reset top margin to 0 } -/* - * 'pjl_write()' - Write a PJL command string, performing substitutions as needed. - */ +// +// 'pjl_write()' - Write a PJL command string, performing substitutions as +// needed. +// void -pjl_write(const char *format, /* I - Format string */ - const char *value, /* I - Value for %s */ - int job_id, /* I - Job ID */ - const char *user, /* I - Username */ - const char *title, /* I - Title */ - int num_options, /* I - Number of options */ - cups_option_t *options) /* I - Options */ +pjl_write(const char *format, // I - Format string + const char *value, // I - Value for %s + int job_id, // I - Job ID + const char *user, // I - Username + const char *title, // I - Title + int num_options, // I - Number of options + cups_option_t *options) // I - Options { - const char *optval; /* Option value */ - char match[255], /* Match string */ - *mptr; /* Pointer into match string */ + const char *optval; // Option value + char match[255], // Match string + *mptr; // Pointer into match string if (!format) @@ -219,55 +218,55 @@ pjl_write(const char *format, /* I - Format string */ { if (*format == '%') { - /* - * Perform substitution... - */ + // + // Perform substitution... + // format ++; switch (*format) { - case 'b' : /* job-billing */ + case 'b' : // job-billing if ((optval = cupsGetOption("job-billing", num_options, options)) != NULL) fputs(optval, stdout); break; - case 'h' : /* job-originating-host-name */ + case 'h' : // job-originating-host-name if ((optval = cupsGetOption("job-originating-host-name", num_options, options)) != NULL) fputs(optval, stdout); break; - case 'j' : /* job-id */ + case 'j' : // job-id printf("%d", job_id); break; - case 'n' : /* CR + LF */ + case 'n' : // CR + LF putchar('\r'); putchar('\n'); break; - case 'q' : /* double quote (") */ + case 'q' : // double quote (") putchar('\"'); break; - case 's' : /* "value" */ + case 's' : // "value" if (value) fputs(value, stdout); break; - case 't' : /* job-name */ + case 't' : // job-name fputs(title, stdout); break; - case 'u' : /* job-originating-user-name */ + case 'u' : // job-originating-user-name fputs(user, stdout); break; - case '?' : /* ?value:string; */ - /* - * Get the match value... - */ + case '?' : // ?value:string; + // + // Get the match value... + // for (format ++, mptr = match; *format && *format != ':'; format ++) if (mptr < (match + sizeof(match) - 1)) @@ -276,27 +275,27 @@ pjl_write(const char *format, /* I - Format string */ if (!*format) return; - /* - * See if we have a match... - */ + // + // See if we have a match... + // format ++; *mptr = '\0'; if (!value || strcmp(match, value)) { - /* - * Value doesn't match; skip the string that follows... - */ + // + // Value doesn't match; skip the string that follows... + // while (*format && *format != ';') format ++; } else { - /* - * Value matches; copy the string that follows... - */ + // + // Value matches; copy the string that follows... + // while (*format && *format != ';') putchar(*format++); @@ -306,9 +305,9 @@ pjl_write(const char *format, /* I - Format string */ return; break; - default : /* Anything else */ + default : // Anything else putchar('%'); - case '%' : /* %% = single % */ + case '%' : // %% = single % putchar(*format); break; } @@ -319,4 +318,3 @@ pjl_write(const char *format, /* I - Format string */ format ++; } } - diff --git a/filter/pcl-common.h b/filter/pcl-common.h index 42d8ab0c5..490d7cb5b 100644 --- a/filter/pcl-common.h +++ b/filter/pcl-common.h @@ -1,18 +1,16 @@ -/* - * Common HP-PCL definitions for CUPS. - * - * Copyright 2007-2011 by Apple Inc. - * Copyright 1993-2005 by Easy Software Products, All Rights Reserved. - * - * These coded instructions, statements, and computer programs are the - * property of Apple Inc. and are protected by Federal copyright - * law. Distribution and use rights are outlined in the file "COPYING" - * which should have been included with this file. - */ +// +// Common HP-PCL definitions for cups-filters. +// +// Copyright 2007-2011 by Apple Inc. +// Copyright 1993-2005 by Easy Software Products, All Rights Reserved. +// +// Licensed under Apache License v2.0. See the file "LICENSE" for more +// information. +// -/* - * Include necessary headers... - */ +// +// Include necessary headers... +// #include #include @@ -20,9 +18,9 @@ #include "pcl.h" -/* - * Functions/macros... - */ +// +// Functions/macros... +// #define pcl_reset()\ printf("\033E") diff --git a/filter/pcl.h b/filter/pcl.h index 802eb9a0d..90caebdc2 100644 --- a/filter/pcl.h +++ b/filter/pcl.h @@ -1,31 +1,28 @@ -/* - * This file contains model number definitions for the CUPS unified - * PCL driver. - * - * Copyright 2007 by Apple Inc. - * Copyright 1997-2005 by Easy Software Products. - * - * These coded instructions, statements, and computer programs are the - * property of Apple Inc. and are protected by Federal copyright - * law. Distribution and use rights are outlined in the file "COPYING" - * which should have been included with this file. - */ +// +// This file contains model number definitions for the unified +// PCL driver of cups-filters. +// +// Copyright 2007 by Apple Inc. +// Copyright 1997-2005 by Easy Software Products. +// +// Licensed under Apache License v2.0. See the file "LICENSE" for more +// information. +// -/* General PCL Support */ -#define PCL_PAPER_SIZE 0x1 /* Use ESC&l#A */ -#define PCL_INKJET 0x2 /* Use inkjet commands */ +// General PCL Support +#define PCL_PAPER_SIZE 0x1 // Use ESC&l#A +#define PCL_INKJET 0x2 // Use inkjet commands -/* Raster Support */ -#define PCL_RASTER_END_COLOR 0x100 /* Use ESC*rC */ -#define PCL_RASTER_CID 0x200 /* Use ESC*v#W */ -#define PCL_RASTER_CRD 0x400 /* Use ESC*g#W */ -#define PCL_RASTER_SIMPLE 0x800 /* Use ESC*r#U */ -#define PCL_RASTER_RGB24 0x1000 /* Use 24-bit RGB mode */ - -/* PJL Support */ -#define PCL_PJL 0x10000 /* Use PJL Commands */ -#define PCL_PJL_PAPERWIDTH 0x20000 /* Use PJL PAPERWIDTH/LENGTH */ -#define PCL_PJL_HPGL2 0x40000 /* Enter HPGL2 */ -#define PCL_PJL_PCL3GUI 0x80000 /* Enter PCL3GUI */ -#define PCL_PJL_RESOLUTION 0x100000 /* Use PJL SET RESOLUTION */ +// Raster Support +#define PCL_RASTER_END_COLOR 0x100 // Use ESC*rC +#define PCL_RASTER_CID 0x200 // Use ESC*v#W +#define PCL_RASTER_CRD 0x400 // Use ESC*g#W +#define PCL_RASTER_SIMPLE 0x800 // Use ESC*r#U +#define PCL_RASTER_RGB24 0x1000 // Use 24-bit RGB mode +// PJL Support +#define PCL_PJL 0x10000 // Use PJL Commands +#define PCL_PJL_PAPERWIDTH 0x20000 // Use PJL PAPERWIDTH/LENGTH +#define PCL_PJL_HPGL2 0x40000 // Enter HPGL2 +#define PCL_PJL_PCL3GUI 0x80000 // Enter PCL3GUI +#define PCL_PJL_RESOLUTION 0x100000 // Use PJL SET RESOLUTION diff --git a/filter/pclmtoraster.c b/filter/pclmtoraster.c index a34cc1a64..6df0926c7 100644 --- a/filter/pclmtoraster.c +++ b/filter/pclmtoraster.c @@ -1,56 +1,50 @@ -/** - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * @brief Decode PCLm to a Raster file - * @file pclmtoraster.c - * @author Vikrant Malik (c) 2020 - */ - -/* - * Include necessary headers... - */ +// +// Legacy CUPS filter wrapper for cfFilterPCLmToRaster() for cups-filters. +// +// Copyright © 2020-2022 by OpenPrinting. +// +// Licensed under Apache License v2.0. See the file "LICENSE" for more +// information. +// + +// +// Include necessary headers... +// #include #include -/* - * Local globals... - */ -static int JobCanceled = 0;/* Set to 1 on SIGTERM */ +// +// Local globals... +// + +static int JobCanceled = 0;// Set to 1 on SIGTERM + int main(int argc, char **argv) { int ret; - /* - * Fire up the cfFilterPCLmToRaster() filter function - */ + // + // Fire up the cfFilterPCLmToRaster() filter function + // cf_filter_out_format_t outformat = CF_FILTER_OUT_FORMAT_PWG_RASTER; char *t = getenv("FINAL_CONTENT_TYPE"); - if (t) { + if (t) + { if (strcasestr(t, "urf")) outformat = CF_FILTER_OUT_FORMAT_APPLE_RASTER; else if (strcasestr(t, "cups-raster")) outformat = CF_FILTER_OUT_FORMAT_CUPS_RASTER; } - ret = ppdFilterCUPSWrapper(argc, argv, cfFilterPCLmToRaster, &outformat, &JobCanceled); + ret = ppdFilterCUPSWrapper(argc, argv, cfFilterPCLmToRaster, &outformat, + &JobCanceled); if (ret) fprintf(stderr, "ERROR: pclmtoraster filter function failed.\n"); - return ret; + return (ret); } diff --git a/filter/pdftopdf.c b/filter/pdftopdf.c index 1e08b1be9..3ec74f116 100644 --- a/filter/pdftopdf.c +++ b/filter/pdftopdf.c @@ -1,49 +1,53 @@ -/* - * Pdf to pdf filter based on cfFilterPDFToPDF() filter function. - */ - - -/* - * Include necessary headers... - */ +// +// Legacy CUPS filter wrapper for ppdFilterPDFToPDF() for cups-filters. +// +// Copyright © 2020-2022 by OpenPrinting. +// +// Licensed under Apache License v2.0. See the file "LICENSE" for more +// information. +// + +// +// Include necessary headers... +// #include #include #include -/* - * Local globals... - */ +// +// Local globals... +// -static int JobCanceled = 0;/* Set to 1 on SIGTERM */ +static int JobCanceled = 0; // Set to 1 on SIGTERM -/* - * Local functions... - */ +// +// Local functions... +// static void cancel_job(int sig); -/* - * 'main()' - Main entry. - */ +// +// 'main()' - Main entry. +// -int /* O - Exit status */ -main(int argc, /* I - Number of command-line args */ - char *argv[]) /* I - Command-line arguments */ +int // O - Exit status +main(int argc, // I - Number of command-line args + char *argv[]) // I - Command-line arguments { int ret; #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) - struct sigaction action; /* Actions for POSIX signals */ -#endif /* HAVE_SIGACTION && !HAVE_SIGSET */ + struct sigaction action; // Actions for POSIX signals +#endif // HAVE_SIGACTION && !HAVE_SIGSET - /* - * Register a signal handler to cleanly cancel a job. - */ + // + // Register a signal handler to cleanly cancel a job. + // -#ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */ +#ifdef HAVE_SIGSET // Use System V signals over POSIX to avoid bugs sigset(SIGTERM, cancel_job); #elif defined(HAVE_SIGACTION) memset(&action, 0, sizeof(action)); @@ -53,11 +57,11 @@ main(int argc, /* I - Number of command-line args */ sigaction(SIGTERM, &action, NULL); #else signal(SIGTERM, cancel_job); -#endif /* HAVE_SIGSET */ +#endif // HAVE_SIGSET - /* - * Fire up the ppdFilterPDFToPDF() filter function - */ + // + // Fire up the ppdFilterPDFToPDF() filter function + // ret = ppdFilterCUPSWrapper(argc, argv, ppdFilterPDFToPDF, NULL, &JobCanceled); @@ -68,12 +72,12 @@ main(int argc, /* I - Number of command-line args */ } -/* - * 'cancel_job()' - Flag the job as canceled. - */ +// +// 'cancel_job()' - Flag the job as canceled. +// static void -cancel_job(int sig) /* I - Signal number (unused) */ +cancel_job(int sig) // I - Signal number (unused) { (void)sig; diff --git a/filter/pdftops.c b/filter/pdftops.c index 28e0e9911..d1cc0dbdb 100644 --- a/filter/pdftops.c +++ b/filter/pdftops.c @@ -1,55 +1,55 @@ -/* - * PDF-to-PostScript filter for CUPS (based on cfFilterPDFToPS() filter function). - * - * Copyright © 2020 by Till Kamppeter - * Copyright © 2007-2018 by Apple Inc. - * Copyright © 1993-2007 by Easy Software Products. - * - * Licensed under Apache License v2.0. See the file "LICENSE" for more - * information. - */ - -/* - * Include necessary headers... - */ +// +// Legacy CUPS filter wrapper for ppdFilterPDFToPS() for cups-filters. +// +// Copyright © 2020 by Till Kamppeter +// Copyright © 2007-2018 by Apple Inc. +// Copyright © 1993-2007 by Easy Software Products. +// +// Licensed under Apache License v2.0. See the file "LICENSE" for more +// information. +// + +// +// Include necessary headers... +// #include #include #include -/* - * Local globals... - */ +// +// Local globals... +// -static int JobCanceled = 0;/* Set to 1 on SIGTERM */ +static int JobCanceled = 0; // Set to 1 on SIGTERM -/* - * Local functions... - */ +// +// Local functions... +// static void cancel_job(int sig); -/* - * 'main()' - Main entry. - */ +// +// 'main()' - Main entry. +// -int /* O - Exit status */ -main(int argc, /* I - Number of command-line args */ - char *argv[]) /* I - Command-line arguments */ +int // O - Exit status +main(int argc, // I - Number of command-line args + char *argv[]) // I - Command-line arguments { int ret; #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) - struct sigaction action; /* Actions for POSIX signals */ -#endif /* HAVE_SIGACTION && !HAVE_SIGSET */ + struct sigaction action; // Actions for POSIX signals +#endif // HAVE_SIGACTION && !HAVE_SIGSET - /* - * Register a signal handler to cleanly cancel a job. - */ + // + // Register a signal handler to cleanly cancel a job. + // -#ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */ +#ifdef HAVE_SIGSET // Use System V signals over POSIX to avoid bugs sigset(SIGTERM, cancel_job); #elif defined(HAVE_SIGACTION) memset(&action, 0, sizeof(action)); @@ -59,11 +59,11 @@ main(int argc, /* I - Number of command-line args */ sigaction(SIGTERM, &action, NULL); #else signal(SIGTERM, cancel_job); -#endif /* HAVE_SIGSET */ +#endif // HAVE_SIGSET - /* - * Fire up the cfFilterPSToPS() filter function - */ + // + // Fire up the ppdFilterPDFToPS() filter function + // ret = ppdFilterCUPSWrapper(argc, argv, ppdFilterPDFToPS, NULL, &JobCanceled); @@ -74,15 +74,14 @@ main(int argc, /* I - Number of command-line args */ } -/* - * 'cancel_job()' - Flag the job as canceled. - */ +// +// 'cancel_job()' - Flag the job as canceled. +// static void -cancel_job(int sig) /* I - Signal number (unused) */ +cancel_job(int sig) // I - Signal number (unused) { (void)sig; JobCanceled = 1; } - diff --git a/filter/pdftoraster.c b/filter/pdftoraster.c index c30bb9220..74a518579 100644 --- a/filter/pdftoraster.c +++ b/filter/pdftoraster.c @@ -1,43 +1,52 @@ -/* - * Include necessary headers... - */ +// +// Legacy CUPS filter wrapper for cfFilterPDFToRaster() for cups-filters. +// +// Copyright © 2020-2022 by OpenPrinting. +// +// Licensed under Apache License v2.0. See the file "LICENSE" for more +// information. +// + +// +// Include necessary headers... +// #include #include #include -/* - * Local globals... - */ +// +// Local globals... +// -static int JobCanceled = 0;/* Set to 1 on SIGTERM */ +static int JobCanceled = 0; // Set to 1 on SIGTERM -/* - * Local functions... - */ +// +// Local functions... +// static void cancel_job(int sig); -/* - * 'main()' - Main entry and processing of driver. - */ +// +// 'main()' - Main entry and processing of driver. +// -int /* O - Exit status */ -main(int argc, /* I - Number of command-line arguments */ - char *argv[]) /* I - Command-line arguments */ +int // O - Exit status +main(int argc, // I - Number of command-line arguments + char *argv[]) // I - Command-line arguments { int ret; #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) - struct sigaction action; /* Actions for POSIX signals */ -#endif /* HAVE_SIGACTION && !HAVE_SIGSET */ + struct sigaction action; // Actions for POSIX signals +#endif // HAVE_SIGACTION && !HAVE_SIGSET - /* - * Register a signal handler to cleanly cancel a job. - */ + // + // Register a signal handler to cleanly cancel a job. + // -#ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */ +#ifdef HAVE_SIGSET // Use System V signals over POSIX to avoid bugs sigset(SIGTERM, cancel_job); #elif defined(HAVE_SIGACTION) memset(&action, 0, sizeof(action)); @@ -47,13 +56,14 @@ main(int argc, /* I - Number of command-line arguments */ sigaction(SIGTERM, &action, NULL); #else signal(SIGTERM, cancel_job); -#endif /* HAVE_SIGSET */ +#endif // HAVE_SIGSET - /* - * Fire up the ppdFilterPDFToRaster() filter function - */ + // + // Fire up the cfFilterPDFToRaster() filter function + // - ret = ppdFilterCUPSWrapper(argc, argv, cfFilterPDFToRaster, NULL, &JobCanceled); + ret = ppdFilterCUPSWrapper(argc, argv, cfFilterPDFToRaster, NULL, + &JobCanceled); if (ret) fprintf(stderr, "ERROR: pdftoraster filter function failed.\n"); @@ -62,12 +72,12 @@ main(int argc, /* I - Number of command-line arguments */ } -/* - * 'cancel_job()' - Flag the job as canceled. - */ +// +// 'cancel_job()' - Flag the job as canceled. +// static void -cancel_job(int sig) /* I - Signal number (unused) */ +cancel_job(int sig) // I - Signal number (unused) { (void)sig; diff --git a/filter/pstops.c b/filter/pstops.c index 06837c4b0..780c32dfc 100644 --- a/filter/pstops.c +++ b/filter/pstops.c @@ -1,55 +1,55 @@ -/* - * PostScript filter for CUPS (based on cfFilterPSToPS() filter function). - * - * Copyright © 2020 by Till Kamppeter - * Copyright © 2007-2018 by Apple Inc. - * Copyright © 1993-2007 by Easy Software Products. - * - * Licensed under Apache License v2.0. See the file "LICENSE" for more - * information. - */ - -/* - * Include necessary headers... - */ +// +// Legacy CUPS filter wrapper for ppdFilterPSToPS() for cups-filters. +// +// Copyright © 2020 by Till Kamppeter +// Copyright © 2007-2018 by Apple Inc. +// Copyright © 1993-2007 by Easy Software Products. +// +// Licensed under Apache License v2.0. See the file "LICENSE" for more +// information. +// + +// +// Include necessary headers... +// #include #include #include -/* - * Local globals... - */ +// +// Local globals... +// -static int JobCanceled = 0;/* Set to 1 on SIGTERM */ +static int JobCanceled = 0; // Set to 1 on SIGTERM -/* - * Local functions... - */ +// +// Local functions... +// static void cancel_job(int sig); -/* - * 'main()' - Main entry. - */ +// +// 'main()' - Main entry. +// -int /* O - Exit status */ -main(int argc, /* I - Number of command-line args */ - char *argv[]) /* I - Command-line arguments */ +int // O - Exit status +main(int argc, // I - Number of command-line args + char *argv[]) // I - Command-line arguments { int ret; #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) - struct sigaction action; /* Actions for POSIX signals */ -#endif /* HAVE_SIGACTION && !HAVE_SIGSET */ + struct sigaction action; // Actions for POSIX signals +#endif // HAVE_SIGACTION && !HAVE_SIGSET - /* - * Register a signal handler to cleanly cancel a job. - */ + // + // Register a signal handler to cleanly cancel a job. + // -#ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */ +#ifdef HAVE_SIGSET // Use System V signals over POSIX to avoid bugs sigset(SIGTERM, cancel_job); #elif defined(HAVE_SIGACTION) memset(&action, 0, sizeof(action)); @@ -59,11 +59,11 @@ main(int argc, /* I - Number of command-line args */ sigaction(SIGTERM, &action, NULL); #else signal(SIGTERM, cancel_job); -#endif /* HAVE_SIGSET */ +#endif // HAVE_SIGSET - /* - * Fire up the cfFilterPSToPS() filter function - */ + // + // Fire up the ppdFilterPSToPS() filter function + // ret = ppdFilterCUPSWrapper(argc, argv, ppdFilterPSToPS, NULL, &JobCanceled); @@ -74,15 +74,14 @@ main(int argc, /* I - Number of command-line args */ } -/* - * 'cancel_job()' - Flag the job as canceled. - */ +// +// 'cancel_job()' - Flag the job as canceled. +// static void -cancel_job(int sig) /* I - Signal number (unused) */ + cancel_job(int sig) // I - Signal number (unused) { (void)sig; JobCanceled = 1; } - diff --git a/filter/pwgtopclm.c b/filter/pwgtopclm.c index b109c4272..c9eac6c60 100644 --- a/filter/pwgtopclm.c +++ b/filter/pwgtopclm.c @@ -1,48 +1,55 @@ -/* - * Raster to PCLm filter (based on cfFilterPWGToPDF() filter function). - */ - - -/* - * Include necessary headers... - */ +// +// Legacy CUPS filter wrapper for cfFilterPWGToPDF() for cups-filters. +// +// PWG Raster to PCLm filter. +// +// Copyright © 2020-2022 by OpenPrinting. +// +// Licensed under Apache License v2.0. See the file "LICENSE" for more +// information. +// + +// +// Include necessary headers... +// #include #include #include -/* - * Local globals... - */ +// +// Local globals... +// + +static int JobCanceled = 0; // Set to 1 on SIGTERM -static int JobCanceled = 0;/* Set to 1 on SIGTERM */ -/* - * Local functions... - */ +// +// Local functions... +// static void cancel_job(int sig); -/* - * 'main()' - Main entry. - */ +// +// 'main()' - Main entry. +// -int /* O - Exit status */ -main(int argc, /* I - Number of command-line args */ - char *argv[]) /* I - Command-line arguments */ +int // O - Exit status +main(int argc, // I - Number of command-line args + char *argv[]) // I - Command-line arguments { int ret; #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) - struct sigaction action; /* Actions for POSIX signals */ -#endif /* HAVE_SIGACTION && !HAVE_SIGSET */ + struct sigaction action; // Actions for POSIX signals +#endif // HAVE_SIGACTION && !HAVE_SIGSET - /* - * Register a signal handler to cleanly cancel a job. - */ + // + // Register a signal handler to cleanly cancel a job. + // -#ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */ +#ifdef HAVE_SIGSET // Use System V signals over POSIX to avoid bugs sigset(SIGTERM, cancel_job); #elif defined(HAVE_SIGACTION) memset(&action, 0, sizeof(action)); @@ -52,14 +59,15 @@ main(int argc, /* I - Number of command-line args */ sigaction(SIGTERM, &action, NULL); #else signal(SIGTERM, cancel_job); -#endif /* HAVE_SIGSET */ +#endif // HAVE_SIGSET - /* - * Fire up the ppdFilterRasterToPDF() filter function. - */ + // + // Fire up the cfFilterPWGToPDF() filter function. + // cf_filter_out_format_t outformat = CF_FILTER_OUT_FORMAT_PCLM; - ret = ppdFilterCUPSWrapper(argc, argv, cfFilterPWGToPDF, &outformat, &JobCanceled); + ret = ppdFilterCUPSWrapper(argc, argv, cfFilterPWGToPDF, &outformat, + &JobCanceled); if (ret) fprintf(stderr, "ERROR: pwgtopclm filter failed.\n"); @@ -67,12 +75,12 @@ main(int argc, /* I - Number of command-line args */ return (ret); } -/* - * 'cancel_job()' - Flag the job as canceled. - */ +// +// 'cancel_job()' - Flag the job as canceled. +// static void -cancel_job(int sig) /* I - Signal number (unused) */ +cancel_job(int sig) // I - Signal number (unused) { (void)sig; diff --git a/filter/pwgtopdf.c b/filter/pwgtopdf.c index bdc0c53ef..aa4a8c96c 100644 --- a/filter/pwgtopdf.c +++ b/filter/pwgtopdf.c @@ -1,48 +1,55 @@ -/* - * Raster to PDF filter (based on cfFilterPWGToPDF() filter function). - */ - - -/* - * Include necessary headers... - */ +// +// Legacy CUPS filter wrapper for cfFilterPWGToPDF() for cups-filters. +// +// PWG Raster to PDF filter. +// +// Copyright © 2020-2022 by OpenPrinting. +// +// Licensed under Apache License v2.0. See the file "LICENSE" for more +// information. +// + +// +// Include necessary headers... +// #include #include #include -/* - * Local globals... - */ +// +// Local globals... +// + +static int JobCanceled = 0; // Set to 1 on SIGTERM -static int JobCanceled = 0;/* Set to 1 on SIGTERM */ -/* - * Local functions... - */ +// +// Local functions... +// static void cancel_job(int sig); -/* - * 'main()' - Main entry. - */ +// +// 'main()' - Main entry. +// -int /* O - Exit status */ -main(int argc, /* I - Number of command-line args */ - char *argv[]) /* I - Command-line arguments */ +int // O - Exit status +main(int argc, // I - Number of command-line args + char *argv[]) // I - Command-line arguments { int ret; #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) - struct sigaction action; /* Actions for POSIX signals */ -#endif /* HAVE_SIGACTION && !HAVE_SIGSET */ + struct sigaction action; // Actions for POSIX signals +#endif // HAVE_SIGACTION && !HAVE_SIGSET - /* - * Register a signal handler to cleanly cancel a job. - */ + // + // Register a signal handler to cleanly cancel a job. + // -#ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */ +#ifdef HAVE_SIGSET // Use System V signals over POSIX to avoid bugs sigset(SIGTERM, cancel_job); #elif defined(HAVE_SIGACTION) memset(&action, 0, sizeof(action)); @@ -52,14 +59,15 @@ main(int argc, /* I - Number of command-line args */ sigaction(SIGTERM, &action, NULL); #else signal(SIGTERM, cancel_job); -#endif /* HAVE_SIGSET */ +#endif // HAVE_SIGSET - /* - * Fire up the ppdFilterRasterToPDF() filter function. - */ + // + // Fire up the cfFilterPWGToPDF() filter function. + // cf_filter_out_format_t outformat = CF_FILTER_OUT_FORMAT_PDF; - ret = ppdFilterCUPSWrapper(argc, argv, cfFilterPWGToPDF, &outformat, &JobCanceled); + ret = ppdFilterCUPSWrapper(argc, argv, cfFilterPWGToPDF, &outformat, + &JobCanceled); if (ret) fprintf(stderr, "ERROR: pwgtopdf filter failed.\n"); @@ -67,12 +75,12 @@ main(int argc, /* I - Number of command-line args */ return (ret); } -/* - * 'cancel_job()' - Flag the job as canceled. - */ +// +// 'cancel_job()' - Flag the job as canceled. +// static void -cancel_job(int sig) /* I - Signal number (unused) */ +cancel_job(int sig) // I - Signal number (unused) { (void)sig; diff --git a/filter/pwgtoraster.c b/filter/pwgtoraster.c index 355567af6..2380643fa 100644 --- a/filter/pwgtoraster.c +++ b/filter/pwgtoraster.c @@ -1,43 +1,53 @@ -/* - * Include necessary headers... - */ +// +// Legacy CUPS filter wrapper for cfFilterPWGToRaster() for cups-filters. +// +// Copyright © 2020-2022 by OpenPrinting. +// +// Licensed under Apache License v2.0. See the file "LICENSE" for more +// information. +// + +// +// Include necessary headers... +// #include #include #include -/* - * Local globals... - */ -static int JobCanceled = 0;/* Set to 1 on SIGTERM */ +// +// Local globals... +// +static int JobCanceled = 0; // Set to 1 on SIGTERM -/* - * Local functions... - */ + +// +// Local functions... +// static void cancel_job(int sig); -/* - * 'main()' - Main entry and processing of driver. - */ +// +// 'main()' - Main entry and processing of driver. +// -int /* O - Exit status */ -main(int argc, /* I - Number of command-line arguments */ - char *argv[]) /* I - Command-line arguments */ +int // O - Exit status +main(int argc, // I - Number of command-line arguments + char *argv[]) // I - Command-line arguments { int ret; #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) - struct sigaction action; /* Actions for POSIX signals */ -#endif /* HAVE_SIGACTION && !HAVE_SIGSET */ + struct sigaction action; // Actions for POSIX signals +#endif // HAVE_SIGACTION && !HAVE_SIGSET - /* - * Register a signal handler to cleanly cancel a job. - */ + // + // Register a signal handler to cleanly cancel a job. + // -#ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */ +#ifdef HAVE_SIGSET // Use System V signals over POSIX to avoid bugs sigset(SIGTERM, cancel_job); #elif defined(HAVE_SIGACTION) memset(&action, 0, sizeof(action)); @@ -47,13 +57,14 @@ main(int argc, /* I - Number of command-line arguments */ sigaction(SIGTERM, &action, NULL); #else signal(SIGTERM, cancel_job); -#endif /* HAVE_SIGSET */ +#endif // HAVE_SIGSET - /* - * Fire up the ppdFilterPWGToRaster() filter function - */ + // + // Fire up the cfFilterPWGToRaster() filter function + // - ret = ppdFilterCUPSWrapper(argc, argv, cfFilterPWGToRaster, NULL, &JobCanceled); + ret = ppdFilterCUPSWrapper(argc, argv, cfFilterPWGToRaster, NULL, + &JobCanceled); if (ret) fprintf(stderr, "ERROR: pwgtoraster filter function failed.\n"); @@ -62,12 +73,12 @@ main(int argc, /* I - Number of command-line arguments */ } -/* - * 'cancel_job()' - Flag the job as canceled. - */ +// +// 'cancel_job()' - Flag the job as canceled. +// static void -cancel_job(int sig) /* I - Signal number (unused) */ + cancel_job(int sig) // I - Signal number (unused) { (void)sig; diff --git a/filter/rastertoescpx.c b/filter/rastertoescpx.c index a9e6e7556..ccd599ea5 100644 --- a/filter/rastertoescpx.c +++ b/filter/rastertoescpx.c @@ -1,31 +1,29 @@ -/* - * Advanced EPSON ESC/P raster driver for CUPS. - * - * Copyright 2007-2011 by Apple Inc. - * Copyright 1993-2005 by Easy Software Products. - * - * These coded instructions, statements, and computer programs are the - * property of Apple Inc. and are protected by Federal copyright - * law. Distribution and use rights are outlined in the file "COPYING" - * which should have been included with this file. - * - * Contents: - * - * Setup() - Prepare the printer for graphics output. - * StartPage() - Start a page of graphics. - * EndPage() - Finish a page of graphics. - * Shutdown() - Shutdown a printer. - * CancelJob() - Cancel the current job... - * CompressData() - Compress a line of graphics. - * OutputBand() - Output a band of graphics. - * ProcessLine() - Read graphics from the page stream and output - * as needed. - * main() - Main entry and processing of driver. - */ - -/* - * Include necessary headers... - */ +// +// Advanced EPSON ESC/P raster driver for cups-filters. +// +// Copyright 2007-2011 by Apple Inc. +// Copyright 1993-2005 by Easy Software Products. +// +// Licensed under Apache License v2.0. See the file "LICENSE" for more +// information. +// +// Contents: +// +// Setup() - Prepare the printer for graphics output. +// StartPage() - Start a page of graphics. +// EndPage() - Finish a page of graphics. +// Shutdown() - Shutdown a printer. +// CancelJob() - Cancel the current job... +// CompressData() - Compress a line of graphics. +// OutputBand() - Output a band of graphics. +// ProcessLine() - Read graphics from the page stream and output +// as needed. +// main() - Main entry and processing of driver. +// + +// +// Include necessary headers... +// #include #include @@ -35,62 +33,62 @@ #include -/* - * Softweave data... - */ +// +// Softweave data... +// typedef struct cups_weave_str { - struct cups_weave_str *prev, /* Previous band */ - *next; /* Next band */ - int x, y, /* Column/Line on the page */ - plane, /* Color plane */ - dirty, /* Is this buffer dirty? */ - row, /* Row in the buffer */ - count; /* Max rows this pass */ - unsigned char *buffer; /* Data buffer */ + struct cups_weave_str *prev, // Previous band + *next; // Next band + int x, y, // Column/Line on the page + plane, // Color plane + dirty, // Is this buffer dirty? + row, // Row in the buffer + count; // Max rows this pass + unsigned char *buffer; // Data buffer } cups_weave_t; -/* - * Globals... - */ - -cf_rgb_t *RGB; /* RGB color separation data */ -cf_cmyk_t *CMYK; /* CMYK color separation data */ -unsigned char *PixelBuffer, /* Pixel buffer */ - *CMYKBuffer, /* CMYK buffer */ - *OutputBuffers[7], /* Output buffers */ - *DotBuffers[7], /* Dot buffers */ - *CompBuffer; /* Compression buffer */ -short *InputBuffer; /* Color separation buffer */ -cups_weave_t *DotAvailList, /* Available buffers */ - *DotUsedList, /* Used buffers */ - *DotBands[128][7]; /* Buffers in use */ -int DotBufferSize, /* Size of dot buffers */ - DotRowMax, /* Maximum row number in buffer */ - DotColStep, /* Step for each output column */ - DotRowStep, /* Step for each output line */ - DotRowFeed, /* Amount to feed for interleave */ - DotRowCount, /* Number of rows to output */ - DotRowOffset[7], /* Offset for each color on print head */ - DotRowCurrent, /* Current row */ - DotSize; /* Dot size (Pro 5000 only) */ -int PrinterPlanes, /* # of color planes */ - BitPlanes, /* # of bit planes per color */ - PrinterTop, /* Top of page */ - PrinterLength; /* Length of page */ -cf_lut_t *DitherLuts[7]; /* Lookup tables for dithering */ -cf_dither_t *DitherStates[7]; /* Dither state tables */ -int OutputFeed; /* Number of lines to skip */ -int Canceled; /* Is the job canceled? */ -cf_logfunc_t logfunc; /* Log function */ -void *ld; /* Log function data */ - - -/* - * Prototypes... - */ +// +// Globals... +// + +cf_rgb_t *RGB; // RGB color separation data +cf_cmyk_t *CMYK; // CMYK color separation data +unsigned char *PixelBuffer, // Pixel buffer + *CMYKBuffer, // CMYK buffer + *OutputBuffers[7], // Output buffers + *DotBuffers[7], // Dot buffers + *CompBuffer; // Compression buffer +short *InputBuffer; // Color separation buffer +cups_weave_t *DotAvailList, // Available buffers + *DotUsedList, // Used buffers + *DotBands[128][7]; // Buffers in use +int DotBufferSize, // Size of dot buffers + DotRowMax, // Maximum row number in buffer + DotColStep, // Step for each output column + DotRowStep, // Step for each output line + DotRowFeed, // Amount to feed for interleave + DotRowCount, // Number of rows to output + DotRowOffset[7], // Offset for each color on print head + DotRowCurrent, // Current row + DotSize; // Dot size (Pro 5000 only) +int PrinterPlanes, // # of color planes + BitPlanes, // # of bit planes per color + PrinterTop, // Top of page + PrinterLength; // Length of page +cf_lut_t *DitherLuts[7]; // Lookup tables for dithering +cf_dither_t *DitherStates[7]; // Dither state tables +int OutputFeed; // Number of lines to skip +int Canceled; // Is the job canceled? +cf_logfunc_t logfunc; // Log function +void *ld; // Log function data + + +// +// Prototypes... +// void Setup(ppd_file_t *); void StartPage(ppd_file_t *, cups_page_header2_t *); @@ -108,45 +106,45 @@ void ProcessLine(ppd_file_t *, cups_raster_t *, cups_page_header2_t *, const int y); -/* - * 'Setup()' - Prepare a printer for graphics output. - */ +// +// 'Setup()' - Prepare a printer for graphics output. +// void -Setup(ppd_file_t *ppd) /* I - PPD file */ +Setup(ppd_file_t *ppd) // I - PPD file { - /* - * Some EPSON printers need an additional command issued at the - * beginning of each job to exit from USB "packet" mode... - */ + // + // Some EPSON printers need an additional command issued at the + // beginning of each job to exit from USB "packet" mode... + // if (ppd->model_number & ESCP_USB) cfWritePrintData("\000\000\000\033\001@EJL 1284.4\n@EJL \n\033@", 29); } -/* - * 'StartPage()' - Start a page of graphics. - */ +// +// 'StartPage()' - Start a page of graphics. +// void -StartPage(ppd_file_t *ppd, /* I - PPD file */ - cups_page_header2_t *header) /* I - Page header */ +StartPage(ppd_file_t *ppd, // I - PPD file + cups_page_header2_t *header) // I - Page header { - int i, y; /* Looping vars */ - int subrow, /* Current subrow */ - modrow, /* Subrow modulus */ - plane; /* Current color plane */ - unsigned char *ptr; /* Pointer into dot buffer */ - int bands; /* Number of bands to allocate */ - int units; /* Units for resolution */ - cups_weave_t *band; /* Current band */ - const char *colormodel; /* Color model string */ + int i, y; // Looping vars + int subrow, // Current subrow + modrow, // Subrow modulus + plane; // Current color plane + unsigned char *ptr; // Pointer into dot buffer + int bands; // Number of bands to allocate + int units; // Units for resolution + cups_weave_t *band; // Current band + const char *colormodel; // Color model string char resolution[PPD_MAX_NAME], - /* Resolution string */ - spec[PPD_MAX_NAME]; /* PPD attribute name */ - ppd_attr_t *attr; /* Attribute from PPD file */ - const float default_lut[2] = /* Default dithering lookup table */ + // Resolution string + spec[PPD_MAX_NAME]; // PPD attribute name + ppd_attr_t *attr; // Attribute from PPD file + const float default_lut[2] = // Default dithering lookup table { 0.0, 1.0 @@ -200,9 +198,9 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */ fprintf(stderr, "DEBUG: cupsRowFeed = %d\n", header->cupsRowFeed); fprintf(stderr, "DEBUG: cupsRowStep = %d\n", header->cupsRowStep); - /* - * Figure out the color model and spec strings... - */ + // + // Figure out the color model and spec strings... + // switch (header->cupsColorSpace) { @@ -231,9 +229,9 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */ if (!header->MediaType[0]) strcpy(header->MediaType, "Plain"); - /* - * Load the appropriate color profiles... - */ + // + // Load the appropriate color profiles... + // RGB = NULL; CMYK = NULL; @@ -268,25 +266,25 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */ fprintf(stderr, "DEBUG: PrinterPlanes = %d\n", PrinterPlanes); - /* - * Get the dithering parameters... - */ + // + // Get the dithering parameters... + // switch (PrinterPlanes) { - case 1 : /* K */ + case 1 : // K DitherLuts[0] = ppdLutLoad(ppd, colormodel, header->MediaType, resolution, "Black", logfunc, ld); break; - case 2 : /* Kk */ + case 2 : // Kk DitherLuts[0] = ppdLutLoad(ppd, colormodel, header->MediaType, resolution, "Black", logfunc, ld); DitherLuts[1] = ppdLutLoad(ppd, colormodel, header->MediaType, resolution, "LightBlack", logfunc, ld); break; - case 3 : /* CMY */ + case 3 : // CMY DitherLuts[0] = ppdLutLoad(ppd, colormodel, header->MediaType, resolution, "Cyan", logfunc, ld); DitherLuts[1] = ppdLutLoad(ppd, colormodel, header->MediaType, @@ -295,7 +293,7 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */ resolution, "Yellow", logfunc, ld); break; - case 4 : /* CMYK */ + case 4 : // CMYK DitherLuts[0] = ppdLutLoad(ppd, colormodel, header->MediaType, resolution, "Cyan", logfunc, ld); DitherLuts[1] = ppdLutLoad(ppd, colormodel, header->MediaType, @@ -306,7 +304,7 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */ resolution, "Black", logfunc, ld); break; - case 6 : /* CcMmYK */ + case 6 : // CcMmYK DitherLuts[0] = ppdLutLoad(ppd, colormodel, header->MediaType, resolution, "Cyan", logfunc, ld); DitherLuts[1] = ppdLutLoad(ppd, colormodel, header->MediaType, @@ -321,7 +319,7 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */ resolution, "Black", logfunc, ld); break; - case 7 : /* CcMmYKk */ + case 7 : // CcMmYKk DitherLuts[0] = ppdLutLoad(ppd, colormodel, header->MediaType, resolution, "Cyan", logfunc, ld); DitherLuts[1] = ppdLutLoad(ppd, colormodel, header->MediaType, @@ -352,35 +350,35 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */ else BitPlanes = 1; - /* - * Initialize the printer... - */ + // + // Initialize the printer... + // printf("\033@"); if (ppd->model_number & ESCP_REMOTE) { - /* - * Go into remote mode... - */ + // + // Go into remote mode... + // cfWritePrintData("\033(R\010\000\000REMOTE1", 13); - /* - * Disable status reporting... - */ + // + // Disable status reporting... + // cfWritePrintData("ST\002\000\000\000", 6); - /* - * Enable borderless printing... - */ + // + // Enable borderless printing... + // if ((attr = ppdFindAttr(ppd, "cupsESCPFP", NULL)) != NULL && attr->value) { - /* - * Set horizontal offset... - */ + // + // Set horizontal offset... + // i = atoi(attr->value); @@ -389,9 +387,9 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */ putchar(i >> 8); } - /* - * Set media type... - */ + // + // Set media type... + // if (header->cupsMediaType) { @@ -399,9 +397,9 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */ if ((attr = ppdFindAttr(ppd, "cupsESCPSN0", spec)) != NULL && attr->value) { - /* - * Set feed sequence... - */ + // + // Set feed sequence... + // cfWritePrintData("SN\003\000\000\000", 6); putchar(atoi(attr->value)); @@ -409,9 +407,9 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */ if ((attr = ppdFindAttr(ppd, "cupsESCPSN1", spec)) != NULL && attr->value) { - /* - * Set platten gap... - */ + // + // Set platten gap... + // cfWritePrintData("SN\003\000\000\001", 6); putchar(atoi(attr->value)); @@ -419,9 +417,9 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */ if ((attr = ppdFindAttr(ppd, "cupsESCPSN2", spec)) != NULL && attr->value) { - /* - * Paper feeding/ejecting sequence... - */ + // + // Paper feeding/ejecting sequence... + // cfWritePrintData("SN\003\000\000\002", 6); putchar(atoi(attr->value)); @@ -429,9 +427,9 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */ if ((attr = ppdFindAttr(ppd, "cupsESCPSN6", spec)) != NULL && attr->value) { - /* - * Eject delay... - */ + // + // Eject delay... + // cfWritePrintData("SN\003\000\000\006", 6); putchar(atoi(attr->value)); @@ -439,9 +437,9 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */ if ((attr = ppdFindAttr(ppd, "cupsESCPMT", spec)) != NULL && attr->value) { - /* - * Set media type. - */ + // + // Set media type. + // cfWritePrintData("MT\003\000\000\000", 6); putchar(atoi(attr->value)); @@ -449,9 +447,9 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */ if ((attr = ppdFindAttr(ppd, "cupsESCPPH", spec)) != NULL && attr->value) { - /* - * Set paper thickness. - */ + // + // Set paper thickness. + // cfWritePrintData("PH\002\000\000", 5); putchar(atoi(attr->value)); @@ -464,9 +462,9 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */ { if ((attr = ppdFindAttr(ppd, "cupsESCPPC", spec)) != NULL && attr->value) { - /* - * Paper check. - */ + // + // Paper check. + // cfWritePrintData("PC\002\000\000", 5); putchar(atoi(attr->value)); @@ -474,9 +472,9 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */ if ((attr = ppdFindAttr(ppd, "cupsESCPPP", spec)) != NULL && attr->value) { - /* - * Paper path. - */ + // + // Paper path. + // int a, b; @@ -490,9 +488,9 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */ if ((attr = ppdFindAttr(ppd, "cupsESCPEX", spec)) != NULL && attr->value) { - /* - * Set media position. - */ + // + // Set media position. + // cfWritePrintData("EX\006\000\000\000\000\000\005", 9); putchar(atoi(attr->value)); @@ -501,16 +499,16 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */ if ((attr = ppdFindAttr(ppd, "cupsESCPMS", spec)) != NULL && attr->value) { - /* - * Set media size... - */ + // + // Set media size... + // cfWritePrintData("MS\010\000\000", 5); putchar(atoi(attr->value)); switch (header->PageSize[1]) { - case 1191 : /* A3 */ + case 1191 : // A3 putchar(0x01); putchar(0x00); putchar(0x00); @@ -518,7 +516,7 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */ putchar(0x00); putchar(0x00); break; - case 1032 : /* B4 */ + case 1032 : // B4 putchar(0x02); putchar(0x00); putchar(0x00); @@ -526,7 +524,7 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */ putchar(0x00); putchar(0x00); break; - case 842 : /* A4 */ + case 842 : // A4 putchar(0x03); putchar(0x00); putchar(0x00); @@ -534,7 +532,7 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */ putchar(0x00); putchar(0x00); break; - case 595 : /* A4.Transverse */ + case 595 : // A4.Transverse putchar(0x03); putchar(0x01); putchar(0x00); @@ -542,7 +540,7 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */ putchar(0x00); putchar(0x00); break; - case 729 : /* B5 */ + case 729 : // B5 putchar(0x04); putchar(0x00); putchar(0x00); @@ -550,7 +548,7 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */ putchar(0x00); putchar(0x00); break; - case 516 : /* B5.Transverse */ + case 516 : // B5.Transverse putchar(0x04); putchar(0x01); putchar(0x00); @@ -558,7 +556,7 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */ putchar(0x00); putchar(0x00); break; - case 1369 : /* Super A3/B */ + case 1369 : // Super A3/B putchar(0x20); putchar(0x00); putchar(0x00); @@ -566,7 +564,7 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */ putchar(0x00); putchar(0x00); break; - case 792 : /* Letter */ + case 792 : // Letter putchar(0x08); putchar(0x00); putchar(0x00); @@ -574,7 +572,7 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */ putchar(0x00); putchar(0x00); break; - case 612 : /* Letter.Transverse */ + case 612 : // Letter.Transverse putchar(0x08); putchar(0x01); putchar(0x00); @@ -582,7 +580,7 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */ putchar(0x00); putchar(0x00); break; - case 1004 : /* Legal */ + case 1004 : // Legal putchar(0x0a); putchar(0x00); putchar(0x00); @@ -590,7 +588,7 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */ putchar(0x00); putchar(0x00); break; - case 1224 : /* Tabloid */ + case 1224 : // Tabloid putchar(0x2d); putchar(0x00); putchar(0x00); @@ -598,7 +596,7 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */ putchar(0x00); putchar(0x00); break; - default : /* Custom size */ + default : // Custom size putchar(0xff); putchar(0xff); i = 360 * header->PageSize[0] / 72; @@ -615,28 +613,30 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */ if ((attr = ppdFindAttr(ppd, "cupsESCPAC", spec)) != NULL && attr->value) { - /* - * Enable/disable cutter. - */ + // + // Enable/disable cutter. + // cfWritePrintData("AC\002\000\000", 5); putchar(atoi(attr->value)); - if ((attr = ppdFindAttr(ppd, "cupsESCPSN80", header->MediaType)) != NULL && attr->value) + if ((attr = ppdFindAttr(ppd, "cupsESCPSN80", + header->MediaType)) != NULL && attr->value) { - /* - * Cutting method... - */ + // + // Cutting method... + // cfWritePrintData("SN\003\000\000\200", 6); putchar(atoi(attr->value)); } - if ((attr = ppdFindAttr(ppd, "cupsESCPSN81", header->MediaType)) != NULL && attr->value) + if ((attr = ppdFindAttr(ppd, "cupsESCPSN81", + header->MediaType)) != NULL && attr->value) { - /* - * Cutting pressure... - */ + // + // Cutting pressure... + // cfWritePrintData("SN\003\000\000\201", 6); putchar(atoi(attr->value)); @@ -645,33 +645,33 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */ if ((attr = ppdFindAttr(ppd, "cupsESCPCO", spec)) != NULL && attr->value) { - /* - * Enable/disable cutter. - */ + // + // Enable/disable cutter. + // cfWritePrintData("CO\010\000\000\000", 6); putchar(atoi(attr->value)); cfWritePrintData("\000\000\000\000\000", 5); } - /* - * Exit remote mode... - */ + // + // Exit remote mode... + // cfWritePrintData("\033\000\000\000", 4); } - /* - * Enter graphics mode... - */ + // + // Enter graphics mode... + // cfWritePrintData("\033(G\001\000\001", 6); - /* - * Set the line feed increment... - */ + // + // Set the line feed increment... + // - /* TODO: get this from the PPD file... */ + // TODO: get this from the PPD file... for (units = 1440; units < header->HWResolution[0]; units *= 2); if (ppd->model_number & ESCP_EXT_UNITS) @@ -689,17 +689,17 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */ putchar(3600 / header->HWResolution[1]); } - /* - * Set the page length... - */ + // + // Set the page length... + // PrinterLength = header->PageSize[1] * header->HWResolution[1] / 72; if (ppd->model_number & ESCP_PAGE_SIZE) { - /* - * Set page size (expands bottom margin)... - */ + // + // Set page size (expands bottom margin)... + // cfWritePrintData("\033(S\010\000", 5); @@ -722,9 +722,9 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */ putchar(PrinterLength >> 8); } - /* - * Set the top and bottom margins... - */ + // + // Set the top and bottom margins... + // PrinterTop = (int)((ppd->sizes[1].length - ppd->sizes[1].top) * header->HWResolution[1] / 72.0); @@ -754,33 +754,33 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */ putchar(PrinterLength >> 8); } - /* - * Set the top position... - */ + // + // Set the top position... + // cfWritePrintData("\033(V\002\000\000\000", 7); - /* - * Enable unidirectional printing depending on the mode... - */ + // + // Enable unidirectional printing depending on the mode... + // if ((attr = ppdFindColorAttr(ppd, "cupsESCPDirection", colormodel, header->MediaType, resolution, spec, sizeof(spec), logfunc, ld)) != NULL) printf("\033U%c", atoi(attr->value)); - /* - * Enable/disable microweaving as needed... - */ + // + // Enable/disable microweaving as needed... + // if ((attr = ppdFindColorAttr(ppd, "cupsESCPMicroWeave", colormodel, header->MediaType, resolution, spec, sizeof(spec), logfunc, ld)) != NULL) printf("\033(i\001%c%c", 0, atoi(attr->value)); - /* - * Set the dot size and print speed as needed... - */ + // + // Set the dot size and print speed as needed... + // if ((attr = ppdFindColorAttr(ppd, "cupsESCPDotSize", colormodel, header->MediaType, resolution, spec, @@ -789,31 +789,31 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */ if (ppd->model_number & ESCP_ESCK) { - /* - * Set the print mode... - */ + // + // Set the print mode... + // if (PrinterPlanes == 1) { - /* - * Fast black printing. - */ + // + // Fast black printing. + // cfWritePrintData("\033(K\002\000\000\001", 7); } else { - /* - * Color printing. - */ + // + // Color printing. + // cfWritePrintData("\033(K\002\000\000\002", 7); } } - /* - * Get softweave settings from header... - */ + // + // Get softweave settings from header... + // if (header->cupsRowCount <= 1) { @@ -833,9 +833,9 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */ DotColStep ++; } - /* - * Setup softweave parameters... - */ + // + // Setup softweave parameters... + // DotRowCurrent = 0; DotRowMax = DotRowCount * DotRowStep; @@ -856,9 +856,9 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */ if (DotRowMax > 1) { - /* - * Compute offsets for the color jets on the print head... - */ + // + // Compute offsets for the color jets on the print head... + // bands = DotRowStep * DotColStep * PrinterPlanes * 4; @@ -866,34 +866,34 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */ if (PrinterPlanes == 1) { - /* - * Use full height of print head... - */ + // + // Use full height of print head... + // if ((attr = ppdFindAttr(ppd, "cupsESCPBlack", resolution)) != NULL && attr->value) { - /* - * Use custom black head data... - */ + // + // Use custom black head data... + // sscanf(attr->value, "%d%d", &DotRowCount, &DotRowStep); } } else if (ppd->model_number & ESCP_STAGGER) { - /* - * Use staggered print head... - */ + // + // Use staggered print head... + // fputs("DEBUG: Offset head detected...\n", stderr); if ((attr = ppdFindAttr(ppd, "cupsESCPOffsets", resolution)) != NULL && attr->value) { - /* - * Use only 1/3 of the print head when printing color... - */ + // + // Use only 1/3 of the print head when printing color... + // sscanf(attr->value, "%d%d%d%d", DotRowOffset + 0, DotRowOffset + 1, DotRowOffset + 2, DotRowOffset + 3); @@ -903,9 +903,9 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */ for (i = 0; i < PrinterPlanes; i ++) fprintf(stderr, "DEBUG: DotRowOffset[%d] = %d\n", i, DotRowOffset[i]); - /* - * Allocate bands... - */ + // + // Allocate bands... + // for (i = 0; i < bands; i ++) { @@ -929,17 +929,17 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */ fputs("DEBUG: ----END----\n", stderr); - /* - * Fill the initial bands... - */ + // + // Fill the initial bands... + // modrow = DotColStep * DotRowStep; if (DotRowFeed == 0) { - /* - * Automatically compute the optimal feed value... - */ + // + // Automatically compute the optimal feed value... + // DotRowFeed = DotRowCount / DotColStep - DotRowStep; @@ -964,27 +964,27 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */ { while (DotBands[subrow][0]) { - /* - * This subrow is already used, move to another one... - */ + // + // This subrow is already used, move to another one... + // subrow = (subrow + 1) % modrow; } for (plane = 0; plane < PrinterPlanes; plane ++) { - /* - * Pull the next available band from the list... - */ + // + // Pull the next available band from the list... + // band = DotAvailList; DotAvailList = DotAvailList->next; DotBands[subrow][plane] = band; - /* - * Start the band in the first few passes, with the number of rows - * varying to allow for a nice interleaved pattern... - */ + // + // Start the band in the first few passes, with the number of rows + // varying to allow for a nice interleaved pattern... + // band->x = subrow / DotRowStep; band->y = (subrow % DotRowStep) + DotRowOffset[plane]; @@ -998,7 +998,8 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */ band->count = DotRowCount; fprintf(stderr, "DEBUG: DotBands[%d][%d] = %p, x = %d, y = %d, plane = %d, count = %d\n", - subrow, plane, (void*)band, band->x, band->y, band->plane, band->count); + subrow, plane, (void*)band, band->x, band->y, band->plane, + band->count); } subrow = (subrow + DotRowFeed) % modrow; @@ -1006,9 +1007,9 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */ } else { - /* - * Allocate memory for a single line of graphics... - */ + // + // Allocate memory for a single line of graphics... + // ptr = calloc(PrinterPlanes, DotBufferSize); @@ -1016,9 +1017,9 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */ DotBuffers[plane] = ptr; } - /* - * Set the output resolution... - */ + // + // Set the output resolution... + // cfWritePrintData("\033(D\004\000", 5); putchar(units); @@ -1026,15 +1027,15 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */ putchar(units * DotRowStep / header->HWResolution[1]); putchar(units * DotColStep / header->HWResolution[0]); - /* - * Set the top of form... - */ + // + // Set the top of form... + // OutputFeed = 0; - /* - * Allocate buffers as needed... - */ + // + // Allocate buffers as needed... + // PixelBuffer = malloc(header->cupsBytesPerLine); InputBuffer = malloc(header->cupsWidth * PrinterPlanes * 2); @@ -1050,31 +1051,31 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */ } -/* - * 'EndPage()' - Finish a page of graphics. - */ +// +// 'EndPage()' - Finish a page of graphics. +// void -EndPage(ppd_file_t *ppd, /* I - PPD file */ - cups_page_header2_t *header) /* I - Page header */ +EndPage(ppd_file_t *ppd, // I - PPD file + cups_page_header2_t *header) // I - Page header { - int i; /* Looping var */ - cups_weave_t *band, /* Current band */ - *next; /* Next band in list */ - int plane; /* Current plane */ - int subrow; /* Current subrow */ - int subrows; /* Number of subrows */ + int i; // Looping var + cups_weave_t *band, // Current band + *next; // Next band in list + int plane; // Current plane + int subrow; // Current subrow + int subrows; // Number of subrows - /* - * Output the last bands of print data as necessary... - */ + // + // Output the last bands of print data as necessary... + // if (DotRowMax > 1) { - /* - * Move the remaining bands to the used or avail lists... - */ + // + // Move the remaining bands to the used or avail lists... + // subrows = DotRowStep * DotColStep; @@ -1083,9 +1084,9 @@ EndPage(ppd_file_t *ppd, /* I - PPD file */ { if (DotBands[subrow][plane]->dirty) { - /* - * Insert into the used list... - */ + // + // Insert into the used list... + // DotBands[subrow][plane]->count = DotBands[subrow][plane]->row; @@ -1093,9 +1094,9 @@ EndPage(ppd_file_t *ppd, /* I - PPD file */ } else { - /* - * Nothing here, so move it to the available list... - */ + // + // Nothing here, so move it to the available list... + // DotBands[subrow][plane]->next = DotAvailList; DotAvailList = DotBands[subrow][plane]; @@ -1104,9 +1105,9 @@ EndPage(ppd_file_t *ppd, /* I - PPD file */ DotBands[subrow][plane] = NULL; } - /* - * Loop until all bands are written... - */ + // + // Loop until all bands are written... + // fputs("DEBUG: Pointer list at end of page...\n", stderr); @@ -1130,9 +1131,9 @@ EndPage(ppd_file_t *ppd, /* I - PPD file */ free(band); } - /* - * Free memory for the available bands, if any... - */ + // + // Free memory for the available bands, if any... + // for (band = DotAvailList; band != NULL; band = next) { @@ -1151,15 +1152,15 @@ EndPage(ppd_file_t *ppd, /* I - PPD file */ DotBuffers[0] = NULL; } - /* - * Output a page eject sequence... - */ + // + // Output a page eject sequence... + // putchar(12); - /* - * Free memory for the page... - */ + // + // Free memory for the page... + // for (i = 0; i < PrinterPlanes; i ++) { @@ -1183,51 +1184,51 @@ EndPage(ppd_file_t *ppd, /* I - PPD file */ } -/* - * 'Shutdown()' - Shutdown a printer. - */ +// +// 'Shutdown()' - Shutdown a printer. +// void -Shutdown(ppd_file_t *ppd) /* I - PPD file */ +Shutdown(ppd_file_t *ppd) // I - PPD file { - /* - * Reset the printer... - */ + // + // Reset the printer... + // printf("\033@"); if (ppd->model_number & ESCP_REMOTE) { - /* - * Go into remote mode... - */ + // + // Go into remote mode... + // cfWritePrintData("\033(R\010\000\000REMOTE1", 13); - /* - * LoadXS defaults... - */ + // + // LoadXS defaults... + // cfWritePrintData("LD\000\000", 4); - /* - * Exit remote mode... - */ + // + // Exit remote mode... + // cfWritePrintData("\033\000\000\000", 4); } } -/* - * 'AddBand()' - Add a band of data to the used list. - */ +// +// 'AddBand()' - Add a band of data to the used list. +// void -AddBand(cups_weave_t *band) /* I - Band to add */ +AddBand(cups_weave_t *band) // I - Band to add { - cups_weave_t *current, /* Current band */ - *prev; /* Previous band */ + cups_weave_t *current, // Current band + *prev; // Previous band if (band->count < 1) @@ -1244,9 +1245,9 @@ AddBand(cups_weave_t *band) /* I - Band to add */ if (current != NULL) { - /* - * Insert the band... - */ + // + // Insert the band... + // band->next = current; band->prev = prev; @@ -1259,9 +1260,9 @@ AddBand(cups_weave_t *band) /* I - Band to add */ } else if (prev != NULL) { - /* - * Append the band to the end... - */ + // + // Append the band to the end... + // band->prev = prev; prev->next = band; @@ -1269,9 +1270,9 @@ AddBand(cups_weave_t *band) /* I - Band to add */ } else { - /* - * First band in list... - */ + // + // First band in list... + // DotUsedList = band; band->prev = NULL; @@ -1280,12 +1281,12 @@ AddBand(cups_weave_t *band) /* I - Band to add */ } -/* - * 'CancelJob()' - Cancel the current job... - */ +// +// 'CancelJob()' - Cancel the current job... +// void -CancelJob(int sig) /* I - Signal */ +CancelJob(int sig) // I - Signal { (void)sig; @@ -1293,55 +1294,55 @@ CancelJob(int sig) /* I - Signal */ } -/* - * 'CompressData()' - Compress a line of graphics. - */ +// +// 'CompressData()' - Compress a line of graphics. +// void -CompressData(ppd_file_t *ppd, /* I - PPD file information */ - const unsigned char *line, /* I - Data to compress */ - const int length,/* I - Number of bytes */ - int plane, /* I - Color plane */ - int type, /* I - Type of compression */ - const int rows, /* I - Number of lines to write */ - const int xstep, /* I - Spacing between columns */ - const int ystep, /* I - Spacing between lines */ - const int offset)/* I - Head offset */ +CompressData(ppd_file_t *ppd, // I - PPD file information + const unsigned char *line, // I - Data to compress + const int length,// I - Number of bytes + int plane, // I - Color plane + int type, // I - Type of compression + const int rows, // I - Number of lines to write + const int xstep, // I - Spacing between columns + const int ystep, // I - Spacing between lines + const int offset)// I - Head offset { register const unsigned char *line_ptr, - /* Current byte pointer */ - *line_end, /* End-of-line byte pointer */ - *start; /* Start of compression sequence */ - register unsigned char *comp_ptr; /* Pointer into compression buffer */ - register int count; /* Count of bytes for output */ - register int bytes; /* Number of bytes per row */ - static int ctable[7][7] = /* Colors */ + // Current byte pointer + *line_end, // End-of-line byte pointer + *start; // Start of compression sequence + register unsigned char *comp_ptr; // Pointer into compression buffer + register int count; // Count of bytes for output + register int bytes; // Number of bytes per row + static int ctable[7][7] = // Colors { - { 0, 0, 0, 0, 0, 0, 0 }, /* K */ - { 0, 16, 0, 0, 0, 0, 0 }, /* Kk */ - { 2, 1, 4, 0, 0, 0, 0 }, /* CMY */ - { 2, 1, 4, 0, 0, 0, 0 }, /* CMYK */ + { 0, 0, 0, 0, 0, 0, 0 }, // K + { 0, 16, 0, 0, 0, 0, 0 }, // Kk + { 2, 1, 4, 0, 0, 0, 0 }, // CMY + { 2, 1, 4, 0, 0, 0, 0 }, // CMYK { 0, 0, 0, 0, 0, 0, 0 }, - { 2, 18, 1, 17, 4, 0, 0 }, /* CcMmYK */ - { 2, 18, 1, 17, 4, 0, 16 }, /* CcMmYKk */ + { 2, 18, 1, 17, 4, 0, 0 }, // CcMmYK + { 2, 18, 1, 17, 4, 0, 16 }, // CcMmYKk }; switch (type) { case 0 : - /* - * Do no compression... - */ + // + // Do no compression... + // line_ptr = (const unsigned char *)line; line_end = (const unsigned char *)line + length; break; default : - /* - * Do TIFF pack-bits encoding... - */ + // + // Do TIFF pack-bits encoding... + // line_ptr = (const unsigned char *)line; line_end = (const unsigned char *)line + length; @@ -1351,18 +1352,18 @@ CompressData(ppd_file_t *ppd, /* I - PPD file information */ { if ((line_ptr + 1) >= line_end) { - /* - * Single byte on the end... - */ + // + // Single byte on the end... + // *comp_ptr++ = 0x00; *comp_ptr++ = *line_ptr++; } else if (line_ptr[0] == line_ptr[1]) { - /* - * Repeated sequence... - */ + // + // Repeated sequence... + // line_ptr ++; count = 2; @@ -1380,9 +1381,9 @@ CompressData(ppd_file_t *ppd, /* I - PPD file information */ } else { - /* - * Non-repeated sequence... - */ + // + // Non-repeated sequence... + // start = line_ptr; line_ptr ++; @@ -1417,9 +1418,9 @@ CompressData(ppd_file_t *ppd, /* I - PPD file information */ break; } - /* - * Position the print head... - */ + // + // Position the print head... + // putchar(0x0d); @@ -1434,17 +1435,17 @@ CompressData(ppd_file_t *ppd, /* I - PPD file information */ putchar(offset >> 8); } - /* - * Send the graphics... - */ + // + // Send the graphics... + // bytes = length / rows; if (ppd->model_number & ESCP_RASTER_ESCI) { - /* - * Send graphics with ESC i command. - */ + // + // Send graphics with ESC i command. + // printf("\033i"); putchar(ctable[PrinterPlanes - 1][plane]); @@ -1457,9 +1458,9 @@ CompressData(ppd_file_t *ppd, /* I - PPD file information */ } else { - /* - * Set the color if necessary... - */ + // + // Set the color if necessary... + // if (PrinterPlanes > 1) { @@ -1471,9 +1472,9 @@ CompressData(ppd_file_t *ppd, /* I - PPD file information */ printf("\033r%c", plane); } - /* - * Send graphics with ESC . command. - */ + // + // Send graphics with ESC . command. + // bytes *= 8; @@ -1490,22 +1491,22 @@ CompressData(ppd_file_t *ppd, /* I - PPD file information */ } -/* - * 'OutputBand()' - Output a band of graphics. - */ +// +// 'OutputBand()' - Output a band of graphics. +// void -OutputBand(ppd_file_t *ppd, /* I - PPD file */ - cups_page_header2_t *header, /* I - Page header */ - cups_weave_t *band) /* I - Current band */ +OutputBand(ppd_file_t *ppd, // I - PPD file + cups_page_header2_t *header, // I - Page header + cups_weave_t *band) // I - Current band { - int xstep, /* Spacing between columns */ - ystep; /* Spacing between rows */ + int xstep, // Spacing between columns + ystep; // Spacing between rows - /* - * Interleaved ESC/P2 graphics... - */ + // + // Interleaved ESC/P2 graphics... + // OutputFeed = band->y - DotRowCurrent; DotRowCurrent = band->y; @@ -1513,16 +1514,16 @@ OutputBand(ppd_file_t *ppd, /* I - PPD file */ fprintf(stderr, "DEBUG: Printing band %p, x = %d, y = %d, plane = %d, count = %d, OutputFeed = %d\n", (void*)band, band->x, band->y, band->plane, band->count, OutputFeed); - /* - * Compute step values... - */ + // + // Compute step values... + // xstep = 3600 * DotColStep / header->HWResolution[0]; ystep = 3600 * DotRowStep / header->HWResolution[1]; - /* - * Output the band... - */ + // + // Output the band... + // if (OutputFeed > 0) { @@ -1536,52 +1537,52 @@ OutputBand(ppd_file_t *ppd, /* I - PPD file */ CompressData(ppd, band->buffer, band->count * DotBufferSize, band->plane, header->cupsCompression, band->count, xstep, ystep, band->x); - /* - * Clear the band... - */ + // + // Clear the band... + // memset(band->buffer, 0, band->count * DotBufferSize); band->dirty = 0; - /* - * Flush the output buffers... - */ + // + // Flush the output buffers... + // fflush(stdout); } -/* - * 'ProcessLine()' - Read graphics from the page stream and output as needed. - */ +// +// 'ProcessLine()' - Read graphics from the page stream and output as needed. +// void -ProcessLine(ppd_file_t *ppd, /* I - PPD file */ - cups_raster_t *ras, /* I - Raster stream */ - cups_page_header2_t *header, /* I - Page header */ - const int y) /* I - Current scanline */ +ProcessLine(ppd_file_t *ppd, // I - PPD file + cups_raster_t *ras, // I - Raster stream + cups_page_header2_t *header, // I - Page header + const int y) // I - Current scanline { - int plane, /* Current color plane */ - width, /* Width of line */ - subwidth, /* Width of interleaved row */ - subrow, /* Subrow for interleaved output */ - offset, /* Offset to current line */ - pass, /* Pass number */ - xstep, /* X step value */ - ystep; /* Y step value */ - cups_weave_t *band; /* Current band */ + int plane, // Current color plane + width, // Width of line + subwidth, // Width of interleaved row + subrow, // Subrow for interleaved output + offset, // Offset to current line + pass, // Pass number + xstep, // X step value + ystep; // Y step value + cups_weave_t *band; // Current band - /* - * Read a row of graphics... - */ + // + // Read a row of graphics... + // if (!cupsRasterReadPixels(ras, PixelBuffer, header->cupsBytesPerLine)) return; - /* - * Perform the color separation... - */ + // + // Perform the color separation... + // width = header->cupsWidth; subwidth = header->cupsWidth / DotColStep; @@ -1620,9 +1621,9 @@ ProcessLine(ppd_file_t *ppd, /* I - PPD file */ break; } - /* - * Dither the pixels... - */ + // + // Dither the pixels... + // for (plane = 0; plane < PrinterPlanes; plane ++) { @@ -1631,9 +1632,9 @@ ProcessLine(ppd_file_t *ppd, /* I - PPD file */ if (DotRowMax == 1) { - /* - * Handle microweaved output... - */ + // + // Handle microweaved output... + // if (cfCheckBytes(OutputBuffers[plane], width)) continue; @@ -1659,17 +1660,17 @@ ProcessLine(ppd_file_t *ppd, /* I - PPD file */ } else { - /* - * Handle softweaved output... - */ + // + // Handle softweaved output... + // for (pass = 0, subrow = y % DotRowStep; pass < DotColStep; pass ++, subrow += DotRowStep) { - /* - * See if we need to output the band... - */ + // + // See if we need to output the band... + // band = DotBands[subrow][plane]; offset = band->row * DotBufferSize; @@ -1687,15 +1688,15 @@ ProcessLine(ppd_file_t *ppd, /* I - PPD file */ { if (band->dirty) { - /* - * Dirty band needs to be added to the used list... - */ + // + // Dirty band needs to be added to the used list... + // AddBand(band); - /* - * Then find a new band... - */ + // + // Then find a new band... + // if (DotAvailList == NULL) { @@ -1722,9 +1723,9 @@ ProcessLine(ppd_file_t *ppd, /* I - PPD file */ } else { - /* - * This band isn't dirty, so reuse it... - */ + // + // This band isn't dirty, so reuse it... + // fprintf(stderr, "DEBUG: Blank band %p, x = %d, y = %d, plane = %d, count = %d\n", (void*)band, band->x, band->y, band->plane, band->count); @@ -1743,44 +1744,44 @@ ProcessLine(ppd_file_t *ppd, /* I - PPD file */ } -/* - * 'main()' - Main entry and processing of driver. - */ +// +// 'main()' - Main entry and processing of driver. +// -int /* O - Exit status */ -main(int argc, /* I - Number of command-line arguments */ - char *argv[]) /* I - Command-line arguments */ +int // O - Exit status +main(int argc, // I - Number of command-line arguments + char *argv[]) // I - Command-line arguments { - int fd; /* File descriptor */ + int fd; // File descriptor int empty = 1; - cups_raster_t *ras; /* Raster stream for printing */ - cups_page_header2_t header; /* Page header from file */ - int page; /* Current page */ - int y; /* Current line */ - ppd_file_t *ppd; /* PPD file */ - int num_options; /* Number of options */ - cups_option_t *options; /* Options */ + cups_raster_t *ras; // Raster stream for printing + cups_page_header2_t header; // Page header from file + int page; // Current page + int y; // Current line + ppd_file_t *ppd; // PPD file + int num_options; // Number of options + cups_option_t *options; // Options #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) - struct sigaction action; /* Actions for POSIX signals */ -#endif /* HAVE_SIGACTION && !HAVE_SIGSET */ + struct sigaction action; // Actions for POSIX signals +#endif // HAVE_SIGACTION && !HAVE_SIGSET - /* - * Log function for the library functions, standard CUPS logging to stderr... - */ + // + // Log function for the library functions, standard CUPS logging to stderr... + // logfunc = cfCUPSLogFunc; ld = NULL; - /* - * Make sure status messages are not buffered... - */ + // + // Make sure status messages are not buffered... + // setbuf(stderr, NULL); - /* - * Check command-line... - */ + // + // Check command-line... + // if (argc < 6 || argc > 7) { @@ -1791,16 +1792,16 @@ main(int argc, /* I - Number of command-line arguments */ num_options = cupsParseOptions(argv[5], 0, &options); - /* - * Open the PPD file... - */ + // + // Open the PPD file... + // ppd = ppdOpenFile(getenv("PPD")); if (!ppd) { - ppd_status_t status; /* PPD error */ - int linenum; /* Line number */ + ppd_status_t status; // PPD error + int linenum; // Line number fputs("ERROR: The PPD file could not be opened.\n", stderr); @@ -1814,9 +1815,9 @@ main(int argc, /* I - Number of command-line arguments */ ppdMarkDefaults(ppd); ppdMarkOptions(ppd, num_options, options); - /* - * Open the page stream... - */ + // + // Open the page stream... + // if (argc == 7) { @@ -1831,14 +1832,14 @@ main(int argc, /* I - Number of command-line arguments */ ras = cupsRasterOpen(fd, CUPS_RASTER_READ); - /* - * Register a signal handler to eject the current page if the - * job is cancelled. - */ + // + // Register a signal handler to eject the current page if the + // job is cancelled. + // Canceled = 0; -#ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */ +#ifdef HAVE_SIGSET // Use System V signals over POSIX to avoid bugs sigset(SIGTERM, CancelJob); #elif defined(HAVE_SIGACTION) memset(&action, 0, sizeof(action)); @@ -1848,25 +1849,26 @@ main(int argc, /* I - Number of command-line arguments */ sigaction(SIGTERM, &action, NULL); #else signal(SIGTERM, CancelJob); -#endif /* HAVE_SIGSET */ +#endif // HAVE_SIGSET - /* - * Process pages as needed... - */ + // + // Process pages as needed... + // page = 0; while (cupsRasterReadHeader2(ras, &header)) { - /* - * Write a status message with the page number and number of copies. - */ + // + // Write a status message with the page number and number of copies. + // if (empty) { - /* - * Initialize the print device... - */ + // + // Initialize the print device... + // + Setup(ppd); empty = 0; } @@ -1883,9 +1885,9 @@ main(int argc, /* I - Number of command-line arguments */ for (y = 0; y < header.cupsHeight; y ++) { - /* - * Let the user know how far we have progressed... - */ + // + // Let the user know how far we have progressed... + // if (Canceled) break; @@ -1898,16 +1900,16 @@ main(int argc, /* I - Number of command-line arguments */ 100 * y / header.cupsHeight); } - /* - * Read and write a line of graphics or whitespace... - */ + // + // Read and write a line of graphics or whitespace... + // ProcessLine(ppd, ras, &header, y); } - /* - * Eject the page... - */ + // + // Eject the page... + // fprintf(stderr, "INFO: Finished page %d.\n", page); @@ -1937,4 +1939,3 @@ main(int argc, /* I - Number of command-line arguments */ } return (page == 0); } - diff --git a/filter/rastertopclx.c b/filter/rastertopclx.c index 07f6b42ed..ded86f114 100644 --- a/filter/rastertopclx.c +++ b/filter/rastertopclx.c @@ -1,30 +1,28 @@ -/* - * Advanced HP Page Control Language and Raster Transfer Language - * filter for CUPS. - * - * Copyright 2007-2011 by Apple Inc. - * Copyright 1993-2005 by Easy Software Products - * - * These coded instructions, statements, and computer programs are the - * property of Apple Inc. and are protected by Federal copyright - * law. Distribution and use rights are outlined in the file "COPYING" - * which should have been included with this file. - * - * Contents: - * - * StartPage() - Start a page of graphics. - * EndPage() - Finish a page of graphics. - * Shutdown() - Shutdown a printer. - * CancelJob() - Cancel the current job... - * CompressData() - Compress a line of graphics. - * OutputLine() - Output the specified number of lines of graphics. - * ReadLine() - Read graphics from the page stream. - * main() - Main entry and processing of driver. - */ - -/* - * Include necessary headers... - */ +// +// Advanced HP Page Control Language and Raster Transfer Language +// filter for cups-filters. +// +// Copyright 2007-2011 by Apple Inc. +// Copyright 1993-2005 by Easy Software Products +// +// Licensed under Apache License v2.0. See the file "LICENSE" for more +// information. +// +// Contents: +// +// StartPage() - Start a page of graphics. +// EndPage() - Finish a page of graphics. +// Shutdown() - Shutdown a printer. +// CancelJob() - Cancel the current job... +// CompressData() - Compress a line of graphics. +// OutputLine() - Output the specified number of lines of graphics. +// ReadLine() - Read graphics from the page stream. +// main() - Main entry and processing of driver. +// + +// +// Include necessary headers... +// #include "pcl-common.h" #include @@ -34,61 +32,61 @@ #include #include -/* - * Output modes... - */ +// +// Output modes... +// typedef enum { - OUTPUT_BITMAP, /* Output bitmap data from RIP */ - OUTPUT_INVERBIT, /* Output inverted bitmap data */ - OUTPUT_RGB, /* Output 24-bit RGB data from RIP */ - OUTPUT_DITHERED /* Output dithered data */ + OUTPUT_BITMAP, // Output bitmap data from RIP + OUTPUT_INVERBIT, // Output inverted bitmap data + OUTPUT_RGB, // Output 24-bit RGB data from RIP + OUTPUT_DITHERED // Output dithered data } pcl_output_t; -/* - * Globals... - */ - -cf_rgb_t *RGB; /* RGB color separation data */ -cf_cmyk_t *CMYK; /* CMYK color separation data */ -unsigned char *PixelBuffer, /* Pixel buffer */ - *CMYKBuffer, /* CMYK buffer */ - *OutputBuffers[6], /* Output buffers */ - *DotBuffers[6], /* Bit buffers */ - *CompBuffer, /* Compression buffer */ - *SeedBuffer, /* Mode 3 seed buffers */ - BlankValue; /* The blank value */ -short *InputBuffer; /* Color separation buffer */ -cf_lut_t *DitherLuts[6]; /* Lookup tables for dithering */ -cf_dither_t *DitherStates[6]; /* Dither state tables */ -int PrinterPlanes, /* Number of color planes */ - SeedInvalid, /* Contents of seed buffer invalid? */ - DotBits[6], /* Number of bits per color */ - DotBufferSizes[6], /* Size of one row of color dots */ - DotBufferSize, /* Size of complete line */ - OutputFeed, /* Number of lines to skip */ - Page; /* Current page number */ -pcl_output_t OutputMode; /* Output mode - see OUTPUT_ consts */ -const int ColorOrders[7][7] = /* Order of color planes */ +// +// Globals... +// + +cf_rgb_t *RGB; // RGB color separation data +cf_cmyk_t *CMYK; // CMYK color separation data +unsigned char *PixelBuffer, // Pixel buffer + *CMYKBuffer, // CMYK buffer + *OutputBuffers[6], // Output buffers + *DotBuffers[6], // Bit buffers + *CompBuffer, // Compression buffer + *SeedBuffer, // Mode 3 seed buffers + BlankValue; // The blank value +short *InputBuffer; // Color separation buffer +cf_lut_t *DitherLuts[6]; // Lookup tables for dithering +cf_dither_t *DitherStates[6]; // Dither state tables +int PrinterPlanes, // Number of color planes + SeedInvalid, // Contents of seed buffer invalid? + DotBits[6], // Number of bits per color + DotBufferSizes[6], // Size of one row of color dots + DotBufferSize, // Size of complete line + OutputFeed, // Number of lines to skip + Page; // Current page number +pcl_output_t OutputMode; // Output mode - see OUTPUT_ consts +const int ColorOrders[7][7] = // Order of color planes { - { 0, 0, 0, 0, 0, 0, 0 }, /* Black */ + { 0, 0, 0, 0, 0, 0, 0 }, // Black { 0, 0, 0, 0, 0, 0, 0 }, - { 0, 1, 2, 0, 0, 0, 0 }, /* CMY */ - { 3, 0, 1, 2, 0, 0, 0 }, /* KCMY */ + { 0, 1, 2, 0, 0, 0, 0 }, // CMY + { 3, 0, 1, 2, 0, 0, 0 }, // KCMY { 0, 0, 0, 0, 0, 0, 0 }, - { 5, 0, 1, 2, 3, 4, 0 }, /* KCMYcm */ - { 5, 0, 1, 2, 3, 4, 6 } /* KCMYcmk */ + { 5, 0, 1, 2, 3, 4, 0 }, // KCMYcm + { 5, 0, 1, 2, 3, 4, 6 } // KCMYcmk }; -int Canceled; /* Is the job canceled? */ -cf_logfunc_t logfunc; /* Log function */ -void *ld; /* Log function data */ +int Canceled; // Is the job canceled? +cf_logfunc_t logfunc; // Log function +void *ld; // Log function data -/* - * Prototypes... - */ +// +// Prototypes... +// void StartPage(cf_filter_data_t *data, ppd_file_t *ppd, cups_page_header2_t *header, int job_id, const char *user, const char *title, int num_options, @@ -104,44 +102,44 @@ void OutputLine(ppd_file_t *ppd, cups_page_header2_t *header); int ReadLine(cups_raster_t *ras, cups_page_header2_t *header); -/* - * 'StartPage()' - Start a page of graphics. - */ +// +// 'StartPage()' - Start a page of graphics. +// void -StartPage(cf_filter_data_t *data, /* I - filter data */ - ppd_file_t *ppd, /* I - PPD file */ - cups_page_header2_t *header, /* I - Page header */ - int job_id, /* I - Job ID */ - const char *user, /* I - User printing job */ - const char *title, /* I - Title of job */ +StartPage(cf_filter_data_t *data, // I - filter data + ppd_file_t *ppd, // I - PPD file + cups_page_header2_t *header, // I - Page header + int job_id, // I - Job ID + const char *user, // I - User printing job + const char *title, // I - Title of job int num_options, - /* I - Number of command-line options */ - cups_option_t *options) /* I - Command-line options */ + // I - Number of command-line options + cups_option_t *options) // I - Command-line options { - int i; /* Temporary/looping var */ - int plane; /* Current plane */ - int cm_disabled; /* Device Color Inhibited */ - char s[255]; /* Temporary value */ - const char *colormodel; /* Color model string */ + int i; // Temporary/looping var + int plane; // Current plane + int cm_disabled; // Device Color Inhibited + char s[255]; // Temporary value + const char *colormodel; // Color model string char resolution[PPD_MAX_NAME], - /* Resolution string */ - spec[PPD_MAX_NAME]; /* PPD attribute name */ - ppd_attr_t *attr; /* Attribute from PPD file */ - ppd_choice_t *choice; /* Selected option */ - const int *order; /* Order to use */ - int xorigin, /* X origin of page */ - yorigin; /* Y origin of page */ - static const float default_lut[2] = /* Default dithering lookup table */ + // Resolution string + spec[PPD_MAX_NAME]; // PPD attribute name + ppd_attr_t *attr; // Attribute from PPD file + ppd_choice_t *choice; // Selected option + const int *order; // Order to use + int xorigin, // X origin of page + yorigin; // Y origin of page + static const float default_lut[2] = // Default dithering lookup table { 0.0, 1.0 }; - cf_cm_calibration_t cm_calibrate; /* Color calibration mode */ + cf_cm_calibration_t cm_calibrate; // Color calibration mode - /* - * Debug info... - */ + // + // Debug info... + // fprintf(stderr, "DEBUG: StartPage...\n"); fprintf(stderr, "DEBUG: MediaClass = \"%s\"\n", header->MediaClass); @@ -188,10 +186,10 @@ StartPage(cf_filter_data_t *data, /* I - filter data */ fprintf(stderr, "DEBUG: cupsCompression = %d\n", header->cupsCompression); #ifdef __APPLE__ - /* - * MacOS X 10.2.x doesn't set most of the page device attributes, so check - * the options and set them accordingly... - */ + // + // MacOS X 10.2.x doesn't set most of the page device attributes, so check + // the options and set them accordingly... + // if (ppd && ppdIsMarked(ppd, "Duplex", "DuplexNoTumble")) { @@ -209,11 +207,11 @@ StartPage(cf_filter_data_t *data, /* I - filter data */ for (i = 0; i < num_options; i ++) fprintf(stderr, "DEBUG: options[%d]=[\"%s\" \"%s\"]\n", i, options[i].name, options[i].value); -#endif /* __APPLE__ */ +#endif // __APPLE__ - /* - * Figure out the color model and spec strings... - */ + // + // Figure out the color model and spec strings... + // switch (header->cupsColorSpace) { @@ -247,17 +245,17 @@ StartPage(cf_filter_data_t *data, /* I - filter data */ if (!header->MediaType[0]) strcpy(header->MediaType, "PLAIN"); - /* - * Get the dithering parameters... - */ + // + // Get the dithering parameters... + // BlankValue = 0x00; if (header->cupsBitsPerColor == 1) { - /* - * Use raw bitmap mode... - */ + // + // Use raw bitmap mode... + // switch (header->cupsColorSpace) { @@ -295,9 +293,9 @@ StartPage(cf_filter_data_t *data, /* I - filter data */ else if (header->cupsColorSpace == CUPS_CSPACE_RGB && (!ppd || (ppd->model_number & PCL_RASTER_RGB24))) { - /* - * Use 24-bit RGB output mode... - */ + // + // Use 24-bit RGB output mode... + // OutputMode = OUTPUT_RGB; PrinterPlanes = 3; @@ -314,9 +312,9 @@ StartPage(cf_filter_data_t *data, /* I - filter data */ (ppd && (ppd->model_number & PCL_RASTER_RGB24)) && header->cupsCompression == 10) { - /* - * Use 24-bit RGB output mode for grayscale/black output... - */ + // + // Use 24-bit RGB output mode for grayscale/black output... + // OutputMode = OUTPUT_RGB; PrinterPlanes = 1; @@ -330,25 +328,26 @@ StartPage(cf_filter_data_t *data, /* I - filter data */ } else { - /* - * Use dithered output mode... - */ + // + // Use dithered output mode... + // OutputMode = OUTPUT_DITHERED; - /* - * Load the appropriate color profiles... - */ + // + // Load the appropriate color profiles... + // RGB = NULL; CMYK = NULL; - fputs("DEBUG: Attempting to load color profiles using the following values:\n", stderr); + fputs("DEBUG: Attempting to load color profiles using the following values:\n", + stderr); fprintf(stderr, "DEBUG: ColorModel = %s\n", colormodel); fprintf(stderr, "DEBUG: MediaType = %s\n", header->MediaType); fprintf(stderr, "DEBUG: Resolution = %s\n", resolution); - /* support the "cm-calibration" option */ + // support the "cm-calibration" option cm_calibrate = cfCmGetCupsColorCalibrateMode(data); if (cm_calibrate == CF_CM_CALIBRATION_ENABLED) @@ -381,25 +380,26 @@ StartPage(cf_filter_data_t *data, /* I - filter data */ PrinterPlanes = 3; else PrinterPlanes = 1; - /*fputs("DEBUG: Loading default K separation.\n", stderr);*/ - fprintf(stderr, "DEBUG: Color Space: %d; Color Planes %d\n", header->cupsColorSpace, PrinterPlanes); + //fputs("DEBUG: Loading default K separation.\n", stderr); + fprintf(stderr, "DEBUG: Color Space: %d; Color Planes %d\n", + header->cupsColorSpace, PrinterPlanes); CMYK = cfCMYKNew(PrinterPlanes); } PrinterPlanes = CMYK->num_channels; - /* - * Use dithered mode... - */ + // + // Use dithered mode... + // switch (PrinterPlanes) { - case 1 : /* K */ + case 1 : // K DitherLuts[0] = ppdLutLoad(ppd, colormodel, header->MediaType, resolution, "Black", logfunc, ld); break; - case 3 : /* CMY */ + case 3 : // CMY DitherLuts[0] = ppdLutLoad(ppd, colormodel, header->MediaType, resolution, "Cyan", logfunc, ld); DitherLuts[1] = ppdLutLoad(ppd, colormodel, header->MediaType, @@ -408,7 +408,7 @@ StartPage(cf_filter_data_t *data, /* I - filter data */ resolution, "Yellow", logfunc, ld); break; - case 4 : /* CMYK */ + case 4 : // CMYK DitherLuts[0] = ppdLutLoad(ppd, colormodel, header->MediaType, resolution, "Cyan", logfunc, ld); DitherLuts[1] = ppdLutLoad(ppd, colormodel, header->MediaType, @@ -419,7 +419,7 @@ StartPage(cf_filter_data_t *data, /* I - filter data */ resolution, "Black", logfunc, ld); break; - case 6 : /* CcMmYK */ + case 6 : // CcMmYK DitherLuts[0] = ppdLutLoad(ppd, colormodel, header->MediaType, resolution, "Cyan", logfunc, ld); DitherLuts[1] = ppdLutLoad(ppd, colormodel, header->MediaType, @@ -454,9 +454,9 @@ StartPage(cf_filter_data_t *data, /* I - filter data */ fprintf(stderr, "DEBUG: PrinterPlanes = %d\n", PrinterPlanes); - /* - * Initialize the printer... - */ + // + // Initialize the printer... + // if (ppd && ((attr = ppdFindAttr(ppd, "cupsInitialNulls", NULL)) != NULL)) for (i = atoi(attr->value); i > 0; i --) @@ -466,9 +466,9 @@ StartPage(cf_filter_data_t *data, /* I - filter data */ { pjl_escape(); - /* - * PJL job setup... - */ + // + // PJL job setup... + // pjl_set_job(job_id, user, title); @@ -577,17 +577,17 @@ StartPage(cf_filter_data_t *data, /* I - filter data */ { if (Page == 1) { - /* - * HP-GL/2 initialization... - */ + // + // HP-GL/2 initialization... + // printf("IN;"); printf("MG\"%d %s %s\";", job_id, user, title); } - /* - * Set media size, position, type, etc... - */ + // + // Set media size, position, type, etc... + // printf("BP5,0;"); printf("PS%.0f,%.0f;", @@ -603,18 +603,18 @@ StartPage(cf_filter_data_t *data, /* I - filter data */ else printf("EC0;"); - /* - * Set graphics mode... - */ + // + // Set graphics mode... + // pcl_set_pcl_mode(0); pcl_set_negative_motion(); } else { - /* - * Set media size, position, type, etc... - */ + // + // Set media size, position, type, etc... + // if (!header->Duplex || (Page & 1)) { @@ -628,41 +628,41 @@ StartPage(cf_filter_data_t *data, /* I - filter data */ if (!ppd || ppdFindAttr(ppd, "cupsPJL", "Duplex") == NULL) pcl_set_duplex(header->Duplex, header->Tumble); - /* - * Set the number of copies... - */ + // + // Set the number of copies... + // if (!ppd || !ppd->manual_copies) pcl_set_copies(header->NumCopies); - /* - * Set the output order/bin... - */ + // + // Set the output order/bin... + // if ((!ppd || ppdFindAttr(ppd, "cupsPJL", "Jog") == NULL) && header->Jog) printf("\033&l%dG", header->Jog); } else { - /* - * Print on the back side... - */ + // + // Print on the back side... + // printf("\033&a2G"); } if (header->Duplex && (ppd && (ppd->model_number & PCL_RASTER_CRD))) { - /* - * Reload the media... - */ + // + // Reload the media... + // pcl_set_media_source(-2); } - /* - * Set the units for cursor positioning and go to the top of the form. - */ + // + // Set the units for cursor positioning and go to the top of the form. + // printf("\033&u%dD", header->HWResolution[0]); printf("\033*p0Y\033*p0X"); @@ -672,9 +672,9 @@ StartPage(cf_filter_data_t *data, /* I - filter data */ header->MediaType, resolution, spec, sizeof(spec), logfunc, ld)) != NULL)) { - /* - * Set the print quality... - */ + // + // Set the print quality... + // if (ppd && (ppd->model_number & PCL_PJL_HPGL2)) printf("QM%d", atoi(attr->value)); @@ -682,22 +682,22 @@ StartPage(cf_filter_data_t *data, /* I - filter data */ printf("\033*o%dM", atoi(attr->value)); } - /* - * Enter graphics mode... - */ + // + // Enter graphics mode... + // if (ppd && (ppd->model_number & PCL_RASTER_CRD)) { - /* - * Use configure raster data command... - */ + // + // Use configure raster data command... + // if (OutputMode == OUTPUT_RGB) { - /* - * Send 12-byte configure raster data command with horizontal and - * vertical resolutions as well as a color count... - */ + // + // Send 12-byte configure raster data command with horizontal and + // vertical resolutions as well as a color count... + // if (ppd && ((attr = ppdFindColorAttr(ppd, "cupsPCLCRDMode", colormodel, header->MediaType, resolution, spec, @@ -707,31 +707,31 @@ StartPage(cf_filter_data_t *data, /* I - filter data */ i = 31; printf("\033*g12W"); - putchar(6); /* Format 6 */ - putchar(i); /* Set pen mode */ - putchar(0x00); /* Number components */ - putchar(0x01); /* (1 for RGB) */ + putchar(6); // Format 6 + putchar(i); // Set pen mode + putchar(0x00); // Number components + putchar(0x01); // (1 for RGB) putchar(header->HWResolution[0] >> 8); putchar(header->HWResolution[0]); putchar(header->HWResolution[1] >> 8); putchar(header->HWResolution[1]); - putchar(header->cupsCompression); /* Compression mode 3 or 10 */ - putchar(0x01); /* Portrait orientation */ - putchar(0x20); /* Bits per pixel (32 = RGB) */ - putchar(0x01); /* Planes per pixel (1 = chunky RGB) */ + putchar(header->cupsCompression); // Compression mode 3 or 10 + putchar(0x01); // Portrait orientation + putchar(0x20); // Bits per pixel (32 = RGB) + putchar(0x01); // Planes per pixel (1 = chunky RGB) } else { - /* - * Send the configure raster data command with horizontal and - * vertical resolutions as well as a color count... - */ + // + // Send the configure raster data command with horizontal and + // vertical resolutions as well as a color count... + // printf("\033*g%dW", PrinterPlanes * 6 + 2); - putchar(2); /* Format 2 */ - putchar(PrinterPlanes); /* Output planes */ + putchar(2); // Format 2 + putchar(PrinterPlanes); // Output planes order = ColorOrders[PrinterPlanes - 1]; @@ -751,24 +751,24 @@ StartPage(cf_filter_data_t *data, /* I - filter data */ else if ((!ppd || (ppd->model_number & PCL_RASTER_CID)) && OutputMode == OUTPUT_RGB) { - /* - * Use configure image data command... - */ + // + // Use configure image data command... + // pcl_set_simple_resolution(header->HWResolution[0]); - /* Set output resolution */ + // Set output resolution cfWritePrintData("\033*v6W\2\3\0\10\10\10", 11); - /* 24-bit sRGB */ + // 24-bit sRGB } else { - /* - * Use simple raster commands... - */ + // + // Use simple raster commands... + // pcl_set_simple_resolution(header->HWResolution[0]); - /* Set output resolution */ + // Set output resolution if (PrinterPlanes == 3) pcl_set_simple_cmy(); @@ -796,9 +796,9 @@ StartPage(cf_filter_data_t *data, /* I - filter data */ OutputFeed = 0; - /* - * Allocate memory for the page... - */ + // + // Allocate memory for the page... + // PixelBuffer = malloc(header->cupsBytesPerLine); @@ -836,41 +836,41 @@ StartPage(cf_filter_data_t *data, /* I - filter data */ } -/* - * 'EndPage()' - Finish a page of graphics. - */ +// +// 'EndPage()' - Finish a page of graphics. +// void -EndPage(ppd_file_t *ppd, /* I - PPD file */ - cups_page_header2_t *header) /* I - Page header */ +EndPage(ppd_file_t *ppd, // I - PPD file + cups_page_header2_t *header) // I - Page header { - int plane; /* Current plane */ + int plane; // Current plane - /* - * End graphics mode... - */ + // + // End graphics mode... + // if (ppd && (ppd->model_number & PCL_RASTER_END_COLOR)) - printf("\033*rC"); /* End color GFX */ + printf("\033*rC"); // End color GFX else - printf("\033*r0B"); /* End B&W GFX */ + printf("\033*r0B"); // End B&W GFX - /* - * Output a page eject sequence... - */ + // + // Output a page eject sequence... + // if (ppd && (ppd->model_number & PCL_PJL_HPGL2)) { - pcl_set_hpgl_mode(0); /* Back to HP-GL/2 mode */ - printf("PG;"); /* Eject the current page */ + pcl_set_hpgl_mode(0); // Back to HP-GL/2 mode + printf("PG;"); // Eject the current page } else if (!(header->Duplex && (Page & 1))) - printf("\014"); /* Eject current page */ + printf("\014"); // Eject current page - /* - * Free memory for the page... - */ + // + // Free memory for the page... + // free(PixelBuffer); @@ -903,35 +903,35 @@ EndPage(ppd_file_t *ppd, /* I - PPD file */ } -/* - * 'Shutdown()' - Shutdown a printer. - */ +// +// 'Shutdown()' - Shutdown a printer. +// void -Shutdown(ppd_file_t *ppd, /* I - PPD file */ - int job_id, /* I - Job ID */ - const char *user, /* I - User printing job */ - const char *title, /* I - Title of job */ - int num_options,/* I - Number of command-line options */ - cups_option_t *options) /* I - Command-line options */ +Shutdown(ppd_file_t *ppd, // I - PPD file + int job_id, // I - Job ID + const char *user, // I - User printing job + const char *title, // I - Title of job + int num_options,// I - Number of command-line options + cups_option_t *options) // I - Command-line options { - ppd_attr_t *attr; /* Attribute from PPD file */ + ppd_attr_t *attr; // Attribute from PPD file if (ppd && ((attr = ppdFindAttr(ppd, "cupsPCL", "EndJob")) != NULL)) { - /* - * Tell the printer how many pages were in the job... - */ + // + // Tell the printer how many pages were in the job... + // putchar(0x1b); printf(attr->value, Page); } else { - /* - * Return the printer to the default state... - */ + // + // Return the printer to the default state... + // pcl_reset(); } @@ -951,12 +951,12 @@ Shutdown(ppd_file_t *ppd, /* I - PPD file */ } -/* - * 'CancelJob()' - Cancel the current job... - */ +// +// 'CancelJob()' - Cancel the current job... +// void -CancelJob(int sig) /* I - Signal */ +CancelJob(int sig) // I - Signal { (void)sig; @@ -964,48 +964,48 @@ CancelJob(int sig) /* I - Signal */ } -/* - * 'CompressData()' - Compress a line of graphics. - */ +// +// 'CompressData()' - Compress a line of graphics. +// void -CompressData(unsigned char *line, /* I - Data to compress */ - int length, /* I - Number of bytes */ - int plane, /* I - Color plane */ - int pend, /* I - End character for data */ - int type) /* I - Type of compression */ +CompressData(unsigned char *line, // I - Data to compress + int length, // I - Number of bytes + int plane, // I - Color plane + int pend, // I - End character for data + int type) // I - Type of compression { - unsigned char *line_ptr, /* Current byte pointer */ - *line_end, /* End-of-line byte pointer */ - *comp_ptr, /* Pointer into compression buffer */ - *start, /* Start of compression sequence */ - *seed; /* Seed buffer pointer */ - int count, /* Count of bytes for output */ - offset, /* Offset of bytes for output */ - temp; /* Temporary count */ - int r, g, b; /* RGB deltas for mode 10 compression */ + unsigned char *line_ptr, // Current byte pointer + *line_end, // End-of-line byte pointer + *comp_ptr, // Pointer into compression buffer + *start, // Start of compression sequence + *seed; // Seed buffer pointer + int count, // Count of bytes for output + offset, // Offset of bytes for output + temp; // Temporary count + int r, g, b; // RGB deltas for mode 10 compression switch (type) { default : - /* - * Do no compression; with a mode-0 only printer, we can compress blank - * lines... - */ + // + // Do no compression; with a mode-0 only printer, we can compress blank + // lines... + // line_ptr = line; if (cfCheckBytes(line, length)) - line_end = line; /* Blank line */ + line_end = line; // Blank line else - line_end = line + length; /* Non-blank line */ + line_end = line + length; // Non-blank line break; case 1 : - /* - * Do run-length encoding... - */ + // + // Do run-length encoding... + // line_end = line + length; for (line_ptr = line, comp_ptr = CompBuffer; @@ -1027,9 +1027,9 @@ CompressData(unsigned char *line, /* I - Data to compress */ break; case 2 : - /* - * Do TIFF pack-bits encoding... - */ + // + // Do TIFF pack-bits encoding... + // line_ptr = line; line_end = line + length; @@ -1039,18 +1039,18 @@ CompressData(unsigned char *line, /* I - Data to compress */ { if ((line_ptr + 1) >= line_end) { - /* - * Single byte on the end... - */ + // + // Single byte on the end... + // *comp_ptr++ = 0x00; *comp_ptr++ = *line_ptr++; } else if (line_ptr[0] == line_ptr[1]) { - /* - * Repeated sequence... - */ + // + // Repeated sequence... + // line_ptr ++; count = 2; @@ -1068,9 +1068,9 @@ CompressData(unsigned char *line, /* I - Data to compress */ } else { - /* - * Non-repeated sequence... - */ + // + // Non-repeated sequence... + // start = line_ptr; line_ptr ++; @@ -1096,9 +1096,9 @@ CompressData(unsigned char *line, /* I - Data to compress */ break; case 3 : - /* - * Do delta-row compression... - */ + // + // Do delta-row compression... + // line_ptr = line; line_end = line + length; @@ -1108,17 +1108,17 @@ CompressData(unsigned char *line, /* I - Data to compress */ while (line_ptr < line_end) { - /* - * Find the next non-matching sequence... - */ + // + // Find the next non-matching sequence... + // start = line_ptr; if (SeedInvalid) { - /* - * The seed buffer is invalid, so do the next 8 bytes, max... - */ + // + // The seed buffer is invalid, so do the next 8 bytes, max... + // offset = 0; @@ -1129,9 +1129,9 @@ CompressData(unsigned char *line, /* I - Data to compress */ } else { - /* - * The seed buffer is valid, so compare against it... - */ + // + // The seed buffer is valid, so compare against it... + // while (*line_ptr == *seed && line_ptr < line_end) @@ -1145,9 +1145,9 @@ CompressData(unsigned char *line, /* I - Data to compress */ offset = line_ptr - start; - /* - * Find up to 8 non-matching bytes... - */ + // + // Find up to 8 non-matching bytes... + // start = line_ptr; count = 0; @@ -1161,16 +1161,16 @@ CompressData(unsigned char *line, /* I - Data to compress */ } } - /* - * Place mode 3 compression data in the buffer; see HP manuals - * for details... - */ + // + // Place mode 3 compression data in the buffer; see HP manuals + // for details... + // if (offset >= 31) { - /* - * Output multi-byte offset... - */ + // + // Output multi-byte offset... + // *comp_ptr++ = ((count - 1) << 5) | 31; @@ -1185,9 +1185,9 @@ CompressData(unsigned char *line, /* I - Data to compress */ } else { - /* - * Output single-byte offset... - */ + // + // Output single-byte offset... + // *comp_ptr++ = ((count - 1) << 5) | offset; } @@ -1203,9 +1203,9 @@ CompressData(unsigned char *line, /* I - Data to compress */ break; case 10 : - /* - * Mode 10 "near lossless" RGB compression... - */ + // + // Mode 10 "near lossless" RGB compression... + // line_ptr = line; line_end = line + length; @@ -1215,15 +1215,15 @@ CompressData(unsigned char *line, /* I - Data to compress */ if (PrinterPlanes == 1) { - /* - * Do grayscale compression to RGB... - */ + // + // Do grayscale compression to RGB... + // while (line_ptr < line_end) { - /* - * Find the next non-matching sequence... - */ + // + // Find the next non-matching sequence... + // start = line_ptr; while (line_ptr < line_end && @@ -1238,9 +1238,9 @@ CompressData(unsigned char *line, /* I - Data to compress */ offset = line_ptr - start; - /* - * Find non-matching grayscale pixels... - */ + // + // Find non-matching grayscale pixels... + // start = line_ptr; while (line_ptr < line_end && @@ -1253,34 +1253,35 @@ CompressData(unsigned char *line, /* I - Data to compress */ count = line_ptr - start; #if 0 - fprintf(stderr, "DEBUG: offset=%d, count=%d, comp_ptr=%p(%d of %d)...\n", + fprintf(stderr, + "DEBUG: offset=%d, count=%d, comp_ptr=%p(%d of %d)...\n", offset, count, comp_ptr, comp_ptr - CompBuffer, BytesPerLine * 5); -#endif /* 0 */ - - /* - * Place mode 10 compression data in the buffer; each sequence - * starts with a command byte that looks like: - * - * CMD SRC SRC OFF OFF CNT CNT CNT - * - * For the purpose of this driver, CMD and SRC are always 0. - * - * If the offset >= 3 then additional offset bytes follow the - * first command byte, each byte == 255 until the last one. - * - * If the count >= 7, then additional count bytes follow each - * group of pixels, each byte == 255 until the last one. - * - * The offset and count are in RGB tuples (not bytes, as for - * Mode 3 and 9)... - */ +#endif // 0 + + // + // Place mode 10 compression data in the buffer; each sequence + // starts with a command byte that looks like: + // + // CMD SRC SRC OFF OFF CNT CNT CNT + // + // For the purpose of this driver, CMD and SRC are always 0. + // + // If the offset >= 3 then additional offset bytes follow the + // first command byte, each byte == 255 until the last one. + // + // If the count >= 7, then additional count bytes follow each + // group of pixels, each byte == 255 until the last one. + // + // The offset and count are in RGB tuples (not bytes, as for + // Mode 3 and 9)... + // if (offset >= 3) { - /* - * Output multi-byte offset... - */ + // + // Output multi-byte offset... + // if (count > 7) *comp_ptr++ = 0x1f; @@ -1298,9 +1299,9 @@ CompressData(unsigned char *line, /* I - Data to compress */ } else { - /* - * Output single-byte offset... - */ + // + // Output single-byte offset... + // if (count > 7) *comp_ptr++ = (offset << 3) | 0x07; @@ -1315,10 +1316,10 @@ CompressData(unsigned char *line, /* I - Data to compress */ { if (count <= temp) { - /* - * This is exceedingly lame... The replacement counts - * are intermingled with the data... - */ + // + // This is exceedingly lame... The replacement counts + // are intermingled with the data... + // if (temp >= 255) *comp_ptr++ = 255; @@ -1328,9 +1329,9 @@ CompressData(unsigned char *line, /* I - Data to compress */ temp -= 255; } - /* - * Get difference between current and see pixels... - */ + // + // Get difference between current and see pixels... + // r = *start - *seed; g = r; @@ -1338,9 +1339,9 @@ CompressData(unsigned char *line, /* I - Data to compress */ if (r < -16 || r > 15 || g < -16 || g > 15 || b < -16 || b > 15) { - /* - * Pack 24-bit RGB into 23 bits... Lame... - */ + // + // Pack 24-bit RGB into 23 bits... Lame... + // g = *start; @@ -1358,9 +1359,9 @@ CompressData(unsigned char *line, /* I - Data to compress */ } else { - /* - * Pack 15-bit RGB difference... - */ + // + // Pack 15-bit RGB difference... + // *comp_ptr++ = 0x80 | ((r << 2) & 0x7c) | ((g >> 3) & 0x03); *comp_ptr++ = ((g << 5) & 0xe0) | (b & 0x1f); @@ -1371,10 +1372,10 @@ CompressData(unsigned char *line, /* I - Data to compress */ seed ++; } - /* - * Make sure we have the ending count if the replacement count - * was exactly 8 + 255n... - */ + // + // Make sure we have the ending count if the replacement count + // was exactly 8 + 255n... + // if (temp == 0) *comp_ptr++ = 0; @@ -1382,15 +1383,15 @@ CompressData(unsigned char *line, /* I - Data to compress */ } else { - /* - * Do RGB compression... - */ + // + // Do RGB compression... + // while (line_ptr < line_end) { - /* - * Find the next non-matching sequence... - */ + // + // Find the next non-matching sequence... + // start = line_ptr; while (line_ptr[0] == seed[0] && @@ -1407,9 +1408,9 @@ CompressData(unsigned char *line, /* I - Data to compress */ offset = (line_ptr - start) / 3; - /* - * Find non-matching RGB tuples... - */ + // + // Find non-matching RGB tuples... + // start = line_ptr; while ((line_ptr[0] != seed[0] || @@ -1423,29 +1424,29 @@ CompressData(unsigned char *line, /* I - Data to compress */ count = (line_ptr - start) / 3; - /* - * Place mode 10 compression data in the buffer; each sequence - * starts with a command byte that looks like: - * - * CMD SRC SRC OFF OFF CNT CNT CNT - * - * For the purpose of this driver, CMD and SRC are always 0. - * - * If the offset >= 3 then additional offset bytes follow the - * first command byte, each byte == 255 until the last one. - * - * If the count >= 7, then additional count bytes follow each - * group of pixels, each byte == 255 until the last one. - * - * The offset and count are in RGB tuples (not bytes, as for - * Mode 3 and 9)... - */ + // + // Place mode 10 compression data in the buffer; each sequence + // starts with a command byte that looks like: + // + // CMD SRC SRC OFF OFF CNT CNT CNT + // + // For the purpose of this driver, CMD and SRC are always 0. + // + // If the offset >= 3 then additional offset bytes follow the + // first command byte, each byte == 255 until the last one. + // + // If the count >= 7, then additional count bytes follow each + // group of pixels, each byte == 255 until the last one. + // + // The offset and count are in RGB tuples (not bytes, as for + // Mode 3 and 9)... + // if (offset >= 3) { - /* - * Output multi-byte offset... - */ + // + // Output multi-byte offset... + // if (count > 7) *comp_ptr++ = 0x1f; @@ -1463,9 +1464,9 @@ CompressData(unsigned char *line, /* I - Data to compress */ } else { - /* - * Output single-byte offset... - */ + // + // Output single-byte offset... + // if (count > 7) *comp_ptr++ = (offset << 3) | 0x07; @@ -1480,10 +1481,10 @@ CompressData(unsigned char *line, /* I - Data to compress */ { if (count <= temp) { - /* - * This is exceedingly lame... The replacement counts - * are intermingled with the data... - */ + // + // This is exceedingly lame... The replacement counts + // are intermingled with the data... + // if (temp >= 255) *comp_ptr++ = 255; @@ -1493,9 +1494,9 @@ CompressData(unsigned char *line, /* I - Data to compress */ temp -= 255; } - /* - * Get difference between current and see pixels... - */ + // + // Get difference between current and see pixels... + // r = start[0] - seed[0]; g = start[1] - seed[1]; @@ -1503,9 +1504,9 @@ CompressData(unsigned char *line, /* I - Data to compress */ if (r < -16 || r > 15 || g < -16 || g > 15 || b < -16 || b > 15) { - /* - * Pack 24-bit RGB into 23 bits... Lame... - */ + // + // Pack 24-bit RGB into 23 bits... Lame... + // *comp_ptr++ = start[0] >> 1; @@ -1521,9 +1522,9 @@ CompressData(unsigned char *line, /* I - Data to compress */ } else { - /* - * Pack 15-bit RGB difference... - */ + // + // Pack 15-bit RGB difference... + // *comp_ptr++ = 0x80 | ((r << 2) & 0x7c) | ((g >> 3) & 0x03); *comp_ptr++ = ((g << 5) & 0xe0) | (b & 0x1f); @@ -1534,10 +1535,10 @@ CompressData(unsigned char *line, /* I - Data to compress */ seed += 3; } - /* - * Make sure we have the ending count if the replacement count - * was exactly 8 + 255n... - */ + // + // Make sure we have the ending count if the replacement count + // was exactly 8 + 255n... + // if (temp == 0) *comp_ptr++ = 0; @@ -1551,43 +1552,43 @@ CompressData(unsigned char *line, /* I - Data to compress */ break; } - /* - * Set the length of the data and write a raster plane... - */ + // + // Set the length of the data and write a raster plane... + // printf("\033*b%d%c", (int)(line_end - line_ptr), pend); cfWritePrintData(line_ptr, line_end - line_ptr); } -/* - * 'OutputLine()' - Output the specified number of lines of graphics. - */ +// +// 'OutputLine()' - Output the specified number of lines of graphics. +// void -OutputLine(ppd_file_t *ppd, /* I - PPD file */ - cups_page_header2_t *header) /* I - Page header */ +OutputLine(ppd_file_t *ppd, // I - PPD file + cups_page_header2_t *header) // I - Page header { - int i, j; /* Looping vars */ - int plane; /* Current plane */ - unsigned char bit; /* Current bit */ - int bytes; /* Number of bytes/plane */ - int width; /* Width of line in pixels */ - const int *order; /* Order to use */ - unsigned char *ptr; /* Pointer into buffer */ + int i, j; // Looping vars + int plane; // Current plane + unsigned char bit; // Current bit + int bytes; // Number of bytes/plane + int width; // Width of line in pixels + const int *order; // Order to use + unsigned char *ptr; // Pointer into buffer - /* - * Output whitespace as needed... - */ + // + // Output whitespace as needed... + // if (OutputFeed > 0) { if (header->cupsCompression < 3) { - /* - * Send blank raster lines... - */ + // + // Send blank raster lines... + // while (OutputFeed > 0) { @@ -1597,9 +1598,9 @@ OutputLine(ppd_file_t *ppd, /* I - PPD file */ } else { - /* - * Send Y offset command and invalidate the seed buffer... - */ + // + // Send Y offset command and invalidate the seed buffer... + // printf("\033*b%dY", OutputFeed); OutputFeed = 0; @@ -1607,13 +1608,13 @@ OutputLine(ppd_file_t *ppd, /* I - PPD file */ } } - /* - * Write bitmap data as needed... - */ + // + // Write bitmap data as needed... + // switch (OutputMode) { - case OUTPUT_BITMAP : /* Send 1-bit bitmap data... */ + case OUTPUT_BITMAP : // Send 1-bit bitmap data... order = ColorOrders[PrinterPlanes - 1]; bytes = header->cupsBytesPerLine / PrinterPlanes; @@ -1627,7 +1628,7 @@ OutputLine(ppd_file_t *ppd, /* I - PPD file */ } break; - case OUTPUT_INVERBIT : /* Send inverted 1-bit bitmap data... */ + case OUTPUT_INVERBIT : // Send inverted 1-bit bitmap data... order = ColorOrders[PrinterPlanes - 1]; bytes = header->cupsBytesPerLine / PrinterPlanes; @@ -1646,12 +1647,12 @@ OutputLine(ppd_file_t *ppd, /* I - PPD file */ } break; - case OUTPUT_RGB : /* Send 24-bit RGB data... */ + case OUTPUT_RGB : // Send 24-bit RGB data... if (PrinterPlanes == 1 && !BlankValue) { - /* - * Invert black to grayscale... - */ + // + // Invert black to grayscale... + // for (i = header->cupsBytesPerLine, ptr = PixelBuffer; i > 0; @@ -1659,9 +1660,9 @@ OutputLine(ppd_file_t *ppd, /* I - PPD file */ *ptr = ~*ptr; } - /* - * Compress the output... - */ + // + // Compress the output... + // CompressData(PixelBuffer, header->cupsBytesPerLine, 0, 'W', header->cupsCompression); @@ -1691,49 +1692,49 @@ OutputLine(ppd_file_t *ppd, /* I - PPD file */ break; } - /* - * The seed buffer, if any, now should contain valid data... - */ + // + // The seed buffer, if any, now should contain valid data... + // SeedInvalid = 0; } -/* - * 'ReadLine()' - Read graphics from the page stream. - */ +// +// 'ReadLine()' - Read graphics from the page stream. +// -int /* O - Number of lines (0 if blank) */ -ReadLine(cups_raster_t *ras, /* I - Raster stream */ - cups_page_header2_t *header) /* I - Page header */ +int // O - Number of lines (0 if blank) +ReadLine(cups_raster_t *ras, // I - Raster stream + cups_page_header2_t *header) // I - Page header { - int plane, /* Current color plane */ - width; /* Width of line */ + int plane, // Current color plane + width; // Width of line - /* - * Read raster data... - */ + // + // Read raster data... + // cupsRasterReadPixels(ras, PixelBuffer, header->cupsBytesPerLine); - /* - * See if it is blank; if so, return right away... - */ + // + // See if it is blank; if so, return right away... + // if (cfCheckValue(PixelBuffer, header->cupsBytesPerLine, BlankValue)) return (0); - /* - * If we aren't dithering, return immediately... - */ + // + // If we aren't dithering, return immediately... + // if (OutputMode != OUTPUT_DITHERED) return (1); - /* - * Perform the color separation... - */ + // + // Perform the color separation... + // width = header->cupsWidth; @@ -1777,60 +1778,61 @@ ReadLine(cups_raster_t *ras, /* I - Raster stream */ break; } - /* - * Dither the pixels... - */ + // + // Dither the pixels... + // for (plane = 0; plane < PrinterPlanes; plane ++) cfDitherLine(DitherStates[plane], DitherLuts[plane], InputBuffer + plane, PrinterPlanes, OutputBuffers[plane]); - /* - * Return 1 to indicate that we have non-blank output... - */ + // + // Return 1 to indicate that we have non-blank output... + // return (1); } -/* - * 'main()' - Main entry and processing of driver. - */ +// +// 'main()' - Main entry and processing of driver. +// -int /* O - Exit status */ -main(int argc, /* I - Number of command-line arguments */ - char *argv[]) /* I - Command-line arguments */ +int // O - Exit status +main(int argc, // I - Number of command-line arguments + char *argv[]) // I - Command-line arguments { - int fd; /* File descriptor */ + int fd; // File descriptor int empty = 1; - cups_raster_t *ras; /* Raster stream for printing */ - cups_page_header2_t header; /* Page header from file */ - int y; /* Current line */ - ppd_file_t *ppd; /* PPD file */ - int job_id; /* Job ID */ - int num_options; /* Number of options */ - cups_option_t *options; /* Options */ + cups_raster_t *ras; // Raster stream for printing + cups_page_header2_t header; // Page header from file + int y; // Current line + ppd_file_t *ppd; // PPD file + int job_id; // Job ID + int num_options; // Number of options + cups_option_t *options; // Options #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) - struct sigaction action; /* Actions for POSIX signals */ -#endif /* HAVE_SIGACTION && !HAVE_SIGSET */ + struct sigaction action; // Actions for POSIX signals +#endif // HAVE_SIGACTION && !HAVE_SIGSET - /* - * Log function for the library functions, standard CUPS logging to stderr... - */ + // + // Log function for the library functions, standard CUPS logging to stderr... + // logfunc = cfCUPSLogFunc; ld = NULL; - /* - * Make sure status messages are not buffered... - */ + // + // Make sure status messages are not buffered... + // setbuf(stderr, NULL); - /* - * Check command-line... - */ + // + // Check command-line... + // + cf_filter_data_t temp; cf_filter_data_t *data = &temp; data->printer = getenv("PRINTER"); @@ -1845,9 +1847,9 @@ main(int argc, /* I - Number of command-line arguments */ num_options = cupsParseOptions(argv[5], 0, &options); - /* - * Open the PPD file... - */ + // + // Open the PPD file... + // ppd = ppdOpenFile(getenv("PPD")); @@ -1858,8 +1860,8 @@ main(int argc, /* I - Number of command-line arguments */ } else { - ppd_status_t status; /* PPD error */ - int linenum; /* Line number */ + ppd_status_t status; // PPD error + int linenum; // Line number fputs("DEBUG: The PPD file could not be opened.\n", stderr); @@ -1868,9 +1870,9 @@ main(int argc, /* I - Number of command-line arguments */ fprintf(stderr, "DEBUG: %s on line %d.\n", ppdErrorString(status), linenum); } - /* - * Open the page stream... - */ + // + // Open the page stream... + // if (argc == 7) { @@ -1885,14 +1887,14 @@ main(int argc, /* I - Number of command-line arguments */ ras = cupsRasterOpen(fd, CUPS_RASTER_READ); - /* - * Register a signal handler to eject the current page if the - * job is cancelled. - */ + // + // Register a signal handler to eject the current page if the + // job is cancelled. + // Canceled = 0; -#ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */ +#ifdef HAVE_SIGSET // Use System V signals over POSIX to avoid bugs sigset(SIGTERM, CancelJob); #elif defined(HAVE_SIGACTION) memset(&action, 0, sizeof(action)); @@ -1902,11 +1904,11 @@ main(int argc, /* I - Number of command-line arguments */ sigaction(SIGTERM, &action, NULL); #else signal(SIGTERM, CancelJob); -#endif /* HAVE_SIGSET */ +#endif // HAVE_SIGSET - /* - * Process pages as needed... - */ + // + // Process pages as needed... + // job_id = atoi(argv[1]); @@ -1914,9 +1916,9 @@ main(int argc, /* I - Number of command-line arguments */ while (cupsRasterReadHeader2(ras, &header)) { - /* - * Write a status message with the page number and number of copies. - */ + // + // Write a status message with the page number and number of copies. + // if (empty) empty = 0; @@ -1934,9 +1936,9 @@ main(int argc, /* I - Number of command-line arguments */ for (y = 0; y < (int)header.cupsHeight; y ++) { - /* - * Let the user know how far we have progressed... - */ + // + // Let the user know how far we have progressed... + // if (Canceled) break; @@ -1949,9 +1951,9 @@ main(int argc, /* I - Number of command-line arguments */ 100 * y / header.cupsHeight); } - /* - * Read and write a line of graphics or whitespace... - */ + // + // Read and write a line of graphics or whitespace... + // if (ReadLine(ras, &header)) OutputLine(ppd, &header); @@ -1959,9 +1961,9 @@ main(int argc, /* I - Number of command-line arguments */ OutputFeed ++; } - /* - * Eject the page... - */ + // + // Eject the page... + // fprintf(stderr, "INFO: Finished page %d.\n", Page); @@ -1988,4 +1990,3 @@ main(int argc, /* I - Number of command-line arguments */ } return (Page == 0); } - diff --git a/filter/rastertops.c b/filter/rastertops.c index f6065bb43..fe2dfcd91 100644 --- a/filter/rastertops.c +++ b/filter/rastertops.c @@ -1,65 +1,53 @@ -/* - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * @brief Convert PWG Raster to a PostScript file - * @file rastertops.c - * @author Pranjal Bhor (C) 2016 - * @author Neil 'Superna' Armstrong (C) 2010 - * @author Tobias Hoffmann (c) 2012 - * @author Till Kamppeter (c) 2014 - */ - -/* - * Include necessary headers... - */ +// +// Legacy CUPS filter wrapper for ppdFilterRasterToPS() for cups-filters. +// +// Copyright © 2020-2022 by OpenPrinting. +// +// Licensed under Apache License v2.0. See the file "LICENSE" for more +// information. +// + +// +// Include necessary headers... +// #include #include #include -/* - * Local globals... - */ -static int JobCanceled = 0;/* Set to 1 on SIGTERM */ +// +// Local globals... +// +static int JobCanceled = 0; // Set to 1 on SIGTERM -/* - * Local functions... - */ + +// +// Local functions... +// static void cancel_job(int sig); -/* - * 'main()' - Main entry and processing of driver. - */ +// +// 'main()' - Main entry and processing of driver. +// -int /* O - Exit status */ -main(int argc, /* I - Number of command-line arguments */ - char *argv[]) /* I - Command-line arguments */ +int // O - Exit status +main(int argc, // I - Number of command-line arguments + char *argv[]) // I - Command-line arguments { int ret; #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) - struct sigaction action; /* Actions for POSIX signals */ -#endif /* HAVE_SIGACTION && !HAVE_SIGSET */ + struct sigaction action; // Actions for POSIX signals +#endif // HAVE_SIGACTION && !HAVE_SIGSET - /* - * Register a signal handler to cleanly cancel a job. - */ + // + // Register a signal handler to cleanly cancel a job. + // -#ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */ +#ifdef HAVE_SIGSET // Use System V signals over POSIX to avoid bugs sigset(SIGTERM, cancel_job); #elif defined(HAVE_SIGACTION) memset(&action, 0, sizeof(action)); @@ -69,11 +57,11 @@ main(int argc, /* I - Number of command-line arguments */ sigaction(SIGTERM, &action, NULL); #else signal(SIGTERM, cancel_job); -#endif /* HAVE_SIGSET */ +#endif // HAVE_SIGSET - /* - * Fire up the cfFilterRasterToPS() filter function - */ + // + // Fire up the ppdFilterRasterToPS() filter function + // ret = ppdFilterCUPSWrapper(argc, argv, ppdFilterRasterToPS, NULL, &JobCanceled); @@ -85,15 +73,14 @@ main(int argc, /* I - Number of command-line arguments */ } -/* - * 'cancel_job()' - Flag the job as canceled. - */ +// +// 'cancel_job()' - Flag the job as canceled. +// static void -cancel_job(int sig) /* I - Signal number (unused) */ +cancel_job(int sig) // I - Signal number (unused) { (void)sig; JobCanceled = 1; } - diff --git a/filter/rastertopwg.c b/filter/rastertopwg.c index e4ae89544..032b49b56 100644 --- a/filter/rastertopwg.c +++ b/filter/rastertopwg.c @@ -1,43 +1,53 @@ -/* - * Include necessary headers... - */ +// +// Legacy CUPS filter wrapper for cfFilterRasterToPWG() for cups-filters. +// +// Copyright © 2020-2022 by OpenPrinting. +// +// Licensed under Apache License v2.0. See the file "LICENSE" for more +// information. +// + +// +// Include necessary headers... +// #include #include #include -/* - * Local globals... - */ -static int JobCanceled = 0;/* Set to 1 on SIGTERM */ +// +// Local globals... +// +static int JobCanceled = 0; // Set to 1 on SIGTERM -/* - * Local functions... - */ + +// +// Local functions... +// static void cancel_job(int sig); -/* - * 'main()' - Main entry and processing of driver. - */ +// +// 'main()' - Main entry and processing of driver. +// -int /* O - Exit status */ -main(int argc, /* I - Number of command-line arguments */ - char *argv[]) /* I - Command-line arguments */ +int // O - Exit status +main(int argc, // I - Number of command-line arguments + char *argv[]) // I - Command-line arguments { int ret; #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) - struct sigaction action; /* Actions for POSIX signals */ -#endif /* HAVE_SIGACTION && !HAVE_SIGSET */ + struct sigaction action; // Actions for POSIX signals +#endif // HAVE_SIGACTION && !HAVE_SIGSET - /* - * Register a signal handler to cleanly cancel a job. - */ + // + // Register a signal handler to cleanly cancel a job. + // -#ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */ +#ifdef HAVE_SIGSET // Use System V signals over POSIX to avoid bugs sigset(SIGTERM, cancel_job); #elif defined(HAVE_SIGACTION) memset(&action, 0, sizeof(action)); @@ -47,11 +57,11 @@ main(int argc, /* I - Number of command-line arguments */ sigaction(SIGTERM, &action, NULL); #else signal(SIGTERM, cancel_job); -#endif /* HAVE_SIGSET */ +#endif // HAVE_SIGSET - /* - * Fire up the ppdFilterRasterToPWG() filter function - */ + // + // Fire up the cfFilterRasterToPWG() filter function + // ret = ppdFilterCUPSWrapper(argc, argv, cfFilterRasterToPWG, NULL, &JobCanceled); @@ -62,12 +72,12 @@ main(int argc, /* I - Number of command-line arguments */ } -/* - * 'cancel_job()' - Flag the job as canceled. - */ +// +// 'cancel_job()' - Flag the job as canceled. +// static void -cancel_job(int sig) /* I - Signal number (unused) */ +cancel_job(int sig) // I - Signal number (unused) { (void)sig; diff --git a/filter/test-external.c b/filter/test-external.c index dbe02ae9c..6d1fa79da 100644 --- a/filter/test-external.c +++ b/filter/test-external.c @@ -1,3 +1,17 @@ +// +// Legacy CUPS filter wrapper for cfFilterExternal() and +// ppdFilterExternalCUPS() for cups-filters. +// +// Primarily for testing and debugging. CUPS filters which can be called +// by these filter functions can also be called directly instead of this +// wrapper. +// +// Copyright © 2020-2022 by OpenPrinting. +// +// Licensed under Apache License v2.0. See the file "LICENSE" for more +// information. +// + // // Include necessary headers... // @@ -7,6 +21,7 @@ #include #include + // // Local globals... // @@ -20,8 +35,9 @@ static int JobCanceled = 0; // Set to 1 on SIGTERM static void cancel_job(int sig); + // -// 'main()' - Main entry and processing of driver. +// 'main()' - Main entry. // int // O - Exit status diff --git a/filter/texttopdf.c b/filter/texttopdf.c index 43b56179c..96535cc27 100644 --- a/filter/texttopdf.c +++ b/filter/texttopdf.c @@ -1,6 +1,15 @@ -/* - * Include necessary headers... - */ +// +// Legacy CUPS filter wrapper for cfFilterTextToPDF() for cups-filters. +// +// Copyright © 2020-2022 by OpenPrinting. +// +// Licensed under Apache License v2.0. See the file "LICENSE" for more +// information. +// + +// +// Include necessary headers... +// #include #include @@ -8,37 +17,39 @@ #include #include -/* - * Local globals... - */ -static int JobCanceled = 0;/* Set to 1 on SIGTERM */ +// +// Local globals... +// +static int JobCanceled = 0; // Set to 1 on SIGTERM -/* - * Local functions... - */ + +// +// Local functions... +// static void cancel_job(int sig); -/* - * 'main()' - Main entry and processing of driver. - */ -int /* O - Exit status */ -main(int argc, /* I - Number of command-line arguments */ - char *argv[]) /* I - Command-line arguments */ +// +// 'main()' - Main entry and processing of driver. +// + +int // O - Exit status +main(int argc, // I - Number of command-line arguments + char *argv[]) // I - Command-line arguments { int ret; #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) - struct sigaction action; /* Actions for POSIX signals */ -#endif /* HAVE_SIGACTION && !HAVE_SIGSET */ + struct sigaction action; // Actions for POSIX signals +#endif // HAVE_SIGACTION && !HAVE_SIGSET - /* - * Register a signal handler to cleanly cancel a job. - */ + // + // Register a signal handler to cleanly cancel a job. + // -#ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */ +#ifdef HAVE_SIGSET // Use System V signals over POSIX to avoid bugs sigset(SIGTERM, cancel_job); #elif defined(HAVE_SIGACTION) memset(&action, 0, sizeof(action)); @@ -48,32 +59,34 @@ main(int argc, /* I - Number of command-line arguments */ sigaction(SIGTERM, &action, NULL); #else signal(SIGTERM, cancel_job); -#endif /* HAVE_SIGSET */ - - /* - * Fire up the ppdFilterTextToPDF() filter function - */ - cf_filter_texttopdf_parameter_t parameters; - char *p; - - if ((p = getenv("CUPS_DATADIR")) != NULL) - parameters.data_dir = p; - else - parameters.data_dir = CUPS_DATADIR; - if ((p = getenv("CHARSET")) != NULL) - parameters.char_set = p; - else - parameters.char_set = NULL; - if ((p = getenv("CONTENT_TYPE")) != NULL) - parameters.content_type = p; - else - parameters.content_type = NULL; - if ((p = getenv("CLASSIFICATION")) != NULL) - parameters.classification = p; - else - parameters.classification = NULL; - - ret = ppdFilterCUPSWrapper(argc, argv, cfFilterTextToPDF, ¶meters, &JobCanceled); +#endif // HAVE_SIGSET + + // + // Fire up the cfFilterTextToPDF() filter function + // + + cf_filter_texttopdf_parameter_t parameters; + char *p; + + if ((p = getenv("CUPS_DATADIR")) != NULL) + parameters.data_dir = p; + else + parameters.data_dir = CUPS_DATADIR; + if ((p = getenv("CHARSET")) != NULL) + parameters.char_set = p; + else + parameters.char_set = NULL; + if ((p = getenv("CONTENT_TYPE")) != NULL) + parameters.content_type = p; + else + parameters.content_type = NULL; + if ((p = getenv("CLASSIFICATION")) != NULL) + parameters.classification = p; + else + parameters.classification = NULL; + + ret = ppdFilterCUPSWrapper(argc, argv, cfFilterTextToPDF, ¶meters, + &JobCanceled); if (ret) fprintf(stderr, "ERROR: texttopdf filter function failed.\n"); @@ -82,12 +95,12 @@ main(int argc, /* I - Number of command-line arguments */ } -/* - * 'cancel_job()' - Flag the job as canceled. - */ +// +// 'cancel_job()' - Flag the job as canceled. +// static void -cancel_job(int sig) /* I - Signal number (unused) */ +cancel_job(int sig) // I - Signal number (unused) { (void)sig; diff --git a/filter/texttops b/filter/texttops index 23609b999..2c071a477 100644 --- a/filter/texttops +++ b/filter/texttops @@ -1,6 +1,6 @@ #!/bin/sh -# texttops - This is a Text-to-PostScript filter for CUPS +# texttops - This is a Text-to-PostScript filter for cups-filters # # Note: This wrapper filter is only included for backward compatibility with # certan custom configurations. It is not mentioned in any of the .convs @@ -11,10 +11,11 @@ # # DO NOT create new PPD or .convs files using this filter! texttops is # DEPRECATED! - +# # (C) 2012 Till Kamppeter # -# Released under GPL 2 or later +# Licensed under Apache License v2.0. See the file "LICENSE" for more +# information. # PDF2PS=`which pdf2ps` diff --git a/filter/texttotext.c b/filter/texttotext.c index d27ab7f14..064feb0c6 100644 --- a/filter/texttotext.c +++ b/filter/texttotext.c @@ -1,43 +1,53 @@ -/* - * Include necessary headers... - */ +// +// Legacy CUPS filter wrapper for cfFilterTextToText() for cups-filters. +// +// Copyright © 2020-2022 by OpenPrinting. +// +// Licensed under Apache License v2.0. See the file "LICENSE" for more +// information. +// + +// +// Include necessary headers... +// #include #include #include -/* - * Local globals... - */ -static int JobCanceled = 0;/* Set to 1 on SIGTERM */ +// +// Local globals... +// +static int JobCanceled = 0; // Set to 1 on SIGTERM -/* - * Local functions... - */ + +// +// Local functions... +// static void cancel_job(int sig); -/* - * 'main()' - Main entry and processing of driver. - */ +// +// 'main()' - Main entry and processing of driver. +// -int /* O - Exit status */ -main(int argc, /* I - Number of command-line arguments */ - char *argv[]) /* I - Command-line arguments */ +int // O - Exit status +main(int argc, // I - Number of command-line arguments + char *argv[]) // I - Command-line arguments { int ret; #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) - struct sigaction action; /* Actions for POSIX signals */ -#endif /* HAVE_SIGACTION && !HAVE_SIGSET */ + struct sigaction action; // Actions for POSIX signals +#endif // HAVE_SIGACTION && !HAVE_SIGSET - /* - * Register a signal handler to cleanly cancel a job. - */ + // + // Register a signal handler to cleanly cancel a job. + // -#ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */ +#ifdef HAVE_SIGSET // Use System V signals over POSIX to avoid bugs sigset(SIGTERM, cancel_job); #elif defined(HAVE_SIGACTION) memset(&action, 0, sizeof(action)); @@ -47,12 +57,11 @@ main(int argc, /* I - Number of command-line arguments */ sigaction(SIGTERM, &action, NULL); #else signal(SIGTERM, cancel_job); -#endif /* HAVE_SIGSET */ - - /* - * Fire up the ppdFilterTextToText() filter function - */ +#endif // HAVE_SIGSET + // + // Fire up the cfFilterTextToText() filter function + // ret = ppdFilterCUPSWrapper(argc, argv, cfFilterTextToText, NULL, &JobCanceled); @@ -64,12 +73,12 @@ main(int argc, /* I - Number of command-line arguments */ } -/* - * 'cancel_job()' - Flag the job as canceled. - */ +// +// 'cancel_job()' - Flag the job as canceled. +// static void -cancel_job(int sig) /* I - Signal number (unused) */ +cancel_job(int sig) // I - Signal number (unused) { (void)sig; diff --git a/filter/universal.c b/filter/universal.c index aaaf98768..5a492d866 100644 --- a/filter/universal.c +++ b/filter/universal.c @@ -1,6 +1,15 @@ -/* - * Include necessary headers... - */ +// +// Legacy CUPS filter wrapper for cfFilterUniversal() for cups-filters. +// +// Copyright © 2020-2022 by OpenPrinting. +// +// Licensed under Apache License v2.0. See the file "LICENSE" for more +// information. +// + +// +// Include necessary headers... +// #include #include @@ -8,27 +17,27 @@ #include -/* - * Local globals... - */ +// +// Local globals... +// -static int JobCanceled = 0;/* Set to 1 on SIGTERM */ +static int JobCanceled = 0; // Set to 1 on SIGTERM -/* - * Local functions... - */ +// +// Local functions... +// static void cancel_job(int sig); -/* - * 'main()' - Main entry. - */ +// +// 'main()' - Main entry. +// -int /* O - Exit status */ -main(int argc, /* I - Number of command-line args */ - char *argv[]) /* I - Command-line arguments */ +int // O - Exit status +main(int argc, // I - Number of command-line args + char *argv[]) // I - Command-line arguments { int ret; char *p; @@ -36,14 +45,14 @@ main(int argc, /* I - Number of command-line args */ char buf[1024]; const char *datadir; #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) - struct sigaction action; /* Actions for POSIX signals */ -#endif /* HAVE_SIGACTION && !HAVE_SIGSET */ + struct sigaction action; // Actions for POSIX signals +#endif // HAVE_SIGACTION && !HAVE_SIGSET - /* - * Register a signal handler to cleanly cancel a job. - */ + // + // Register a signal handler to cleanly cancel a job. + // -#ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */ +#ifdef HAVE_SIGSET // Use System V signals over POSIX to avoid bugs sigset(SIGTERM, cancel_job); #elif defined(HAVE_SIGACTION) memset(&action, 0, sizeof(action)); @@ -53,9 +62,9 @@ main(int argc, /* I - Number of command-line args */ sigaction(SIGTERM, &action, NULL); #else signal(SIGTERM, cancel_job); -#endif /* HAVE_SIGSET */ +#endif // HAVE_SIGSET - universal_parameters.actual_output_type = NULL; /* Determined by PPD file */ + universal_parameters.actual_output_type = NULL; // Determined by PPD file if ((p = getenv("CUPS_DATADIR")) != NULL) universal_parameters.texttopdf_params.data_dir = strdup(p); @@ -98,15 +107,14 @@ main(int argc, /* I - Number of command-line args */ } -/* - * 'cancel_job()' - Flag the job as canceled. - */ +// +// 'cancel_job()' - Flag the job as canceled. +// static void -cancel_job(int sig) /* I - Signal number (unused) */ +cancel_job(int sig) // I - Signal number (unused) { (void)sig; JobCanceled = 1; } - -- 2.47.3