/* * ut_done -- indicate test is done, exit program */ void ut_done(const char *file, int line, const char *func, const char *fmt, ...) { va_list ap; va_start(ap, fmt); if (!getenv("UNITTEST_DO_NOT_CHECK_OPEN_FILES")) check_open_files(); prefix(file, line, func, 0); vout(OF_NAME, "Done", fmt, ap); va_end(ap); if (Outfp != NULL) fclose(Outfp); if (Errfp != NULL) fclose(Errfp); if (Tracefp != NULL) fclose(Tracefp); exit(0); }
/* * ut_done -- indicate test is done, exit program */ void ut_done(const char *file, int line, const char *func, const char *fmt, ...) { va_list ap; va_start(ap, fmt); check_open_files(); prefix(file, line, func, 0); vout(OF_NAME, "Done", fmt, ap); va_end(ap); if (Outfp != NULL) fclose(Outfp); if (Errfp != NULL) fclose(Errfp); if (Tracefp != NULL) fclose(Tracefp); exit(0); }
void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry, bool include_hex, int serialize_flags) { entry.pushKV("txid", tx.GetHash().GetHex()); entry.pushKV("hash", tx.GetWitnessHash().GetHex()); entry.pushKV("version", tx.nVersion); entry.pushKV("size", (int)::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION)); entry.pushKV("vsize", (GetTransactionWeight(tx) + WITNESS_SCALE_FACTOR - 1) / WITNESS_SCALE_FACTOR); entry.pushKV("weight", GetTransactionWeight(tx)); entry.pushKV("locktime", (int64_t)tx.nLockTime); UniValue vin(UniValue::VARR); for (unsigned int i = 0; i < tx.vin.size(); i++) { const CTxIn& txin = tx.vin[i]; UniValue in(UniValue::VOBJ); if (tx.IsCoinBase()) in.pushKV("coinbase", HexStr(txin.scriptSig.begin(), txin.scriptSig.end())); else { in.pushKV("txid", txin.prevout.hash.GetHex()); in.pushKV("vout", (int64_t)txin.prevout.n); UniValue o(UniValue::VOBJ); o.pushKV("asm", ScriptToAsmStr(txin.scriptSig, true)); o.pushKV("hex", HexStr(txin.scriptSig.begin(), txin.scriptSig.end())); in.pushKV("scriptSig", o); if (!tx.vin[i].scriptWitness.IsNull()) { UniValue txinwitness(UniValue::VARR); for (const auto& item : tx.vin[i].scriptWitness.stack) { txinwitness.push_back(HexStr(item.begin(), item.end())); } in.pushKV("txinwitness", txinwitness); } } in.pushKV("sequence", (int64_t)txin.nSequence); vin.push_back(in); } entry.pushKV("vin", vin); UniValue vout(UniValue::VARR); for (unsigned int i = 0; i < tx.vout.size(); i++) { const CTxOut& txout = tx.vout[i]; UniValue out(UniValue::VOBJ); out.pushKV("value", ValueFromAmount(txout.nValue)); out.pushKV("n", (int64_t)i); UniValue o(UniValue::VOBJ); ScriptPubKeyToUniv(txout.scriptPubKey, o, true); out.pushKV("scriptPubKey", o); vout.push_back(out); } entry.pushKV("vout", vout); if (!hashBlock.IsNull()) entry.pushKV("blockhash", hashBlock.GetHex()); if (include_hex) { entry.pushKV("hex", EncodeHexTx(tx, serialize_flags)); // The hex-encoded transaction. Used the name "hex" to be consistent with the verbose output of "getrawtransaction". } }
void TxToUniv(const CTransaction &tx, const uint256 &hashBlock, UniValue &entry) { entry.pushKV("txid", tx.GetId().GetHex()); entry.pushKV("hash", tx.GetHash().GetHex()); entry.pushKV("version", tx.nVersion); entry.pushKV("locktime", (int64_t)tx.nLockTime); UniValue vin(UniValue::VARR); for (unsigned int i = 0; i < tx.vin.size(); i++) { const CTxIn &txin = tx.vin[i]; UniValue in(UniValue::VOBJ); if (tx.IsCoinBase()) { in.pushKV("coinbase", HexStr(txin.scriptSig.begin(), txin.scriptSig.end())); } else { in.pushKV("txid", txin.prevout.hash.GetHex()); in.pushKV("vout", (int64_t)txin.prevout.n); UniValue o(UniValue::VOBJ); o.pushKV("asm", ScriptToAsmStr(txin.scriptSig, true)); o.pushKV("hex", HexStr(txin.scriptSig.begin(), txin.scriptSig.end())); in.pushKV("scriptSig", o); } in.pushKV("sequence", (int64_t)txin.nSequence); vin.push_back(in); } entry.pushKV("vin", vin); UniValue vout(UniValue::VARR); for (unsigned int i = 0; i < tx.vout.size(); i++) { const CTxOut &txout = tx.vout[i]; UniValue out(UniValue::VOBJ); UniValue outValue(UniValue::VNUM, FormatMoney(txout.nValue.GetSatoshis())); out.pushKV("value", outValue); out.pushKV("n", (int64_t)i); UniValue o(UniValue::VOBJ); ScriptPubKeyToUniv(txout.scriptPubKey, o, true); out.pushKV("scriptPubKey", o); vout.push_back(out); } entry.pushKV("vout", vout); if (!hashBlock.IsNull()) { entry.pushKV("blockhash", hashBlock.GetHex()); } // the hex-encoded transaction. used the name "hex" to be consistent with // the verbose output of "getrawtransaction". entry.pushKV("hex", EncodeHexTx(tx)); }
/* * out -- printf-like output controlled by flags */ static void out(int flags, const char *fmt, ...) { va_list ap; va_start(ap, fmt); vout(flags, NULL, fmt, ap); va_end(ap); }
Eigen::VectorXd mrpt::vision::pnp::rpnp::getpoly7(const Eigen::VectorXd& vin) { Eigen::VectorXd vout(8); vout << 4 * pow(vin(0), 2), 7 * vin(1) * vin(0), 6 * vin(2) * vin(0) + 3 * pow(vin(1), 2), 5 * vin(3) * vin(0) + 5 * vin(2) * vin(1), 4 * vin(4) * vin(0) + 4 * vin(3) * vin(1) + 2 * pow(vin(2), 2), 3 * vin(4) * vin(1) + 3 * vin(3) * vin(2), 2 * vin(4) * vin(2) + pow(vin(3), 2), vin(4) * vin(3); return vout; }
std::vector<double> MATHNS::mat_vec_mult(int lda, double **A, std::vector<double> X) { if(lda!=X.size()) merrors->kill(FERR,"MATHNS::mat_vec_mult()",LERR,"leading dimension of A != leading dimension of X!"); std::vector<double> vout(lda); for(int ii=0; ii<lda; ii++) { vout[ii] = 0.; for(int kk=0; kk<lda; kk++) vout[ii] += A[ii][kk]*X[kk]; } return vout; }
/* * ut_fatal -- indicate fatal error, exit program */ void ut_fatal(const char *file, int line, const char *func, const char *fmt, ...) { va_list ap; va_start(ap, fmt); prefix(file, line, func, OF_ERR); vout(OF_ERR|OF_NAME, "Error", fmt, ap); va_end(ap); abort(); }
/* * ut_out -- output to stdout */ void ut_out(const char *file, int line, const char *func, const char *fmt, ...) { va_list ap; int saveerrno = errno; va_start(ap, fmt); prefix(file, line, func, 0); vout(0, NULL, fmt, ap); va_end(ap); errno = saveerrno; }
/* * ut_err -- output to stderr */ void ut_err(const char *file, int line, const char *func, const char *fmt, ...) { va_list ap; int saveerrno = errno; va_start(ap, fmt); prefix(file, line, func, OF_ERR); vout(OF_ERR|OF_NAME, NULL, fmt, ap); va_end(ap); errno = saveerrno; }
void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry) { entry.pushKV("txid", tx.GetHash().GetHex()); entry.pushKV("version", tx.nVersion); entry.pushKV("locktime", (int64_t)tx.nLockTime); UniValue vin(UniValue::VARR); BOOST_FOREACH(const CTxIn& txin, tx.vin) { UniValue in(UniValue::VOBJ); if (tx.IsCoinBase()) in.pushKV("coinbase", HexStr(txin.scriptSig.begin(), txin.scriptSig.end())); else { in.pushKV("txid", txin.prevout.hash.GetHex()); in.pushKV("vout", (int64_t)txin.prevout.n); UniValue o(UniValue::VOBJ); o.pushKV("asm", txin.scriptSig.ToString()); o.pushKV("hex", HexStr(txin.scriptSig.begin(), txin.scriptSig.end())); in.pushKV("scriptSig", o); } in.pushKV("sequence", (int64_t)txin.nSequence); vin.push_back(in); } entry.pushKV("vin", vin); UniValue vout(UniValue::VARR); for (unsigned int i = 0; i < tx.vout.size(); i++) { const CTxOut& txout = tx.vout[i]; UniValue out(UniValue::VOBJ); UniValue outValue(UniValue::VNUM, FormatMoney(txout.nValue)); out.pushKV("value", outValue); out.pushKV("n", (int64_t)i); UniValue o(UniValue::VOBJ); ScriptPubKeyToUniv(txout.scriptPubKey, o, true); out.pushKV("scriptPubKey", o); vout.push_back(out); } entry.pushKV("vout", vout); if (hashBlock != 0) entry.pushKV("blockhash", hashBlock.GetHex()); }
RH wclient::send_command(std::string command) { RH result; result.set_ok(); vout(VOUT_DEBUG) << "[wclient] sending command to " << ip.host_and_port() << ": " << command << std::endl; socket->set_endline("\r\n"); ::pthread_mutex_lock(&request_command_mutex); result = socket->sendline(command); // std::cout << "!!!!!!!!!!!!!" << (result.is_ok() ? "OK ":"NOT OK ") << result.text() << std::endlc; if (result.is_ok()) { // std::cout << "command " << command << " sent succesfully to " << ip.host_and_port() << std::endlc; request_command.push(command); sent_message = true; timers.restart_stopwatch(last_sent_message); } ::pthread_mutex_unlock(&request_command_mutex); return(result); }
/* * ut_start -- initialize unit test framework, indicate test started */ void ut_start(const char *file, int line, const char *func, int argc, char * const argv[], const char *fmt, ...) { va_list ap; int saveerrno = errno; char logname[MAXLOGNAME]; char *logsuffix; va_start(ap, fmt); if (getenv("UNITTEST_NO_SIGHANDLERS") == NULL) ut_register_sighandlers(); if (getenv("UNITTEST_QUIET") != NULL) Quiet++; Testname = getenv("UNITTEST_NAME"); if ((logsuffix = getenv("UNITTEST_NUM")) == NULL) logsuffix = ""; snprintf(logname, MAXLOGNAME, "out%s.log", logsuffix); if ((Outfp = fopen(logname, "w")) == NULL) { perror(logname); exit(1); } snprintf(logname, MAXLOGNAME, "err%s.log", logsuffix); if ((Errfp = fopen(logname, "w")) == NULL) { perror(logname); exit(1); } snprintf(logname, MAXLOGNAME, "trace%s.log", logsuffix); if ((Tracefp = fopen(logname, "w")) == NULL) { perror(logname); exit(1); } setlinebuf(Outfp); setlinebuf(Errfp); setlinebuf(Tracefp); setlinebuf(stdout); prefix(file, line, func, 0); vout(OF_LOUD|OF_NAME, "START", fmt, ap); out(OF_NONL, 0, " args:"); for (int i = 0; i < argc; i++) out(OF_NONL, " %s", argv[i]); out(0, NULL); va_end(ap); record_open_files(); long long sc = sysconf(_SC_PAGESIZE); if (sc < 0) abort(); Ut_pagesize = (unsigned long)sc; errno = saveerrno; }
void BufferedLoggerMark::out(const char* format, ...) { va_list ap; va_start(ap, format); vout(format,ap); va_end(ap); }
/* * Parse events and execute the appropriate functions. */ int fs_parse(char *buf) { struct bot_in *bot_t = pthread_getspecific(bot); struct socket_in *fs_t = pthread_getspecific(fs_s); vout(3, "FS", "->", buf); /* If a user is added to/deleted from a conference, announce it. */ if(strncmp(buf+strlen(buf)-20, "Action: add-member", 18) == 0 || strncmp(buf+strlen(buf)-20, "Action: del-member", 18) == 0) { char mesg[513], *caller, *conf; size_t len, num = fs_caller_name_re.re_nsub+1, num2 = fs_caller_num_re.re_nsub+1; regmatch_t *preg = calloc(num, sizeof(*preg)), *preg2 = calloc(num2, sizeof(*preg2)); if(regexec(&fs_conference_re, buf, num, preg, 0) != 0) return 0; len = preg[1].rm_eo-preg[1].rm_so; conf = calloc(len+1, sizeof(*conf)); strncpy(conf, buf+preg[1].rm_so, len); if(regexec(&fs_caller_num_re, buf, num2, preg2, 0) == 0) { len = preg2[2].rm_eo-preg2[2].rm_so; caller = calloc(len+3, sizeof(*caller)); /* Setup our mask. */ memcpy(caller, "XXX-XXX-XXXX", 12); /* Copy in our real digits. */ memcpy(caller, buf+preg2[2].rm_so, 3); memcpy(caller+4, buf+preg2[2].rm_so+3, 3); /* * We keep the suffix masked for privacy. You can decide to * show the last for digits of phone numbers by uncommenting the following. * memcpy(caller+8, buf+preg2[2].rm_so+6, 4); */ } else if(regexec(&fs_caller_name_re, buf, num, preg, 0) == 0) { len = preg[1].rm_eo-preg[1].rm_so; caller = calloc(len+1, sizeof(*caller)); strncpy(caller, buf+preg[1].rm_so, len); } else { caller = calloc(8, sizeof(*caller)); strncpy(caller, "Unknown", 8); } /* XXX Use MySQL to get the name of the conference and the channel to say it in. */ if(strncmp(buf+strlen(buf)-20, "Action: add-member", 18) == 0) snprintf(mesg, 512, "%s has joined the %s bridge (ext. %s).", caller, conf, conf); else snprintf(mesg, 512, "%s is leaving the %s bridge (ext. %s).", caller, conf, conf); /* * XXX Replace #telconinja with the actual channel the info should go to. * We will be using the MySQL stuff for this.. but for now, everthing to #tn */ irc_cmd(IRC_ACTION, "#telconinja", mesg); /* Do some cleanup. */ free(caller); /*free(chan); */ free(conf); free(preg); free(preg2); return 0; } if(strncmp(buf, "Content-Type: api/response", 26) == 0) { switch(bot_t->fs_last_api) { case FS_CONFLIST: irc_cmd(IRC_PRIVMSG, "#bots", strstr(buf, "\n\n")+2); break; } return 0; } /* * If we need to authenticate then do so, and also send the event request for the * conference notices. * XXX This probably only happens at the start of the connection and therefore * should appear closer to the end of this function. */ if(strcmp(buf, "Content-Type: auth/request") == 0) { /* * XXX After we get the configuration stuff done, this should be changed * to use the value in the bot's configuration file. */ sprintf(buf, "auth %s\n\nevent plain CUSTOM conference::maintenance\n\n", bot_t->fs_pass); socket_send(fs_t, buf); return 0; } return 0; }
/* * Load a module, scary... * Return value: * Returns 0 on success, otherwise returns error code. */ int mod_load(char *mod) { struct mod_object *mhand, *mlist; void (*module_init)(struct mod_object *); int (**func_mod_load)(char *); int (**func_mod_unload)(const char *); int (**func_irc_cmd)(int, const char *, const char *); int (**func_mod_register_irc)(struct mod_object *, int (*)(const char *, const char *, const char *, const char *)); /* Allocate memory and load our .so */ if((mhand = calloc(1, sizeof(*mhand))) == NULL) goto not_enough_mem; if((mhand->dl_handler = dlopen(mod, RTLD_LAZY|RTLD_LOCAL)) == NULL) goto dlopen_error; else { char *file = basename(mod); if(file == NULL) return(-1); mhand->filename = strdup(file); } /* Lock our mutex while we add our new module. */ pthread_mutex_lock(&mtx_mod); /* Get the last used module object in our chain. */ if(modules == NULL) modules = mhand; else { for(mlist = modules; mlist->next != NULL; mlist = mlist->next) { if(mlist == mhand) { vout(3, VOUT_FLOW_INBOUND, "Modules", "Module already loaded."); goto dlopen_error; } } mlist->next = mhand; } /* Unlock our mutex, not necessary anymore. */ pthread_mutex_unlock(&mtx_mod); /* Load our function pointers. */ if((func_mod_load = dlsym(mhand->dl_handler, "mod_load")) != NULL) *func_mod_load = &mod_load; if((func_mod_unload = dlsym(mhand->dl_handler, "mod_unload")) != NULL) *func_mod_unload = &mod_unload; if((func_mod_register_irc = dlsym(mhand->dl_handler, "mod_register_irc")) != NULL) *func_mod_register_irc = &mod_register_irc; if((func_irc_cmd = dlsym(mhand->dl_handler, "irc_cmd")) != NULL) *func_irc_cmd = &irc_cmd; /* Runn our new plugin's module_init() function. */ if((*(void **)(&module_init) = dlsym(mhand->dl_handler, "module_init")) != NULL) (*module_init)(mhand); return(0); dlopen_error: free(mhand); not_enough_mem: return(-1); }
flagType DoText ( int yLow, int yHigh ) { REGISTER int yCur; int yMin = -1; int yMax = 0; flagType fReturn = TRUE; struct lineAttr *plaFile = NULL; struct lineAttr *plaScr = NULL; struct lineAttr *plaFileLine; struct lineAttr *plaScrLine; char *pchFileLine = NULL; char pchScrLine[ 2 * sizeof(linebuf) * (1 + sizeof(struct lineAttr))]; int cchScrLine; // int chkpnt = yHigh - yLow > 25 ? 20 : 5; int chkpnt = yHigh - yLow > 25 ? 10 : 3; fReDraw = FALSE; plaScr = (struct lineAttr *) (pchScrLine + sizeof(linebuf)); if (cWin > 1) { pchFileLine = pchScrLine + sizeof(linebuf) * (1 + sizeof(struct lineAttr)); plaFile = (struct lineAttr *) (pchFileLine + sizeof(linebuf)); } /* * For each line in the window, if the line is marked changed, update it. */ for (yCur = yLow; yCur < yHigh; ) { if (TESTFLAG(fChange[yCur], FMODIFY)) { if (yMin == -1) { yMin = yCur; } yMax = yCur; /* * get and display the line */ plaScrLine = plaScr; plaFileLine = plaFile; cchScrLine = DisplayLine (yCur, pchScrLine, &plaScrLine, pchFileLine, &plaFileLine); coutb (0, yCur, pchScrLine, cchScrLine, plaScrLine); RSETFLAG(fChange[yCur],FMODIFY); /* * if it is time to check, and there is a character waiting, stop * the update process, and go process it */ if ( (yCur % chkpnt == 0) && TypeAhead() ) { fReturn = FALSE; break; } } yCur++; } if (fReturn) { RSETFLAG (fDisplay, RTEXT); } // // Update the screen // fReDraw = TRUE; vout(0,0,NULL,0,0); return fReturn; }
void Settings::writeSettings() { setValue(KEY_LANGUAGE, language()); setValue(KEY_SESSION_AUTOPLAY, sessionAutoplay()); setValue(KEY_SESSION_CHANNEL, sessionChannel()); setValue(KEY_SESSION_REMEMBER_VOLUME, sessionRememberVolume()); setValue(KEY_SESSION_VOLUME, sessionVolume()); if (globalConfig && globalConfig->disableSettings("channels")) { remove("channels"); } else { setValue(KEY_PLAYLIST, playlist()); setValue(KEY_PLAYLIST_UPDATE, playlistUpdate()); setValue(KEY_PLAYLIST_UPDATE_URL, playlistUpdateUrl()); setValue(KEY_RADIO_CATEGORY, radioCategory()); setValue(KEY_HD_CATEGORY, hdCategory()); setValue(KEY_UDPXY, udpxy()); setValue(KEY_UDPXY_URL, udpxyUrl()); setValue(KEY_UDPXY_PORT, udpxyPort()); } if (globalConfig && globalConfig->disableSettings("gui")) { remove("gui"); } else { setValue(KEY_WIDTH, width()); setValue(KEY_HEIGHT, height()); setValue(KEY_POS_X, posX()); setValue(KEY_POS_Y, posY()); setValue(KEY_OSD, osd()); setValue(KEY_TRAY_ENABLED, trayEnabled()); setValue(KEY_HIDE_TO_TRAY, hideToTray()); setValue(KEY_MOUSE_WHEEL, mouseWheel()); setValue(KEY_REMEMBER_GUI_SESSION, rememberGuiSession()); setValue(KEY_ICONS, icons()); } if (globalConfig && globalConfig->disableSettings("backend")) { remove("backend"); } else { setValue(KEY_VOUT, vout()); setValue(KEY_AOUT, aout()); setValue(KEY_YUV_TO_RGB, yuvToRgb()); setValue(KEY_SPDIF, spdif()); setValue(KEY_REMEMBER_VIDEO_SETTINGS, rememberVideoSettings()); setValue(KEY_REMEMBER_VIDEO_PER_CHANNEL, rememberVideoPerChannel()); setValue(KEY_ASPECT_RATIO, aspectRatio()); setValue(KEY_CROP_RATIO, cropRatio()); setValue(KEY_DEINTERLACING, deinterlacing()); setValue(KEY_AUDIO_LANGUAGE, audioLanguage()); setValue(KEY_SUBTITLE_LANGUAGE, subtitleLanguage()); setValue(KEY_MUTE_ON_MINIMIZE, muteOnMinimize()); setValue(KEY_TELETEXT, teletext()); } if (globalConfig && globalConfig->disableSettings("recorder")) { remove("recorder"); } else { setValue(KEY_RECORDER_DIRECTORY, recorderDirectory()); setValue(KEY_SNAPSHOTS_DIRECTORY, snapshotsDirectory()); } if (globalConfig && globalConfig->disableSettings("xmltv")) { remove("xmltv"); } else { setValue(KEY_XMLTV_UPDATE, xmltvUpdate()); setValue(KEY_XMLTV_UPDATE_LOCATION, xmltvUpdateLocation()); setValue(KEY_XMLTV_UPDATE_REMOTE, xmltvUpdateRemote()); } sync(); }