1
0
mirror of https://github.com/rfivet/uemacs.git synced 2024-12-21 00:26:27 -05:00

Review interface of fileio.

This commit is contained in:
Renaud 2013-06-09 17:31:28 +08:00
parent b57c1adc20
commit 4bf4c48056
5 changed files with 36 additions and 23 deletions

2
edef.h
View File

@ -81,8 +81,6 @@ extern char falsem[]; /* false litereal */
extern int cmdstatus; /* last command status */
extern char palstr[]; /* palette string */
extern int saveflag; /* Flags, saved with the $target var */
extern char *fline; /* dynamic return line */
extern int flen; /* current length of fline */
extern int rval; /* return value of a subprocess */
#if PKCODE
extern int nullflag;

View File

@ -256,10 +256,18 @@
#undef TRUE
#endif
#if 0
#define FALSE 0 /* False, no, bad, etc. */
#define TRUE 1 /* True, yes, good, etc. */
#define ABORT 2 /* Death, ^G, abort, etc. */
#define FAILED 3 /* not-quite fatal false return */
#endif
typedef enum {
FALSE,
TRUE
} boolean ;
#define ABORT 2
#define STOP 0 /* keyboard macro not in use */
#define PLAY 1 /* playing */

View File

@ -17,14 +17,16 @@
#include "edef.h"
static FILE *ffp; /* File pointer, all functions. */
static int eofflag; /* end-of-file flag */
static boolean eofflag ; /* end-of-file flag */
char *fline = NULL; /* dynamic return line */
int flen = 0; /* current length of fline */
int ftype ;
/*
* Open a file for reading.
*/
int ffropen( const char *fn)
fio_code ffropen( const char *fn)
{
if ((ffp = fopen(fn, "r")) == NULL)
return FIOFNF;
@ -37,7 +39,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( const char *fn)
fio_code ffwopen( const char *fn)
{
#if VMS
int fd;
@ -56,7 +58,7 @@ int ffwopen( const char *fn)
/*
* Close a file. Should look at the status in all systems.
*/
int ffclose(void)
fio_code ffclose(void)
{
/* free this since we do not need it anymore */
if (fline) {
@ -87,7 +89,7 @@ int ffclose(void)
* and the "nbuf" is its length, less the free newline. Return the status.
* Check only at the newline.
*/
int ffputline( char *buf, int nbuf, int dosflag)
fio_code ffputline( char *buf, int nbuf, int dosflag)
{
int i;
#if CRYPT
@ -126,7 +128,7 @@ int ffputline( char *buf, int nbuf, int dosflag)
* at the end of the file that don't have a newline present. Check for I/O
* errors too. Return status.
*/
int ffgetline(void)
fio_code ffgetline(void)
{
int c; /* current character read */
int i; /* current index into fline */
@ -225,7 +227,7 @@ int ffgetline(void)
*
* char *fname; file to check for existance
*/
int fexist( const char *fname)
boolean fexist( const char *fname)
{
FILE *fp;

View File

@ -1,25 +1,32 @@
#ifndef _FILEIO_H_
#define _FILEIO_H_
#define FIOSUC 0 /* File I/O, success. */
#define FIOFNF 1 /* File I/O, file not found. */
#define FIOEOF 2 /* File I/O, end of file. */
#define FIOERR 3 /* File I/O, error. */
#define FIOMEM 4 /* File I/O, out of memory */
#define FIOFUN 5 /* File I/O, eod of file/bad line */
#include "estruct.h"
typedef enum {
FIOSUC, /* File I/O, success. */
FIOFNF, /* File I/O, file not found. */
FIOEOF, /* File I/O, end of file. */
FIOERR, /* File I/O, error. */
FIOMEM, /* File I/O, out of memory */
FIOFUN /* File I/O, eod of file/bad line */
} fio_code ;
#define FTYPE_NONE 0
#define FTYPE_UNIX 1
#define FTYPE_DOS 2
#define FTYPE_MAC 4
/* FTYPE_MIXED [ 3, 5, 6, 7] */
extern char *fline ; /* dynamic return line */
extern int flen ; /* current length of fline */
extern int ftype ;
int fexist( const char *fname) ;
int ffclose( void) ;
int ffgetline( void) ;
int ffputline( char *buf, int nbuf, int dosflag) ;
int ffropen( const char *fn) ;
int ffwopen( const char *fn) ;
boolean fexist( const char *fname) ;
fio_code ffclose( void) ;
fio_code ffgetline( void) ;
fio_code ffputline( char *buf, int nbuf, int dosflag) ;
fio_code ffropen( const char *fn) ;
fio_code ffwopen( const char *fn) ;
#endif

View File

@ -78,8 +78,6 @@ char falsem[] = "FALSE"; /* false litereal */
int cmdstatus = TRUE; /* last command status */
char palstr[49] = ""; /* palette string */
int saveflag = 0; /* Flags, saved with the $target var */
char *fline = NULL; /* dynamic return line */
int flen = 0; /* current length of fline */
int rval = 0; /* return value of a subprocess */
#if PKCODE
int nullflag = FALSE; /* accept null characters */