759ef658 |
1 | /* -*-c-*- |
759ef658 |
2 | * |
3 | * File descriptor passing |
4 | * |
5 | * (c) 2003 Straylight/Edgeware |
6 | */ |
7 | |
d4efbcd9 |
8 | /*----- Licensing notice --------------------------------------------------* |
759ef658 |
9 | * |
10 | * This file is part of the mLib utilities library. |
11 | * |
12 | * mLib is free software; you can redistribute it and/or modify |
13 | * it under the terms of the GNU Library General Public License as |
14 | * published by the Free Software Foundation; either version 2 of the |
15 | * License, or (at your option) any later version. |
d4efbcd9 |
16 | * |
759ef658 |
17 | * mLib 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 Library General Public License for more details. |
d4efbcd9 |
21 | * |
759ef658 |
22 | * You should have received a copy of the GNU Library General Public |
23 | * License along with mLib; if not, write to the Free |
24 | * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, |
25 | * MA 02111-1307, USA. |
26 | */ |
27 | |
759ef658 |
28 | #ifndef MLIB_FDPASS_H |
29 | #define MLIB_FDPASS_H |
30 | |
31 | #ifdef __cplusplus |
32 | extern "C" { |
33 | #endif |
34 | |
35 | /*----- Header files ------------------------------------------------------*/ |
36 | |
37 | #include <sys/types.h> |
38 | #include <unistd.h> |
39 | |
40 | /*----- Functions provided ------------------------------------------------*/ |
41 | |
42 | /* --- @fdpass_send@ --- * |
43 | * |
44 | * Arguments: @int sock@ = socket to send over |
45 | * @int fd@ = file descriptor to send |
46 | * @const void *p@ = pointer to data to send |
47 | * @size_t sz@ = size of buffer to send |
48 | * |
49 | * Returns: On error, @-1@, otherwise number of bytes transferred from |
50 | * @p@. |
51 | * |
52 | * Use: Sends a copy of file descriptor @fd@ to the other end of |
53 | * @sock@. |
54 | */ |
55 | |
56 | extern ssize_t fdpass_send(int /*sock*/, int /*fd*/, |
57 | const void */*p*/, size_t /*sz*/); |
58 | |
59 | /* --- @fdpass_recv@ --- * |
60 | * |
61 | * Arguments: @int sock@ = socket to send over |
62 | * @int *fd@ = where to put received descriptor |
63 | * @void *p@ = pointer to where to put data |
64 | * @size_t sz@ = size of buffer |
65 | * |
66 | * Returns: On error, @-1@, otherwise number of bytes transferred. |
67 | * |
68 | * Use: Receives a file descriptor. If the call succeeds, and there |
69 | * was a file descriptor, then @fd@ won't be @-1@ on exit; |
70 | * otherwise it will. At most one descriptor will be collected. |
71 | */ |
72 | |
73 | extern ssize_t fdpass_recv(int /*sock*/, int */*fd*/, |
74 | void */*p*/, size_t /*sz*/); |
75 | |
76 | /*----- That's all, folks -------------------------------------------------*/ |
77 | |
78 | #ifdef __cplusplus |
79 | } |
80 | #endif |
81 | |
82 | #endif |