3 * Reference counted file descriptors
5 * (c) 1999 Straylight/Edgeware
8 /*----- Licensing notice --------------------------------------------------*
10 * This file is part of the `fw' port forwarder.
12 * `fw' is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * `fw' is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with `fw'; if not, write to the Free Software Foundation,
24 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29 /*----- Main code ---------------------------------------------------------*/
31 /* --- @reffd_init@ --- *
33 * Arguments: @int fd@ = file descriptor
35 * Returns: Reference-counted file descriptor object.
37 * Use: Creates a refcounted file descriptor.
40 reffd *reffd_init(int fd)
42 reffd *r = CREATE(reffd);
50 /* --- @reffd_handler@ --- *
52 * Arguments: @reffd *r@ = pointer to reference counted filehandle
53 * @void (*proc)(void *p)@ = procedure to call
58 * Use: Sets the reference counted file descriptor to call @proc@
59 * when it is no longer required.
62 void reffd_handler(reffd *r, void (*proc)(void *p), void *p)
68 /* --- @reffd_inc@ --- *
70 * Arguments: @reffd *r@ = pointer to reference counted filehandle
74 * Use: Increments the reference count for a file descriptor.
77 void reffd_inc(reffd *r) { REFFD_INC(r); }
79 /* --- @reffd_dec@ --- *
81 * Arguments: @reffd *r@ = pointer to reference counted filehandle
85 * Use: Decrements the reference count for a file descriptor.
88 void reffd_dec(reffd *r) { REFFD_DEC(r); }
90 /*----- That's all, folks -------------------------------------------------*/