home *** CD-ROM | disk | FTP | other *** search
- /*
- ┌────────────────────────────────────────────────────────────────────────────┐
- │jzgetpce.c │
- │Return a delimited portion of a string. │
- │ │
- │Parms │
- │ fsource : source string with delimiters │
- │ fdestin : destin string to be returned │
- │ fdel : char which is to be used as a delimiter │
- │ fnum : which occurrance of the delimited string do you want? (base 1) │
- │ │
- └────────────────────────────────────────────────────────────────────────────┘
- */
-
- char *jzgetpce(fsource , fdestin , fdel , fnum )
- char *fsource , *fdestin , fdel;
- int fnum;
- {
- char *p;
- int w;
- int wcount;
-
- wcount = 1; /* search for specified piece */
- while (*fsource && (wcount < fnum))
- if (*fsource++ == fdel)
- wcount ++;
-
- if ((w = index(fsource,fdel)) != -1) { /* this is not the last piece */
- strncpy(fdestin,fsource,w);
- *(fdestin+w) = 0;
- }
- else
- strcpy(fdestin,fsource);
-
- return(fdestin);
-
- }