1 /* Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
2 * 2004, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public License
6 * as published by the Free Software Foundation; either version 3 of
7 * the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 #define _LARGEFILE64_SOURCE /* ask for stat64 etc */
23 #define _GNU_SOURCE /* ask for LONG_LONG_MAX/LONG_LONG_MIN */
31 #include "libguile/_scm.h"
32 #include "libguile/strings.h"
33 #include "libguile/validate.h"
34 #include "libguile/gc.h"
35 #include "libguile/posix.h"
36 #include "libguile/dynwind.h"
37 #include "libguile/hashtab.h"
39 #include "libguile/fports.h"
50 #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
57 #include <sys/types.h>
60 #include "libguile/iselect.h"
62 #include <full-write.h>
64 #if SIZEOF_OFF_T == SIZEOF_INT
65 #define OFF_T_MAX INT_MAX
66 #define OFF_T_MIN INT_MIN
67 #elif SIZEOF_OFF_T == SIZEOF_LONG
68 #define OFF_T_MAX LONG_MAX
69 #define OFF_T_MIN LONG_MIN
70 #elif SIZEOF_OFF_T == SIZEOF_LONG_LONG
71 #define OFF_T_MAX LONG_LONG_MAX
72 #define OFF_T_MIN LONG_LONG_MIN
74 #error Oops, unknown OFF_T size
77 scm_t_bits scm_tc16_fport
;
80 /* default buffer size, used if the O/S won't supply a value. */
81 static const size_t default_buffer_size
= 1024;
83 /* create FPORT buffer with specified sizes (or -1 to use default size or
86 scm_fport_buffer_add (SCM port
, long read_size
, int write_size
)
87 #define FUNC_NAME "scm_fport_buffer_add"
89 scm_t_port
*pt
= SCM_PTAB_ENTRY (port
);
91 if (read_size
== -1 || write_size
== -1)
94 #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
96 scm_t_fport
*fp
= SCM_FSTREAM (port
);
98 default_size
= (fstat (fp
->fdes
, &st
) == -1) ? default_buffer_size
101 default_size
= default_buffer_size
;
104 read_size
= default_size
;
105 if (write_size
== -1)
106 write_size
= default_size
;
109 if (SCM_INPUT_PORT_P (port
) && read_size
> 0)
111 pt
->read_buf
= scm_gc_malloc_pointerless (read_size
, "port buffer");
112 pt
->read_pos
= pt
->read_end
= pt
->read_buf
;
113 pt
->read_buf_size
= read_size
;
117 pt
->read_pos
= pt
->read_buf
= pt
->read_end
= &pt
->shortbuf
;
118 pt
->read_buf_size
= 1;
121 if (SCM_OUTPUT_PORT_P (port
) && write_size
> 0)
123 pt
->write_buf
= scm_gc_malloc_pointerless (write_size
, "port buffer");
124 pt
->write_pos
= pt
->write_buf
;
125 pt
->write_buf_size
= write_size
;
129 pt
->write_buf
= pt
->write_pos
= &pt
->shortbuf
;
130 pt
->write_buf_size
= 1;
133 pt
->write_end
= pt
->write_buf
+ pt
->write_buf_size
;
134 if (read_size
> 0 || write_size
> 0)
135 SCM_SET_CELL_WORD_0 (port
, SCM_CELL_WORD_0 (port
) & ~SCM_BUF0
);
137 SCM_SET_CELL_WORD_0 (port
, SCM_CELL_WORD_0 (port
) | SCM_BUF0
);
141 SCM_DEFINE (scm_setvbuf
, "setvbuf", 2, 1, 0,
142 (SCM port
, SCM mode
, SCM size
),
143 "Set the buffering mode for @var{port}. @var{mode} can be:\n"
150 "block buffered, using a newly allocated buffer of @var{size} bytes.\n"
151 "If @var{size} is omitted, a default size will be used.\n"
153 #define FUNC_NAME s_scm_setvbuf
161 port
= SCM_COERCE_OUTPORT (port
);
163 SCM_VALIDATE_OPFPORT (1,port
);
164 cmode
= scm_to_int (mode
);
165 if (cmode
!= _IONBF
&& cmode
!= _IOFBF
&& cmode
!= _IOLBF
)
166 scm_out_of_range (FUNC_NAME
, mode
);
170 SCM_SET_CELL_WORD_0 (port
, SCM_CELL_WORD_0 (port
) | SCM_BUFLINE
);
175 SCM_SET_CELL_WORD_0 (port
, SCM_CELL_WORD_0 (port
) & ~(scm_t_bits
)SCM_BUFLINE
);
178 if (SCM_UNBNDP (size
))
187 csize
= scm_to_int (size
);
188 if (csize
< 0 || (cmode
== _IONBF
&& csize
> 0))
189 scm_out_of_range (FUNC_NAME
, size
);
192 pt
= SCM_PTAB_ENTRY (port
);
194 if (SCM_INPUT_PORT_P (port
))
196 /* Drain pending input from PORT. Don't use `scm_drain_input' since
197 it returns a string, whereas we want binary input here. */
198 ndrained
= pt
->read_end
- pt
->read_pos
;
199 if (pt
->read_buf
== pt
->putback_buf
)
200 ndrained
+= pt
->saved_read_end
- pt
->saved_read_pos
;
204 drained
= scm_gc_malloc_pointerless (ndrained
, "file port");
205 scm_take_from_input_buffers (port
, drained
, ndrained
);
211 if (SCM_OUTPUT_PORT_P (port
))
214 if (pt
->read_buf
== pt
->putback_buf
)
216 pt
->read_buf
= pt
->saved_read_buf
;
217 pt
->read_pos
= pt
->saved_read_pos
;
218 pt
->read_end
= pt
->saved_read_end
;
219 pt
->read_buf_size
= pt
->saved_read_buf_size
;
221 if (pt
->read_buf
!= &pt
->shortbuf
)
222 scm_gc_free (pt
->read_buf
, pt
->read_buf_size
, "port buffer");
223 if (pt
->write_buf
!= &pt
->shortbuf
)
224 scm_gc_free (pt
->write_buf
, pt
->write_buf_size
, "port buffer");
226 scm_fport_buffer_add (port
, csize
, csize
);
229 /* Put DRAINED back to PORT. */
230 while (ndrained
-- > 0)
231 scm_unget_byte (drained
[ndrained
], port
);
233 return SCM_UNSPECIFIED
;
237 /* Move ports with the specified file descriptor to new descriptors,
238 * resetting the revealed count to 0.
241 scm_i_evict_port (void *closure
, SCM port
)
243 int fd
= * (int*) closure
;
245 if (SCM_FPORTP (port
))
250 /* XXX: In some cases, we can encounter a port with no associated ptab
252 p
= SCM_PTAB_ENTRY (port
);
253 fp
= (p
!= NULL
) ? (scm_t_fport
*) p
->stream
: NULL
;
255 if ((fp
!= NULL
) && (fp
->fdes
== fd
))
259 scm_syserror ("scm_evict_ports");
260 scm_set_port_revealed_x (port
, scm_from_int (0));
266 scm_evict_ports (int fd
)
268 scm_c_port_for_each (scm_i_evict_port
, (void *) &fd
);
272 SCM_DEFINE (scm_file_port_p
, "file-port?", 1, 0, 0,
274 "Determine whether @var{obj} is a port that is related to a file.")
275 #define FUNC_NAME s_scm_file_port_p
277 return scm_from_bool (SCM_FPORTP (obj
));
282 static SCM sys_file_port_name_canonicalization
;
283 SCM_SYMBOL (sym_relative
, "relative");
284 SCM_SYMBOL (sym_absolute
, "absolute");
287 fport_canonicalize_filename (SCM filename
)
289 SCM mode
= scm_fluid_ref (sys_file_port_name_canonicalization
);
291 if (!scm_is_string (filename
))
295 else if (scm_is_eq (mode
, sym_relative
))
299 path
= scm_variable_ref (scm_c_module_lookup (scm_the_root_module (),
301 rel
= scm_i_relativize_path (filename
, path
);
303 return scm_is_true (rel
) ? rel
: filename
;
305 else if (scm_is_eq (mode
, sym_absolute
))
309 str
= scm_to_locale_string (filename
);
310 canon
= canonicalize_file_name (str
);
313 return canon
? scm_take_locale_string (canon
) : filename
;
323 * Return a new port open on a given file.
325 * The mode string must match the pattern: [rwa+]** which
326 * is interpreted in the usual unix way.
328 * Return the new port.
330 SCM_DEFINE (scm_open_file
, "open-file", 2, 0, 0,
331 (SCM filename
, SCM mode
),
332 "Open the file whose name is @var{filename}, and return a port\n"
333 "representing that file. The attributes of the port are\n"
334 "determined by the @var{mode} string. The way in which this is\n"
335 "interpreted is similar to C stdio. The first character must be\n"
336 "one of the following:\n"
339 "Open an existing file for input.\n"
341 "Open a file for output, creating it if it doesn't already exist\n"
342 "or removing its contents if it does.\n"
344 "Open a file for output, creating it if it doesn't already\n"
345 "exist. All writes to the port will go to the end of the file.\n"
346 "The \"append mode\" can be turned off while the port is in use\n"
347 "@pxref{Ports and File Descriptors, fcntl}\n"
349 "The following additional characters can be appended:\n"
352 "Open the underlying file in binary mode, if supported by the system.\n"
353 "Also, open the file using the binary-compatible character encoding\n"
354 "\"ISO-8859-1\", ignoring the port's encoding and the coding declaration\n"
355 "at the top of the input file, if any.\n"
357 "Open the port for both input and output. E.g., @code{r+}: open\n"
358 "an existing file for both input and output.\n"
360 "Create an \"unbuffered\" port. In this case input and output\n"
361 "operations are passed directly to the underlying port\n"
362 "implementation without additional buffering. This is likely to\n"
363 "slow down I/O operations. The buffering mode can be changed\n"
364 "while a port is in use @pxref{Ports and File Descriptors,\n"
367 "Add line-buffering to the port. The port output buffer will be\n"
368 "automatically flushed whenever a newline character is written.\n"
370 "When the file is opened, this procedure will scan for a coding\n"
371 "declaration@pxref{Character Encoding of Source Files}. If present\n"
372 "will use that encoding for interpreting the file. Otherwise, the\n"
373 "port's encoding will be used.\n"
375 "In theory we could create read/write ports which were buffered\n"
376 "in one direction only. However this isn't included in the\n"
377 "current interfaces. If a file cannot be opened with the access\n"
378 "requested, @code{open-file} throws an exception.")
379 #define FUNC_NAME s_scm_open_file
382 int fdes
, flags
= 0, use_encoding
= 1;
383 unsigned int retries
;
384 char *file
, *md
, *ptr
;
386 scm_dynwind_begin (0);
388 file
= scm_to_locale_string (filename
);
389 scm_dynwind_free (file
);
391 md
= scm_to_locale_string (mode
);
392 scm_dynwind_free (md
);
400 flags
|= O_WRONLY
| O_CREAT
| O_TRUNC
;
403 flags
|= O_WRONLY
| O_CREAT
| O_APPEND
;
406 scm_out_of_range (FUNC_NAME
, mode
);
414 flags
= (flags
& ~(O_RDONLY
| O_WRONLY
)) | O_RDWR
;
418 #if defined (O_BINARY)
422 case '0': /* unbuffered: handled later. */
423 case 'l': /* line buffered: handled during output. */
426 scm_out_of_range (FUNC_NAME
, mode
);
431 for (retries
= 0, fdes
= -1;
432 fdes
< 0 && retries
< 2;
435 SCM_SYSCALL (fdes
= open_or_open64 (file
, flags
, 0666));
440 if (en
== EMFILE
&& retries
== 0)
441 /* Run the GC in case it collects open file ports that are no
442 longer referenced. */
443 scm_i_gc (FUNC_NAME
);
445 SCM_SYSERROR_MSG ("~A: ~S",
446 scm_cons (scm_strerror (scm_from_int (en
)),
447 scm_cons (filename
, SCM_EOL
)), en
);
451 /* Create a port from this file descriptor. The port's encoding is initially
452 %default-port-encoding. */
453 port
= scm_i_fdes_to_port (fdes
, scm_i_mode_bits (mode
),
454 fport_canonicalize_filename (filename
));
458 /* If this file has a coding declaration, use that as the port
460 if (SCM_INPUT_PORT_P (port
))
462 char *enc
= scm_i_scan_for_encoding (port
);
464 scm_i_set_port_encoding_x (port
, enc
);
468 /* If this is a binary file, use the binary-friendly ISO-8859-1
470 scm_i_set_port_encoding_x (port
, NULL
);
479 /* Building Guile ports from a file descriptor. */
481 /* Build a Scheme port from an open file descriptor `fdes'.
482 MODE indicates whether FILE is open for reading or writing; it uses
483 the same notation as open-file's second argument.
484 NAME is a string to be used as the port's filename.
487 scm_i_fdes_to_port (int fdes
, long mode_bits
, SCM name
)
488 #define FUNC_NAME "scm_fdes_to_port"
493 /* Test that fdes is valid. */
495 int flags
= fcntl (fdes
, F_GETFL
, 0);
500 && ((flags
!= O_WRONLY
&& (mode_bits
& SCM_WRTNG
))
501 || (flags
!= O_RDONLY
&& (mode_bits
& SCM_RDNG
))))
503 SCM_MISC_ERROR ("requested file mode not available on fdes", SCM_EOL
);
506 /* If we don't have F_GETFL, as on mingw, at least we can test that
507 it is a valid file descriptor. */
509 if (fstat (fdes
, &st
) != 0)
513 scm_i_scm_pthread_mutex_lock (&scm_i_port_table_mutex
);
515 port
= scm_new_port_table_entry (scm_tc16_fport
);
516 SCM_SET_CELL_TYPE(port
, scm_tc16_fport
| mode_bits
);
517 pt
= SCM_PTAB_ENTRY(port
);
520 = (scm_t_fport
*) scm_gc_malloc_pointerless (sizeof (scm_t_fport
),
524 pt
->rw_random
= SCM_FDES_RANDOM_P (fdes
);
525 SCM_SETSTREAM (port
, fp
);
526 if (mode_bits
& SCM_BUF0
)
527 scm_fport_buffer_add (port
, 0, 0);
529 scm_fport_buffer_add (port
, -1, -1);
531 SCM_SET_FILENAME (port
, name
);
532 scm_i_pthread_mutex_unlock (&scm_i_port_table_mutex
);
538 scm_fdes_to_port (int fdes
, char *mode
, SCM name
)
540 return scm_i_fdes_to_port (fdes
, scm_mode_bits (mode
), name
);
543 /* Return a lower bound on the number of bytes available for input. */
545 fport_input_waiting (SCM port
)
547 int fdes
= SCM_FSTREAM (port
)->fdes
;
549 /* `FD_SETSIZE', which is 1024 on GNU systems, effectively limits the
550 highest numerical value of file descriptors that can be monitored.
551 Thus, use poll(2) whenever that is possible. */
553 #if defined(HAVE_POLL) && defined(HAVE_STRUCT_POLLFD)
554 struct pollfd pollfd
= { fdes
, POLLIN
, 0 };
556 if (poll (&pollfd
, 1, 0) < 0)
557 scm_syserror ("fport_input_waiting");
559 return pollfd
.revents
& POLLIN
? 1 : 0;
561 #elif defined(HAVE_SELECT)
562 struct timeval timeout
;
563 SELECT_TYPE read_set
;
564 SELECT_TYPE write_set
;
565 SELECT_TYPE except_set
;
568 FD_ZERO (&write_set
);
569 FD_ZERO (&except_set
);
571 FD_SET (fdes
, &read_set
);
576 if (select (SELECT_SET_SIZE
,
577 &read_set
, &write_set
, &except_set
, &timeout
)
579 scm_syserror ("fport_input_waiting");
580 return FD_ISSET (fdes
, &read_set
) ? 1 : 0;
582 #elif HAVE_IOCTL && defined (FIONREAD)
583 int fdes
= SCM_FSTREAM (port
)->fdes
;
585 ioctl(fdes
, FIONREAD
, &remir
);
589 scm_misc_error ("fport_input_waiting",
590 "Not fully implemented on this platform",
597 fport_print (SCM exp
, SCM port
, scm_print_state
*pstate SCM_UNUSED
)
599 scm_puts ("#<", port
);
600 scm_print_port_mode (exp
, port
);
601 if (SCM_OPFPORTP (exp
))
604 SCM name
= SCM_FILENAME (exp
);
605 if (scm_is_string (name
) || scm_is_symbol (name
))
606 scm_display (name
, port
);
608 scm_puts (SCM_PTOBNAME (SCM_PTOBNUM (exp
)), port
);
609 scm_putc (' ', port
);
610 fdes
= (SCM_FSTREAM (exp
))->fdes
;
612 #if (defined HAVE_TTYNAME) && (defined HAVE_POSIX)
614 scm_display (scm_ttyname (exp
), port
);
616 #endif /* HAVE_TTYNAME */
617 scm_intprint (fdes
, 10, port
);
621 scm_puts (SCM_PTOBNAME (SCM_PTOBNUM (exp
)), port
);
622 scm_putc (' ', port
);
623 scm_uintprint ((scm_t_bits
) SCM_PTAB_ENTRY (exp
), 16, port
);
625 scm_putc ('>', port
);
629 static void fport_flush (SCM port
);
631 /* fill a port's read-buffer with a single read. returns the first
632 char or EOF if end of file. */
634 fport_fill_input (SCM port
)
637 scm_t_port
*pt
= SCM_PTAB_ENTRY (port
);
638 scm_t_fport
*fp
= SCM_FSTREAM (port
);
640 SCM_SYSCALL (count
= read (fp
->fdes
, pt
->read_buf
, pt
->read_buf_size
));
642 scm_syserror ("fport_fill_input");
644 return (scm_t_wchar
) EOF
;
647 pt
->read_pos
= pt
->read_buf
;
648 pt
->read_end
= pt
->read_buf
+ count
;
649 return *pt
->read_buf
;
654 fport_seek (SCM port
, scm_t_off offset
, int whence
)
656 scm_t_port
*pt
= SCM_PTAB_ENTRY (port
);
657 scm_t_fport
*fp
= SCM_FSTREAM (port
);
659 off_t_or_off64_t result
;
661 if (pt
->rw_active
== SCM_PORT_WRITE
)
663 if (offset
!= 0 || whence
!= SEEK_CUR
)
666 result
= rv
= lseek_or_lseek64 (fp
->fdes
, offset
, whence
);
670 /* read current position without disturbing the buffer. */
671 rv
= lseek_or_lseek64 (fp
->fdes
, offset
, whence
);
672 result
= rv
+ (pt
->write_pos
- pt
->write_buf
);
675 else if (pt
->rw_active
== SCM_PORT_READ
)
677 if (offset
!= 0 || whence
!= SEEK_CUR
)
679 /* could expand to avoid a second seek. */
680 scm_end_input (port
);
681 result
= rv
= lseek_or_lseek64 (fp
->fdes
, offset
, whence
);
685 /* read current position without disturbing the buffer
686 (particularly the unread-char buffer). */
687 rv
= lseek_or_lseek64 (fp
->fdes
, offset
, whence
);
688 result
= rv
- (pt
->read_end
- pt
->read_pos
);
690 if (pt
->read_buf
== pt
->putback_buf
)
691 result
-= pt
->saved_read_end
- pt
->saved_read_pos
;
694 else /* SCM_PORT_NEITHER */
696 result
= rv
= lseek_or_lseek64 (fp
->fdes
, offset
, whence
);
700 scm_syserror ("fport_seek");
706 fport_truncate (SCM port
, scm_t_off length
)
708 scm_t_fport
*fp
= SCM_FSTREAM (port
);
710 if (ftruncate (fp
->fdes
, length
) == -1)
711 scm_syserror ("ftruncate");
715 fport_write (SCM port
, const void *data
, size_t size
)
716 #define FUNC_NAME "fport_write"
718 /* this procedure tries to minimize the number of writes/flushes. */
719 scm_t_port
*pt
= SCM_PTAB_ENTRY (port
);
721 if (pt
->write_buf
== &pt
->shortbuf
722 || (pt
->write_pos
== pt
->write_buf
&& size
>= pt
->write_buf_size
))
724 /* Unbuffered port, or port with empty buffer and data won't fit in
726 if (full_write (SCM_FPORT_FDES (port
), data
, size
) < size
)
733 scm_t_off space
= pt
->write_end
- pt
->write_pos
;
737 /* data fits in buffer. */
738 memcpy (pt
->write_pos
, data
, size
);
739 pt
->write_pos
+= size
;
740 if (pt
->write_pos
== pt
->write_end
)
743 /* we can skip the line-buffering check if nothing's buffered. */
749 memcpy (pt
->write_pos
, data
, space
);
750 pt
->write_pos
= pt
->write_end
;
753 const void *ptr
= ((const char *) data
) + space
;
754 size_t remaining
= size
- space
;
756 if (size
>= pt
->write_buf_size
)
758 if (full_write (SCM_FPORT_FDES (port
), ptr
, remaining
)
765 memcpy (pt
->write_pos
, ptr
, remaining
);
766 pt
->write_pos
+= remaining
;
771 /* handle line buffering. */
772 if ((SCM_CELL_WORD_0 (port
) & SCM_BUFLINE
) && memchr (data
, '\n', size
))
779 fport_flush (SCM port
)
782 scm_t_port
*pt
= SCM_PTAB_ENTRY (port
);
783 scm_t_fport
*fp
= SCM_FSTREAM (port
);
784 size_t count
= pt
->write_pos
- pt
->write_buf
;
786 written
= full_write (fp
->fdes
, pt
->write_buf
, count
);
788 scm_syserror ("scm_flush");
790 pt
->write_pos
= pt
->write_buf
;
791 pt
->rw_active
= SCM_PORT_NEITHER
;
794 /* clear the read buffer and adjust the file position for unread bytes. */
796 fport_end_input (SCM port
, int offset
)
798 scm_t_fport
*fp
= SCM_FSTREAM (port
);
799 scm_t_port
*pt
= SCM_PTAB_ENTRY (port
);
801 offset
+= pt
->read_end
- pt
->read_pos
;
805 pt
->read_pos
= pt
->read_end
;
806 /* will throw error if unread-char used at beginning of file
807 then attempting to write. seems correct. */
808 if (lseek (fp
->fdes
, -offset
, SEEK_CUR
) == -1)
809 scm_syserror ("fport_end_input");
811 pt
->rw_active
= SCM_PORT_NEITHER
;
815 fport_close (SCM port
)
817 scm_t_fport
*fp
= SCM_FSTREAM (port
);
818 scm_t_port
*pt
= SCM_PTAB_ENTRY (port
);
822 SCM_SYSCALL (rv
= close (fp
->fdes
));
823 if (rv
== -1 && errno
!= EBADF
)
825 if (scm_gc_running_p
)
826 /* silently ignore the error. scm_error would abort if we
830 scm_syserror ("fport_close");
832 if (pt
->read_buf
== pt
->putback_buf
)
833 pt
->read_buf
= pt
->saved_read_buf
;
834 if (pt
->read_buf
!= &pt
->shortbuf
)
835 scm_gc_free (pt
->read_buf
, pt
->read_buf_size
, "port buffer");
836 if (pt
->write_buf
!= &pt
->shortbuf
)
837 scm_gc_free (pt
->write_buf
, pt
->write_buf_size
, "port buffer");
838 scm_gc_free (fp
, sizeof (*fp
), "file port");
843 fport_free (SCM port
)
852 scm_t_bits tc
= scm_make_port_type ("file", fport_fill_input
, fport_write
);
854 scm_set_port_free (tc
, fport_free
);
855 scm_set_port_print (tc
, fport_print
);
856 scm_set_port_flush (tc
, fport_flush
);
857 scm_set_port_end_input (tc
, fport_end_input
);
858 scm_set_port_close (tc
, fport_close
);
859 scm_set_port_seek (tc
, fport_seek
);
860 scm_set_port_truncate (tc
, fport_truncate
);
861 scm_set_port_input_waiting (tc
, fport_input_waiting
);
869 scm_tc16_fport
= scm_make_fptob ();
871 scm_c_define ("_IOFBF", scm_from_int (_IOFBF
));
872 scm_c_define ("_IOLBF", scm_from_int (_IOLBF
));
873 scm_c_define ("_IONBF", scm_from_int (_IONBF
));
875 sys_file_port_name_canonicalization
= scm_make_fluid ();
876 scm_c_define ("%file-port-name-canonicalization",
877 sys_file_port_name_canonicalization
);
879 #include "libguile/fports.x"