tag_create_function find_tag_create_func(attr attributes) { int i = 0; const char *protocol = attr_get_str(attributes, "protocol", NULL); const char *make = attr_get_str(attributes, "make", attr_get_str(attributes, "manufacturer", NULL)); const char *family = attr_get_str(attributes, "family", NULL); const char *model = attr_get_str(attributes, "model", NULL); int num_entries = (sizeof(tag_type_map)/sizeof(tag_type_map[0])); /* if protocol is set, then use it to match. */ if(protocol && str_length(protocol) > 0) { for(i=0; i < num_entries; i++) { if(tag_type_map[i].protocol && str_cmp(tag_type_map[i].protocol, protocol) == 0) { pdebug(DEBUG_INFO,"Matched protocol=%s", protocol); return tag_type_map[i].tag_constructor; } } } else { /* match make/family/model */ for(i=0; i < num_entries; i++) { if(tag_type_map[i].make && make && str_cmp_i(tag_type_map[i].make, make) == 0) { pdebug(DEBUG_INFO,"Matched make=%s",make); if(tag_type_map[i].family) { if(family && str_cmp_i(tag_type_map[i].family, family) == 0) { pdebug(DEBUG_INFO, "Matched make=%s family=%s", make, family); if(tag_type_map[i].model) { if(model && str_cmp_i(tag_type_map[i].model, model) == 0) { pdebug(DEBUG_INFO, "Matched make=%s family=%s model=%s", make, family, model); return tag_type_map[i].tag_constructor; } } else { /* matches until a NULL */ pdebug(DEBUG_INFO, "Matched make=%s family=%s model=NULL", make, family); return tag_type_map[i].tag_constructor; } } } else { /* matched until a NULL, so we matched */ pdebug(DEBUG_INFO, "Matched make=%s family=NULL model=NULL", make); return tag_type_map[i].tag_constructor; } } } } /* no match */ return NULL; }
ab_connection_p session_find_connection_by_path_unsafe(ab_session_p session,const char *path) { ab_connection_p connection; connection = session->connections; /* * there are a lot of conditions. * We do not want to use connections that are in the process of shutting down. * We do not want to use connections that are used exclusively by one tag. * We want to use connections that have the same path as the tag. */ while (connection && !connection_is_usable(connection) && str_cmp_i(connection->path, path) != 0) { connection = connection->next; } /* add to the ref count since we found an existing one. */ if(connection) { connection_acquire(connection); } return connection; }
static int str_equal_i(const char *a, const char *b) { return str_cmp_i(a, b) == 0; }