Print this page
8485 Remove set but unused variables in usr/src/cmd
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/cmd/lp/lib/papi/ppd.c
+++ new/usr/src/cmd/lp/lib/papi/ppd.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
↓ open down ↓ |
11 lines elided |
↑ open up ↑ |
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 + * Copyright 2017 Gary Mills
22 23 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
23 24 * Use is subject to license terms.
24 25 */
25 26
26 -#pragma ident "%Z%%M% %I% %E% SMI"
27 -
28 27 /*
29 28 * This file contains an extremely rudimentary implementation of PPD file
30 29 * parsing support. The parsing done here converts the contents of a PPD
31 30 * file into a set of PAPI attributes that applications can use to build
32 31 * print panels.
33 32 */
34 33
35 34 #include <stdio.h>
36 35 #include <ctype.h>
37 36 #include <string.h>
38 37 #include <papi.h>
39 38
40 39 static void
41 40 process_line(char *line, char **key, char **value, char **comment)
42 41 {
43 42 char *ptr, *ptr2;
44 43
45 44 *key = &line[1];
46 45 *value = NULL;
47 46 *comment = NULL;
48 47
49 48 if ((ptr = strchr(line, ':')) == NULL)
50 49 return;
51 50
52 51 /*
53 52 * line is in the form:
54 53 * *key: value/comment
55 54 * or
56 55 * *key value/comment: data
57 56 */
58 57 *ptr++ = NULL;
59 58 while (isspace(*ptr) != 0)
60 59 ptr++;
61 60
62 61 if ((ptr2 = strchr(line, ' ')) != NULL) {
63 62 ptr = ptr2;
64 63 /*
65 64 * line is in the form:
66 65 * *key value/comment: data
67 66 */
68 67 *ptr++ = NULL;
69 68 while (*ptr == ' ')
70 69 ptr++;
71 70 }
72 71
73 72 if (*ptr == '*')
74 73 ptr++;
75 74
76 75 *value = ptr;
77 76
78 77 if ((ptr = strchr(ptr, '/')) != NULL) {
79 78 *ptr++ = NULL;
80 79 *comment = ptr;
81 80 }
82 81 }
↓ open down ↓ |
45 lines elided |
↑ open up ↑ |
83 82
84 83 papi_status_t
85 84 PPDFileToAttributesList(papi_attribute_t ***attributes, char *filename)
86 85 {
87 86 papi_status_t status = PAPI_OK;
88 87 FILE *fp;
89 88 char line[256];
90 89 char capability[256];
91 90 char def[256];
92 91 char supported[256];
93 - char *current_group_name = NULL;
94 92
95 93 int ui = 0;
96 94
97 95 if ((fp = fopen(filename, "r")) == NULL)
98 96 return (PAPI_NOT_POSSIBLE);
99 97
100 98 while ((status == PAPI_OK) &&
101 99 (fgets(line, sizeof (line), fp) != NULL)) {
102 100 char *key = NULL, *value = NULL, *text = NULL;
103 101
104 102 /* we want *key...: "value" */
105 103 if (line[0] != '*')
106 104 continue;
107 105
108 106 if (strchr(line, ':') == NULL)
109 107 continue;
110 108
111 109 if ((text = strrchr(line, '\n')) != NULL)
112 110 *text = NULL;
↓ open down ↓ |
9 lines elided |
↑ open up ↑ |
113 111
114 112 process_line(line, &key, &value, &text);
115 113
116 114 if ((strcasecmp(key, "PageSize") == 0) ||
117 115 (strcasecmp(key, "InputSlot") == 0))
118 116 key = "media";
119 117
120 118 if (strcasecmp(key, "OpenGroup") == 0) {
121 119 if (value == NULL)
122 120 value = "unknown";
123 - current_group_name = strdup(value);
124 121 } else if (strcasecmp(key, "OpenUI") == 0) {
125 122 if ((strcasecmp(value, "PageSize") == 0) ||
126 123 (strcasecmp(value, "InputSlot") == 0))
127 124 value = "media";
128 125 snprintf(capability, sizeof (capability), "%s", value);
129 126 snprintf(def, sizeof (def),
130 127 "%s-default", value);
131 128 snprintf(supported, sizeof (supported),
132 129 "%s-supported", value);
133 130 ui = 1;
134 131 } else if (strcasecmp(key, "CloseGroup") == 0) {
135 132 /* do nothing */
136 133 } else if (strcasecmp(key, "CloseUI") == 0) {
137 134 ui = 0;
138 135 /* do nothing */
139 136 } else if (strcasecmp(key, "Manufacturer") == 0) {
140 137 status = papiAttributeListAddString(attributes,
141 138 PAPI_ATTR_EXCL,
142 139 "printer-make", value);
143 140 } else if (strcasecmp(key, "ModelName") == 0) {
144 141 status = papiAttributeListAddString(attributes,
145 142 PAPI_ATTR_EXCL,
146 143 "printer-model", value);
147 144 } else if (strcasecmp(key, "ShortNickName") == 0) {
148 145 status = papiAttributeListAddString(attributes,
149 146 PAPI_ATTR_EXCL,
150 147 "printer-make-and-model", value);
151 148 } else if ((strncasecmp(key, "Default", 7) == 0) && ui) {
152 149 status = papiAttributeListAddString(attributes,
153 150 PAPI_ATTR_EXCL,
154 151 def, value);
155 152 } else if ((strcasecmp(key, capability) == 0) && ui) {
156 153 status = papiAttributeListAddString(attributes,
157 154 PAPI_ATTR_APPEND,
158 155 supported, value);
159 156 }
160 157 }
161 158 fclose(fp);
162 159
163 160 return (status);
164 161 }
↓ open down ↓ |
31 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX