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