/* File fgets_prot.c */

#if !defined(COMPILE_ENVIRONMENT)
#include <gp/stdcenvf.h> /* std compile environment for functions */
#endif

PROTECTED_CHR_STR *fgets_prot(PROTECTED_CHR_STR *ps, FILE *stream)

 /**********************************************************************/
 /*                                                                    */
 /* Reads the next record into the protected character string *ps,     */
 /* stopping if a newline is encountered; the newline is included in   */
 /* the string, which is terminated by '\0'.                           */
 /*                                                                    */
 /**********************************************************************/

 {char *proc = "fgets_prot";
  char next_char;
  boolean line_read_in = F;
db_enter_msg(proc,1); /* debug only */
  strcpy_prot_s(ps,"");
  while ((!line_read_in)&&((next_char=fgetc(stream)) != EOF))
    {strcat_prot_i(ps,next_char);
     if (next_char == '\n') line_read_in = T;
    }
db_leave_msg(proc,1); /* debug only */
  if (next_char == EOF) return NULL;
  else                  return ps;
 }
