Diff for /libaitio/src/bufio.c between versions 1.7 and 1.9.8.1

version 1.7, 2013/03/13 14:54:39 version 1.9.8.1, 2016/08/11 12:25:51
Line 12  terms: Line 12  terms:
 All of the documentation and software included in the ELWIX and AITNET  All of the documentation and software included in the ELWIX and AITNET
 Releases is copyrighted by ELWIX - Sofia/Bulgaria <info@elwix.org>  Releases is copyrighted by ELWIX - Sofia/Bulgaria <info@elwix.org>
   
Copyright 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013Copyright 2004 - 2016
         by Michael Pounov <misho@elwix.org>.  All rights reserved.          by Michael Pounov <misho@elwix.org>.  All rights reserved.
   
 Redistribution and use in source and binary forms, with or without  Redistribution and use in source and binary forms, with or without
Line 53  unmap_cf(struct tagBufIO *buf) Line 53  unmap_cf(struct tagBufIO *buf)
                 munmap(buf->buf_base, buf->buf_size);                  munmap(buf->buf_base, buf->buf_size);
 }  }
   
   #ifndef __linux__
 static int  static int
 cf_(struct tagBufIO *buf)  cf_(struct tagBufIO *buf)
 {  {
Line 240  wf_inf(struct tagBufIO *buf, const char *dat, int siz) Line 241  wf_inf(struct tagBufIO *buf, const char *dat, int siz)
         buf->buf_offset += siz;          buf->buf_offset += siz;
         return siz;          return siz;
 }  }
   #endif
   
   
 /*  /*
Line 268  io_fmemopen(void ** __restrict base, off_t basesize) Line 270  io_fmemopen(void ** __restrict base, off_t basesize)
                 memset(buf, 0, sizeof(struct tagBufIO));                  memset(buf, 0, sizeof(struct tagBufIO));
   
         if (!*base) {          if (!*base) {
   #ifndef __linux__
                 *base = e_malloc(basesize);                  *base = e_malloc(basesize);
                 if (!*base) {                  if (!*base) {
                         LOGERR;                          LOGERR;
Line 276  io_fmemopen(void ** __restrict base, off_t basesize) Line 279  io_fmemopen(void ** __restrict base, off_t basesize)
                 } else                  } else
                         memset(*base, 0, basesize);                          memset(*base, 0, basesize);
   
                   buf->buf_base = *base;
                   buf->buf_size = basesize;
   #endif
                 buf->buf_mode = BUFIO_MODE_INFINIT;                  buf->buf_mode = BUFIO_MODE_INFINIT;
        } else        } else {
                 buf->buf_base = *base;
                 buf->buf_size = basesize;
 
                 buf->buf_mode = BUFIO_MODE_LIMIT;                  buf->buf_mode = BUFIO_MODE_LIMIT;
           }
   
        buf->buf_base = *base;#ifndef __linux__
        buf->buf_size = basesize; 
 
 #ifdef __NetBSD__  #ifdef __NetBSD__
         if (buf->buf_mode == BUFIO_MODE_INFINIT)          if (buf->buf_mode == BUFIO_MODE_INFINIT)
                 f = funopen(buf, (int (*)(void *, char *, int)) rf_lim,                   f = funopen(buf, (int (*)(void *, char *, int)) rf_lim, 
Line 306  io_fmemopen(void ** __restrict base, off_t basesize) Line 314  io_fmemopen(void ** __restrict base, off_t basesize)
                                 (fpos_t (*)(void *, fpos_t, int)) sf_lim,                                   (fpos_t (*)(void *, fpos_t, int)) sf_lim, 
                                 (int (*)(void *)) cf_);                                  (int (*)(void *)) cf_);
 #endif  #endif
   #else
           if (buf->buf_mode == BUFIO_MODE_INFINIT)
                   f = open_memstream((char**) &buf->buf_base, (size_t*) &buf->buf_size);
           else
                   f = fmemopen(buf->buf_base, buf->buf_size, "r+");
   #endif
         if (!f) {          if (!f) {
                 LOGERR;                  LOGERR;
   #ifndef __linux__
                 if (buf->buf_mode == BUFIO_MODE_INFINIT) {                  if (buf->buf_mode == BUFIO_MODE_INFINIT) {
                         e_free(*base);                          e_free(*base);
                         *base = NULL;                          *base = NULL;
                 }                  }
   #endif
                 e_free(buf);                  e_free(buf);
                 return NULL;                  return NULL;
         }          }
   #ifdef __linux__
           if (buf->buf_mode == BUFIO_MODE_INFINIT)
                   *base = buf->buf_base;
   #endif
   
         return f;          return f;
 }  }
Line 386  io_fmapopen(const char *csFile, int mode, int perm, in Line 406  io_fmapopen(const char *csFile, int mode, int perm, in
         buf->buf_size = basesize;          buf->buf_size = basesize;
         buf->buf_unmap = unmap_cf;          buf->buf_unmap = unmap_cf;
   
   #ifndef __linux__
 #ifdef __NetBSD__  #ifdef __NetBSD__
         f = funopen(buf, (int (*)(void *, char *, int)) rf_lim,           f = funopen(buf, (int (*)(void *, char *, int)) rf_lim, 
                         (int (*)(void *, char const *, int)) wf_lim,                           (int (*)(void *, char const *, int)) wf_lim, 
Line 397  io_fmapopen(const char *csFile, int mode, int perm, in Line 418  io_fmapopen(const char *csFile, int mode, int perm, in
                         (fpos_t (*)(void *, fpos_t, int)) sf_lim,                           (fpos_t (*)(void *, fpos_t, int)) sf_lim, 
                         (int (*)(void *)) cf_);                          (int (*)(void *)) cf_);
 #endif  #endif
   #else
           f = fmemopen(buf->buf_base, buf->buf_size, "r+");
   #endif
         if (!f) {          if (!f) {
                 LOGERR;                  LOGERR;
                 e_free(buf);                  e_free(buf);
Line 447  err: Line 471  err:
  * @mode = Permissions for new buffered file I/O   * @mode = Permissions for new buffered file I/O
  * return: NULL error or open buffered file   * return: NULL error or open buffered file
  */   */
inline FILE *FILE *
 io_fd2buf(int fd, const char *mode)  io_fd2buf(int fd, const char *mode)
 {  {
         FILE *f;          FILE *f;

Removed from v.1.7  
changed lines
  Added in v.1.9.8.1


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>