/* ******************************************************************************* * Copyright (c) 1996 Martin Poole * ******************************************************************************* ** ** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! ** ** Any changes to be made to this file should first be checked with ** mplib1 source control for library integrity. ** ** mplib1 source control can be reached at mplib1@quatermass.co.uk ** * * $Source$ * $Author$ * $Date$ * $Revision$ * ******************************************************************************* * * Change History * * $Log$ * ******************************************************************************* */ #ident "$Header$" /* ------------------------------------------------------------------ Include files ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ defines ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ Code starts here ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ Include files ------------------------------------------------------------------ */ #include #include #include /* ------------------------------------------------------------------ Defines ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ Structure definitions ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ Global variables ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ Function prototypes ------------------------------------------------------------------ */ /* --------------------------------------------------------------------------- Function : fget_line Summary : This function returns a line from a file, having : removed the trailing EOL character Input Parameters : FILE pointer : Pointer to line buffer : length of line buffer Output Parameters : None Global Variables : None Return Value : 0 = success, <> 0 failure (of some description) --------------------------------------------------------------------------*/ int fgetline( FILE *fh, char *line_buf, int line_len ) { int rv; char *cp; if (fgets(line_buf,line_len,fh) != NULL) { /* remove any trailing newline characters */ if (strlen(line_buf)) { cp = line_buf + strlen(line_buf) - 1; while ( cp >= line_buf && *cp == '\n') *cp-- = '\0'; } rv = 0; }else rv = -1; return(rv); } /* -- End of File -- */