LCOV - code coverage report
Current view: top level - src - funopen.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 7 0.0 %
Date: 2016-12-01 18:29:29 Functions: 0 1 0.0 %

          Line data    Source code
       1             : /* funopen.c - Replacement for funopen.
       2             :  * Copyright (C) 2003, 2005 Free Software Foundation, Inc.
       3             :  *
       4             :  * This file is part of Assuan.
       5             :  *
       6             :  * Assuan is free software; you can redistribute it and/or modify it
       7             :  * under the terms of the GNU Lesser General Public License as
       8             :  * published by the Free Software Foundation; either version 2.1 of
       9             :  * the License, or (at your option) any later version.
      10             :  *
      11             :  * Assuan is distributed in the hope that it will be useful, but
      12             :  * WITHOUT ANY WARRANTY; without even the implied warranty of
      13             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      14             :  * Lesser General Public License for more details.
      15             :  *
      16             :  * You should have received a copy of the GNU Lesser General Public
      17             :  * License along with this program; if not, see <http://www.gnu.org/licenses/>.
      18             :  */
      19             : 
      20             : #ifdef HAVE_CONFIG_H
      21             : #include <config.h>
      22             : #endif
      23             : 
      24             : #include <stdio.h>
      25             : 
      26             : 
      27             : /* Replacement for the *BSD function:
      28             : 
      29             :   FILE *funopen (void *cookie,
      30             :                  int (*readfn)(void *, char *, int),
      31             :                  int (*writefn)(void *, const char *, int),
      32             :                  fpos_t (*seekfn)(void *, fpos_t, int),
      33             :                  int (*closefn)(void *));
      34             : 
      35             :   The functions to provide my either be NULL if not required or
      36             :   similar to the unistd function with the exception of using the
      37             :   cookie instead of the file descriptor.
      38             : */
      39             : 
      40             : 
      41             : #ifdef HAVE_FOPENCOOKIE
      42             : FILE *
      43           0 : _assuan_funopen(void *cookie,
      44             :                 cookie_read_function_t *readfn,
      45             :                 cookie_write_function_t *writefn,
      46             :                 cookie_seek_function_t *seekfn,
      47             :                 cookie_close_function_t *closefn)
      48             : {
      49             :   cookie_io_functions_t io;
      50             : 
      51           0 :   io.read = readfn;
      52           0 :   io.write = writefn;
      53           0 :   io.seek = seekfn;
      54           0 :   io.close = closefn;
      55             : 
      56           0 :   return fopencookie (cookie,
      57             :                       readfn ? ( writefn ? "rw" : "r" )
      58           0 :                       : ( writefn ? "w" : ""), io);
      59             : }
      60             : #else
      61             : #error No known way to implement funopen.
      62             : #endif

Generated by: LCOV version 1.11