Blame kacpimon/connection_list.h

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