/* This file is part of Lcrzo.
*/

int lcrzo_close(void)
{
  /* ignore double close */
  if (!lcrzo_priv_lcrzowasinitialized)
  { return(LCRZO_ERR_OK);
  }
  lcrzo_priv_lcrzowasinitialized=LCRZO_FALSE;

#if defined LCRZODEF_SYSTEM_Unix
#elif defined LCRZODEF_SYSTEM_Windows
  lcrzo_er(lcrzo_priv_winsock_close());
#else
 #error "Unknown value for LCRZODEF_SYSTEM"
#endif
  lcrzo_er(lcrzo_priv_globalvars_close());

#if defined LCRZODEF_SYSTEM_Unix
  lcrzo_priv_childprocesses_killall();
#elif defined LCRZODEF_SYSTEM_Windows
  lcrzo_er(lcrzo_priv_criticalsection_close());
  lcrzo_er(lcrzo_priv_close_tlsalloc());
#else
 #error "Unknown value for LCRZODEF_SYSTEM"
#endif
  
  return(LCRZO_ERR_OK);
}

