summaryrefslogtreecommitdiff
path: root/src/iosocket.h
blob: 92010087be36b248bf6ecee46ae7977c43ac8d78 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#ifndef _IOSOCKET_H_
#define _IOSOCKET_H_

/**
 * make sure we know about OPENSSL all the time
 *
 * if we don't include config.h here we run into different sizes
 * for the iosocket-struct depending on config.h include before
 * iosocket.h or not
 */

#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

#if defined HAVE_LIBSSL && defined HAVE_OPENSSL_SSL_H
# define USE_OPENSSL
# include <openssl/ssl.h>
#endif

#include "settings.h"

typedef enum {
	IOSOCKET_TYPE_UNSET,
	IOSOCKET_TYPE_SOCKET,
	IOSOCKET_TYPE_PIPE
} iosocket_t;

/**
 * a non-blocking fd
 */
typedef struct {
	int fd;
	int fde_ndx;

#ifdef USE_OPENSSL
	SSL *ssl;
#endif

	iosocket_t type; /**< sendfile on solaris doesn't work on pipes */
} iosocket;

LI_EXPORT iosocket * iosocket_init(void);
LI_EXPORT void iosocket_free(iosocket *sock);

#endif