GNU.WIKI: The GNU/Linux Knowledge Base

  [HOME] [PHP Manual] [HowTo] [ABS] [MAN1] [MAN2] [MAN3] [MAN4] [MAN5] [MAN6] [MAN7] [MAN8] [MAN9]

  [0-9] [Aa] [Bb] [Cc] [Dd] [Ee] [Ff] [Gg] [Hh] [Ii] [Jj] [Kk] [Ll] [Mm] [Nn] [Oo] [Pp] [Qq] [Rr] [Ss] [Tt] [Uu] [Vv] [Ww] [Xx] [Yy] [Zz]


       xgetaline,   xfseek,   xfopen,   xfclose,   getaline,  fassert  -  file
       manipulation utilities


       #include <files.h>

       FILE *xfopen(const char *filename, const char *mode);
       void xfclose(FILE *fp);
       void xfseek(FILE *fp, long offset, int origin);
       char *getaline(FILE *fp);
       char *xgetaline(FILE *fp);
       void fassert(FILE *fp);


       These functions are useful for file manipulation.  The  functions  that
       begin  with  x  work  like  the functions without the letter, except if
       there is an error, they print an error message and kill the program.

       getaline reads a line from the given file.  It allocates the memory for
       the  line with malloc(3), and returns a pointer to the beginning of the
       line.  If there is an error, it returns NULL.  If the returned value is
       not  NULL,  the  caller  is  responsible  for  freeing the memory.  The
       newline is removed from the end of the line.

       fassert checks that the argument is not NULL, and that (for a  non-NULL
       argument)  the  file  does  not  have its error indicator flag set.  If
       either condition is true, it prints an error message and termiantes the
       program.    If neither condition is true, it does nothing.  This can be
       used to add checks that the I/O in a program is going well; however, it
       is mostly useful only for small programs, because more serious programs
       need to handle the errors more gracefully.




       Lars Wirzenius (

  All copyrights belong to their respective owners. Other content (c) 2014-2018, GNU.WIKI. Please report site errors to
Page load time: 0.116 seconds. Last modified: November 04 2018 12:49:43.