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