static void find_domain_ep_from_query(coap_pdu_t *pdu, std::string &domain, std::string &ep) { std::string domain_key = "d"; std::string ep_key = "ep"; query_value(pdu, domain_key, domain); query_value(pdu, ep_key, ep); }
/* * Queries a registry value's type and data for a given HKEY. * * TLVs: * * req: TLV_TYPE_HKEY - The HKEY to query the value on * req: TLV_TYPE_VALUE_NAME - The name of the value to query */ DWORD request_registry_query_value(Remote *remote, Packet *packet) { HKEY hkey = (HKEY)packet_get_tlv_value_qword(packet, TLV_TYPE_HKEY); query_value(remote, packet, hkey); return ERROR_SUCCESS; }
void CoAPWrapper::get_query_value(CoAPCallback &callback, std::string key, std::string &value) { coap_pdu_t *pdu = (coap_pdu_t*)(callback.request_); if ( pdu != 0) query_value(pdu, key, value); }
/* * Queries a registry value's type and data for a given HKEY. * * TLVs: * * req: TLV_TYPE_ROOT_KEY - The root key * req: TLV_TYPE_BASE_KEY - The base key * opt: TLV_TYPE_PERMISSION - Permissions with which to open the key * req: TLV_TYPE_VALUE_NAME - The name of the value to query */ DWORD request_registry_query_value_direct(Remote *remote, Packet *packet) { HKEY rootkey, hkey = NULL; open_key(packet, &rootkey, &hkey); query_value(remote, packet, hkey); if (hkey) RegCloseKey(hkey); return ERROR_SUCCESS; }
static BOOL read_registry_settings(DEVMODEW *dm) { char wine_x11_reg_key[128]; HKEY hkey; DWORD type, size; BOOL ret = TRUE; dm->dmFields = 0; if (!get_display_device_reg_key(wine_x11_reg_key, sizeof(wine_x11_reg_key))) return FALSE; if (RegOpenKeyExA(HKEY_CURRENT_CONFIG, wine_x11_reg_key, 0, KEY_READ, &hkey)) return FALSE; #define query_value(name, data) \ size = sizeof(DWORD); \ if (RegQueryValueExA(hkey, name, 0, &type, (LPBYTE)(data), &size) || \ type != REG_DWORD || size != sizeof(DWORD)) \ ret = FALSE query_value("DefaultSettings.BitsPerPel", &dm->dmBitsPerPel); dm->dmFields |= DM_BITSPERPEL; query_value("DefaultSettings.XResolution", &dm->dmPelsWidth); dm->dmFields |= DM_PELSWIDTH; query_value("DefaultSettings.YResolution", &dm->dmPelsHeight); dm->dmFields |= DM_PELSHEIGHT; query_value("DefaultSettings.VRefresh", &dm->dmDisplayFrequency); dm->dmFields |= DM_DISPLAYFREQUENCY; query_value("DefaultSettings.Flags", &dm->u2.dmDisplayFlags); dm->dmFields |= DM_DISPLAYFLAGS; query_value("DefaultSettings.XPanning", &dm->u1.s2.dmPosition.x); query_value("DefaultSettings.YPanning", &dm->u1.s2.dmPosition.y); query_value("DefaultSettings.Orientation", &dm->u1.s2.dmDisplayOrientation); query_value("DefaultSettings.FixedOutput", &dm->u1.s2.dmDisplayFixedOutput); #undef query_value RegCloseKey(hkey); return ret; }
void CoAPWrapper::get_query_value(CoAPCallback &callback, std::string key, int &value) { std::string tmp; coap_pdu_t *pdu = (coap_pdu_t*)(callback.request_); if ( pdu != 0) query_value(pdu, key, tmp); if( !tmp.empty()) { value = ACE_OS::atoi(tmp.c_str()); } }
bool has_key(const std::string& key) const { return !query_value(key).is_null(); }
INT4 init_hbase_client() { JNIEnv *jni_env = (JNIEnv *)NULL; jclass cls = 0; JavaVMInitArgs vm_args; JavaVMOption options[1]; jmethodID mid = 0; INT1 value[TABLE_STRING_LEN] = {0}; INT1 *conf_value = NULL; conf_value = get_value(g_controller_configure, "[controller]", "hbase_ip"); NULL == conf_value ? strncpy(g_hbase_ip, "127.0.0.1", 16 - 1) : strncpy(g_hbase_ip, conf_value, 300 - 1); conf_value = get_value(g_controller_configure, "[controller]", "hbase_port"); NULL == conf_value ? strncpy(g_hbase_port, "60000", 6 - 1) : strncpy(g_hbase_port, conf_value, 300 - 1); // int jarCount = 0; // struct dirent **jar_files; // char option_str[10240] = {0}; // strcat(option_str, "-Djava.class.path="); // strcat(option_str, g_hbase_client_file_path); // if ((jarCount = scandir(g_hbase_lib_path, &jar_files, filter_jar, alphasort)) > 0) // { // while (jarCount--) // { // strcat(option_str, ":"); // strcat(option_str, g_hbase_lib_path); // strcat(option_str, "/"); // strcat(option_str, jar_files[jarCount]->d_name); // // free(jar_files[jarCount]); // } // // free(jar_files); // } // else // { // printf("No libs found in the given hbase lib path."); // } // // options[0].optionString = option_str; // printf("Option string: %s\n", option_str); options[0].optionString = "-Djava.class.path=../hbase/hbase_client.jar:../hbase/hbase_lib.jar"; vm_args.version = JNI_VERSION_1_6; vm_args.nOptions = 1; vm_args.options = options; //Create java vm if(JNI_CreateJavaVM(&g_jvm, (void **)&jni_env, &vm_args) != JNI_OK) { LOG_PROC("ERROR", "Create JVM failed"); return GN_ERR; } //Find class "hbase_client" cls = (*jni_env)->FindClass(jni_env, "hbase_client"); g_hbase_client = (jclass)((*jni_env)->NewGlobalRef(jni_env, cls)); if(0 == g_hbase_client) { LOG_PROC("ERROR", "Jni can not find class named \"hbase_client\""); return GN_ERR; } //Init env conf mid = (*jni_env)->GetStaticMethodID(jni_env, g_hbase_client, "Init_conf", "(Ljava/lang/String;Ljava/lang/String;)V"); if(0 != mid) { jstring arg_ip = (*jni_env)->NewStringUTF(jni_env, g_hbase_ip); jstring arg_port = (*jni_env)->NewStringUTF(jni_env, g_hbase_port); (*jni_env)->CallStaticObjectMethod(jni_env, g_hbase_client, mid, arg_ip, arg_port); } else { LOG_PROC("ERROR", "Call method \"Init_conf\" failed"); return GN_ERR; } //Get method: add record mid = (*jni_env)->GetStaticMethodID(jni_env, g_hbase_client, "addRecord", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V"); if(0 == mid) { LOG_PROC("ERROR", "Jni can not find method named \"addRecord\""); return GN_ERR; } g_method_addrecord = (jmethodID)((*jni_env)->NewGlobalRef(jni_env, (jobject)mid)); //Get method: delete records by row key mid = (*jni_env)->GetStaticMethodID(jni_env, g_hbase_client, "deleteRecord", "(Ljava/lang/String;Ljava/lang/String;)V"); if(0 == mid) { LOG_PROC("ERROR", "Jni can not find method named \"deleteRecord\""); return GN_ERR; } g_method_deleterecord = (jmethodID)((*jni_env)->NewGlobalRef(jni_env, (jobject)mid)); //Get method: get records by filter mid = (*jni_env)->GetStaticMethodID(jni_env, g_hbase_client, "getRecordsByFilter", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)[Ljava/lang/String;"); if(0 == mid) { LOG_PROC("ERROR", "Jni can not find method named \"getRecordsByFilter\""); return GN_ERR; } g_method_getrecordsbyfilter = (jmethodID)((*jni_env)->NewGlobalRef(jni_env, (jobject)mid)); //Get method: get all records mid = (*jni_env)->GetStaticMethodID(jni_env, g_hbase_client, "getAllRecords", "(Ljava/lang/String;Ljava/lang/String;)[Ljava/lang/String;"); if(0 == mid) { LOG_PROC("ERROR", "Jni can not find method named \"getAllRecords\""); return GN_ERR; } g_method_getallrecords = (jmethodID)((*jni_env)->NewGlobalRef(jni_env, (jobject)mid)); //Get method: get one record mid = (*jni_env)->GetStaticMethodID(jni_env, g_hbase_client, "getOneRecord", "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;"); if(0 == mid) { LOG_PROC("ERROR", "Jni can not find method named \"getOneRecord\""); return GN_ERR; } g_method_getonerecord = (jmethodID)((*jni_env)->NewGlobalRef(jni_env, (jobject)mid)); //Get the latest version of topology query_value(TOPO_VER, value); g_topology_version = atoi(value); LOG_PROC("INFO", "Topology version: %d", g_topology_version); //Get the latest master of topology query_value(MASTER_ID, value); g_master_id = strtoul(value, 0, 10); LOG_PROC("INFO", "User specified master is: %llu", g_master_id); return GN_OK; }
T const* query(std::string const& query) { return dynamic_cast<T const*>(query_value(query)); }