home *** CD-ROM | disk | FTP | other *** search
- /**
- *
- * Name stcright -- Extract the rightmost characters
- *
- * Synopsis amov = stcright(ptarget,psource,cpos,tarsize);
- *
- * int amov Number of characters extracted
- * char *ptarget Pointer to target string
- * char *psource Pointer to source string
- * int cpos Starting position from which to
- * extract characters.
- * int tarsize The maximum length of ptarget.
- *
- * Description STCRIGHT extracts the rightmost characters of psource
- * starting at character position cpos (characters are
- * numbered from 0). The characters are moved to the
- * string ptarget, but no more than tarsize minus 1
- * characters are transferred. The actual number of
- * characters extracted is returned.
- *
- * Returns amov The number of characters moved.
- * ptarget The string of extracted characters.
- *
- * Version 3.0 (C)Copyright Blaise Computing Inc. 1983, 1984, 1986
- *
- **/
-
- #include <string.h>
-
- #include <bstring.h>
-
- int stcright(ptarget,psource,cpos,tarsize)
- register char *ptarget,*psource;
- int cpos,tarsize;
- {
- register int i,npos;
-
- npos = (int) strlen(psource); /* Compute the starting position*/
- npos = max(0,min(npos,cpos)); /* within psource. */
- psource += npos;
- for (i = 0; (i < (tarsize - 1)) && (*ptarget++ = *psource++); i++);
- *ptarget = '\0';
-
- return(i);
- }