|
Packit Service |
26469c |
/*
|
|
Packit Service |
26469c |
* connection_list.h - ACPI daemon 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 |
/* ??? suggest passing a pointer to this connection struct */
|
|
Packit Service |
26469c |
void (* process)(int fd);
|
|
Packit Service |
26469c |
|
|
Packit Service |
26469c |
/* Optional. Used by find_connection_name() to find the connection for a
|
|
Packit Service |
26469c |
specific file. Set to NULL if not specified. Memory will be freed
|
|
Packit Service |
26469c |
with free() when connection is deleted. */
|
|
Packit Service |
26469c |
char *pathname;
|
|
Packit Service |
26469c |
|
|
Packit Service |
26469c |
/* 0 indicates this is probably not a keyboard device */
|
|
Packit Service |
26469c |
int kybd;
|
|
Packit Service |
26469c |
};
|
|
Packit Service |
26469c |
|
|
Packit Service |
26469c |
/* add a connection to the list */
|
|
Packit Service |
26469c |
extern int add_connection(struct connection *p);
|
|
Packit Service |
26469c |
|
|
Packit Service |
26469c |
/* delete a connection from the list */
|
|
Packit Service |
26469c |
extern void delete_connection(int fd);
|
|
Packit Service |
26469c |
|
|
Packit Service |
26469c |
/* find a connection in the list by file descriptor */
|
|
Packit Service |
26469c |
/* ??? This routine is unnecessary. When we call the connection's process
|
|
Packit Service |
26469c |
* routine, we should pass a pointer to the connection. That will have
|
|
Packit Service |
26469c |
* the usual fd along with everything else. */
|
|
Packit Service |
26469c |
extern struct connection *find_connection(int fd);
|
|
Packit Service |
26469c |
|
|
Packit Service |
26469c |
/* find a connection in the list by pathname */
|
|
Packit Service |
26469c |
/* ??? unused last I checked */
|
|
Packit Service |
26469c |
extern struct connection *find_connection_name(char *pathname);
|
|
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 |
/* delete all connections, closing the fds */
|
|
Packit Service |
26469c |
extern void delete_all_connections(void);
|
|
Packit Service |
26469c |
|
|
Packit Service |
26469c |
#endif /* CONNECTION_LIST_H__ */
|