|
Packit |
a94d48 |
/*
|
|
Packit |
a94d48 |
* connection_list.h - connection list
|
|
Packit |
a94d48 |
*
|
|
Packit |
a94d48 |
* Copyright (C) 2008, Ted Felix (www.tedfelix.com)
|
|
Packit |
a94d48 |
*
|
|
Packit |
a94d48 |
* This program is free software; you can redistribute it and/or modify
|
|
Packit |
a94d48 |
* it under the terms of the GNU General Public License as published by
|
|
Packit |
a94d48 |
* the Free Software Foundation; either version 2 of the License, or
|
|
Packit |
a94d48 |
* (at your option) any later version.
|
|
Packit |
a94d48 |
*
|
|
Packit |
a94d48 |
* This program is distributed in the hope that it will be useful,
|
|
Packit |
a94d48 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
a94d48 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit |
a94d48 |
* GNU General Public License for more details.
|
|
Packit |
a94d48 |
*
|
|
Packit |
a94d48 |
* You should have received a copy of the GNU General Public License
|
|
Packit |
a94d48 |
* along with this program; if not, write to the Free Software
|
|
Packit |
a94d48 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
Packit |
a94d48 |
*
|
|
Packit |
a94d48 |
* Tabs at 4
|
|
Packit |
a94d48 |
*/
|
|
Packit |
a94d48 |
|
|
Packit |
a94d48 |
#ifndef CONNECTION_LIST_H__
|
|
Packit |
a94d48 |
#define CONNECTION_LIST_H__
|
|
Packit |
a94d48 |
|
|
Packit |
a94d48 |
#include <sys/select.h>
|
|
Packit |
a94d48 |
|
|
Packit |
a94d48 |
/*****************************************************************
|
|
Packit |
a94d48 |
* Connection List Public Members
|
|
Packit |
a94d48 |
*****************************************************************/
|
|
Packit |
a94d48 |
|
|
Packit |
a94d48 |
struct connection
|
|
Packit |
a94d48 |
{
|
|
Packit |
a94d48 |
/* file descriptor */
|
|
Packit |
a94d48 |
int fd;
|
|
Packit |
a94d48 |
|
|
Packit |
a94d48 |
/* process incoming data on the connection */
|
|
Packit |
a94d48 |
void (* process)(int fd);
|
|
Packit |
a94d48 |
};
|
|
Packit |
a94d48 |
|
|
Packit |
a94d48 |
/* add a connection to the list */
|
|
Packit |
a94d48 |
extern void add_connection(struct connection *p);
|
|
Packit |
a94d48 |
|
|
Packit |
a94d48 |
/* find a connection in the list by file descriptor */
|
|
Packit |
a94d48 |
extern struct connection *find_connection(int fd);
|
|
Packit |
a94d48 |
|
|
Packit |
a94d48 |
/* get the number of connections in the list */
|
|
Packit |
a94d48 |
extern int get_number_of_connections(void);
|
|
Packit |
a94d48 |
|
|
Packit |
a94d48 |
/* get a specific connection by index from the list */
|
|
Packit |
a94d48 |
extern struct connection *get_connection(int i);
|
|
Packit |
a94d48 |
|
|
Packit |
a94d48 |
/* get an fd_set with all the fd's that have been added to the list */
|
|
Packit |
a94d48 |
extern const fd_set *get_fdset(void);
|
|
Packit |
a94d48 |
|
|
Packit |
a94d48 |
/* get the highest fd that was added to the list */
|
|
Packit |
a94d48 |
extern int get_highestfd(void);
|
|
Packit |
a94d48 |
|
|
Packit |
402d07 |
/* delete all connections, closing the fds */
|
|
Packit |
402d07 |
extern void delete_all_connections(void);
|
|
Packit |
402d07 |
|
|
Packit |
a94d48 |
#endif /* CONNECTION_LIST_H__ */
|