4 * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd.
6 * Licensed under the Apache License, Version 2.0 (the License);
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
23 #define VENDOR_HP_1 "Hewlett-Packard"
24 #define VENDOR_HP_2 "Hewlett Packard"
25 #define VENDOR_HP_3 "HP"
26 #define VENDOR_SAMSUNG "Samsung"
28 static void remove_underbar(char *name)
36 for (i = 0 ; i < strlen(name); temp++, i++) {
42 static void remove_non_alphabet(char *name)
50 pos = name + strlen(name) - 1;
52 for (i = strlen(name); i > 0 ; i--, pos--) {
53 if ((*pos >= 48 && *pos <= 57) /* number */
54 || (*pos >= 65 && *pos <= 90) /* uppercase letter */
55 || (*pos >= 97 && *pos <= 122) /* lowercase letter */
56 || *pos == '-' /* hyphen */
57 || *pos == ' ') /* white space */
61 while (*temp != '\0') {
68 static void change_to_short(char *name, int len)
70 if (strcasestr(name, VENDOR_HP_1)) {
71 snprintf(name, len, "%s", VENDOR_HP_3);
75 if (strcasestr(name, VENDOR_HP_2)) {
76 snprintf(name, len, "%s", VENDOR_HP_3);
80 if (strcasestr(name, VENDOR_HP_3)) {
81 snprintf(name, len, "%s", VENDOR_HP_3);
85 if (strcasestr(name, VENDOR_SAMSUNG)) {
86 snprintf(name, len, "%s", VENDOR_SAMSUNG);
91 static void remove_vendor(char *model, char *vendor)
96 pos = strcasestr(model, vendor);
100 temp = pos + strlen(vendor);
102 while(*pos != '\0') {
109 int verify_vendor_name(const char *vendor, char *buf, int len)
113 if (!vendor || !buf || len <= 0)
116 snprintf(name, sizeof(name), "%s", vendor);
118 remove_underbar(name);
120 remove_non_alphabet(name);
122 change_to_short(name, strlen(name));
124 snprintf(buf, len, "%s", name);
128 int verify_model_name(const char *model, char *vendor, char *buf, int len)
132 if (!model || !vendor || !buf || len <= 0)
135 snprintf(name, sizeof(name), "%s", model);
137 remove_underbar(name);
139 remove_non_alphabet(name);
141 change_to_short(name, strlen(name));
143 remove_vendor(name, vendor);
145 snprintf(buf, len, "%s", name);