| iMatix home page | << | < | > | >> |
SFL Version 2.11 |
#include "sflstr.h" int matchtable ( char *strbuf, char *strmatch, char *strsept, int ncase)
Function to compare a string with a set of strings.
iret = matchtable (strname, "bill|william|billy", "|", IGNORECASE); If strname == "william", then matchtable would return 1. Returns >= 0 if match is found. a -1 if no match is found. Submitted by Scott Beasley <jscottb@infoave.com>
{ int nstate = -1, cnt = 0, icmpres; int ilen; char *strtemp; ASSERT (strbuf); ASSERT (strmatch); ASSERT (strsept); while (1) { ilen = getstrfldlen (strmatch, cnt, 0, strsept); strtemp = (char *) malloc (sizeof (char) * ilen + 1); ASSERT (strtemp); getstrfld (strmatch, cnt, 0, strsept, strtemp); if (*strtemp) { trim (strtemp); if (!ncase) { icmpres = lexcmp (strbuf, strtemp); } else { icmpres = strcmp (strbuf, strtemp); } if (!icmpres) { nstate = cnt; break; } else { if (!strcmp (strbuf, strtemp)) { nstate = cnt; break; } } } else { nstate = -1; break; } cnt++; free (strtemp); } return nstate; }
| << | < | > | >> | Copyright © 1996-2000 iMatix Corporation |