1 /*
2  *   PPD file generation program for the CUPS drivers.
3  *
4  *   Copyright 1993-2008 by Mike Sweet and Robert Krawitz.
5  *
6  *   This program is free software; you can redistribute it and/or modify it
7  *   under the terms of the GNU General Public License as published by the Free
8  *   Software Foundation; either version 2 of the License, or (at your option)
9  *   any later version.
10  *
11  *   This program is distributed in the hope that it will be useful, but
12  *   WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13  *   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14  *   for more details.
15  *
16  *   You should have received a copy of the GNU General Public License
17  *   along with this program.  If not, see <https://www.gnu.org/licenses/>.
18  *
19  * Contents:
20  *
21  *   main()              - Process files on the command-line...
22  *   cat_ppd()           - Copy the named PPD to stdout.
23  *   generate_ppd()      - Generate a PPD file.
24  *   getlangs()          - Get a list of available translations.
25  *   help()              - Show detailed help.
26  *   is_special_option() - Determine if an option should be grouped.
27  *   list_ppds()         - List the available drivers.
28  *   print_group_close() - Close a UI group.
29  *   print_group_open()  - Open a new UI group.
30  *   printlangs()        - Print list of available translations.
31  *   printmodels()       - Print a list of available models.
32  *   usage()             - Show program usage.
33  *   write_ppd()         - Write a PPD file.
34  */
35 
36 #include "i18n.h"
37 #ifdef HAVE_CONFIG_H
38 #include <config.h>
39 #endif
40 #include <stdio.h>
41 #include <stdlib.h>
42 #include <string.h>
43 #include <dirent.h>
44 #include <unistd.h>
45 #include <fcntl.h>
46 #include <sys/types.h>
47 #include <sys/stat.h>
48 #include <string.h>
49 #include <ctype.h>
50 #include <errno.h>
51 #include <libgen.h>
52 #include <strings.h>
53 #include <sys/types.h>
54 #include <sys/wait.h>
55 
56 #include <cups/raster.h>
57 
58 extern char	**getlangs(void);
59 
60 
61 typedef enum
62 {
63   PPD_STANDARD = 0,
64   PPD_SIMPLIFIED = 1,
65   PPD_NO_COLOR_OPTS = 2
66 } ppd_type_t;
67 
68 #ifdef HAVE_LIBZ
69 #include <zlib.h>
70 #endif
71 
72 typedef union
73 {
74 #ifdef HAVE_LIBZ
75   gzFile gzf;
76 #endif
77   FILE *f;
78 } gpfile;
79 typedef gpfile *gpFile;
80 
81 extern const char *ppdext;
82 extern const char *cups_modeldir;
83 extern const char *gpext;
84 extern int cups_ppd_ps_level;
85 extern int localize_numbers;
86 extern int use_base_version;
87 
88 extern int	write_ppd(gpFile fp, const stp_printer_t *p,
89 		          const char *language, const char *ppd_location,
90 			  ppd_type_t ppd_type, const char *filename,
91 			  int compress);
92