xref: /openbsd-src/lib/libsndio/aucat.h (revision 5cfb95924b3a94dcec1a7ebd8f1fd3cea3bf6fe7)
1*5cfb9592Sratchov /*	$OpenBSD: aucat.h,v 1.8 2019/07/05 22:53:47 ratchov Exp $	*/
2*5cfb9592Sratchov /*
3*5cfb9592Sratchov  * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
4*5cfb9592Sratchov  *
5*5cfb9592Sratchov  * Permission to use, copy, modify, and distribute this software for any
6*5cfb9592Sratchov  * purpose with or without fee is hereby granted, provided that the above
7*5cfb9592Sratchov  * copyright notice and this permission notice appear in all copies.
8*5cfb9592Sratchov  *
9*5cfb9592Sratchov  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10*5cfb9592Sratchov  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11*5cfb9592Sratchov  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12*5cfb9592Sratchov  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13*5cfb9592Sratchov  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14*5cfb9592Sratchov  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15*5cfb9592Sratchov  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16*5cfb9592Sratchov  */
17*5cfb9592Sratchov 
1882bfc72bSratchov #ifndef AUCAT_H
1982bfc72bSratchov #define AUCAT_H
2082bfc72bSratchov 
2182bfc72bSratchov #include "amsg.h"
2282bfc72bSratchov 
2382bfc72bSratchov struct aucat {
2482bfc72bSratchov 	int fd;				/* socket */
2582bfc72bSratchov 	struct amsg rmsg, wmsg;		/* temporary messages */
2682bfc72bSratchov 	size_t wtodo, rtodo;		/* bytes to complete the packet */
2782bfc72bSratchov #define RSTATE_MSG	0		/* message being received */
2882bfc72bSratchov #define RSTATE_DATA	1		/* data being received */
2982bfc72bSratchov 	unsigned rstate;		/* one of above */
3082bfc72bSratchov #define WSTATE_IDLE	2		/* nothing to do */
3182bfc72bSratchov #define WSTATE_MSG	3		/* message being transferred */
3282bfc72bSratchov #define WSTATE_DATA	4		/* data being transferred */
3382bfc72bSratchov 	unsigned wstate;		/* one of above */
345ffd5747Sratchov 	unsigned maxwrite;		/* bytes we're allowed to write */
3582bfc72bSratchov };
3682bfc72bSratchov 
37d418f94bSratchov int _aucat_rmsg(struct aucat *, int *);
38d418f94bSratchov int _aucat_wmsg(struct aucat *, int *);
39d418f94bSratchov size_t _aucat_rdata(struct aucat *, void *, size_t, int *);
40d418f94bSratchov size_t _aucat_wdata(struct aucat *, const void *, size_t, unsigned, int *);
41163486f8Sratchov int _aucat_open(struct aucat *, const char *, unsigned);
42d418f94bSratchov void _aucat_close(struct aucat *, int);
43d418f94bSratchov int _aucat_pollfd(struct aucat *, struct pollfd *, int);
44d418f94bSratchov int _aucat_revents(struct aucat *, struct pollfd *);
45d418f94bSratchov int _aucat_setfl(struct aucat *, int, int *);
4682bfc72bSratchov 
4782bfc72bSratchov #endif /* !defined(AUCAT_H) */
48