/[mailutils]/mailutils/mailbox/stream.c
ViewVC logotype

Diff of /mailutils/mailbox/stream.c

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

revision 1.21 by polak, Sun Dec 29 12:52:08 2002 UTC revision 1.22 by gray, Sat Jan 18 14:59:43 2003 UTC
# Line 641  stream_set_flags (stream_t stream, int f Line 641  stream_set_flags (stream_t stream, int f
641    return 0;    return 0;
642  }  }
643    
644    int
645    stream_set_strerror (stream_t stream,
646                         int (*fp) (stream_t, const char **), void *owner)
647    {
648      if (stream == NULL)
649        return EINVAL;
650      if (stream->owner != owner)
651        return EACCES;
652      stream->_strerror = fp;
653      return 0;
654    }
655    
656    int
657    stream_sequential_read (stream_t stream, char *buf, size_t size,
658                            size_t *nbytes)
659    {
660      size_t rdbytes;
661      int rc = stream_read (stream, buf, size, stream->offset, &rdbytes);
662      if (!rc)
663        {
664          stream->offset += rdbytes;
665          if (nbytes)
666            *nbytes = rdbytes;
667        }
668      return rc;
669    }
670    
671    int
672    stream_sequential_readline (stream_t stream, char *buf, size_t size,
673                                size_t *nbytes)
674    {
675      size_t rdbytes;
676      int rc = stream_readline (stream, buf, size, stream->offset, &rdbytes);
677      if (!rc)
678        {
679          stream->offset += rdbytes;
680          if (nbytes)
681            *nbytes = rdbytes;
682        }
683      return rc;
684    }
685    
686    int
687    stream_sequential_write (stream_t stream, char *buf, size_t size)
688    {
689      while (size > 0)
690        {
691          size_t sz;
692          int rc = stream_write (stream, buf, size, stream->offset, &sz);
693          if (rc)
694            return rc;
695    
696          buf += sz;
697          size -= sz;
698          stream->offset += sz;
699        }
700      return 0;
701    }
702    
703    int
704    stream_strerror (stream_t stream, const char **p)
705    {
706      if (stream->_strerror)
707        return stream->_strerror (stream, p);
708      return ENOSYS;
709    }
710    
711  static int  static int
712  refill (stream_t stream, off_t offset)  refill (stream_t stream, off_t offset)
713  {  {

Legend:
Removed from v.1.21  
changed lines
  Added in v.1.22

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