fwd.c (fw_log): Report the timezone in log messages.
[fwd] / reffd.c
1 /* -*-c-*-
2 *
3 * Reference counted file descriptors
4 *
5 * (c) 1999 Straylight/Edgeware
6 */
7
8 /*----- Licensing notice --------------------------------------------------*
9 *
10 * This file is part of the `fwd' port forwarder.
11 *
12 * `fwd' 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.
16 *
17 * `fwd' 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.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with `fwd'; if not, write to the Free Software Foundation,
24 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 */
26
27 #include "fwd.h"
28
29 /*----- Main code ---------------------------------------------------------*/
30
31 /* --- @reffd_init@ --- *
32 *
33 * Arguments: @int fd@ = file descriptor
34 *
35 * Returns: Reference-counted file descriptor object.
36 *
37 * Use: Creates a refcounted file descriptor.
38 */
39
40 reffd *reffd_init(int fd)
41 {
42 reffd *r = CREATE(reffd);
43 r->fd = fd;
44 r->ref = 1;
45 r->proc = 0;
46 r->p = 0;
47 return (r);
48 }
49
50 /* --- @reffd_handler@ --- *
51 *
52 * Arguments: @reffd *r@ = pointer to reference counted filehandle
53 * @void (*proc)(void *p)@ = procedure to call
54 * @void *p@
55 *
56 * Returns: ---
57 *
58 * Use: Sets the reference counted file descriptor to call @proc@
59 * when it is no longer required.
60 */
61
62 void reffd_handler(reffd *r, void (*proc)(void *p), void *p)
63 {
64 r->proc = proc;
65 r->p = p;
66 }
67
68 /* --- @reffd_inc@ --- *
69 *
70 * Arguments: @reffd *r@ = pointer to reference counted filehandle
71 *
72 * Returns: ---
73 *
74 * Use: Increments the reference count for a file descriptor.
75 */
76
77 void reffd_inc(reffd *r) { REFFD_INC(r); }
78
79 /* --- @reffd_dec@ --- *
80 *
81 * Arguments: @reffd *r@ = pointer to reference counted filehandle
82 *
83 * Returns: ---
84 *
85 * Use: Decrements the reference count for a file descriptor.
86 */
87
88 void reffd_dec(reffd *r) { REFFD_DEC(r); }
89
90 /*----- That's all, folks -------------------------------------------------*/