Last change
on this file since 0580615 was 0580615, checked in by Thomas Lopatic <thomas@…>, 7 years ago |
Point of no return.
|
-
Property mode
set to
100644
|
File size:
726 bytes
|
Rev | Line | |
---|
[f40a309] | 1 | /*
|
---|
| 2 | ============================================================================
|
---|
| 3 | strlcmp(s,l) -- compare string s to list l
|
---|
| 4 | Version 1 -- 1987-03-03 -- D.N. Lynx Crowe
|
---|
| 5 |
|
---|
| 6 | Compares string s to each entry in the list l of strings
|
---|
| 7 | until a match is found or until list l is exhausted.
|
---|
| 8 | List l consists of a zero-entry terminated array of
|
---|
| 9 | pointers to zero terminated strings.
|
---|
| 10 | String s must be zero terminated.
|
---|
| 11 |
|
---|
| 12 | Returns 0 if no match was found, or the 1-origin index
|
---|
| 13 | of the string in the list l.
|
---|
| 14 | ============================================================================
|
---|
| 15 | */
|
---|
| 16 |
|
---|
[0580615] | 17 | int strlcmp(char *s, char *l[])
|
---|
[f40a309] | 18 | {
|
---|
| 19 | int rc;
|
---|
| 20 |
|
---|
| 21 | rc = 0;
|
---|
| 22 |
|
---|
| 23 | while (l[rc]) {
|
---|
| 24 |
|
---|
| 25 | if (0 == strcmp(s, l[rc]))
|
---|
| 26 | return(++rc);
|
---|
| 27 |
|
---|
| 28 | rc++;
|
---|
| 29 | }
|
---|
| 30 |
|
---|
| 31 | return(0);
|
---|
| 32 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.