From 1f457376b478257b88d4a857f5ec1b6155442dd7 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Sun, 20 Sep 2020 03:03:26 +0000 Subject: CTAN sync 202009200303 --- support/dktools/wprclean2.c | 191 +++++++++++++++++++++++--------------------- 1 file changed, 101 insertions(+), 90 deletions(-) (limited to 'support/dktools/wprclean2.c') diff --git a/support/dktools/wprclean2.c b/support/dktools/wprclean2.c index 477d24bff0..057f699566 100644 --- a/support/dktools/wprclean2.c +++ b/support/dktools/wprclean2.c @@ -1,12 +1,18 @@ /* - WARNING: This file was generated by dkct. +Copyright (C) 2017-2020, Dirk Krause +SPDX-License-Identifier: BSD-3-Clause +*/ + +/* + WARNING: This file was generated by the dkct program (see + http://dktools.sourceforge.net/ for details). Changes you make here will be lost if dkct is run again! You should modify the original source and run dkct on it. Original source: wprclean2.ctr */ -#line 5 "wprclean2.ctr" +#line 7 "wprclean2.ctr" /** @file wprclean.c Cleanup Windows print queues. */ @@ -83,11 +89,14 @@ #include "dk4hnamed.h" #include "dk4user.h" +#ifndef DK4WMAIN_H_INCLUDED +#include "dk4wmain.h" +#endif -#line 84 "wprclean2.ctr" +#line 89 "wprclean2.ctr" @@ -115,7 +124,7 @@ dkT("wprclean.str"), NULL -#line 113 "wprclean2.ctr" +#line 118 "wprclean2.ctr" }; @@ -165,7 +174,7 @@ dkT("\"!"), NULL -#line 159 "wprclean2.ctr" +#line 164 "wprclean2.ctr" }; @@ -210,7 +219,7 @@ dkT("\t--license\tShow license information."), NULL -#line 178 "wprclean2.ctr" +#line 183 "wprclean2.ctr" }; @@ -224,7 +233,8 @@ dkT("This software uses code from the following projects, either directly or as" dkT("a library:"), dkT(""), dkT("dktools\t\tDirk Krause's tools and libraries."), -dkT("\t\tSee http://dktools.sourceforge.net/ for more information."), +dkT("\t\tSee http://sourceforge.net/p/dktools/wiki/Home/"), +dkT("\t\tfor more information."), #if DK4_HAVE_ZLIB_H dkT(""), dkT("zlib\t\tData compression library."), @@ -251,27 +261,28 @@ dkT(""), dkT("Redistribution and use in source and binary forms, with or without"), dkT("modification, are permitted provided that the following conditions are met:"), dkT(""), -dkT("* Redistributions of source code must retain the above copyright notice,"), -dkT(" this list of conditions and the following disclaimer."), -dkT("* Redistributions in binary form must reproduce the above copyright"), -dkT(" notice, this list of conditions and the following disclaimer in the"), -dkT(" documentation and/or other materials provided with the distribution."), -dkT("* Neither the name of the Dirk Krause nor the names of contributors may be"), -dkT(" used to endorse or promote products derived from this software without"), -dkT(" specific prior written permission."), +dkT("1. Redistributions of source code must retain the above copyright notice,"), +dkT(" this list of conditions and the following disclaimer."), +dkT("2. Redistributions in binary form must reproduce the above copyright"), +dkT(" notice, this list of conditions and the following disclaimer in the"), +dkT(" documentation and/or other materials provided with the distribution."), +dkT("3. Neither the name of the copyright holder nor the names of its"), +dkT(" contributors may be used to endorse or promote products derived from"), +dkT(" this software without specific prior written permission."), dkT(""), -dkT("THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\""), -dkT("AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE"), -dkT("IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE"), -dkT("ARE DISCLAIMED."), +dkT("THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS"), +dkT("``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT"), +dkT("LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR"), +dkT("A PARTICULAR PURPOSE ARE DISCLAIMED."), +dkT("IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY"), +dkT("DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES"), +dkT("(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR"), +dkT("SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER"), +dkT("CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT"), +dkT("LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY"), +dkT("OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF"), +dkT("SUCH DAMAGE."), dkT(""), -dkT("IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,"), -dkT("INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,"), -dkT("BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,"), -dkT("DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY"), -dkT("OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING"), -dkT("NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,"), -dkT("EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."), #if DK4_HAVE_ZLIB_H dkT(""), dkT(""), @@ -345,7 +356,7 @@ dkT(""), NULL -#line 311 "wprclean2.ctr" +#line 318 "wprclean2.ctr" }; @@ -472,56 +483,56 @@ check_options(void) dkChar *ptr; -#line 436 "wprclean2.ctr" +#line 443 "wprclean2.ctr" host_long[0] = dkT('\0'); host_short[0] = dkT('\0'); user_name[0] = dkT('\0'); if (0 != dk4app_opt_is_set_short(app, dkT('v'), NULL)) { verbose = 1; -#line 441 "wprclean2.ctr" +#line 448 "wprclean2.ctr" } if (0 != dk4app_opt_is_set_short(app, dkT('c'), NULL)) { -#line 443 "wprclean2.ctr" +#line 450 "wprclean2.ctr" if (0 != dk4hostname(host_long, DK4_SIZEOF(host_long,dkChar), NULL)) { only_this_host = 1; -#line 445 "wprclean2.ctr" +#line 452 "wprclean2.ctr" if (0 != dk4str_cpy_s(host_short, sz_host_short, host_long, NULL)) { ptr = dk4str_chr(host_short, dkT('.')); -#line 447 "wprclean2.ctr" +#line 454 "wprclean2.ctr" if (NULL != ptr) { -#line 448 "wprclean2.ctr" +#line 455 "wprclean2.ctr" *ptr = dkT('\0'); have_short_host = 1; } #if TRACE_DEBUG else { -#line 453 "wprclean2.ctr" +#line 460 "wprclean2.ctr" } #endif } #if TRACE_DEBUG else { -#line 458 "wprclean2.ctr" +#line 465 "wprclean2.ctr" } #endif } #if TRACE_DEBUG else { -#line 463 "wprclean2.ctr" +#line 470 "wprclean2.ctr" } #endif } -#line 467 "wprclean2.ctr" +#line 474 "wprclean2.ctr" } @@ -601,34 +612,34 @@ setup_for_queue_list(void) int back = 0; -#line 545 "wprclean2.ctr" +#line 552 "wprclean2.ctr" s_q = dk4sto_open(NULL); if (NULL != s_q) { -#line 547 "wprclean2.ctr" +#line 554 "wprclean2.ctr" dk4sto_set_comp(s_q, compare_queues, 0); i_q = dk4sto_it_open(s_q, NULL); if (NULL != i_q) { -#line 550 "wprclean2.ctr" +#line 557 "wprclean2.ctr" back = 1; } #if TRACE_DEBUG else { -#line 554 "wprclean2.ctr" +#line 561 "wprclean2.ctr" } #endif } #if TRACE_DEBUG else { -#line 559 "wprclean2.ctr" +#line 566 "wprclean2.ctr" } #endif -#line 562 "wprclean2.ctr" +#line 569 "wprclean2.ctr" return back; } @@ -643,12 +654,12 @@ cleanup_for_queue_list(void) dkChar *p; -#line 575 "wprclean2.ctr" +#line 582 "wprclean2.ctr" /* Release all queue names saved, close iterator. */ if (NULL != i_q) { -#line 578 "wprclean2.ctr" +#line 585 "wprclean2.ctr" dk4sto_it_reset(i_q); do { p = (dkChar *)dk4sto_it_next(i_q); @@ -657,19 +668,19 @@ cleanup_for_queue_list(void) } } while (NULL != p); -#line 585 "wprclean2.ctr" +#line 592 "wprclean2.ctr" dk4sto_it_close(i_q); i_q = NULL; } /* Close storage. */ if (NULL != s_q) { -#line 590 "wprclean2.ctr" +#line 597 "wprclean2.ctr" dk4sto_close(s_q); s_q = NULL; } -#line 593 "wprclean2.ctr" +#line 600 "wprclean2.ctr" } @@ -697,7 +708,7 @@ retrieve_queue_list(void) int back = 0; -#line 619 "wprclean2.ctr" +#line 626 "wprclean2.ctr" cbNeeded = cbReturned = szPeb = (DWORD)0UL; #if DK4_CHAR_SIZE > 1 EnumPrintersW(PRINTER_ENUM_LOCAL,NULL,2,NULL,szPeb,&cbNeeded,&cbReturned); @@ -729,7 +740,7 @@ retrieve_queue_list(void) if (0 == dk4sto_add(s_q, pn, NULL)) { dk4mem_free(pn); -#line 649 "wprclean2.ctr" +#line 656 "wprclean2.ctr" back = 0; exval = EXIT_FAILURE; /* ERROR: Memory */ @@ -737,7 +748,7 @@ retrieve_queue_list(void) } } else { -#line 655 "wprclean2.ctr" +#line 662 "wprclean2.ctr" back = 0; exval = EXIT_FAILURE; /* ERROR: Memory */ @@ -745,7 +756,7 @@ retrieve_queue_list(void) } } else { -#line 661 "wprclean2.ctr" +#line 668 "wprclean2.ctr" back = 0; exval = EXIT_FAILURE; /* ERROR: Invalid printer configuration */ @@ -755,11 +766,11 @@ retrieve_queue_list(void) } } else { -#line 669 "wprclean2.ctr" +#line 676 "wprclean2.ctr" } } else { -#line 671 "wprclean2.ctr" +#line 678 "wprclean2.ctr" exval = EXIT_FAILURE; /* ERROR: Printer enumeration failed */ dk4app_log_1(app, msg, sz_msg, DK4_LL_ERROR, 2); @@ -767,16 +778,16 @@ retrieve_queue_list(void) dk4mem_release(peb); } else { -#line 677 "wprclean2.ctr" +#line 684 "wprclean2.ctr" exval = EXIT_FAILURE; } } else { -#line 680 "wprclean2.ctr" +#line 687 "wprclean2.ctr" } -#line 682 "wprclean2.ctr" +#line 689 "wprclean2.ctr" return back; #else return 1; @@ -821,13 +832,13 @@ handle_one_queue(const dkChar *pn) BOOL br5 = FALSE; /* SetJob res */ -#line 725 "wprclean2.ctr" +#line 732 "wprclean2.ctr" /* Prepare data structures. */ s_j = dk4sto_open(NULL); if (NULL == s_j) { -#line 729 "wprclean2.ctr" +#line 736 "wprclean2.ctr" exval = EXIT_FAILURE; /* ERROR: Memory */ dk4app_log_base1(app, DK4_LL_ERROR, 90); @@ -837,7 +848,7 @@ handle_one_queue(const dkChar *pn) i_j = dk4sto_it_open(s_j, NULL); if (NULL == i_j) { -#line 737 "wprclean2.ctr" +#line 744 "wprclean2.ctr" exval = EXIT_FAILURE; /* ERROR: Memory */ dk4app_log_base1(app, DK4_LL_ERROR, 90); @@ -852,7 +863,7 @@ handle_one_queue(const dkChar *pn) #endif if (!(bres)) { -#line 750 "wprclean2.ctr" +#line 757 "wprclean2.ctr" h_pr = INVALID_HANDLE_VALUE; exval = EXIT_FAILURE; /* ERROR: Failed to open printer */ @@ -868,13 +879,13 @@ handle_one_queue(const dkChar *pn) #endif if ((DWORD)0UL == sz1) { -#line 764 "wprclean2.ctr" +#line 771 "wprclean2.ctr" -#line 765 "wprclean2.ctr" +#line 772 "wprclean2.ctr" -#line 766 "wprclean2.ctr" +#line 773 "wprclean2.ctr" exval = EXIT_FAILURE; /* ERROR: Failed to request print queue */ dk4app_log_3(app, msg, sz_msg, DK4_LL_ERROR, 5, 6, pn); @@ -882,7 +893,7 @@ handle_one_queue(const dkChar *pn) } if ((DWORD)0UL == sz1) { -#line 772 "wprclean2.ctr" +#line 779 "wprclean2.ctr" exval = EXIT_FAILURE; /* ERROR: Failed to request print queue */ dk4app_log_3(app, msg, sz_msg, DK4_LL_ERROR, 5, 6, pn); @@ -891,7 +902,7 @@ handle_one_queue(const dkChar *pn) pc1 = dk4mem_new_app(char,(size_t)sz1,app); if (NULL == pc1) { -#line 779 "wprclean2.ctr" +#line 786 "wprclean2.ctr" exval = EXIT_FAILURE; goto finished; } @@ -902,7 +913,7 @@ handle_one_queue(const dkChar *pn) #endif if (!(br2)) { -#line 788 "wprclean2.ctr" +#line 795 "wprclean2.ctr" exval = EXIT_FAILURE; /* ERROR: GetPrinter failed */ dk4app_log_3(app, msg, sz_msg, DK4_LL_ERROR, 9, 10, pn); @@ -910,7 +921,7 @@ handle_one_queue(const dkChar *pn) } if (sz2 > sz1) { -#line 794 "wprclean2.ctr" +#line 801 "wprclean2.ctr" exval = EXIT_FAILURE; /* ERROR: Number of bytes increased. */ dk4app_log_3(app, msg, sz_msg, DK4_LL_ERROR, 9, 10, pn); @@ -920,7 +931,7 @@ handle_one_queue(const dkChar *pn) nJobs = pi2->cJobs; if ((DWORD)0UL == nJobs) { -#line 802 "wprclean2.ctr" +#line 809 "wprclean2.ctr" goto finished; } /* Retrieve job data and build sorted storage @@ -936,7 +947,7 @@ handle_one_queue(const dkChar *pn) #endif if ((!(br3)) || ((DWORD)0UL == sz3)) { -#line 816 "wprclean2.ctr" +#line 823 "wprclean2.ctr" exval = EXIT_FAILURE; /* ERROR: Failed to find required byte number */ dk4app_log_3(app, msg, sz_msg, DK4_LL_ERROR, 7, 8, pn); @@ -945,7 +956,7 @@ handle_one_queue(const dkChar *pn) pc2 = dk4mem_new_app(char,(size_t)sz3,app); if (NULL == pc2) { -#line 823 "wprclean2.ctr" +#line 830 "wprclean2.ctr" exval = EXIT_FAILURE; goto finished; } @@ -961,7 +972,7 @@ handle_one_queue(const dkChar *pn) #endif if (!(br4)) { -#line 837 "wprclean2.ctr" +#line 844 "wprclean2.ctr" exval = EXIT_FAILURE; /* ERROR: EnumJobs */ dk4app_log_3(app, msg, sz_msg, DK4_LL_ERROR, 7, 8, pn); @@ -969,7 +980,7 @@ handle_one_queue(const dkChar *pn) } if (sz4 > sz3) { -#line 843 "wprclean2.ctr" +#line 850 "wprclean2.ctr" exval = EXIT_FAILURE; /* ERROR: Number of bytes changed */ dk4app_log_3(app, msg, sz_msg, DK4_LL_ERROR, 7, 8, pn); @@ -985,19 +996,19 @@ handle_one_queue(const dkChar *pn) um = 1; if (0 != only_this_host) { -#line 857 "wprclean2.ctr" +#line 864 "wprclean2.ctr" if (NULL != ji1->pMachineName) { -#line 858 "wprclean2.ctr" +#line 865 "wprclean2.ctr" if (0 != dk4str_casecmp(host_long, ji1->pMachineName)) { mm = 0; if (0 != have_short_host) { -#line 861 "wprclean2.ctr" +#line 868 "wprclean2.ctr" if (0 == dk4str_casecmp(host_short, ji1->pMachineName)) { mm = 1; -#line 863 "wprclean2.ctr" +#line 870 "wprclean2.ctr" } } } @@ -1010,22 +1021,22 @@ handle_one_queue(const dkChar *pn) } else { -#line 874 "wprclean2.ctr" +#line 881 "wprclean2.ctr" um = 0; } if ((0 != mm) && (0 != um)) { -#line 877 "wprclean2.ctr" +#line 884 "wprclean2.ctr" pj = dk4mem_new_app(wprclean_printjob_t,1,app); if (NULL != pj) { pj->position = i; pj->jobid = ji1->JobId; -#line 882 "wprclean2.ctr" +#line 889 "wprclean2.ctr" if (0 == dk4sto_add(s_j, pj, NULL)) { -#line 883 "wprclean2.ctr" +#line 890 "wprclean2.ctr" dk4mem_free(pj); exval = EXIT_FAILURE; /* ERROR: Memory */ @@ -1033,7 +1044,7 @@ handle_one_queue(const dkChar *pn) } } else { -#line 889 "wprclean2.ctr" +#line 896 "wprclean2.ctr" exval = EXIT_FAILURE; } } @@ -1046,7 +1057,7 @@ handle_one_queue(const dkChar *pn) pj = (wprclean_printjob_t *)dk4sto_it_next(i_j); if (NULL != pj) { -#line 900 "wprclean2.ctr" +#line 907 "wprclean2.ctr" #if DK4_CHAR_SIZE > 1 br5 = SetJobW(h_pr, pj->jobid, 0, NULL, JOB_CONTROL_DELETE); #else @@ -1054,14 +1065,14 @@ handle_one_queue(const dkChar *pn) #endif if (!(br5)) { -#line 906 "wprclean2.ctr" +#line 913 "wprclean2.ctr" exval = EXIT_FAILURE; /* ERROR: Failed to remove job */ dk4app_log_3(app, msg, sz_msg, DK4_LL_ERROR, 11, 12, pn); } else { -#line 911 "wprclean2.ctr" +#line 918 "wprclean2.ctr" } } } while(NULL != pj); @@ -1093,7 +1104,7 @@ handle_one_queue(const dkChar *pn) } -#line 941 "wprclean2.ctr" +#line 948 "wprclean2.ctr" } @@ -1142,10 +1153,10 @@ int main(int argc, char *argv[]) { -#line 988 "wprclean2.ctr" +#line 995 "wprclean2.ctr" -#line 989 "wprclean2.ctr" +#line 996 "wprclean2.ctr" app = dk4app_open_cmd( argc, argv, wprclean_options, wprclean_sz_options, wprclean_kwnl[0], DKT_VERSION_DK, @@ -1169,10 +1180,10 @@ int main(int argc, char *argv[]) } -#line 1011 "wprclean2.ctr" +#line 1018 "wprclean2.ctr" -#line 1012 "wprclean2.ctr" +#line 1019 "wprclean2.ctr" exit(exval); return exval; } -- cgit v1.2.3