read files in text mode.

review fileio prototypes.
This commit is contained in:
Renaud 2013-05-17 22:58:27 +08:00
parent d9bb0ea262
commit a65f7ca38c
4 changed files with 23 additions and 13 deletions

View File

@ -28,7 +28,7 @@ OBJ=basic.o bind.o buffer.o crypt.o display.o eval.o exec.o \
termio.o window.o word.o names.o globals.o \
wrapper.o utf8.o
HDR=ebind.h edef.h efunc.h estruct.h version.h
HDR=ebind.h edef.h efunc.h estruct.h fileio.h version.h
# DO NOT ADD OR MODIFY ANY LINES ABOVE THIS -- make source creates them
@ -139,7 +139,7 @@ display.o: display.c estruct.h edef.h utf8.h version.h
eval.o: eval.c estruct.h edef.h version.h
exec.o: exec.c estruct.h edef.h
file.o: file.c estruct.h edef.h
fileio.o: fileio.c estruct.h edef.h
fileio.o: fileio.c fileio.h estruct.h edef.h
ibmpc.o: ibmpc.c estruct.h edef.h
input.o: input.c estruct.h edef.h
isearch.o: isearch.c estruct.h edef.h

View File

@ -221,12 +221,7 @@ extern int filename(int f, int n);
extern int ifile(char *fname);
/* fileio.c */
int ffropen( const char *fn) ;
extern int ffwopen(char *fn);
extern int ffclose(void);
extern int ffputline(char *buf, int nbuf);
extern int ffgetline(void);
extern int fexist(char *fname);
#include "fileio.h"
/* exec.c */
extern int namedcmd(int f, int n);

View File

@ -1,3 +1,7 @@
/* fileio.c -- implements fileio.h */
#include "fileio.h"
/* FILEIO.C
*
* The routines in this file read and write ASCII files from the disk. All of
@ -6,9 +10,9 @@
* modified by Petri Kutvonen
*/
#include <stdio.h>
#include <stdio.h>
#include "estruct.h"
#include "edef.h"
#include "edef.h"
#include "efunc.h"
static FILE *ffp; /* File pointer, all functions. */
@ -19,7 +23,7 @@ static int eofflag; /* end-of-file flag */
*/
int ffropen( const char *fn)
{
if ((ffp = fopen(fn, "r")) == NULL)
if ((ffp = fopen(fn, "rt")) == NULL)
return FIOFNF;
eofflag = FALSE;
return FIOSUC;
@ -29,7 +33,7 @@ int ffropen( const char *fn)
* Open a file for writing. Return TRUE if all is well, and FALSE on error
* (cannot create).
*/
int ffwopen(char *fn)
int ffwopen( const char *fn)
{
#if VMS
int fd;
@ -205,7 +209,7 @@ int ffgetline(void)
*
* char *fname; file to check for existance
*/
int fexist(char *fname)
int fexist( const char *fname)
{
FILE *fp;

11
fileio.h Normal file
View File

@ -0,0 +1,11 @@
#ifndef _FILEIO_H_
#define _FILEIO_H_
int fexist( const char *fname) ;
int ffclose( void) ;
int ffgetline( void) ;
int ffputline( char *buf, int nbuf) ;
int ffropen( const char *fn) ;
int ffwopen( const char *fn) ;
#endif