/* This file is part of Lcrzo.
*/

int lcrzo_priv_wait_sniff_wait(lcrzo_sniff *psniff, 
                                   lcrzo_time *pmaxwaitingtime, 
                                   lcrzo_bool *pevent)
#if LCRZODEF_LIBPCAPINSTALLED==1
 #if defined LCRZODEF_SYSTEM_Unix
{ return(lcrzo_priv_wait_fd_wait(psniff->pcapfd, pmaxwaitingtime, pevent));
}
 #elif defined LCRZODEF_SYSTEM_Windows
{
 /* Always return true because pcap_getevent() doesn't work (always
     returns a NULL handle).
     Also, the reading function is set to non blocking thanks to a to_ms==0
     in pcap_open_live()
  */

  if (pevent!=NULL) *pevent=LCRZO_TRUE;
  return(LCRZO_ERR_OK);
  /* just for the compiler warning */
  pmaxwaitingtime=NULL;
  psniff=NULL;
#if 0
  /* pcap_getevent() always returns a NULL handle under NT
     Moreover, packet PacketSetMintoCopy is not implemented under Windows 95,
     so packets arrive grouped. */
  HANDLE h;
  DWORD err;
  lcrzo_uint32 msec;

  /* get the event handle */
  h=pcap_getevent(psniff->ppcapt);

  /* wait */
  lcrzo_er(lcrzo_priv_wait_winmsec_init_time(pmaxwaitingtime, &msec));
  err=WaitForSingleObject(h, msec);
  if ( err==WAIT_TIMEOUT )
  { if (pevent!=NULL) *pevent=LCRZO_FALSE;
  }
  else if ( err==WAIT_OBJECT_0 )
  { if (pevent!=NULL) *pevent=LCRZO_TRUE;
  }
  else
  { return(LCRZO_ERR_FUWAITFORSINGLEOBJECT);
  }
  return(LCRZO_ERR_OK);
#endif
}
 #else
  #error "Unknown value for LCRZODEF_SYSTEM"
 #endif
#else
{ return (LCRZO_ERR_IEUNIMPLEMENTED);
  /* just for the compiler warning */
  psniff=psniff;
  pmaxwaitingtime=pmaxwaitingtime;
  pevent=pevent;
}
#endif

