Blame kacpimon/connection_list.h.kacpimon-dynamic-connections

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