1 |
pcg |
1.2 |
#if defined(HAVE_SYS_POLL_H) && defined(HAVE_POLL) |
2 |
|
|
# include <sys/poll.h> |
3 |
|
|
#else |
4 |
|
|
|
5 |
|
|
|
6 |
pcg |
1.1 |
/*---------------------------------------------------------------------------*\ |
7 |
pcg |
1.2 |
$Id: poll.h,v 1.1 2003/10/14 17:24:19 pcg Exp $ |
8 |
pcg |
1.1 |
|
9 |
|
|
NAME |
10 |
|
|
|
11 |
|
|
poll - select(2)-based poll() emulation function for BSD systems. |
12 |
|
|
|
13 |
|
|
SYNOPSIS |
14 |
|
|
#include "poll.h" |
15 |
|
|
|
16 |
|
|
struct pollfd |
17 |
|
|
{ |
18 |
|
|
int fd; |
19 |
|
|
short events; |
20 |
|
|
short revents; |
21 |
|
|
} |
22 |
|
|
|
23 |
|
|
int poll (struct pollfd *pArray, unsigned long n_fds, int timeout) |
24 |
|
|
|
25 |
|
|
DESCRIPTION |
26 |
|
|
|
27 |
|
|
This file, and the accompanying "poll.c", implement the System V |
28 |
|
|
poll(2) system call for BSD systems (which typically do not provide |
29 |
|
|
poll()). Poll() provides a method for multiplexing input and output |
30 |
|
|
on multiple open file descriptors; in traditional BSD systems, that |
31 |
|
|
capability is provided by select(). While the semantics of select() |
32 |
|
|
differ from those of poll(), poll() can be readily emulated in terms |
33 |
|
|
of select() -- which is how this function is implemented. |
34 |
|
|
|
35 |
|
|
REFERENCES |
36 |
|
|
Stevens, W. Richard. Unix Network Programming. Prentice-Hall, 1990. |
37 |
|
|
|
38 |
|
|
NOTES |
39 |
|
|
1. This software requires an ANSI C compiler. |
40 |
|
|
|
41 |
|
|
LICENSE |
42 |
|
|
|
43 |
|
|
This software is released under the following license: |
44 |
|
|
|
45 |
|
|
Copyright (c) 1995-2002 Brian M. Clapper |
46 |
|
|
All rights reserved. |
47 |
|
|
|
48 |
|
|
Redistribution and use in source and binary forms are |
49 |
|
|
permitted provided that: (1) source distributions retain |
50 |
|
|
this entire copyright notice and comment; (2) modifications |
51 |
|
|
made to the software are prominently mentioned, and a copy |
52 |
|
|
of the original software (or a pointer to its location) are |
53 |
|
|
included; and (3) distributions including binaries display |
54 |
|
|
the following acknowledgement: "This product includes |
55 |
|
|
software developed by Brian M. Clapper <bmc@clapper.org>" |
56 |
|
|
in the documentation or other materials provided with the |
57 |
|
|
distribution. The name of the author may not be used to |
58 |
|
|
endorse or promote products derived from this software |
59 |
|
|
without specific prior written permission. |
60 |
|
|
|
61 |
|
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS |
62 |
|
|
OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE |
63 |
|
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A |
64 |
|
|
PARTICULAR PURPOSE. |
65 |
|
|
|
66 |
|
|
Effectively, this means you can do what you want with the software |
67 |
|
|
except remove this notice or take advantage of the author's name. |
68 |
|
|
If you modify the software and redistribute your modified version, |
69 |
|
|
you must indicate that your version is a modification of the |
70 |
|
|
original, and you must provide either a pointer to or a copy of the |
71 |
|
|
original. |
72 |
|
|
\*---------------------------------------------------------------------------*/ |
73 |
|
|
|
74 |
|
|
#ifndef _POLL_EMUL_H_ |
75 |
|
|
#define _POLL_EMUL_H_ |
76 |
|
|
|
77 |
|
|
#define POLLIN 0x01 |
78 |
|
|
#define POLLPRI 0x02 |
79 |
|
|
#define POLLOUT 0x04 |
80 |
|
|
#define POLLERR 0x08 |
81 |
|
|
#define POLLHUP 0x10 |
82 |
|
|
#define POLLNVAL 0x20 |
83 |
|
|
|
84 |
|
|
struct pollfd |
85 |
|
|
{ |
86 |
|
|
int fd; |
87 |
|
|
short events; |
88 |
|
|
short revents; |
89 |
|
|
}; |
90 |
|
|
|
91 |
|
|
#ifdef __cplusplus |
92 |
|
|
extern "C" |
93 |
|
|
{ |
94 |
|
|
#endif |
95 |
|
|
|
96 |
|
|
#if (__STDC__ > 0) || defined(__cplusplus) |
97 |
|
|
extern int poll (struct pollfd *pArray, unsigned long n_fds, int timeout); |
98 |
|
|
#else |
99 |
|
|
extern int poll(); |
100 |
|
|
#endif |
101 |
|
|
|
102 |
|
|
#ifdef __cplusplus |
103 |
|
|
} |
104 |
|
|
#endif |
105 |
|
|
|
106 |
|
|
#endif |
107 |
|
|
|
108 |
|
|
#endif /* _POLL_EMUL_H_ */ |