]> git.ipfire.org Git - thirdparty/cups.git/blame - ppdc/ppdi.cxx
Remove all of the Subversion keywords from various source files.
[thirdparty/cups.git] / ppdc / ppdi.cxx
CommitLineData
ac884b6a 1//
503b54c9 2// PPD file import utility for the CUPS PPD Compiler.
ac884b6a 3//
503b54c9
MS
4// Copyright 2007-2011 by Apple Inc.
5// Copyright 2002-2005 by Easy Software Products.
ac884b6a 6//
503b54c9
MS
7// These coded instructions, statements, and computer programs are the
8// property of Apple Inc. and are protected by Federal copyright
9// law. Distribution and use rights are outlined in the file "LICENSE.txt"
10// which should have been included with this file. If this file is
11// file is missing or damaged, see the license at "http://www.cups.org/".
ac884b6a
MS
12//
13
14//
15// Include necessary headers...
16//
17
38e73f87 18#include "ppdc-private.h"
ac884b6a
MS
19#include <unistd.h>
20#include <sys/stat.h>
21#include <sys/types.h>
22
23
24//
25// Local functions...
26//
27
28static void usage(void);
29
30
31//
32// 'main()' - Main entry for the PPD import utility.
33//
34
35int // O - Exit status
36main(int argc, // I - Number of command-line arguments
37 char *argv[]) // I - Command-line arguments
38{
39 int i; // Looping var
40 char *opt; // Current option
41 const char *srcfile; // Output file
42 ppdcSource *src; // PPD source file data
43
44
61cf44e2
MS
45 _cupsSetLocale(argv);
46
ac884b6a
MS
47 // Scan the command-line...
48 srcfile = NULL;
49 src = NULL;
50
51 for (i = 1; i < argc; i ++)
52 if (argv[i][0] == '-')
53 {
54 for (opt = argv[i] + 1; *opt; opt ++)
55 switch (*opt)
56 {
57 case 'o' : // Output file
58 if (srcfile || src)
59 usage();
60
61 i ++;
62 if (i >= argc)
63 usage();
64
65 srcfile = argv[i];
66 break;
67
68 case 'I' : // Include dir
69 i ++;
70 if (i >= argc)
71 usage();
72
73 ppdcSource::add_include(argv[i]);
74 break;
75
76 default : // Unknown
77 usage();
78 break;
79 }
80 }
81 else
82 {
83 // Open and load the driver info file...
84 if (!srcfile)
85 srcfile = "ppdi.drv";
86
87 if (!src)
88 {
89 if (access(srcfile, 0))
90 src = new ppdcSource();
91 else
92 src = new ppdcSource(srcfile);
93 }
94
95 // Import the PPD file...
96 src->import_ppd(argv[i]);
97 }
98
99 // If no drivers have been loaded, display the program usage message.
100 if (!src)
101 usage();
102
103 // Write the driver info file back to disk...
104 src->write_file(srcfile);
105
106 // Delete the printer driver information...
e4572d57 107 src->release();
ac884b6a
MS
108
109 // Return with no errors.
110 return (0);
111}
112
113
114//
115// 'usage()' - Show usage and exit.
116//
117
118static void
119usage(void)
120{
0837b7e8
MS
121 _cupsLangPuts(stdout, _("Usage: ppdi [options] filename.ppd [ ... "
122 "filenameN.ppd ]"));
123 _cupsLangPuts(stdout, _("Options:"));
84315f46
MS
124 _cupsLangPuts(stdout, _(" -I include-dir Add include directory to "
125 "search path."));
126 _cupsLangPuts(stdout, _(" -o filename.drv Set driver information "
127 "file (otherwise ppdi.drv)."));
ac884b6a
MS
128
129 exit(1);
130}