MCPcopy Create free account
hub / github.com/F-Stack/f-stack / match_token_relaxed

Function match_token_relaxed

tools/ipfw/ipfw2.c:696–716  ·  view source on GitHub ↗

* match_token_relaxed takes a table and a string, returns the value associated * with the string for the best match. * * Returns: * value from @table for matched records * -1 for non-matched records * -2 if more than one records match @string. */

Source from the content-addressed store, hash-verified

694 * -2 if more than one records match @string.
695 */
696int
697match_token_relaxed(struct _s_x *table, const char *string)
698{
699 struct _s_x *pt, *m;
700 int i, c;
701
702 i = strlen(string);
703 c = 0;
704
705 for (pt = table ; i != 0 && pt->s != NULL ; pt++) {
706 if (strncmp(pt->s, string, i) != 0)
707 continue;
708 m = pt;
709 c++;
710 }
711
712 if (c == 1)
713 return (m->x);
714
715 return (c > 0 ? -2: -1);
716}
717
718int
719get_token(struct _s_x *table, const char *string, const char *errbase)

Callers 1

get_tokenFunction · 0.85

Calls 1

strncmpFunction · 0.85

Tested by

no test coverage detected