apdu_shutdown_reader (int slot)
{
  int sw;

  if (DBG_READER)
    log_debug ("enter: apdu_shutdown_reader: slot=%d\n", slot);

  if (slot < 0 || slot >= MAX_READER || !reader_table[slot].used )
    {
      if (DBG_READER)
        log_debug ("leave: apdu_shutdown_reader => SW_HOST_NO_DRIVER\n");
      return SW_HOST_NO_DRIVER;
    }
  sw = apdu_disconnect (slot);
  if (sw)
    {
      if (DBG_READER)
        log_debug ("leave: apdu_shutdown_reader => 0x%x (apdu_disconnect)\n",
                   sw);
      return sw;
    }
  if (reader_table[slot].shutdown_reader)
    {
      sw = reader_table[slot].shutdown_reader (slot);
      if (DBG_READER)
        log_debug ("leave: apdu_shutdown_reader => 0x%x (close_reader)\n", sw);
      return sw;
    }
  if (DBG_READER)
    log_debug ("leave: apdu_shutdown_reader => SW_HOST_NOT_SUPPORTED\n");
  return SW_HOST_NOT_SUPPORTED;
}
apdu_shutdown_reader (int slot)
{
  int sw;

  if (DBG_READER)
    log_debug ("enter: apdu_shutdown_reader: slot=%d\n", slot);

  if (slot < 0 || slot >= MAX_READER || !reader_table[slot].used )
    {
      if (DBG_READER)
        log_debug ("leave: apdu_shutdown_reader => SW_HOST_NO_DRIVER\n");
      return SW_HOST_NO_DRIVER;
    }
  sw = apdu_disconnect (slot);
  if (sw)
    {
      if (DBG_READER)
        log_debug ("leave: apdu_shutdown_reader => 0x%x (apdu_disconnect)\n",
                   sw);
      return sw;
    }
  if (reader_table[slot].shutdown_reader)
    {
      sw = reader_table[slot].shutdown_reader (slot);
      if (DBG_READER)
        log_debug ("leave: apdu_shutdown_reader => 0x%x (close_reader)\n", sw);
      return sw;
    }
  if (DBG_READER)
    log_debug ("leave: apdu_shutdown_reader => SW_HOST_NOT_SUPPORTED\n");
  return SW_HOST_NOT_SUPPORTED;
}