blob: 6bbe1dbe18063c19a5ace13a785db024ae84badc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
//
// "$Id: ppdc-option.cxx 11173 2013-07-23 12:31:34Z msweet $"
//
// Option class for the CUPS PPD Compiler.
//
// Copyright 2007-2011 by Apple Inc.
// Copyright 2002-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 "LICENSE.txt"
// which should have been included with this file. If this file is
// file is missing or damaged, see the license at "http://www.cups.org/".
//
// Contents:
//
// ppdcOption::ppdcOption() - Copy a new option.
// ppdcOption::~ppdcOption() - Destroy an option.
// ppdcOption::find_choice() - Find an option choice.
// ppdcOption::set_defchoice() - Set the default choice.
//
//
// Include necessary headers...
//
#include "ppdc-private.h"
//
// 'ppdcOption::ppdcOption()' - Create a new option.
//
ppdcOption::ppdcOption(ppdcOptType ot, // I - Option type
const char *n, // I - Option name
const char *t, // I - Option text
ppdcOptSection s, // I - Section
float o) // I - Ordering number
: ppdcShared()
{
PPDC_NEW;
type = ot;
name = new ppdcString(n);
text = new ppdcString(t);
section = s;
order = o;
choices = new ppdcArray();
defchoice = 0;
}
//
// 'ppdcOption::ppdcOption()' - Copy a new option.
//
ppdcOption::ppdcOption(ppdcOption *o) // I - Template option
{
PPDC_NEW;
o->name->retain();
o->text->retain();
if (o->defchoice)
o->defchoice->retain();
type = o->type;
name = o->name;
text = o->text;
section = o->section;
order = o->order;
choices = new ppdcArray(o->choices);
defchoice = o->defchoice;
}
//
// 'ppdcOption::~ppdcOption()' - Destroy an option.
//
ppdcOption::~ppdcOption()
{
PPDC_DELETE;
name->release();
text->release();
if (defchoice)
defchoice->release();
choices->release();
}
//
// 'ppdcOption::find_choice()' - Find an option choice.
//
ppdcChoice * // O - Choice or NULL
ppdcOption::find_choice(const char *n) // I - Name of choice
{
ppdcChoice *c; // Current choice
for (c = (ppdcChoice *)choices->first(); c; c = (ppdcChoice *)choices->next())
if (!_cups_strcasecmp(n, c->name->value))
return (c);
return (0);
}
//
// 'ppdcOption::set_defchoice()' - Set the default choice.
//
void
ppdcOption::set_defchoice(ppdcChoice *c) // I - Choice
{
if (defchoice)
defchoice->release();
if (c->name)
c->name->retain();
defchoice = c->name;
}
//
// End of "$Id: ppdc-option.cxx 11173 2013-07-23 12:31:34Z msweet $".
//
|