#ifndef JB_SOCKET_SET_H_INCLUDED
#define JB_SOCKET_SET_H_INCLUDED
#define JB_SOCKET_SET_H_VERSION "$Id: jb_socket_set.h,v 1.1 2003/05/23 17:02:20 lionel Exp $"
/*********************************************************************
 *
 * File        :  $Source: /ds6/cvs/privoxy/src/jb_socket_set.h,v $
 *
 * Purpose     :  Declares functions to handle sets of sockets
 *
 * Copyright   :  Written by and Copyright (C) 2002 Lionel Elie Mamane
 *                <lionel@mamane.lu>
 *
 *                This program is free software; you can redistribute it
 *                and/or modify it under the terms of the GNU General
 *                Public License as published by the Free Software
 *                Foundation; either version 2 of the License, or (at
 *                your option) any later version.
 *
 *                This program is distributed in the hope that it will
 *                be useful, but WITHOUT ANY WARRANTY; without even the
 *                implied warranty of MERCHANTABILITY or FITNESS FOR A
 *                PARTICULAR PURPOSE.  See the GNU General Public
 *                License for more details.
 *
 *                The GNU General Public License should be included with
 *                this file.  If not, you can view it at
 *                http://www.gnu.org/copyleft/gpl.html
 *                or write to the Free Software Foundation, Inc., 59
 *                Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * Revisions   :
 *    $Log: jb_socket_set.h,v $
 *    Revision 1.1  2003/05/23 17:02:20  lionel
 *    Socket set implementation
 *
 *
 *********************************************************************/
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
#include "project.h"

struct jb_socket_set_struct
{
   unsigned int size; /* size allocated*/
   unsigned int occupied; /* size occupied - 1 == index of final JB_INVALID_SOCKET
                             == number of sockets in the set */
   jb_socket *data; /* Array containing the sockets, JB_INVALID_SOCKET-terminated */
};

typedef struct jb_socket_set_struct jb_socket_set;
typedef const jb_socket* jb_socket_set_iterate_state;

void init_jb_socket_set(jb_socket_set*);

jb_socket_set_iterate_state jb_socket_set_iteration_begin(jb_socket_set *);
jb_socket jb_socket_set_iteration_next(jb_socket_set_iterate_state*);

int jb_socket_set_add(jb_socket_set*, jb_socket);

void destroy_jb_socket_set(jb_socket_set *l);
int is_empty_jb_socket_set(jb_socket_set *l);

#define freez_jb_socket_set(X)  { if(X) { destroy_jb_socket_set(X); X = NULL ; } }

int jb_select(jb_socket_set *readfds, jb_socket_set *writefds, jb_socket_set *exceptfds, struct timeval *timeout);

#endif /* ndef JB_SOCKET_SET_H_INCLUDED */

/*
  Local Variables:
  tab-width: 3
  c-file-style: "stroustrup"
  c-basic-offset: 3
  indent-tabs-mode: nil
  end:
*/
