X-Git-Url: https://git.hcoop.net/bpt/guile.git/blobdiff_plain/7dc6e7547ac790e76dd56aebf630a9780c31c883..fbf0c8c7b194202e01338f8b5324126bf73af4c9:/libguile/fports.h diff --git a/libguile/fports.h b/libguile/fports.h index f345c9761..3d970d9a8 100644 --- a/libguile/fports.h +++ b/libguile/fports.h @@ -2,7 +2,7 @@ #ifndef FPORTSH #define FPORTSH -/* Copyright (C) 1995,1996,1997,1998 Free Software Foundation, Inc. +/* Copyright (C) 1995,1996,1997,1998,1999, 2000 Free Software Foundation, Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -42,6 +42,9 @@ * If you write modifications of your own for GUILE, it is your choice * whether to permit this exception to apply to your modifications. * If you do not wish that, delete this exception notice. */ + +/* Software engineering face-lift by Greg J. Badros, 11-Dec-1999, + gjb@cs.washington.edu, http://www.cs.washington.edu/homes/gjb */ #include "libguile/__scm.h" @@ -50,18 +53,37 @@ -extern scm_ptobfuns scm_fptob; -extern scm_ptobfuns scm_pipob; +/* struct allocated for each buffered FPORT. */ +struct scm_fport { + int fdes; /* file descriptor. */ +}; + +extern scm_bits_t scm_tc16_fport; + +#define SCM_FSTREAM(x) ((struct scm_fport *) SCM_STREAM (x)) +#define SCM_FPORT_FDES(x) (SCM_FSTREAM (x)->fdes) + +#define SCM_FPORTP(x) (!SCM_IMP (x) && (SCM_TYP16 (x) == scm_tc16_fport)) +#define SCM_OPFPORTP(x) (SCM_FPORTP (x) && (SCM_CELL_WORD_0 (x) & SCM_OPN)) +#define SCM_OPINFPORTP(x) (SCM_OPFPORTP (x) && (SCM_CELL_WORD_0 (x) & SCM_RDNG)) +#define SCM_OPOUTFPORTP(x) (SCM_OPFPORTP (x) && (SCM_CELL_WORD_0 (x) & SCM_WRTNG)) + +/* test whether fdes supports random access. */ +#define SCM_FDES_RANDOM_P(fdes) ((lseek (fdes, 0, SEEK_CUR) == -1) ? 0 : 1) extern SCM scm_setbuf0 (SCM port); extern SCM scm_setvbuf (SCM port, SCM mode, SCM size); -extern SCM scm_freopen SCM_P ((SCM filename, SCM modes, SCM port)); -extern void scm_setfileno (FILE *fs, int fd); extern void scm_evict_ports (int fd); extern SCM scm_open_file (SCM filename, SCM modes); -extern SCM scm_stdio_to_port (FILE *file, char *mode, SCM name); -extern SCM scm_standard_stream_to_port (FILE *file, char *mode, char *name); -extern void scm_init_fports SCM_P ((void)); +extern SCM scm_fdes_to_port (int fdes, char *mode, SCM name); +extern SCM scm_file_port_p (SCM obj); +extern void scm_init_fports (void); #endif /* FPORTSH */ + +/* + Local Variables: + c-file-style: "gnu" + End: +*/