/* -TAG:LICENSE-

   This file is under the DigitalSpark Freeware Class License, see the
   file LICENSE for complete licensing information.

                                                         -TAG:LICENSE- */

#define IN_CB
#include <Threading.h>
#include <Strings.h>
#include "tricky.h"

extern  size_t	Write( int slot, void *data, size_t size );
extern	int	cBusRemove( int Sock );

/* Sends data to all authorized clients on the bus */

int	cBusBroadcast( char *data, int size )
{
int i=0;

while ( i <= MAX_CLIENTS )
   {
   if ( Client[i].State == CS_USED )
      {
      if ( Client[i].Authorized == 1 )
         if ( Write(Client[i].Sock,data,size) == -1 )
            {
            cBusRemove(Client[i].Sock);
            }
      }
   i++;
   }

return 0;
}
