Lines Matching +full:line +full:- +full:name
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * names.c -- USB name database manipulation routines
8 * - names_deinit() is added.
28 char name[1]; member
34 char name[1]; member
40 char name[1]; member
46 char name[1]; member
52 char name[1]; member
58 char name[1]; member
73 return num & (HASHSZ-1); in hashnum()
88 for (; v; v = v->next) in names_vendor()
89 if (v->vendorid == vendorid) in names_vendor()
90 return v->name; in names_vendor()
99 for (; p; p = p->next) in names_product()
100 if (p->vendorid == vendorid && p->productid == productid) in names_product()
101 return p->name; in names_product()
110 for (; c; c = c->next) in names_class()
111 if (c->classid == classid) in names_class()
112 return c->name; in names_class()
121 for (; s; s = s->next) in names_subclass()
122 if (s->classid == classid && s->subclassid == subclassid) in names_subclass()
123 return s->name; in names_subclass()
134 for (; p; p = p->next) in names_protocol()
135 if (p->classid == classid && p->subclassid == subclassid && in names_protocol()
136 p->protocolid == protocolid) in names_protocol()
137 return p->name; in names_protocol()
157 p->mem = calloc(1, size); in my_malloc()
158 if (!p->mem) { in my_malloc()
163 p->next = pool_head; in my_malloc()
166 return p->mem; in my_malloc()
179 if (pool->mem) in names_free()
180 free(pool->mem); in names_free()
183 pool = pool->next; in names_free()
188 static int new_vendor(const char *name, u_int16_t vendorid) in new_vendor() argument
194 for (; v; v = v->next) in new_vendor()
195 if (v->vendorid == vendorid) in new_vendor()
196 return -1; in new_vendor()
197 v = my_malloc(sizeof(struct vendor) + strlen(name)); in new_vendor()
199 return -1; in new_vendor()
200 strcpy(v->name, name); in new_vendor()
201 v->vendorid = vendorid; in new_vendor()
202 v->next = vendors[h]; in new_vendor()
207 static int new_product(const char *name, u_int16_t vendorid, in new_product() argument
214 for (; p; p = p->next) in new_product()
215 if (p->vendorid == vendorid && p->productid == productid) in new_product()
216 return -1; in new_product()
217 p = my_malloc(sizeof(struct product) + strlen(name)); in new_product()
219 return -1; in new_product()
220 strcpy(p->name, name); in new_product()
221 p->vendorid = vendorid; in new_product()
222 p->productid = productid; in new_product()
223 p->next = products[h]; in new_product()
228 static int new_class(const char *name, u_int8_t classid) in new_class() argument
234 for (; c; c = c->next) in new_class()
235 if (c->classid == classid) in new_class()
236 return -1; in new_class()
237 c = my_malloc(sizeof(struct class) + strlen(name)); in new_class()
239 return -1; in new_class()
240 strcpy(c->name, name); in new_class()
241 c->classid = classid; in new_class()
242 c->next = classes[h]; in new_class()
247 static int new_subclass(const char *name, u_int8_t classid, u_int8_t subclassid) in new_subclass() argument
253 for (; s; s = s->next) in new_subclass()
254 if (s->classid == classid && s->subclassid == subclassid) in new_subclass()
255 return -1; in new_subclass()
256 s = my_malloc(sizeof(struct subclass) + strlen(name)); in new_subclass()
258 return -1; in new_subclass()
259 strcpy(s->name, name); in new_subclass()
260 s->classid = classid; in new_subclass()
261 s->subclassid = subclassid; in new_subclass()
262 s->next = subclasses[h]; in new_subclass()
267 static int new_protocol(const char *name, u_int8_t classid, u_int8_t subclassid, in new_protocol() argument
275 for (; p; p = p->next) in new_protocol()
276 if (p->classid == classid && p->subclassid == subclassid in new_protocol()
277 && p->protocolid == protocolid) in new_protocol()
278 return -1; in new_protocol()
279 p = my_malloc(sizeof(struct protocol) + strlen(name)); in new_protocol()
281 return -1; in new_protocol()
282 strcpy(p->name, name); in new_protocol()
283 p->classid = classid; in new_protocol()
284 p->subclassid = subclassid; in new_protocol()
285 p->protocolid = protocolid; in new_protocol()
286 p->next = protocols[h]; in new_protocol()
295 int lastvendor = -1; in parse()
296 int lastclass = -1; in parse()
297 int lastsubclass = -1; in parse()
298 int lasthut = -1; in parse()
299 int lastlang = -1; in parse()
304 /* remove line ends */ in parse()
329 lasthut = lastclass = lastvendor = lastsubclass = -1; in parse()
331 * set 1 as pseudo-id to indicate that the parser is in parse()
343 err("Invalid class spec at line %u", linectr); in parse()
350 err("Invalid class spec at line %u", linectr); in parse()
354 err("Duplicate class spec at line %u class %04x %s", in parse()
356 dbg("line %5u class %02x %s", linectr, u, cp); in parse()
357 lasthut = lastlang = lastvendor = lastsubclass = -1; in parse()
376 err("Invalid vendor spec at line %u", linectr); in parse()
380 err("Duplicate vendor spec at line %u vendor %04x %s", in parse()
382 dbg("line %5u vendor %04x %s", linectr, u, cp); in parse()
384 lasthut = lastlang = lastclass = lastsubclass = -1; in parse()
393 err("Invalid product/subclass spec at line %u", in parse()
397 if (lastvendor != -1) { in parse()
399 err("Duplicate product spec at line %u product %04x:%04x %s", in parse()
401 dbg("line %5u product %04x:%04x %s", linectr, in parse()
405 if (lastclass != -1) { in parse()
407 err("Duplicate subclass spec at line %u class %02x:%02x %s", in parse()
409 dbg("line %5u subclass %02x:%02x %s", linectr, in parse()
414 if (lasthut != -1) { in parse()
418 if (lastlang != -1) { in parse()
422 err("Product/Subclass spec without prior Vendor/Class spec at line %u", in parse()
432 err("Invalid protocol spec at line %u", in parse()
436 if (lastclass != -1 && lastsubclass != -1) { in parse()
439 err("Duplicate protocol spec at line %u class %02x:%02x:%02x %s", in parse()
442 dbg("line %5u protocol %02x:%02x:%02x %s", in parse()
446 err("Protocol spec without prior Class and Subclass spec at line %u", in parse()
456 lastlang = lastclass = lastvendor = lastsubclass = -1; in parse()
458 * set 1 as pseudo-id to indicate that the parser is in parse()
470 err("Unknown line at line %u", linectr); in parse()