* Search CommandTag by name * * Returns CommandTag, or CMDTAG_UNKNOWN if not recognized */
| 71 | * Returns CommandTag, or CMDTAG_UNKNOWN if not recognized |
| 72 | */ |
| 73 | CommandTag |
| 74 | GetCommandTagEnum(const char *commandname) |
| 75 | { |
| 76 | const CommandTagBehavior *base, |
| 77 | *last, |
| 78 | *position; |
| 79 | int result; |
| 80 | |
| 81 | if (commandname == NULL || *commandname == '\0') |
| 82 | return CMDTAG_UNKNOWN; |
| 83 | |
| 84 | base = tag_behavior; |
| 85 | last = tag_behavior + lengthof(tag_behavior) - 1; |
| 86 | while (last >= base) |
| 87 | { |
| 88 | position = base + ((last - base) >> 1); |
| 89 | result = pg_strcasecmp(commandname, position->name); |
| 90 | if (result == 0) |
| 91 | return (CommandTag) (position - tag_behavior); |
| 92 | else if (result < 0) |
| 93 | last = position - 1; |
| 94 | else |
| 95 | base = position + 1; |
| 96 | } |
| 97 | return CMDTAG_UNKNOWN; |
| 98 | } |
no test coverage detected