wxString
DlgRuleEditorListProperty::examineContextFilterPolicy(
    ContextFilterPolicy *filter) const
{
	wxString	 text;
	PolicyRuleSet	*ruleSet;

	ruleSet = filter->getParentRuleSet();

	switch (type_) {
	case PROPERTY_ID:
		EXTRACT_ID(text, filter);
		break;
	case PROPERTY_TYPE:
		text = filter->getContextTypeName();
		if (ruleSet && ruleSet->isAdmin()) {
			text.Append(wxT("(A)"));
		}
		break;
	case PROPERTY_SCOPE:
		text = filter->getScopeName();
		break;
	case PROPERTY_BINARY:
		text = filter->getBinaryName();
		break;
	default:
		text = wxEmptyString;
		break;
	}

	return (text);
}
wxString
DlgRuleEditorListProperty::examineDefaultFilterPolicy(
    DefaultFilterPolicy *filter) const
{
	wxString	 text;
	PolicyRuleSet	*ruleSet;

	ruleSet = filter->getParentRuleSet();

	switch (type_) {
	case PROPERTY_ID:
		EXTRACT_ID(text, filter);
		break;
	case PROPERTY_TYPE:
		EXTRACT_TYPE(text, ruleSet, filter);
		break;
	case PROPERTY_SCOPE:
		text = filter->getScopeName();
		break;
	case PROPERTY_ACTION:
		text = filter->getActionName();
		break;
	case PROPERTY_LOG:
		text = filter->getLogName();
		break;
	default:
		text = wxEmptyString;
		break;
	}

	return (text);
}
uint8_t
Filesystem_CloseDir(UID fd)
{
    if(!initialized)return -1;
    FileDescriptor *desc = (FileDescriptor*)Filesystem_FindDescriptorFromUID(fd);
    uint8_t result = desc->driver->_H_Filesystem_CloseDir(desc, EXTRACT_ID(fd));
    return result;
}
uint8_t
Filesystem_ReadDir(UID dd,
                   Filesystem_DirEntry *dir)
{
    if(!initialized)return -1;
    FileDescriptor *desc = (FileDescriptor*)Filesystem_FindDescriptorFromUID(dd);
    uint8_t result = desc->driver->_H_Filesystem_ReadDir(desc, EXTRACT_ID(dd), dir);
    return result;
}
static int
mn103int_ioctl(struct hw *me,
	       hw_ioctl_request request,
	       va_list ap)
{
  struct mn103int *controller = (struct mn103int *)hw_data(me);
  controller->group[0].request = EXTRACT_ID(4);
  mn103int_port_event(me, 2 /* nmi_port(syserr) */, NULL, 0, 0);
  return 0;
}
uint64_t
Filesystem_SeekFile(UID fd,
                    uint64_t offset,
                    int whence)
{
    if(!initialized)return -1;
    FileDescriptor *desc = (FileDescriptor*)Filesystem_FindDescriptorFromUID(fd);
    uint64_t result = desc->driver->_H_Filesystem_SeekFile(desc, EXTRACT_ID(fd), offset, whence);
    return result;
}
uint64_t
Filesystem_ReadFile(UID id,
                    uint8_t *buffer,
                    size_t size)
{
    if(!initialized)return -1;
    FileDescriptor *desc = (FileDescriptor*)Filesystem_FindDescriptorFromUID(id);
    uint64_t result = desc->driver->_H_Filesystem_ReadFile(desc, EXTRACT_ID(id), buffer, size);
    return result;
}
wxString
DlgRuleEditorListProperty::examineAppPolicy(AppPolicy *app) const
{
	wxString	 text;
	PolicyRuleSet	*ruleSet;

	ruleSet = app->getParentRuleSet();

	switch (type_) {
	case PROPERTY_ID:
		EXTRACT_ID(text, app);
		break;
	case PROPERTY_TYPE:
		EXTRACT_TYPE(text, ruleSet, app);
		break;
	case PROPERTY_USER:
		if (ruleSet && (ruleSet->getUid() != (uid_t)-1)) {
			text = MainUtils::instance()->getUserNameById(
			    ruleSet->getUid());
		} else {
			text = wxT("default");
		}
		break;
	case PROPERTY_DETAILS:
		text = wxEmptyString;
		if (app->getFlag(APN_RULE_NOSFS)) {
			text = wxT("nosfs");
		}
		if (app->getFlag(APN_RULE_PGFORCE)) {
			if (!text.IsEmpty()) {
				text.Append(wxT(", "));
			}
			text.Append(wxT("pgforce"));
		}
		if (app->getFlag(APN_RULE_PGONLY)) {
			if (!text.IsEmpty()) {
				text.Append(wxT(", "));
			}
			text.Append(wxT("pgonly"));
		}
		break;
	case PROPERTY_BINARY:
		text = app->getBinaryName();
		break;
	default:
		text = wxEmptyString;
		break;
	}

	return (text);
}
wxString
DlgRuleEditorListProperty::examineSfsFilterPolicy(
    SfsFilterPolicy *filter) const
{
	wxString	 text;
	PolicyRuleSet	*ruleSet;

	ruleSet = filter->getParentRuleSet();

	switch (type_) {
	case PROPERTY_ID:
		EXTRACT_ID(text, filter);
		break;
	case PROPERTY_TYPE:
		EXTRACT_TYPE(text, ruleSet, filter);
		break;
	case PROPERTY_SCOPE:
		text = filter->getScopeName();
		break;
	case PROPERTY_PATH:
		text = filter->getPath();
		break;
	case PROPERTY_SUB:
		text = filter->getSubjectName();
		break;
	case PROPERTY_VALACT:
		text = filter->getValidActionName();
		break;
	case PROPERTY_VALLOG:
		text = filter->getValidLogName();
		break;
	case PROPERTY_INVALACT:
		text = filter->getInvalidActionName();
		break;
	case PROPERTY_INVALLOG:
		text = filter->getInvalidLogName();
		break;
	case PROPERTY_UNKACT:
		text = filter->getUnknownActionName();
		break;
	case PROPERTY_UNKLOG:
		text = filter->getUnknownLogName();
		break;
	default:
		text = wxEmptyString;
		break;
	}

	return (text);
}
wxString
DlgRuleEditorListProperty::examineAlfFilterPolicy(AlfFilterPolicy
    *filter) const
{
	wxString	 text;
	PolicyRuleSet	*ruleSet;

	ruleSet = filter->getParentRuleSet();

	switch (type_) {
	case PROPERTY_ID:
		EXTRACT_ID(text, filter);
		break;
	case PROPERTY_TYPE:
		EXTRACT_TYPE(text, ruleSet, filter);
		break;
	case PROPERTY_ACTION:
		text = filter->getActionName();
		break;
	case PROPERTY_LOG:
		text = filter->getLogName();
		break;
	case PROPERTY_SCOPE:
		text = filter->getScopeName();
		break;
	case PROPERTY_DIR:
		text = filter->getDirectionName();
		break;
	case PROPERTY_PROT:
		text = filter->getProtocolName();
		break;
	case PROPERTY_FHOST:
		text = filter->getFromHostName();
		break;
	case PROPERTY_FPORT:
		text = filter->getFromPortName();
		break;
	case PROPERTY_THOST:
		text = filter->getToHostName();
		break;
	case PROPERTY_TPORT:
		text = filter->getToPortName();
		break;
	default:
		text = wxEmptyString;
		break;
	}

		return (text);
}
static void
write_icr (struct hw *me,
	   struct mn103int *controller,
	   unsigned_word base,
	   unsigned8 val)
{
  unsigned_word offset;
  struct mn103int_group *group = decode_group (me, controller, base, &offset);
  switch (group->type)
    {

    case NMI_GROUP:
      switch (offset)
	{
	case 0:
	  HW_TRACE ((me, "write-icr group=%d:0 nmi 0x%02x",
		     group->gid, val));
	  group->request &= ~EXTRACT_ID (val);
	  break;
	  /* Special backdoor access to SYSEF flag from CPU.  See
             interp.c:program_interrupt(). */
	case 3:
	  HW_TRACE ((me, "write-icr-special group=%d:0 nmi 0x%02x",
		     group->gid, val));
	  group->request |= EXTRACT_ID (val);
	default:
	  break;
	}
      break;

    case LEVEL_GROUP:
      switch (offset)
	{
	case 0: /* request/detect */
	  /* Clear any ID bits and then set them according to IR */
	  HW_TRACE ((me, "write-icr group=%d:0 level 0x%02x %x:%x:%x",
		     group->gid, val,
		     group->request, EXTRACT_IR (val), EXTRACT_ID (val)));
	  group->request =
	    ((EXTRACT_IR (val) & EXTRACT_ID (val))
	     | (EXTRACT_IR (val) & group->request)
	     | (~EXTRACT_IR (val) & ~EXTRACT_ID (val) & group->request));
	  break;
	case 1: /* level/enable */
	  HW_TRACE ((me, "write-icr group=%d:1 level 0x%02x",
		     group->gid, val));
	  group->level = EXTRACT_LV (val);
	  group->enable = EXTRACT_IE (val);
	  break;
	default:
	  /* ignore */
	  break;
	}
      push_interrupt_level (me, controller);
      break;

    default:
      break;

    }
}