|
| iMatix home page | << | < | > | >> |
SFLVersion 2.10 |
#include "sflstr.h"
int
getstrfldlen (
char *strbuf,
int fldno,
int ofset,
char *sep)
Get the length of as a field in a string. Used mainly for getting the len to malloc mem to call getstrfld with. Returns the length of the field. Submitted by Scott Beasley jscottb@infoave.com
{
char *offset, *strptr;
int curfld, retlen = 0;
offset = strptr = (char *)NULL;
curfld = 0;
strbuf += ofset;
while (*strbuf)
{
strptr = !offset ? strbuf : offset;
offset = strpbrk ((!offset ? strbuf : offset), sep);
if (offset)
offset++;
else if (curfld != fldno)
{
retlen = 0;
break;
}
if (curfld == fldno)
{
retlen = (int)(!offset ? strlen (strptr) + 1 :
(int)(offset - strptr));
break;
}
curfld++;
}
return retlen;
}
| | << | < | > | >> |
|