action_t* special_effect_t::create_action() const { // Custom actions have done their create_proc_action() call in the second phase init of the // special effect if ( action_type() != SPECIAL_EFFECT_ACTION_CUSTOM && action_type() != SPECIAL_EFFECT_ACTION_NONE ) { if ( action_t* a = player -> create_proc_action( name(), *this ) ) { return a; } } switch ( action_type() ) { case SPECIAL_EFFECT_ACTION_CUSTOM: return execute_action; case SPECIAL_EFFECT_ACTION_SPELL: return initialize_offensive_spell_action(); case SPECIAL_EFFECT_ACTION_HEAL: return initialize_heal_action(); case SPECIAL_EFFECT_ACTION_ATTACK: return initialize_attack_action(); case SPECIAL_EFFECT_ACTION_RESOURCE: return initialize_resource_action(); default: return nullptr; } }
/* 'extract' extracts some mime part from a message */ static MuError cmd_extract (ServerContext *ctx, GHashTable *args, GError **err) { MuMsg *msg; int docid, index, action; MuError rv; MuMsgOptions opts; const char* actionstr, *indexstr; opts = get_encrypted_msg_opts (args); rv = MU_ERROR; /* read parameters */ GET_STRING_OR_ERROR_RETURN (args, "action", &actionstr, err); GET_STRING_OR_ERROR_RETURN (args, "index", &indexstr, err); index = atoi (indexstr); docid = determine_docid (ctx->query, args, err); if (docid == MU_STORE_INVALID_DOCID) { print_and_clear_g_error (err); return MU_OK; } if ((action = action_type (actionstr)) == INVALID_ACTION) { print_error (MU_ERROR_IN_PARAMETERS, "invalid action"); return MU_OK; } msg = mu_store_get_msg (ctx->store, docid, err); if (!msg) { print_error (MU_ERROR, "failed to get message"); return MU_OK; } switch (action) { case SAVE: rv = save_part (msg, docid, index, opts, args, err); break; case OPEN: rv = open_part (msg, docid, index, opts, err); break; case TEMP: rv = temp_part (msg, docid, index, opts, args, err); break; default: print_error (MU_ERROR_INTERNAL, "unknown action"); } if (rv != MU_OK) print_and_clear_g_error (err); mu_msg_unref (msg); return MU_OK; }
bool nas_acl_action_t::operator!= (const nas_acl_action_t& rhs) const { if (action_type() != rhs.action_type()) return true; switch (_a_info.values_type) { case NDI_ACL_ACTION_PORT: if (_ifindex_list != rhs._ifindex_list) { return true; } break; case NDI_ACL_ACTION_OBJ_ID: if (_nas_oid != rhs._nas_oid) { return true; } /* Intentional Fall through */ case NDI_ACL_ACTION_OBJ_ID_LIST: if (_nas2ndi_oid_tbl != rhs._nas2ndi_oid_tbl) { NAS_ACL_LOG_DETAIL ("NAS to NDI OID Table modified for action %s", name()); return true; } break; case NDI_ACL_ACTION_NO_VALUE: break; default: if (memcmp (&_a_info, &rhs._a_info, sizeof(_a_info))) return true; break; } return false; }
void nas_acl_action_t::dbg_dump () const { NAS_ACL_LOG_DUMP ("Action: %s", name ()); switch (_a_info.values_type) { case NDI_ACL_ACTION_NO_VALUE: break; case NDI_ACL_ACTION_PKT_ACTION: NAS_ACL_LOG_DUMP (" Pkt action = %s", _get_pkt_action_name(_a_info.pkt_action)); break; case NDI_ACL_ACTION_PORT: case NDI_ACL_ACTION_PORTLIST: NAS_ACL_LOG_DUMP (" Port = "); for (auto ifindex: _ifindex_list) { NAS_ACL_LOG_DUMP ("%d, ", ifindex); } NAS_ACL_LOG_DUMP (""); break; case NDI_ACL_ACTION_U32: NAS_ACL_LOG_DUMP (" U32 = %d",_a_info.values.u32); break; case NDI_ACL_ACTION_U16: NAS_ACL_LOG_DUMP (" U16 = %d",_a_info.values.u16); break; case NDI_ACL_ACTION_U8: NAS_ACL_LOG_DUMP (" U8 = %d",_a_info.values.u8); break; case NDI_ACL_ACTION_OBJ_ID: if (is_counter ()) { NAS_ACL_LOG_DUMP (" counter id = %ld", counter_id()); break; } else if (action_type() == BASE_ACL_ACTION_TYPE_REDIRECT_PORT) { NAS_ACL_LOG_DUMP (" Port = "); for (auto ifindex: _ifindex_list) { NAS_ACL_LOG_DUMP ("%d, ", ifindex); } NAS_ACL_LOG_DUMP (""); } else { for (auto nas2ndi_oid_pair: _nas2ndi_oid_tbl) { NAS_ACL_LOG_DUMP (" nas external obj id ref = %ld",nas2ndi_oid_pair.first); } } for (auto nas2ndi_oid_pair: _nas2ndi_oid_tbl) { auto& ndi_oid_tbl = nas2ndi_oid_pair.second; NAS_ACL_LOG_DUMP (" External NDI obj IDs (blob): count = %ld ", ndi_oid_tbl.size()); for (auto& npu2ndi_oid_pair: ndi_oid_tbl) { NAS_ACL_LOG_DUMP ("(NPU %d, %ld) ", npu2ndi_oid_pair.first, npu2ndi_oid_pair.second ); } } NAS_ACL_LOG_DUMP (""); break; case NDI_ACL_ACTION_MAC_ADDR: NAS_ACL_LOG_DUMP (" mac_match = %0x:%0x:%0x:%0x:%0x:%0x ", _a_info.values.mac[0], _a_info.values.mac[1], _a_info.values.mac[2], _a_info.values.mac[3], _a_info.values.mac[4], _a_info.values.mac[5]); break; case NDI_ACL_ACTION_IPV4_ADDR: { char buff [INET_ADDRSTRLEN]; NAS_ACL_LOG_DUMP (" ipv4 address = %s", inet_ntop (AF_INET, &_a_info.values.ipv4, buff, sizeof (buff))); } break; case NDI_ACL_ACTION_IPV6_ADDR: { char buff [INET6_ADDRSTRLEN]; NAS_ACL_LOG_DUMP (" ipv6 address = %s", inet_ntop (AF_INET6, &_a_info.values.ipv6, buff, sizeof (buff))); } break; default: break; } }