/[guile]/guile/guile-core/libguile/fports.c
ViewVC logotype

Diff of /guile/guile-core/libguile/fports.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.79 by mdj, Tue Jun 13 00:49:40 2000 UTC revision 1.79.2.1 by ttn, Sat Feb 9 23:39:04 2002 UTC
# Line 1  Line 1 
1  /*      Copyright (C) 1995,1996,1997,1998,1999, 2000 Free Software Foundation, Inc.  /*      Copyright (C) 1995,1996,1997,1998,1999, 2000 Free Software Foundation, Inc.
2   *   *
3   * This program is free software; you can redistribute it and/or modify   * This program is free software; you can redistribute it and/or modify
4   * it under the terms of the GNU General Public License as published by   * it under the terms of the GNU General Public License as published by
5   * the Free Software Foundation; either version 2, or (at your option)   * the Free Software Foundation; either version 2, or (at your option)
6   * any later version.   * any later version.
7   *   *
8   * This program is distributed in the hope that it will be useful,   * This program is distributed in the hope that it will be useful,
9   * but WITHOUT ANY WARRANTY; without even the implied warranty of   * but WITHOUT ANY WARRANTY; without even the implied warranty of
10   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11   * GNU General Public License for more details.   * GNU General Public License for more details.
12   *   *
13   * You should have received a copy of the GNU General Public License   * You should have received a copy of the GNU General Public License
14   * along with this software; see the file COPYING.  If not, write to   * along with this software; see the file COPYING.  If not, write to
15   * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,   * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
# Line 60  Line 60 
60  #else  #else
61  scm_sizet fwrite ();  scm_sizet fwrite ();
62  #endif  #endif
63  #ifdef HAVE_ST_BLKSIZE  #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
64  #include <sys/stat.h>  #include <sys/stat.h>
65  #endif  #endif
66    
# Line 83  scm_fport_buffer_add (SCM port, int read Line 83  scm_fport_buffer_add (SCM port, int read
83    if (read_size == -1 || write_size == -1)    if (read_size == -1 || write_size == -1)
84      {      {
85        int default_size;        int default_size;
86  #ifdef HAVE_ST_BLKSIZE  #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
87        struct stat st;        struct stat st;
88          
89        default_size = (fstat (fp->fdes, &st) == -1) ? default_buffer_size        default_size = (fstat (fp->fdes, &st) == -1) ? default_buffer_size
90          : st.st_blksize;          : st.st_blksize;
91  #else  #else
# Line 132  scm_fport_buffer_add (SCM port, int read Line 132  scm_fport_buffer_add (SCM port, int read
132      SCM_SET_CELL_WORD_0 (port, SCM_CELL_WORD_0 (port) | SCM_BUF0);      SCM_SET_CELL_WORD_0 (port, SCM_CELL_WORD_0 (port) | SCM_BUF0);
133  }  }
134    
135  SCM_DEFINE (scm_setvbuf, "setvbuf", 2, 1, 0,  SCM_DEFINE (scm_setvbuf, "setvbuf", 2, 1, 0,
136              (SCM port, SCM mode, SCM size),              (SCM port, SCM mode, SCM size),
137              "Set the buffering mode for @var{port}.  @var{mode} can be:\n"              "Set the buffering mode for @var{port}.  @var{mode} can be:\n"
138              "@table @code\n"              "@table @code\n"
# Line 402  fport_input_waiting (SCM port) Line 402  fport_input_waiting (SCM port)
402    FD_ZERO (&except_set);    FD_ZERO (&except_set);
403    
404    FD_SET (fdes, &read_set);    FD_SET (fdes, &read_set);
405      
406    timeout.tv_sec = 0;    timeout.tv_sec = 0;
407    timeout.tv_usec = 0;    timeout.tv_usec = 0;
408    
# Line 415  fport_input_waiting (SCM port) Line 415  fport_input_waiting (SCM port)
415    int remir;    int remir;
416    ioctl(fdes, FIONREAD, &remir);    ioctl(fdes, FIONREAD, &remir);
417    return remir;    return remir;
418  #else      #else
419    scm_misc_error ("fport_input_waiting",    scm_misc_error ("fport_input_waiting",
420                    "Not fully implemented on this platform",                    "Not fully implemented on this platform",
421                    SCM_EOL);                    SCM_EOL);
# Line 423  fport_input_waiting (SCM port) Line 423  fport_input_waiting (SCM port)
423  }  }
424    
425    
426  static int  static int
427  prinfport (SCM exp,SCM port,scm_print_state *pstate)  prinfport (SCM exp,SCM port,scm_print_state *pstate)
428  {  {
429    scm_puts ("#<", port);    scm_puts ("#<", port);
430    scm_print_port_mode (exp, port);        scm_print_port_mode (exp, port);
431    if (SCM_OPFPORTP (exp))    if (SCM_OPFPORTP (exp))
432      {      {
433        int fdes;        int fdes;
# Line 438  prinfport (SCM exp,SCM port,scm_print_st Line 438  prinfport (SCM exp,SCM port,scm_print_st
438                  port);                  port);
439        scm_putc (' ', port);        scm_putc (' ', port);
440        fdes = (SCM_FSTREAM (exp))->fdes;        fdes = (SCM_FSTREAM (exp))->fdes;
441          
442        if (isatty (fdes))        if (isatty (fdes))
443          scm_puts (ttyname (fdes), port);          scm_puts (ttyname (fdes), port);
444        else        else
# Line 552  fport_seek (SCM port, off_t offset, int Line 552  fport_seek (SCM port, off_t offset, int
552      }      }
553    else /* SCM_PORT_NEITHER */    else /* SCM_PORT_NEITHER */
554      {      {
555        result = rv = lseek (fp->fdes, offset, whence);              result = rv = lseek (fp->fdes, offset, whence);
556      }      }
557    
558    if (rv == -1)    if (rv == -1)
# Line 583  fport_write (SCM port, const void *data, Line 583  fport_write (SCM port, const void *data,
583        if (write (fdes, data, size) == -1)        if (write (fdes, data, size) == -1)
584          scm_syserror ("fport_write");          scm_syserror ("fport_write");
585      }      }
586    else    else
587      {      {
588        const char *input = (char *) data;        const char *input = (char *) data;
589        size_t remaining = size;        size_t remaining = size;
# Line 609  fport_write (SCM port, const void *data, Line 609  fport_write (SCM port, const void *data,
609    
610  /* becomes 1 when process is exiting: normal exception handling won't  /* becomes 1 when process is exiting: normal exception handling won't
611     work by this time.  */     work by this time.  */
612  extern int terminating;  extern int terminating;
613    
614  static void  static void
615  fport_flush (SCM port)  fport_flush (SCM port)
# Line 630  fport_flush (SCM port) Line 630  fport_flush (SCM port)
630            /* error.  assume nothing was written this call, but            /* error.  assume nothing was written this call, but
631               fix up the buffer for any previous successful writes.  */               fix up the buffer for any previous successful writes.  */
632            int done = init_size - remaining;            int done = init_size - remaining;
633                  
634            if (done > 0)            if (done > 0)
635              {              {
636                int i;                int i;
# Line 668  fport_end_input (SCM port, int offset) Line 668  fport_end_input (SCM port, int offset)
668  {  {
669    struct scm_fport *fp = SCM_FSTREAM (port);    struct scm_fport *fp = SCM_FSTREAM (port);
670    scm_port *pt = SCM_PTAB_ENTRY (port);    scm_port *pt = SCM_PTAB_ENTRY (port);
671      
672    offset += pt->read_end - pt->read_pos;    offset += pt->read_end - pt->read_pos;
673    
674    if (offset > 0)    if (offset > 0)

Legend:
Removed from v.1.79  
changed lines
  Added in v.1.79.2.1

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26