* Find a node by absolute name. The name should NOT end with ':' * The name "." means "this node" and "[xxx]" means "the node * with ID (ie, at address) xxx". * * Returns the node if found, else NULL. * Eventually should add something faster than a sequential search. * Note it acquires a reference on the node so you can be sure it's still * there. */
| 912 | * there. |
| 913 | */ |
| 914 | node_p |
| 915 | ng_name2noderef(node_p here, const char *name) |
| 916 | { |
| 917 | node_p node; |
| 918 | ng_ID_t temp; |
| 919 | int hash; |
| 920 | |
| 921 | /* "." means "this node" */ |
| 922 | if (strcmp(name, ".") == 0) { |
| 923 | NG_NODE_REF(here); |
| 924 | return(here); |
| 925 | } |
| 926 | |
| 927 | /* Check for name-by-ID */ |
| 928 | if ((temp = ng_decodeidname(name)) != 0) { |
| 929 | return (ng_ID2noderef(temp)); |
| 930 | } |
| 931 | |
| 932 | /* Find node by name. */ |
| 933 | hash = hash32_str(name, HASHINIT) & V_ng_name_hmask; |
| 934 | NAMEHASH_RLOCK(); |
| 935 | LIST_FOREACH(node, &V_ng_name_hash[hash], nd_nodes) |
| 936 | if (NG_NODE_IS_VALID(node) && |
| 937 | (strcmp(NG_NODE_NAME(node), name) == 0)) { |
| 938 | NG_NODE_REF(node); |
| 939 | break; |
| 940 | } |
| 941 | NAMEHASH_RUNLOCK(); |
| 942 | |
| 943 | return (node); |
| 944 | } |
| 945 | |
| 946 | /* |
| 947 | * Decode an ID name, eg. "[f03034de]". Returns 0 if the |
no test coverage detected