-/* Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+/* Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2003 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
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this software; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- * Boston, MA 02111-1307 USA
- *
- * As a special exception, the Free Software Foundation gives permission
- * for additional uses of the text contained in its release of GUILE.
- *
- * The exception is that, if you link the GUILE library with other files
- * to produce an executable, this does not by itself cause the
- * resulting executable to be covered by the GNU General Public License.
- * Your use of that executable is in no way restricted on account of
- * linking the GUILE library code into it.
- *
- * This exception does not however invalidate any other reasons why
- * the executable file might be covered by the GNU General Public License.
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
*
- * This exception applies only to the code released by the
- * Free Software Foundation under the name GUILE. If you copy
- * code from other Free Software Foundation releases into a copy of
- * GUILE, as the General Public License permits, the exception does
- * not apply to the code that you add in this way. To avoid misleading
- * anyone as to the status of such modified files, you must delete
- * this exception notice from them.
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
*
- * 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. */
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
-/* Software engineering face-lift by Greg J. Badros, 11-Dec-1999,
- gjb@cs.washington.edu, http://www.cs.washington.edu/homes/gjb */
\f
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include <stdio.h>
#include <errno.h>
#include <fcntl.h>
+#ifdef HAVE_IO_H
+#include <io.h>
+#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
old = SCM_COERCE_OUTPORT (old);
new = SCM_COERCE_OUTPORT (new);
- SCM_VALIDATE_OPFPORT (1,old);
- SCM_VALIDATE_OPFPORT (2,new);
+ SCM_VALIDATE_OPFPORT (1, old);
+ SCM_VALIDATE_OPFPORT (2, new);
oldfd = SCM_FPORT_FDES (old);
fp = SCM_FSTREAM (new);
newfd = fp->fdes;
oldfd = SCM_INUM (fd_or_port);
else
{
- SCM_VALIDATE_OPFPORT (1,fd_or_port);
+ SCM_VALIDATE_OPFPORT (1, fd_or_port);
oldfd = SCM_FPORT_FDES (fd_or_port);
}
#define FUNC_NAME s_scm_fileno
{
port = SCM_COERCE_OUTPORT (port);
- SCM_VALIDATE_OPFPORT (1,port);
+ SCM_VALIDATE_OPFPORT (1, port);
return SCM_MAKINUM (SCM_FPORT_FDES (port));
}
#undef FUNC_NAME
"same as that accepted by @ref{File Ports, open-file}.")
#define FUNC_NAME s_scm_fdopen
{
- SCM_VALIDATE_INUM (1,fdes);
+ SCM_VALIDATE_INUM (1, fdes);
SCM_VALIDATE_STRING (2, modes);
- SCM_STRING_COERCE_0TERMINATION_X (modes);
return scm_fdes_to_port (SCM_INUM (fdes), SCM_STRING_CHARS (modes), SCM_BOOL_F);
}
port = SCM_COERCE_OUTPORT (port);
- SCM_VALIDATE_OPFPORT (1,port);
- SCM_VALIDATE_INUM (2,fd);
+ SCM_VALIDATE_OPFPORT (1, port);
+ SCM_VALIDATE_INUM (2, fd);
stream = SCM_FSTREAM (port);
old_fd = stream->fdes;
new_fd = SCM_INUM (fd);
int int_fd;
long i;
- SCM_VALIDATE_INUM_COPY (1,fd,int_fd);
+ SCM_VALIDATE_INUM_COPY (1, fd, int_fd);
- for (i = 0; i < scm_t_portable_size; i++)
+ scm_mutex_lock (&scm_i_port_table_mutex);
+ for (i = 0; i < scm_i_port_table_size; i++)
{
- if (SCM_OPFPORTP (scm_t_portable[i]->port)
- && ((scm_t_fport *) scm_t_portable[i]->stream)->fdes == int_fd)
- result = scm_cons (scm_t_portable[i]->port, result);
+ if (SCM_OPFPORTP (scm_i_port_table[i]->port)
+ && ((scm_t_fport *) scm_i_port_table[i]->stream)->fdes == int_fd)
+ result = scm_cons (scm_i_port_table[i]->port, result);
}
+ scm_mutex_unlock (&scm_i_port_table_mutex);
return result;
}
#undef FUNC_NAME
{
scm_add_feature ("i/o-extensions");
-#ifndef SCM_MAGIC_SNARFER
#include "libguile/ioext.x"
-#endif
}