#ifndef FPORTSH
#define FPORTSH
-/* Copyright (C) 1995,1996,1997 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
* 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 */
\f
#include "libguile/__scm.h"
\f
-extern scm_ptobfuns scm_fptob;
-extern scm_ptobfuns scm_pipob;
+/* struct allocated for each buffered FPORT. */
+struct scm_fport {
+ int fdes; /* file descriptor. */
+};
-\f
+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))
-extern SCM scm_setbuf0 SCM_P ((SCM port));
-extern void scm_evict_ports SCM_P ((int fd));
-extern SCM scm_open_file SCM_P ((SCM filename, SCM modes));
-extern SCM scm_stdio_to_port SCM_P ((FILE *file, char *name, char *modes));
-extern void scm_init_fports SCM_P ((void));
+/* test whether fdes supports random access. */
+#define SCM_FDES_RANDOM_P(fdes) ((lseek (fdes, 0, SEEK_CUR) == -1) ? 0 : 1)
+
+\f
+extern SCM scm_setbuf0 (SCM port);
+extern SCM scm_setvbuf (SCM port, SCM mode, SCM size);
+extern void scm_evict_ports (int fd);
+extern SCM scm_open_file (SCM filename, SCM modes);
+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:
+*/