| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- /*
- * Standard I/O wrapper functions.
- */
- #include "unp.h"
- void
- Fclose(FILE *fp)
- {
- if (fclose(fp) != 0)
- err_sys("fclose error");
- }
- FILE *
- Fdopen(int fd, const char *type)
- {
- FILE *fp;
- if ( (fp = fdopen(fd, type)) == NULL)
- err_sys("fdopen error");
- return(fp);
- }
- char *
- Fgets(char *ptr, int n, FILE *stream)
- {
- char *rptr;
- if ( (rptr = fgets(ptr, n, stream)) == NULL && ferror(stream))
- err_sys("fgets error");
- return (rptr);
- }
- FILE *
- Fopen(const char *filename, const char *mode)
- {
- FILE *fp;
- if ( (fp = fopen(filename, mode)) == NULL)
- err_sys("fopen error");
- return(fp);
- }
- void
- Fputs(const char *ptr, FILE *stream)
- {
- if (fputs(ptr, stream) == EOF)
- err_sys("fputs error");
- }
|