summaryrefslogtreecommitdiff
path: root/lib/libsndio/sioctl_priv.h
blob: bfe806c0757b8cf2a347bdc1e8227aa52134ac91 (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*	$OpenBSD: sioctl_priv.h,v 1.1 2020/02/26 13:53:58 ratchov Exp $	*/
/*
 * Copyright (c) 2014-2020 Alexandre Ratchov <alex@caoua.org>
 *
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */
#ifndef SIOCTL_PRIV_H
#define SIOCTL_PRIV_H

#include <sndio.h>

#define SIOCTL_MAXNFDS	4

/*
 * private ``handle'' structure
 */
struct sioctl_hdl {
	struct sioctl_ops *ops;
	void (*desc_cb)(void *, struct sioctl_desc *, int);
	void *desc_arg;
	void (*ctl_cb)(void *, unsigned int, unsigned int);
	void *ctl_arg;
	unsigned int mode;		/* SIOCTL_READ | SIOCTL_WRITE */
	int nbio;			/* true if non-blocking io */
	int eof;			/* true if error occured */
};

/*
 * operations every device should support
 */
struct sioctl_ops {
	void (*close)(struct sioctl_hdl *);
	int (*nfds)(struct sioctl_hdl *);
	int (*pollfd)(struct sioctl_hdl *, struct pollfd *, int);
	int (*revents)(struct sioctl_hdl *, struct pollfd *);
	int (*setctl)(struct sioctl_hdl *, unsigned int, unsigned int);
	int (*onctl)(struct sioctl_hdl *);
	int (*ondesc)(struct sioctl_hdl *);
};

struct sioctl_hdl *_sioctl_aucat_open(const char *, unsigned int, int);
struct sioctl_hdl *_sioctl_obsd_open(const char *, unsigned int, int);
struct sioctl_hdl *_sioctl_fake_open(const char *, unsigned int, int);
struct sioctl_hdl *_sioctl_sun_open(const char *, unsigned int, int);
void _sioctl_create(struct sioctl_hdl *,
    struct sioctl_ops *, unsigned int, int);
void _sioctl_ondesc_cb(struct sioctl_hdl *,
    struct sioctl_desc *, unsigned int);
void _sioctl_onval_cb(struct sioctl_hdl *, unsigned int, unsigned int);
int _sioctl_psleep(struct sioctl_hdl *, int);

#endif /* !defined(SIOCTL_PRIV_H) */