home *** CD-ROM | disk | FTP | other *** search
- /*
- * sgets.c
- * contains: sgets()
- *
- */
-
- #include <stdio.h>
- #include "gfuncts.h"
-
- /*
- * char *
- * sgets(dest,source,maxc)
- *
- * ARGUMENT
- * (char *) dest - Destination string
- * (char *) source - Source string
- * (int) maxc - Maximum number of characters to transfer
- *
- * DESCRIPTION
- * Used for extracting lines from multi-line buffers. Reads characters from
- * the source string into the destination string until a new line is read
- * from the source string or maxc characters have been read or a NULL
- * character has been read.
- *
- * RETURNS
- * pointer to next line in string or NULL if at end of string
- *
- * AUTHOR
- * Copyright (C)1987-1990 Greenleaf Software Inc. All Rights Reserved.
- */
- char* GF_CONV sgets(dest,source,imax)
- char *dest,*source;
- int imax;
- {
- if(!*source) {
- *dest='\0';
- return(NULL);
- }
- for(;*source&&*source!='\n'&&imax;--imax,++source,++dest)
- *dest=*source;
- *dest='\n';
- *(dest+1)='\0';
- return((*source)?source+1:source);
- }
-