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