Call libssh2_channel_close() before freeing it.
[libpwmd.git] / assuan / funopen.c
blobfb87f962670c3c0f30d33c41333c0abb1c4140bd
1 /* funopen.c - Replacement for funopen.
2 * Copyright (C) 2003, 2005 Free Software Foundation, Inc.
4 * This file is part of Assuan.
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.
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.
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/>.
20 #ifdef HAVE_CONFIG_H
21 #include <config.h>
22 #endif
24 #include <stdio.h>
27 /* Replacement for the *BSD function:
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 *));
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 fiel descripor.
41 #ifdef HAVE_FOPENCOOKIE
42 FILE *
43 _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)
49 cookie_io_functions_t io;
51 io.read = readfn;
52 io.write = writefn;
53 io.seek = seekfn;
54 io.close = closefn;
56 return fopencookie (cookie,
57 readfn ? ( writefn ? "rw" : "r" )
58 : ( writefn ? "w" : ""), io);
60 #else
61 #error No known way to implement funopen.
62 #endif