xref: /openbsd-src/lib/libsndio/sioctl_priv.h (revision d20001a803bf8b9a154852114830dee9c70d1206)
1*d20001a8Sjsg /*	$OpenBSD: sioctl_priv.h,v 1.3 2024/05/21 06:07:06 jsg Exp $	*/
2d07fece6Sratchov /*
3d07fece6Sratchov  * Copyright (c) 2014-2020 Alexandre Ratchov <alex@caoua.org>
4d07fece6Sratchov  *
5d07fece6Sratchov  * Permission to use, copy, modify, and distribute this software for any
6d07fece6Sratchov  * purpose with or without fee is hereby granted, provided that the above
7d07fece6Sratchov  * copyright notice and this permission notice appear in all copies.
8d07fece6Sratchov  *
9d07fece6Sratchov  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10d07fece6Sratchov  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11d07fece6Sratchov  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12d07fece6Sratchov  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13d07fece6Sratchov  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14d07fece6Sratchov  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15d07fece6Sratchov  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16d07fece6Sratchov  */
17d07fece6Sratchov #ifndef SIOCTL_PRIV_H
18d07fece6Sratchov #define SIOCTL_PRIV_H
19d07fece6Sratchov 
20d07fece6Sratchov #include <sndio.h>
21d07fece6Sratchov 
22d07fece6Sratchov #define SIOCTL_MAXNFDS	4
23d07fece6Sratchov 
24d07fece6Sratchov /*
25d07fece6Sratchov  * private ``handle'' structure
26d07fece6Sratchov  */
27d07fece6Sratchov struct sioctl_hdl {
28d07fece6Sratchov 	struct sioctl_ops *ops;
29d07fece6Sratchov 	void (*desc_cb)(void *, struct sioctl_desc *, int);
30d07fece6Sratchov 	void *desc_arg;
31d07fece6Sratchov 	void (*ctl_cb)(void *, unsigned int, unsigned int);
32d07fece6Sratchov 	void *ctl_arg;
33d07fece6Sratchov 	unsigned int mode;		/* SIOCTL_READ | SIOCTL_WRITE */
34d07fece6Sratchov 	int nbio;			/* true if non-blocking io */
352c53affbSjmc 	int eof;			/* true if error occurred */
36d07fece6Sratchov };
37d07fece6Sratchov 
38d07fece6Sratchov /*
39d07fece6Sratchov  * operations every device should support
40d07fece6Sratchov  */
41d07fece6Sratchov struct sioctl_ops {
42d07fece6Sratchov 	void (*close)(struct sioctl_hdl *);
43d07fece6Sratchov 	int (*nfds)(struct sioctl_hdl *);
44d07fece6Sratchov 	int (*pollfd)(struct sioctl_hdl *, struct pollfd *, int);
45d07fece6Sratchov 	int (*revents)(struct sioctl_hdl *, struct pollfd *);
46d07fece6Sratchov 	int (*setctl)(struct sioctl_hdl *, unsigned int, unsigned int);
47d07fece6Sratchov 	int (*onctl)(struct sioctl_hdl *);
48d07fece6Sratchov 	int (*ondesc)(struct sioctl_hdl *);
49d07fece6Sratchov };
50d07fece6Sratchov 
51d07fece6Sratchov struct sioctl_hdl *_sioctl_aucat_open(const char *, unsigned int, int);
52d07fece6Sratchov struct sioctl_hdl *_sioctl_sun_open(const char *, unsigned int, int);
53d07fece6Sratchov void _sioctl_create(struct sioctl_hdl *,
54d07fece6Sratchov     struct sioctl_ops *, unsigned int, int);
55d07fece6Sratchov void _sioctl_ondesc_cb(struct sioctl_hdl *,
56d07fece6Sratchov     struct sioctl_desc *, unsigned int);
57d07fece6Sratchov void _sioctl_onval_cb(struct sioctl_hdl *, unsigned int, unsigned int);
58d07fece6Sratchov int _sioctl_psleep(struct sioctl_hdl *, int);
59d07fece6Sratchov 
60d07fece6Sratchov #endif /* !defined(SIOCTL_PRIV_H) */
61