void Perceptron::doSetParams() { mLearningRatio = getParam("LearningRatio", 1.0); }
void L6470::Dump(void) { #ifndef NDEBUG uint8_t reg; printf("Registers:\n"); printf("01:ABS_POS - Current position: %ld\n", getPos()); printf("02:EL_POS - Electrical position: %ld\n", getParam(L6470_PARAM_EL_POS)); printf("03:MARK - Mark position: %ld\n", getMark()); printf("04:SPEED - Current speed: %ld (raw)\n", getParam(L6470_PARAM_SPEED)); printf("05:ACC - Acceleration: %.2f steps/s2\n", getAcc()); printf("06:DEC - Deceleration: %.2f steps/s2\n", getDec()); printf("07:MAX_SPEED - Maximum speed: %.2f steps/s\n", getMaxSpeed()); printf("08:MIN_SPEED - Minimum speed: %.2f steps/s\n", getMinSpeed()); printf("09:KVAL_HOLD - Holding KVAL: %d\n", (int) getHoldKVAL()); printf("0A:KVAL_RUN - Constant speed KVAL: %d\n", (int) getRunKVAL()); printf("0B:KVAL_ACC - Acceleration starting KVAL: %d\n", (int) getAccKVAL()); printf("0C:KVAL_Dec - Deceleration starting KVAL: %d\n", (int) getDecKVAL()); printf("0D:INT_SPEED - Intersect speed: 0x%.4X (raw)\n", (unsigned int) getParam(L6470_PARAM_INT_SPD)); reg = getParam(L6470_PARAM_ST_SLP); printf("0E:ST_SLP - Start slope: %.3f\%% s/step (0x%.2X)\n", (float) 100 * SlpCalcValueReg(reg), reg); reg = getParam(L6470_PARAM_FN_SLP_ACC); printf("0F:FN_SLP_ACC - Acceleration final slope: %.3f\%% s/step (0x%.2X)\n", (float) 100 * SlpCalcValueReg(reg), reg); reg = getParam(L6470_PARAM_FN_SLP_DEC); printf("10:FN_SLP_DEC - Deceleration final slope: %.3f\%% s/step (0x%.2X)\n", (float) 100 * SlpCalcValueReg(reg), reg); reg = getParam(L6470_PARAM_K_THERM); printf("11:K_THERM - Thermal compensation factor: %.3f (0x%.2X)\n", KThermCalcValueReg(reg), reg); reg = getParam(L6470_PARAM_ADC_OUT); printf("12:ADC_OUT - ADC output: 0x%.2X\n", reg & 0x1F); reg = getOCThreshold(); printf("13:OCD_TH - OCD threshold: %d mA (0x%.2X)\n", OcdThCalcValueReg(reg), reg); reg = getParam(L6470_PARAM_STALL_TH); printf("14:STALL_TH - STALL threshold: %d mA (0x%.2X)\n", StallThCalcValueReg(reg & 0x7F), reg); printf("15:FS_SPD - Full-step speed: %.2f steps/s\n", getFullSpeed()); printf("16:STEP_MODE - Step mode: %d microsteps\n", 1 << getStepMode()); printf("17:ALARM_EN - Alarm enable: 0x%.2X\n", (unsigned int) getParam(L6470_PARAM_ALARM_EN)); printf("18:CONFIG - IC configuration: 0x%.4X\n", (unsigned int) getParam(L6470_PARAM_CONFIG)); #endif }
int main(void) { //Redirect before initializing headers mysqlpp::Connection c(false); if (!c.connect("okzoniom", "localhost", "okzoniom", getDBIdent().c_str())) { cgi_redirect("./error.okz?state=err_db"); return 0; } else { //Set UTF8 mysqlpp::Query q = c.query("SET NAMES utf8"); q.exec(); } cgi_init(); cgi_session_save_path("sessions/"); cgi_session_start(); cgi_process_form(); std::string login = getParam("n"); cgi_init_headers(); header("sidebar_profil", ", "+login); menu(); sidebar(); std::cout << "<div class=\"body\"><div class=\"main\">"; initializeFaction(c); int id,faction, xp, level; mysqlpp::Query query = c.query("SELECT id,faction,xp,level FROM game_account where login = %0Q;"); query.parse(); mysqlpp::StoreQueryResult r = query.store(login); if (r && r.num_rows() > 0) { //Should only be one account with that name id = r[0]["id"]; //Will be used to get the number of units faction = r[0]["faction"]; xp = r[0]["xp"]; level = r[0]["level"]; std::cout << "<p>" << __tr("account") << ": <strong>" << login << "</strong><br />" << __tr("xp") << ": <strong>" << xp << "</strong><br />" << __tr("level") << ": <strong>" << level << "</strong><br />" << __tr("faction") << ": <strong>" << __tr(factionName[faction]) << "</strong>" "<div class=\"hr\"></div>" "<center><p><strong>" << __tr("army_composition") << ":</strong></p>"; //Now we have the account, get its units and their number query.reset(); query << "select unit_name,unit_number from game_unit_available where id_account = %0;"; query.parse(); mysqlpp::StoreQueryResult u = query.store(id); if (u && u.num_rows() > 0) { std::cout << "<table class=\"army\"><tr>" << "<td><strong>" << __tr("unit") << "</strong></td>" << "<td><strong>" << __tr("number") << "</strong></td></tr>"; for (size_t i = 0; i < u.num_rows(); ++i) { int num = u[i]["unit_number"]; if( num > 0) { std::string name; u[i]["unit_name"].to_string(name); std::cout << "<tr><td><strong>" << __tr(name) << "</strong></td>" << "<td><strong>" << num << "</strong></td></tr>"; } } std::cout << "</table></center>"; } else { std::cout << "<center><em>" << __tr("army_empty") << "</em></center>"; } std::cout << "</p>" << std::endl; } else { std::cout << "<p>" << __tr("player_notfound") << "</p>" << std::endl; } std::cout << "</div></div>"; footer(); return 0; }
static int mod_handler_execute(request_rec *r) { if (!config.secretKey) { if (config.debugLevel >= 1) { ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r->server, "No such secretKey set"); } return DECLINED; } if (!config.iv) { if (config.debugLevel >= 1) { ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r->server, "No such IV set"); } return DECLINED; } if (!config.algorithm) { if (config.debugLevel >= 1) { ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r->server, "No such algorithm set"); } return DECLINED; } if (!strcasecmp(config.algorithm, "aes") && !strcasecmp(config.algorithm, "desede")) { if (config.debugLevel >= 2) { ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r->server, "No such algorithm %s exists", config.algorithm); } return DECLINED; } apr_table_t*GET; ap_args_to_table(r, &GET); const char* tokenParam = config.tokenParam == 0 ? "token" : config.tokenParam; const char *token = getParam(GET, tokenParam, ""); size_t tokenLength = strlen((char*)token); if (tokenLength == 0) { if (config.debugLevel >= 2) { ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r->server, "No such token passed"); } return DECLINED; } const unsigned char* key = config.secretKey; const unsigned char* ivEncoded = config.iv; int ivEncodedLen = strlen((char*) config.iv); long keylength = strlen((char*) config.secretKey); unsigned char* ivDecoded = 0; int ivDecodedLen = 0; unsigned char* dataDecoded = 0; int dataDecodedLen = 0; cryptoc_data* deciphereddata = 0; if (config.debugLevel >= 3) { ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r->server, "Process started"); } deciphereddata = (cryptoc_data*) malloc(sizeof(cryptoc_data)); if (!deciphereddata) { if (config.debugLevel >= 2) { ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r->server, "Could not allocate memory for decrypt data"); } _free_crypto_data(deciphereddata, dataDecoded, ivDecoded); return DECLINED; } dataDecoded = (unsigned char*) malloc(sizeof(unsigned char) * tokenLength); if (!dataDecoded) { if (config.debugLevel >= 2) { ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r->server, "Could not allocate memory for decoded data"); } _free_crypto_data(deciphereddata, dataDecoded, ivDecoded); return DECLINED; } dataDecodedLen = cryptoc_base64_decode(token, tokenLength, dataDecoded); if (!dataDecodedLen || !dataDecoded) { if (config.debugLevel >= 2) { ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r->server, "Could not base64 decode data"); } _free_crypto_data(deciphereddata, dataDecoded, ivDecoded); return DECLINED; } if (config.debugLevel >= 3) { ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, 0, r->server, "Data decoded successfully"); } ivDecoded = (unsigned char*) malloc(sizeof(unsigned char) * strlen((const char*)ivEncoded)); if (!ivDecoded) { if (config.debugLevel >= 2) { ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r->server, "Could not allocate memory for IV"); } _free_crypto_data(deciphereddata, dataDecoded, ivDecoded); return DECLINED; } ivDecodedLen = cryptoc_base64_decode(ivEncoded, strlen((const char*)ivEncoded), ivDecoded); if (!ivDecodedLen || !ivDecoded) { if (config.debugLevel >= 2) { ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r->server, "Could not base64 decode IV"); } _free_crypto_data(deciphereddata, dataDecoded, ivDecoded); return DECLINED; } if (config.debugLevel >= 3) { ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, 0, r->server, "IV decoded successfully"); } *deciphereddata = cryptoc_decrypt_iv(CRYPTOC_DES_EDE3_CBC, key, keylength, ivDecoded, ivDecodedLen, dataDecoded, dataDecodedLen); if (!deciphereddata || deciphereddata->error) { if (deciphereddata) { if (config.debugLevel >= 2) { ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r->server, "Deciphering error: %s", deciphereddata->errorMessage); } } else { ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r->server, "Deciphering error: unknown error"); } _free_crypto_data(deciphereddata, dataDecoded, ivDecoded); return DECLINED; } if (config.debugLevel >= 3) { ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, 0, r->server, "Data decrypted successfully"); } unsigned char* finalData = 0; finalData = (unsigned char*) malloc(sizeof(unsigned char) * deciphereddata->length + 1); if (!finalData){ if (config.debugLevel >= 2) { ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r->server, "Could not allocate final data"); } return DECLINED; } strncpy(finalData, deciphereddata->data, deciphereddata->length); finalData[deciphereddata->length + 1] = '\0'; if (config.debugLevel >= 2) { ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, 0, r->server, "Final data copied successfully. Decrypted data: %s", finalData); } _free_crypto_data(deciphereddata, dataDecoded, ivDecoded); if (config.debugLevel >= 3) { ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r->server, "Process finished"); } return OK; }
Return<AudioHwSync> Device::getHwAvSync() { int halHwAvSync; Result retval = getParam(AudioParameter::keyHwAvSync, &halHwAvSync); return retval == Result::OK ? halHwAvSync : AUDIO_HW_SYNC_INVALID; }
void SmsPluginSetting::initConfigData(MSG_SIM_STATUS_T SimStatus) { MSG_BEGIN(); msg_error_t err = MSG_SUCCESS; // Init SMS Parameter int paramCnt = 0; int failCnt = 0; paramCnt = getParamCount(); MSG_DEBUG("Parameter Count [%d]", paramCnt); MSG_SMSC_DATA_S tmpSmscData = {}; MSG_SMSC_LIST_S tmpSmscList = {}; for (int index = 0; index < paramCnt; index++) { if (getParam(index, &tmpSmscData) == false) { failCnt++; continue; } memcpy(&(tmpSmscList.smscData[index]), &tmpSmscData, sizeof(MSG_SMSC_DATA_S)); MSG_DEBUG("pid[%d]", tmpSmscList.smscData[index].pid); MSG_DEBUG("val_period[%d]", tmpSmscList.smscData[index].valPeriod); MSG_DEBUG("name[%s]", tmpSmscList.smscData[index].name); MSG_DEBUG("ton[%d]", tmpSmscList.smscData[index].smscAddr.ton); MSG_DEBUG("npi[%d]", tmpSmscList.smscData[index].smscAddr.npi); MSG_DEBUG("address[%s]", tmpSmscList.smscData[index].smscAddr.address); } tmpSmscList.totalCnt = (paramCnt - failCnt); tmpSmscList.selected = selectedParam; if (paramCnt > 0) { err = addSMSCList(&tmpSmscList); if (err == MSG_SUCCESS) { MSG_DEBUG("######## Add SMSC List Success !!! #######"); } else { MSG_DEBUG("######## Add SMSC List Fail !!! return : %d #######", err); } } // Init CB Config if (SimStatus == MSG_SIM_STATUS_CHANGED) { MSG_DEBUG("simStatus == MSG_SIM_STATUS_CHANGED"); MSG_CBMSG_OPT_S cbMsgOpt = {}; if (getCbConfig(&cbMsgOpt) == true) { err = addCbOpt(&cbMsgOpt); if (err == MSG_SUCCESS) { MSG_DEBUG("######## Add CB Option Success !!! #######"); } else { MSG_DEBUG("######## Add CB Option Fail !!! return : %d #######", err); } } } else if (SimStatus == MSG_SIM_STATUS_NORMAL) { MSG_DEBUG("simStatus == MSG_SIM_STATUS_NORMAL"); // Set CB Data into SIM in case of same SIM MSG_SETTING_S cbSetting; cbSetting.type = MSG_CBMSG_OPT; getCbOpt(&cbSetting); setCbConfig(&(cbSetting.option.cbMsgOpt)); } MSG_END(); }
/* default constructor */ PointerDetectorFilter::PointerDetectorFilter ( MediaSet &mediaSet, std::shared_ptr<MediaPipeline> parent, const std::map<std::string, KmsMediaParam> ¶ms) : Filter (mediaSet, parent, g_KmsMediaPointerDetectorFilterType_constants.TYPE_NAME, params) { const KmsMediaParam *p; KmsMediaPointerDetectorWindowSet windowSet; element = gst_element_factory_make ("filterelement", NULL); g_object_set (element, "filter-factory", "pointerdetector", NULL); g_object_ref (element); gst_bin_add (GST_BIN (parent->pipeline), element); gst_element_sync_state_with_parent (element); GstBus *bus = gst_pipeline_get_bus (GST_PIPELINE (parent->pipeline) ); GstElement *pointerDetector; g_object_get (G_OBJECT (element), "filter", &pointerDetector, NULL); this->pointerDetector = pointerDetector; if (this->pointerDetector == NULL) { g_object_unref (bus); KmsMediaServerException except; createKmsMediaServerException (except, g_KmsMediaErrorCodes_constants.MEDIA_OBJECT_NOT_AVAILAIBLE, "Media Object not available"); throw except; } p = getParam (params, g_KmsMediaPointerDetectorFilterType_constants.CONSTRUCTOR_PARAMS_DATA_TYPE); if (p != NULL) { GstStructure *buttonsLayout; //there are data about windows unmarshalStruct (windowSet, p->data); /* set the window layout list */ buttonsLayout = gst_structure_new_empty ("windowsLayout"); for (auto it = windowSet.windows.begin(); it != windowSet.windows.end(); ++it) { KmsMediaPointerDetectorWindow windowInfo = *it; GstStructure *buttonsLayoutAux; buttonsLayoutAux = gst_structure_new ( windowInfo.id.c_str(), "upRightCornerX", G_TYPE_INT, windowInfo.topRightCornerX, "upRightCornerY", G_TYPE_INT, windowInfo.topRightCornerY, "width", G_TYPE_INT, windowInfo.width, "height", G_TYPE_INT, windowInfo.height, "id", G_TYPE_STRING, windowInfo.id.c_str(), NULL); gst_structure_set (buttonsLayout, windowInfo.id.c_str(), GST_TYPE_STRUCTURE, buttonsLayoutAux, NULL); gst_structure_free (buttonsLayoutAux); } g_object_set (G_OBJECT (this->pointerDetector), WINDOWS_LAYOUT, buttonsLayout, NULL); gst_structure_free (buttonsLayout); } windowSet.windows.clear(); bus_handler_id = g_signal_connect (bus, "message", G_CALLBACK (pointerDetector_receive_message), this); g_object_unref (bus); // There is no need to reference pointerdetector because its life cycle is the same as the filter life cycle g_object_unref (pointerDetector); }
char const * Sinful::getAlias() const { return getParam(ATTR_ALIAS); }
char const * Sinful::getPrivateAddr() const { return getParam("PrivAddr"); }
char const * Sinful::getCCBContact() const { return getParam(ATTR_CCBID); }
char const * Sinful::getSharedPortID() const { return getParam(ATTR_SOCK); }
void MLProcDebug::doParams() { mVerbose = getParam("verbose"); mParamsChanged = false; }
string LoginSocket::vkReq(string &data) { string viewer_id = getParam(data, "viewer_id"); string api_id = getParam(data, "api_id"); string auth_key = getParam(data, "auth_key"); string user_id = getParam(data, "user_id"); string referrer = getParam(data, "referrer"); string api_url = getParam(data, "api_url"); string secret = getParam(data, "secret"); string sid = getParam(data, "sid"); string lc_name = getParam(data, "lc_name"); string api_result = getParam(data, "api_result"); api_result = UrlDecodeString(api_result); string first_name = getJsonParamStr(api_result, "first_name"); string last_name = getJsonParamStr(api_result, "last_name"); string nickname = getJsonParamStr(api_result, "nickname"); int sex = atoi(getJsonParamInt(api_result, "sex").c_str()); string photo_medium = getJsonParamStr(api_result, "photo_medium"); if (viewer_id.empty() || api_id.empty() || _social_net[SocialNetDesc::VK].app_id != api_id) { traceerr("%s, trace req. data: %s", "Error wrong req parameters, Warning!Possible hacking attempt!", data.c_str()); return ""; } char hash[(MD5_DIGEST_LENGTH+2)*2] = {"\0"}; getMD5((char*)(api_id + string("_") + viewer_id + string("_") + _social_net[SocialNetDesc::VK].app_secret).c_str(), hash); string hash_str = string(hash); if (auth_key != hash_str) { traceerr("%s, trace req. auth_key: %s; local_hash: %s", "Error auth_key fail, Warning!Possible hacking attempt!", auth_key.c_str(), hash_str.c_str()); return ""; } uint32 vid = atoi(viewer_id.c_str()); shared_ptr<User> user = iStorage->getLocalUser(vid, SocialNetDesc::VK); if (user == shared_ptr<User>()) { traceerr("Error! Requested user not found!"); return ""; } user->set("first_name", Value(first_name, true)); user->set("last_name", Value(last_name, true)); user->set("nickname", Value(nickname, true)); user->set("avatar", Value(photo_medium, true)); user->set("sex", Value(sex, true)); //GENERATE NEADED FLASHVARS string iframe = _social_net[SocialNetDesc::VK].iframe; char flashvars[1024] = {'\0'}; snprintf(flashvars, 1024, "api_id: \"%s\",viewer_id: \"%s\",user_id: \"%s\", referrer: \"%s\", api_url: \"%s\", secret: \"%s\", sid: \"%s\", lc_name:\ \"%s\"", api_id.c_str(), viewer_id.c_str(), user_id.c_str(), referrer.c_str(), api_url.c_str(), secret.c_str(), sid.c_str(), lc_name.c_str()); string::size_type pos = iframe.find("var flashvars = {"); if (pos == string::npos) { traceerr("%s", "Error: wrong VK template!"); return ""; } iframe.insert(pos+17, flashvars); return iframe; }
char SpiDrv::readChar() { uint8_t readChar = 0; getParam(&readChar); return readChar; }
bool RIN2CGGTTS::read(string paramsFile) { DBGMSG(debugStream,1,"reading" << paramsFile); ifstream fin(paramsFile.c_str()); string line; if (!fin.good()){ DBGMSG(debugStream,1,"unable to open" << paramsFile); return false; } bool ok =true; while (!fin.eof()){ // This file should be strictly formatted but the keywords // may be in arbitrary order getline(fin,line); Utility::trim(line); ok = ok && getParam(fin,line,"REV DATE",revDate); ok = ok && getParam(fin,line,"RCVR",rcvr); ok = ok && getParam(fin,line,"CH",&ch); ok = ok && getParam(fin,line,"LAB NAME",lab); ok = ok && getParam(fin,line,"X COORDINATE",&antpos[0]); ok = ok && getParam(fin,line,"Y COORDINATE",&antpos[1]); ok = ok && getParam(fin,line,"Z COORDINATE",&antpos[2]); ok = ok && getParam(fin,line,"COMMENTS",comments); ok = ok && getParam(fin,line,"FRAME",frame); ok = ok && getParam(fin,line,"REF",ref); ok = ok && getParam(fin,line,"INT DELAY P1 XR+XS (in ns)",&P1delay); ok = ok && getParam(fin,line,"INT DELAY P1 GLO (in ns)",&P2delayGLO); ok = ok && getParam(fin,line,"INT DELAY C1 XR+XS (in ns)",&P1delay); // FIXME WTF ok = ok && getParam(fin,line,"INT DELAY P2 XR+XS (in ns)",&P2delay); ok = ok && getParam(fin,line,"INT DELAY P2 GLO (in ns)",&P2delayGLO); ok = ok && getParam(fin,line,"ANT CAB DELAY (in ns)",&cabDelay); ok = ok && getParam(fin,line,"LEAP SECOND",&leapSeconds); ok = ok && getParam(fin,line,"CLOCK CAB DELAY XP+XO (in ns)",&refDelay); } fin.close(); return ok; }
char const * Sinful::getPrivateNetworkName() const { return getParam("PrivNet"); }
bool ALSAWriter::processParams(bool *paramsCorrected) { const unsigned chn = getParam("chn").toUInt(); const unsigned rate = getParam("rate").toUInt(); const bool resetAudio = channels != chn || sample_rate != rate; channels = chn; sample_rate = rate; if (resetAudio || err) { snd_pcm_hw_params_t *params; snd_pcm_hw_params_alloca(¶ms); close(); QString chosenDevName = devName; if (autoFindMultichannelDevice && channels > 2) { bool mustAutoFind = true, forceStereo = false; if (!snd_pcm_open(&snd, chosenDevName.toLocal8Bit(), SND_PCM_STREAM_PLAYBACK, 0)) { if (snd_pcm_type(snd) == SND_PCM_TYPE_HW) { unsigned max_chn = 0; snd_pcm_hw_params_any(snd, params); mustAutoFind = snd_pcm_hw_params_get_channels_max(params, &max_chn) || max_chn < channels; } #ifdef HAVE_CHMAP else if (paramsCorrected) { snd_pcm_chmap_query_t **chmaps = snd_pcm_query_chmaps(snd); if (chmaps) snd_pcm_free_chmaps(chmaps); else forceStereo = true; } #endif snd_pcm_close(snd); snd = NULL; } if (mustAutoFind) { QString newDevName; if (channels <= 4) newDevName = "surround40"; else if (channels <= 6) newDevName = "surround51"; else newDevName = "surround71"; if (!newDevName.isEmpty() && newDevName != chosenDevName) { if (ALSACommon::getDevices().first.contains(newDevName)) chosenDevName = newDevName; else if (forceStereo) { channels = 2; *paramsCorrected = true; } } } } if (!chosenDevName.isEmpty()) { bool sndOpen = !snd_pcm_open(&snd, chosenDevName.toLocal8Bit(), SND_PCM_STREAM_PLAYBACK, 0); if (devName != chosenDevName) { if (sndOpen) QMPlay2Core.logInfo("ALSA :: " + devName + "\" -> \"" + chosenDevName + "\""); else { sndOpen = !snd_pcm_open(&snd, devName.toLocal8Bit(), SND_PCM_STREAM_PLAYBACK, 0); QMPlay2Core.logInfo("ALSA :: " + tr("Cannot open") + " \"" + chosenDevName + "\", " + tr("back to") + " \"" + devName + "\""); } } if (sndOpen) { snd_pcm_hw_params_any(snd, params); snd_pcm_format_t fmt = SND_PCM_FORMAT_UNKNOWN; if (!snd_pcm_hw_params_test_format(snd, params, SND_PCM_FORMAT_S32)) { fmt = SND_PCM_FORMAT_S32; sample_size = 4; } else if (!snd_pcm_hw_params_test_format(snd, params, SND_PCM_FORMAT_S16)) { fmt = SND_PCM_FORMAT_S16; sample_size = 2; } else if (!snd_pcm_hw_params_test_format(snd, params, SND_PCM_FORMAT_S8)) { fmt = SND_PCM_FORMAT_S8; sample_size = 1; } unsigned delay_us = round(delay * 1000000.0); if (fmt != SND_PCM_FORMAT_UNKNOWN && set_snd_pcm_hw_params(snd, params, fmt, channels, sample_rate, delay_us)) { bool err2 = false; if (channels != chn || sample_rate != rate) { if (paramsCorrected) *paramsCorrected = true; else err2 = true; } if (!err2) { err2 = snd_pcm_hw_params(snd, params); if (err2 && paramsCorrected) //jakiś błąd, próba zmiany sample_rate { snd_pcm_hw_params_any(snd, params); err2 = snd_pcm_hw_params_set_rate_resample(snd, params, false) || !set_snd_pcm_hw_params(snd, params, fmt, channels, sample_rate, delay_us) || snd_pcm_hw_params(snd, params); if (!err2) *paramsCorrected = true; } if (!err2) { modParam("delay", delay_us / 1000000.0); if (paramsCorrected && *paramsCorrected) { modParam("chn", channels); modParam("rate", sample_rate); } canPause = snd_pcm_hw_params_can_pause(params) && snd_pcm_hw_params_can_resume(params); mustSwapChn = channels == 6 || channels == 8; #ifdef HAVE_CHMAP if (mustSwapChn) { snd_pcm_chmap_query_t **chmaps = snd_pcm_query_chmaps(snd); if (chmaps) { for (int i = 0; chmaps[i]; ++i) { if (chmaps[i]->map.channels >= channels) { for (uint j = 0; j < channels; ++j) { mustSwapChn &= chmaps[i]->map.pos[j] == j + SND_CHMAP_FL; if (!mustSwapChn) break; } break; } } snd_pcm_free_chmaps(chmaps); } } #endif return true; } } } } } err = true; QMPlay2Core.logError("ALSA :: " + tr("Cannot open audio output stream")); } return readyWrite(); }
bool Sinful::noUDP() const { return getParam("noUDP") != NULL; }
int SpiDrv::readAndCheckChar(char checkChar, char *readChar) { getParam( (uint8_t *) readChar ); return *readChar == checkChar; }
const char* HttpCookie::getExpires(void) const { return getParam("Expires"); }
static int mod_handler_debug(request_rec *r) { // The first thing we will do is write a simple "Hello, world!" back to the client. ap_set_content_type(r, "text/html"); /* force a raw text output */ ap_rputs("Hello, world!<br/>\n", r); if (config.secretKey) { ap_rprintf(r, "SecretKey is: %s<br/>\n", config.secretKey); } if (config.iv) { ap_rprintf(r, "IV is: %s<br/>\n", config.iv); } if (config.tokenParam) { ap_rprintf(r, "TokenParam is: %s<br/>\n", config.tokenParam); } if (config.algorithm) { ap_rprintf(r, "Algorithm is: %s<br/>\n", config.algorithm); } ap_rprintf(r, "parsed_uri.path: %s<br/>\n", r->parsed_uri.path); ap_rprintf(r, "parsed_uri.fragment: %s<br/>\n", r->parsed_uri.fragment); ap_rprintf(r, "parsed_uri.hostinfo: %s<br/>\n", r->parsed_uri.hostinfo); ap_rprintf(r, "parsed_uri.query: %s<br/>\n", r->parsed_uri.query); ap_rprintf(r, "parsed_uri.hostname: %s<br/>\n", r->parsed_uri.hostname); ap_rprintf(r, "parsed_uri.user: %s<br/>\n", r->parsed_uri.user); ap_rprintf(r, "parsed_uri.scheme: %s<br/>\n", r->parsed_uri.scheme); ap_rprintf(r, "request: %s<br/>\n", r->path_info); ap_rprintf(r, "filename: %s<br/>\n", r->filename); apr_table_t*GET; ap_args_to_table(r, &GET); apr_array_header_t*POST; ap_parse_form_data(r, NULL, &POST, -1, 8192); if (!config.secretKey) { ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r->server, "No such secretKey set"); return DECLINED; } if (!config.iv) { ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r->server, "No such IV set"); return DECLINED; } if (!config.algorithm) { ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r->server, "No such algorithm set"); return DECLINED; } /* Get the "digest" key from the query string, if any. */ // use const unsigned char *plain = (unsigned char*) getParam(GET, "plain", "The fox jumped over the lazy dog"); /* Get the "digest" key from the query string, if any. */ // use const unsigned char *cipherparam = (unsigned char*) getParam(GET, "cipher", ""); // use const const unsigned char *iv = (unsigned char*) "aefpojaefojaepfojaepaoejfapeojfaeopjaej"; long ivlength = strlen((char*)iv); /* Get the "digest" key from the query string, if any. */ // use const unsigned char *key = (unsigned char*) getParam(GET, "key", "The fox jumped over the lazy dog"); long keylength = strlen((char*)key); if (strlen((char*)key) > 0) { if (strlen((char*)plain) > 0) { cryptoc_data ciphereddata = cryptoc_encrypt_iv(CRYPTOC_AES_192_CBC, key, keylength, iv, ivlength, plain, strlen((char*)plain)); if (!ciphereddata.error) { ap_rprintf(r, "Ciphered data: %s \n<br />", ciphereddata.data); ap_rputs("Ciphered HEX data: ", r); ap_rprintf_hex(r, ciphereddata.data, ciphereddata.length); ap_rputs("\n<br />", r); cryptoc_data deciphereddata = cryptoc_decrypt_iv(CRYPTOC_AES_192_CBC, key, keylength, iv, ivlength, ciphereddata.data, ciphereddata.length); if (!deciphereddata.error) { deciphereddata.data[deciphereddata.length] = '\0'; ap_rprintf(r, "DECiphered data: %s <br />", deciphereddata.data); } else { ap_rprintf(r, "Error!! %s", deciphereddata.errorMessage); } } else { ap_rprintf(r, "Error!! %s", ciphereddata.errorMessage); } } if (strlen((char*)cipherparam) > 0) { unsigned char* cipher = ap_hex_to_char(r, cipherparam, strlen((char*)cipherparam)); /* The following line just prints a message to the errorlog */ //ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, 0, r->server, "Cipher is %s / %s / %d", cipher, (cipherparam), strlen((char*)cipherparam)); cryptoc_data deciphereddata = cryptoc_decrypt_iv(CRYPTOC_AES_192_CBC, key, keylength, iv, ivlength, cipher, strlen((char*)cipher)); if (!deciphereddata.error) { deciphereddata.data[deciphereddata.length] = '\0'; ap_rprintf(r, "DECiphered data: %s <br />", deciphereddata.data); } else { ap_rprintf(r, "Error!! %s", deciphereddata.errorMessage); } } } else { /* The following line just prints a message to the errorlog */ //ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, 0, r->server, "mod_token_auth: key is empty. %s %s", plain, cipherparam); } return OK; }
const char* HttpCookie::getDomain(void) const { return getParam("Domain"); }
int runMany() { StateMap threads; { string orig = getParam( "host" ); bool showPorts = false; if ( orig == "" ) orig = "localhost"; if ( orig.find( ":" ) != string::npos || hasParam( "port" ) ) showPorts = true; StringSplitter ss( orig.c_str() , "," ); while ( ss.more() ) { string host = ss.next(); if ( showPorts && host.find( ":" ) == string::npos) { // port supplied, but not for this host. use default. if ( hasParam( "port" ) ) host += ":" + _params["port"].as<string>(); else host += ":27017"; } _add( threads , host ); } } sleepsecs(1); int row = 0; bool discover = hasParam( "discover" ); int maxLockedDbWidth = 0; while ( 1 ) { sleepsecs( (int)ceil(_statUtil.getSeconds()) ); // collect data vector<Row> rows; for ( map<string,shared_ptr<ServerState> >::iterator i=threads.begin(); i!=threads.end(); ++i ) { scoped_lock lk( i->second->lock ); if ( i->second->error.size() ) { rows.push_back( Row( i->first , i->second->error ) ); } else if ( i->second->prev.isEmpty() || i->second->now.isEmpty() ) { rows.push_back( Row( i->first ) ); } else { BSONObj out = _statUtil.doRow( i->second->prev , i->second->now ); rows.push_back( Row( i->first , out ) ); } if ( discover && ! i->second->now.isEmpty() ) { if ( _discover( threads , i->first , i->second ) ) break; } } // compute some stats unsigned longestHost = 0; BSONObj biggest; for ( unsigned i=0; i<rows.size(); i++ ) { if ( rows[i].host.size() > longestHost ) longestHost = rows[i].host.size(); if ( rows[i].data.nFields() > biggest.nFields() ) biggest = rows[i].data; // adjust width up as longer 'locked db' values appear setMaxLockedDbWidth( &rows[i].data, &maxLockedDbWidth ); } { // check for any headers not in biggest // TODO: we put any new headers at end, // ideally we would interleave set<string> seen; BSONObjBuilder b; { // iterate biggest BSONObjIterator i( biggest ); while ( i.more() ) { BSONElement e = i.next(); seen.insert( e.fieldName() ); b.append( e ); } } // now do the rest for ( unsigned j=0; j<rows.size(); j++ ) { BSONObjIterator i( rows[j].data ); while ( i.more() ) { BSONElement e = i.next(); if ( seen.count( e.fieldName() ) ) continue; seen.insert( e.fieldName() ); b.append( e ); } } biggest = b.obj(); } // display data cout << endl; // header if ( row++ % 5 == 0 && ! biggest.isEmpty() ) { cout << setw( longestHost ) << "" << "\t"; printHeaders( biggest ); } // rows for ( unsigned i=0; i<rows.size(); i++ ) { cout << setw( longestHost ) << rows[i].host << "\t"; if ( rows[i].err.size() ) cout << rows[i].err << endl; else if ( rows[i].data.isEmpty() ) cout << "no data" << endl; else printData( rows[i].data , biggest ); } } return 0; }
const char* HttpCookie::getPath(void) const { return getParam("Path"); }
void MLProcBiquad::calcCoeffs(const int frames) { static MLSymbol modeSym("mode"); int mode = (int)getParam(modeSym); const MLSignal& frequency = getInput(2); const MLSignal& q = getInput(3); int coeffFrames; float twoPiOverSr = kMLTwoPi*getContextInvSampleRate(); bool paramSignalsAreConstant = frequency.isConstant() && q.isConstant(); if (paramSignalsAreConstant) { coeffFrames = 1; } else { coeffFrames = frames; } // set proper constant state for coefficient signals mA0.setConstant(paramSignalsAreConstant); mA1.setConstant(paramSignalsAreConstant); mA2.setConstant(paramSignalsAreConstant); mB1.setConstant(paramSignalsAreConstant); mB2.setConstant(paramSignalsAreConstant); float a0, a1, a2, b0, b1, b2; float qm1, omega, alpha, sinOmega, cosOmega; float highLimit = getContextSampleRate() * 0.33f; // generate coefficient signals // TODO SSE for(int n=0; n<coeffFrames; ++n) { qm1 = 1.f/(q[n] + 0.05f); omega = clamp(frequency[n], kLowFrequencyLimit, highLimit) * twoPiOverSr; sinOmega = fsin1(omega); cosOmega = fcos1(omega); alpha = sinOmega * 0.5f * qm1; b0 = 1.f/(1.f + alpha); switch (mode) { default: case kLowpass: a0 = ((1.f - cosOmega) * 0.5f) * b0; a1 = (1.f - cosOmega); a2 = a0; b1 = (-2.f * cosOmega); b2 = (1.f - alpha); break; case kHighpass: a0 = ((1.f + cosOmega) * 0.5f); a1 = -(1.f + cosOmega); a2 = a0; b1 = (-2.f * cosOmega); b2 = (1.f - alpha); break; case kBandpass: a0 = alpha; a1 = 0.f; a2 = -alpha; b1 = -2.f * cosOmega; b2 = (1.f - alpha); break; case kNotch: a0 = 1; a1 = -2.f * cosOmega; a2 = 1; b1 = -2.f * cosOmega; b2 = (1.f - alpha); break; } mA0[n] = a0*b0; mA1[n] = a1*b0; mA2[n] = a2*b0; mB1[n] = b1*b0; mB2[n] = b2*b0; } }
int Tool::main( int argc , char ** argv ){ static StaticObserver staticObserver; cmdLine.prealloc = false; boost::filesystem::path::default_name_check( boost::filesystem::no_check ); _name = argv[0]; /* using the same style as db.cpp */ int command_line_style = (((po::command_line_style::unix_style ^ po::command_line_style::allow_guessing) | po::command_line_style::allow_long_disguise) ^ po::command_line_style::allow_sticky); try { po::options_description all_options("all options"); all_options.add(*_options).add(*_hidden_options); po::store( po::command_line_parser( argc , argv ). options(all_options). positional( _positonalOptions ). style(command_line_style).run() , _params ); po::notify( _params ); } catch (po::error &e) { cerr << "ERROR: " << e.what() << endl << endl; printHelp(cerr); return EXIT_BADOPTIONS; } // hide password from ps output for (int i=0; i < (argc-1); ++i){ if (!strcmp(argv[i], "-p") || !strcmp(argv[i], "--password")){ char* arg = argv[i+1]; while (*arg){ *arg++ = 'x'; } } } if ( _params.count( "help" ) ){ printHelp(cout); return 0; } if ( _params.count( "verbose" ) ) { logLevel = 1; } for (string s = "vv"; s.length() <= 10; s.append("v")) { if (_params.count(s)) { logLevel = s.length(); } } preSetup(); bool useDirectClient = hasParam( "dbpath" ); if ( ! useDirectClient ) { _host = "127.0.0.1"; if ( _params.count( "host" ) ) _host = _params["host"].as<string>(); if ( _params.count( "port" ) ) _host += ':' + _params["port"].as<string>(); if ( _noconnection ){ // do nothing } else if ( _host.find( "," ) == string::npos ){ DBClientConnection * c = new DBClientConnection( _autoreconnect ); _conn = c; string errmsg; if ( ! c->connect( _host , errmsg ) ){ cerr << "couldn't connect to [" << _host << "] " << errmsg << endl; return -1; } } else { log(1) << "using pairing" << endl; DBClientPaired * c = new DBClientPaired(); _paired = true; _conn = c; if ( ! c->connect( _host ) ){ cerr << "couldn't connect to paired server: " << _host << endl; return -1; } } (_usesstdout ? cout : cerr ) << "connected to: " << _host << endl; } else { if ( _params.count( "directoryperdb" ) ) { directoryperdb = true; } assert( lastError.get( true ) ); Client::initThread("tools"); _conn = new DBDirectClient(); _host = "DIRECT"; static string myDbpath = getParam( "dbpath" ); dbpath = myDbpath.c_str(); try { acquirePathLock(); } catch ( DBException& e ){ cerr << endl << "If you are running a mongod on the same " "path you should connect to that instead of direct data " "file access" << endl << endl; dbexit( EXIT_CLEAN ); return -1; } theFileAllocator().start(); } if ( _params.count( "db" ) ) _db = _params["db"].as<string>(); if ( _params.count( "collection" ) ) _coll = _params["collection"].as<string>(); if ( _params.count( "username" ) ) _username = _params["username"].as<string>(); if ( _params.count( "password" ) && ( _password.empty() ) ) { _password = askPassword(); } if (_params.count("ipv6")) enableIPv6(); int ret = -1; try { ret = run(); } catch ( DBException& e ){ cerr << "assertion: " << e.toString() << endl; ret = -1; } if ( currentClient.get() ) currentClient->shutdown(); if ( useDirectClient ) dbexit( EXIT_CLEAN ); return ret; }
bool DepthCamera::_applyConfigParams(const ConfigSet *params) { for(auto i = 0; i < params->paramNames.size(); i++) { if(params->paramNames[i].compare(0, 2, "0x") == 0) { logger(LOG_INFO) << "DepthCamera: Setting register '" << params->paramNames[i] << "'" << std::endl; char *endptr; uint32_t reg = (uint32_t)strtol(params->paramNames[i].c_str(), &endptr, 16); uint32_t value = (uint32_t)strtol(params->get(params->paramNames[i]).c_str(), &endptr, 0); if(!_programmer->writeRegister(reg, value)) { logger(LOG_ERROR) << "Failed to write to register @0x" << std::hex << reg << " = 0x" << value << std::dec << std::endl; } continue; } else if(params->paramNames[i] == "frame_rate") { float rate = params->getFloat(params->paramNames[i]); FrameRate r; r.numerator = rate*10000; r.denominator = 10000; uint g = gcd(r.numerator, r.denominator); r.numerator /= g; r.denominator /= g; if(!setFrameRate(r)) { logger(LOG_ERROR) << "DepthCamera: Failed to set frame rate to " << rate << "fps" << std::endl; return false; } continue; } logger(LOG_INFO) << "DepthCamera: Setting parameter '" << params->paramNames[i] << "'" << std::endl; const Parameter *p = getParam(params->paramNames[i]).get(); if(!p) { logger(LOG_ERROR) << "DepthCamera: Ignoring unknown parameter " << params->paramNames[i] << std::endl; return false; } const BoolParameter *bp = dynamic_cast<const BoolParameter *>(p); const EnumParameter *ep = dynamic_cast<const EnumParameter *>(p); const IntegerParameter *ip = dynamic_cast<const IntegerParameter *>(p); const UnsignedIntegerParameter *up = dynamic_cast<const UnsignedIntegerParameter *>(p); const FloatParameter *fp = dynamic_cast<const FloatParameter *>(p); if(bp) { if(!set(params->paramNames[i], params->getBoolean(params->paramNames[i]))) return false; } else if(ip || ep) { if(!set(params->paramNames[i], params->getInteger(params->paramNames[i]))) return false; } else if(up) { if(!set(params->paramNames[i], (uint)params->getInteger(params->paramNames[i]))) return false; } else if(fp) { if(!set(params->paramNames[i], params->getFloat(params->paramNames[i]))) return false; } else { logger(LOG_ERROR) << "DepthCamera: Parameter type unknown for " << params->paramNames[i] << std::endl; return false; } } return true; }
static void static_dump_request_cb(struct evhttp_request *req, void *arg) { const char *cmdtype; struct evkeyvalq *headers; struct evkeyval *header; struct evbuffer *buf; switch (evhttp_request_get_command(req)) { case EVHTTP_REQ_GET: cmdtype = "GET"; break; case EVHTTP_REQ_POST: cmdtype = "POST"; break; default: cmdtype = "unknown"; break; } printf("Received a %s request for %s\nHeaders:\n", cmdtype, evhttp_request_get_uri(req)); headers = evhttp_request_get_input_headers(req); for (header = headers->tqh_first; header; header = header->next.tqe_next) { printf(" %s: %s\n", header->key, header->value); } buf = evhttp_request_get_input_buffer(req); puts("Input data: <<<"); printf("len:%d", evbuffer_get_length(buf)); /* while (evbuffer_get_length(buf)) { int n; char cbuf[128]; n = evbuffer_remove(buf, cbuf, sizeof(buf)-1); if (n > 0) (void) fwrite(cbuf, 1, n, stdout); } puts(">>>"); */ //get params struct evkeyvalq *query_params_ptr = calloc(sizeof(struct evkeyvalq), 1); getParams(req, query_params_ptr); char *test = NULL; test = getParam(query_params_ptr, "test"); if (test != NULL) { fprintf(stderr, "param test: %s", test); } evhttp_clear_headers(query_params_ptr); free(test); //post params struct evkeyvalq *post_params_ptr = calloc(sizeof(struct evkeyvalq), 1); postParams(req, post_params_ptr); char *name = NULL; name = postParam(post_params_ptr, "name"); if (name != NULL) { fprintf(stderr, "param name: %s", name); } evhttp_clear_headers(post_params_ptr); free(name); evhttp_send_reply(req, 200, "OK", NULL); //evhttp_request_free(req); }
void run(){ hunt(getParam()); }
void LCGWSpinBBHNR1::DispAllParam(std::ostream * out) { for(int iP=0; iP<NParams; iP++) (*out) << " " << getParam(iP); }