void check_key_length (ssl_context *ssl) { uint32_t key_bits; const x509_cert *certificate; const rsa_context *public_key; char buf[1024]; certificate = ssl_get_peer_cert (ssl); if (NULL == certificate) { die ("Getting certificate failed\n"); } x509parse_dn_gets(buf, 1024, &certificate->subject); verb ("V: Certificate for subject '%s'\n", buf); public_key = &certificate->rsa; if (NULL == public_key) { die ("public key extraction failure\n"); } else { verb ("V: public key is ready for inspection\n"); } key_bits = mpi_msb (&public_key->N); if (MIN_PUB_KEY_LEN >= key_bits) { die ("Unsafe public key size: %d bits\n", key_bits); } else { verb ("V: key length appears safe\n"); } }
void check_key_length (SSL *ssl) { uint32_t key_bits; X509 *certificate; EVP_PKEY *public_key; certificate = SSL_get_peer_certificate (ssl); public_key = X509_get_pubkey (certificate); if (NULL == public_key) { die ("public key extraction failure\n"); } else { verb ("V: public key is ready for inspection\n"); } key_bits = get_certificate_keybits (public_key); if (MIN_PUB_KEY_LEN >= key_bits && public_key->type != EVP_PKEY_EC) { die ("Unsafe public key size: %d bits\n", key_bits); } else { if (public_key->type == EVP_PKEY_EC) if(key_bits >= MIN_ECC_PUB_KEY_LEN && key_bits <= MAX_ECC_PUB_KEY_LEN) { verb ("V: ECC key length appears safe\n"); } else { die ("Unsafe ECC key size: %d bits\n", key_bits); } else { verb ("V: key length appears safe\n"); } } EVP_PKEY_free (public_key); }
int init_debug_output_file(int is_master) { // g_verbosity = 1; // g_debug_file_logging = 0; char tmpPath[128]; getcwd(tmpPath, sizeof(tmpPath)); memset(g_logfilename, 0, sizeof(char) * MAX_LOG_FILE_NAME_LEN); if ( is_master != 0 ) { snprintf(g_logfilename, (MAX_LOG_FILE_NAME_LEN / 2) - 1, "%s-%s.%s", g_logfilename_prefix, "master", g_logfilename_suffix); } else { snprintf(g_logfilename, (MAX_LOG_FILE_NAME_LEN / 2) - 1, "%s-%s.%s", g_logfilename_prefix, "minion", g_logfilename_suffix); } snprintf(g_full_log_filename, MAX_LOG_FILE_NAME_LEN, "%s/%s", tmpPath, g_logfilename); if ( g_debug_file_logging > 0 ) { verb(VERB_2, "[%s] opening log file g_full_log_filename", __func__, g_full_log_filename); fflush(stderr); FILE* debug_file = fopen(g_full_log_filename, "a"); if ( !debug_file ) { g_debug_file_logging = 0; verb(VERB_2, "[%s] unable to open log file, error %d", __func__, g_full_log_filename, errno); } else { fclose(debug_file); } verb(VERB_2, "********"); verb(VERB_2, "********"); verb(VERB_2, "[%s] log file opened as %s", __func__, g_full_log_filename); } return 0; }
void openssl_time_callback (const SSL* ssl, int where, int ret) { if (where == SSL_CB_CONNECT_LOOP && (ssl->state == SSL3_ST_CR_SRVR_HELLO_A || ssl->state == SSL3_ST_CR_SRVR_HELLO_B)) { // XXX TODO: If we want to trust the remote system for time, // can we just read that time out of the remote system and if the // cert verifies, decide that the time is reasonable? // Such a process seems to indicate that a once valid cert would be // forever valid - we stopgap that by ensuring it isn't less than // the latest compiled_time and isn't above max_reasonable_time... // XXX TODO: Solve eternal question about the Chicken and the Egg... uint32_t compiled_time = RECENT_COMPILE_DATE; uint32_t max_reasonable_time = MAX_REASONABLE_TIME; uint32_t server_time; verb("V: freezing time for x509 verification"); memcpy(&server_time, ssl->s3->server_random, sizeof(uint32_t)); if (compiled_time < ntohl(server_time) && ntohl(server_time) < max_reasonable_time) { verb("V: remote peer provided: %d, preferred over compile time: %d", ntohl(server_time), compiled_time); verb("V: freezing time with X509_VERIFY_PARAM_set_time"); X509_VERIFY_PARAM_set_time(ssl->ctx->cert_store->param, (time_t) ntohl(server_time) + 86400); } else { die("V: the remote server is a false ticker! server: %d compile: %d", ntohl(server_time), compiled_time); } } }
int socks4a_connect(BIO *b) { struct proxy_ctx *ctx = (struct proxy_ctx *) b->ptr; int r; unsigned char buf[NI_MAXHOST + 16]; uint16_t port_n = htons(ctx->port); size_t sz = 0; verb("V: proxy4: connecting %s:%d", ctx->host, ctx->port); /* * Packet layout: * 1b: Version (must be 0x04) * 1b: command (0x01 is connect) * 2b: port number, big-endian * 4b: 0x00, 0x00, 0x00, 0x01 (bogus IPv4 addr) * 1b: 0x00 (empty 'userid' field) * nb: hostname, null-terminated */ buf[0] = 0x04; buf[1] = 0x01; sz += 2; memcpy(buf + 2, &port_n, sizeof(port_n)); sz += sizeof(port_n); buf[4] = 0x00; buf[5] = 0x00; buf[6] = 0x00; buf[7] = 0x01; sz += 4; buf[8] = 0x00; sz += 1; memcpy(buf + sz, ctx->host, strlen(ctx->host) + 1); sz += strlen(ctx->host) + 1; r = BIO_write(b->next_bio, buf, sz); if ( -1 == r ) return -1; if ( (size_t) r != sz) return 0; /* server reply: 1 + 1 + 2 + 4 */ r = BIO_read(b->next_bio, buf, 8); if ( -1 == r ) return -1; if ( (size_t) r != 8) return 0; if (buf[1] == 0x5a) { verb("V: proxy4: connected"); ctx->connected = 1; return 1; } return 0; }
void SkIntersectionHelper::dump() const { SkDPoint::Dump(pts()[0]); SkDPoint::Dump(pts()[1]); if (verb() >= SkPath::kQuad_Verb) { SkDPoint::Dump(pts()[2]); } if (verb() >= SkPath::kCubic_Verb) { SkDPoint::Dump(pts()[3]); } }
uint32_t get_certificate_keybits (EVP_PKEY *public_key) { /* In theory, we could use check_bitlen_dsa() and check_bitlen_rsa() */ uint32_t key_bits; switch (public_key->type) { case EVP_PKEY_RSA: verb("V: key type: EVP_PKEY_RSA"); key_bits = BN_num_bits(public_key->pkey.rsa->n); break; case EVP_PKEY_RSA2: verb("V: key type: EVP_PKEY_RSA2"); key_bits = BN_num_bits(public_key->pkey.rsa->n); break; case EVP_PKEY_DSA: verb("V: key type: EVP_PKEY_DSA"); key_bits = BN_num_bits(public_key->pkey.dsa->p); break; case EVP_PKEY_DSA1: verb("V: key type: EVP_PKEY_DSA1"); key_bits = BN_num_bits(public_key->pkey.dsa->p); break; case EVP_PKEY_DSA2: verb("V: key type: EVP_PKEY_DSA2"); key_bits = BN_num_bits(public_key->pkey.dsa->p); break; case EVP_PKEY_DSA3: verb("V: key type: EVP_PKEY_DSA3"); key_bits = BN_num_bits(public_key->pkey.dsa->p); break; case EVP_PKEY_DSA4: verb("V: key type: EVP_PKEY_DSA4"); key_bits = BN_num_bits(public_key->pkey.dsa->p); break; case EVP_PKEY_DH: verb("V: key type: EVP_PKEY_DH"); key_bits = BN_num_bits(public_key->pkey.dh->pub_key); break; case EVP_PKEY_EC: verb("V: key type: EVP_PKEY_EC"); key_bits = EVP_PKEY_bits(public_key); break; // Should we also care about EVP_PKEY_HMAC and EVP_PKEY_CMAC? default: key_bits = 0; die ("unknown public key type"); break; } verb ("V: keybits: %d", key_bits); return key_bits; }
void smooth(const char *fname){ outLC=1; initOutLC(); int l=profileLength; bTrack *tr=new bTrack(fname); for(int i=0,k=0; i<l; i+=wProfStep,k++){ double d; d=100.*k/(l/wProfStep); if(k%10000 ==0) verb("\nSmooother: %4.1f%% (%6i/%i) ",d,k,l/wProfStep); else if(k%1000 ==0) verb("."); double *pr1=tr->getProfile(i,0); // decode the first profile. Decoder uses hasCompl and complFg flags and combines profiles if(smoothProf==0) getMem(smoothProf,profWithFlanksLength+10, "storeCorrTrack"); if(smTmp==0) getMem(smTmp,profWithFlanksLength+10, "storeCorrTrack"); kern->fftx(pr1,0); calcSmoothProfile(&(kern->fx),0, 0); // calculate smooth ptrofile c=\int f*\rho addLCProf(LCorrelation.re,i); } char pfil[4096],wfil[4096]; makeFileName(pfil,trackPath,fname); char *s=strrchr(pfil,'/'); if(s==0) s=wfil; s=strrchr(s,'.'); if(s) *s=0; sprintf(wfil,"%s_sm.bgr",pfil); //================ normalize double tt=0,ee=0,dd=0,nn=0; for(int i=0; i<l; i++) { double x=lcProfile->get(i); ee+=x; nn++; dd+=x*x; } tt=ee; ee/=nn; dd=dd/nn-ee*ee; dd=sqrt(dd); for(int i=0; i<l; i++) { double x=lcProfile->get(i); if(smoothZ){if((x-ee)/dd < smoothZ) x=0;} else {x=x*tr->total/tt/binSize;} lcProfile->set(i,x); } FILE *f=gopen(wfil,"w"); char b[4096]; strcpy(b,fname); s=strrchr(b,'.'); if(s) *s=0; s=strchr(b,'/'); if(s==0) s=b; fprintf(f,"track type=bedGraph name=\"%s_Sm\" description=\"Smoothed track. Width=%.0f\"\n",s, kernelSigma); verb("\n Write Smooth profile...\n"); writeBedGr(f,lcProfile, NA, NA); verb(" Done\n"); }
void enable_seccomp(void) { #ifdef HAVE_SECCOMP_FILTER int status; prctl (PR_SET_NAME, "tlsdate seccomp"); verb ("V: seccomp support is enabled"); if (enable_setter_seccomp()) { status = SETTER_NO_SBOX; _exit (status); } #else verb ("V: seccomp support is disabled"); #endif }
int ParseOptions(int argc, char * argv[]) { if ((argc == 0) || (argv[0][0] == '-')) { cerr << "Query Symbol takes at least one argument" << endl; throw exception(); } ExportedSymbol = argv[0]; cout << "Symbol: Export Symbol is " << ExportedSymbol << endl; if (argc <= 1) return 1; string verb(argv[1]); cout << "Symbol: Verbose is " << verb << endl; if (verb == "0") Verbose = false; else if (verb == "1") Verbose = true; else return 1; return 2; }
QNetworkReply* QWebDAV::list(QString dir, int depth ) { // Make sure the user has already initialized this instance! if (!mInitialized) return 0; // This is the Url of the webdav server + the directory we want a listing of QUrl url(mHostname+dir); // Prepare the query. We want a listing of all properties the WebDAV // server is willing to provide mRequestNumber++; QByteArray *query = new QByteArray(); *query += "<?xml version=\"1.0\" encoding=\"utf-8\" ?>"; *query += "<D:propfind xmlns:D=\"DAV:\">"; *query += "<D:prop xmlns:D=\"DAV:\">"; *query += "<D:getlastmodified/>"; *query += "<D:getlastmodified/>"; *query += "<D:getcontentlength/>"; // *query += "<D:resourcetype/>"; // *query += "<D:quota-used-bytes/>"; // *query += "<D:quota-available-bytes/>"; // *query += "<D:getetag/>"; *query += "<D:getcontenttype/>"; *query += "<D:lockdiscovery/>"; *query += "</D:prop>"; *query += "</D:propfind>"; QBuffer *data = new QBuffer(query); QByteArray verb("PROPFIND"); mRequestQueries[mRequestNumber] = query; mRequestData[mRequestNumber] = data; // Finally send this to the WebDAV server return sendWebdavRequest(url,DAVLIST,verb,data,QString("%1").arg(depth)); }
void calcCovar(){ int nIter=100; cMtx.init(nfiles); for(int i=0; i<nfiles; i++){ for(int j=i; j<nfiles; j++){ verb("Covariations %i~%i: <%s>~<%s> ",i,j,tracks[i]->name,tracks[j]->name); cMtx.calc(i,j); } } char b[2048]; sprintf(b,"%s.cvr",confFile); FILE *f=xopen(b,"wt"); cMtx.print(f); Matrix *x = new Matrix(&cMtx); getMem(eValues,nfiles+10,"eigenVal"); zeroMem(eValues,nfiles); eVectors=eigenVectors(x,eValues,nIter,1.E-3); fputs("eigenVectors\n",f); eVectors->printMtx(f); fputs("eigenValues\n",f); for(int i=0; i<nfiles; i++) fprintf(f,"%.5f; ",eValues[i]); fprintf(f,"\n"); fclose(f); del(x); }
uint32_t verify_signature (SSL *ssl, const char *hostname) { long ssl_verify_result; X509 *certificate; certificate = SSL_get_peer_certificate(ssl); if (NULL == certificate) { die ("Getting certificate failed"); } // In theory, we verify that the cert is valid ssl_verify_result = SSL_get_verify_result(ssl); switch (ssl_verify_result) { case X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT: case X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN: die ("certificate is self signed"); case X509_V_OK: verb ("V: certificate verification passed"); break; default: die ("certification verification error: %ld", ssl_verify_result); } return 0; }
void QWebDAV::processPutFinished(QNetworkReply *reply) { // Check if a prefix exists that must be removed now that it finished QString prefix = reply->request().attribute( QNetworkRequest::Attribute( QNetworkRequest::User+ATTPREFIX)).toString(); if( prefix != "" ) { QString tokens = ""; QString fileNameTemp = reply->request().url().toString().replace(mHostname,"/files/webdav.php/"); QString to = reply->request().url().toString().replace(prefix,""); QString fileName = to; fileName.replace(mHostname,""); if(mTransferLockRequests.contains(fileName)) { TransferLockRequest *request = &(mTransferLockRequests[fileName]); tokens = "<"+fileNameTemp+ "> (<" + request->tokenTemp + ">)" +"</files/webdav.php/" +fileName +"> (<"+request->token+">)"; } QByteArray verb("MOVE"); sendWebdavRequest(reply->request().url(),DAVMOVE,verb,0, to,tokens); } emit uploadComplete( reply->request().url().path().replace( QRegExp("^"+mPathFilter),"").replace(prefix,"")); }
void resize_pipe(int fd) { FILE *f; int r; if ( max_pipe_size<=-2 ) return; if ( max_pipe_size==-1 ) { if ( (f = fopen(PROC_MAX_PIPE_SIZE, "r"))==NULL ) { max_pipe_size = -2; warning(errno, "could not open '%s'", PROC_MAX_PIPE_SIZE); return; } if ( fscanf(f, "%d", &max_pipe_size)!=1 ) { max_pipe_size = -2; warning(errno, "could not read from '%s'", PROC_MAX_PIPE_SIZE); return; } } r = fcntl(fd, F_SETPIPE_SZ, max_pipe_size); if ( r==-1 ) { warning(errno, "could not change pipe size"); } verb("set pipe fd %d to size %d", fd, r); }
uint32_t dns_label_count(char *label, char *delim) { char *label_tmp; char *saveptr; char *saveptr_tmp; uint32_t label_count; label_tmp = strdup(label); label_count = 0; saveptr = NULL; saveptr_tmp = NULL; saveptr = strtok_r(label_tmp, delim, &saveptr); if (NULL != saveptr) { // Did we find our first label? if (saveptr[0] != delim[0]) { label_count++; } do { // Find all subsequent labels label_count++; saveptr_tmp = strtok_r(NULL, delim, &saveptr); } while (NULL != saveptr_tmp); } verb ("V: label found; total label count: %d\n", label_count); free(label_tmp); return label_count; }
uint32_t verify_signature (ssl_context *ssl, const char *hostname) { int ssl_verify_result; ssl_verify_result = ssl_get_verify_result (ssl); if (ssl_verify_result & BADCERT_EXPIRED) { die ("certificate has expired"); } if (ssl_verify_result & BADCERT_REVOKED) { die ("certificate has been revoked"); } if (ssl_verify_result & BADCERT_CN_MISMATCH) { die ("CN and subject AltName mismatch for certificate"); } if (ssl_verify_result & BADCERT_NOT_TRUSTED) { die ("certificate is self-signed or not signed by a trusted CA"); } if (0 == ssl_verify_result) { verb ("V: verify success"); } else { die ("certificate verification error: -0x%04x", -ssl_verify_result); } return 0; }
void Tournament::player_damage(identifier_t owner, Player *p, NPC *npc, int damage, const std::string& weapon) { if (damage) { check_friendly_fire(owner, p); /* get damage levels */ int damage2 = damage / (p->state.server_state.armor ? 2 : 1); /* reduce armor */ if (damage >= p->state.server_state.armor) { p->state.server_state.armor = 0; } else { p->state.server_state.armor -= damage; } /* reduce health */ if (damage2 >= p->state.server_state.health) { /* player dies */ player_dies(p, ""); /* increment owner's frag counter */ std::string verb("killed"); if (npc) { const std::string& die_verb = npc->get_value("die_verb"); if (die_verb.length()) { verb = die_verb; } } for (Players::iterator it = players.begin(); it != players.end(); it++) { Player *fp = *it; if (fp->state.id == owner) { if (fp != p) { fp->state.server_state.frags++; frag_point(fp, p); std::string msg(fp->get_player_name() + " " + verb + " " + p->get_player_name()); add_msg_response(msg.c_str()); if (logger) { logger->log(ServerLogger::LogTypeFrag, msg, fp, p, (npc ? npc->get_name().c_str() : weapon.c_str())); } } else { fp->state.server_state.score -= 1; std::string msg(fp->get_player_name() + " " + verb + " himself"); add_msg_response(msg.c_str()); if (logger) { logger->log(ServerLogger::LogTypeKill, msg, fp, p, (npc ? npc->get_name().c_str() : weapon.c_str())); } } break; } } } else { add_state_response(GPCPlayerHurt, 0, 0); p->state.server_state.health -= damage2; } } }
/** This extracts the first commonName and checks it against hostname. */ uint32_t check_cn (SSL *ssl, const char *hostname) { uint32_t ret; char *cn_buf; X509 *certificate; X509_NAME *xname; cn_buf = malloc(HOST_NAME_MAX + 1); if (NULL == cn_buf) { die ("Unable to allocate memory for cn_buf\n"); } certificate = SSL_get_peer_certificate(ssl); if (NULL == certificate) { die ("Unable to extract certificate\n"); } memset(cn_buf, '\0', (HOST_NAME_MAX + 1)); xname = X509_get_subject_name(certificate); ret = X509_NAME_get_text_by_NID(xname, NID_commonName, cn_buf, HOST_NAME_MAX); if (-1 == ret && ret != strlen(hostname)) { die ("Unable to extract commonName\n"); } if (strcasecmp(cn_buf, hostname)) { verb ("V: commonName mismatch! Expected: %s - received: %s\n", hostname, cn_buf); } else { verb ("V: commonName matched: %s\n", cn_buf); X509_NAME_free(xname); X509_free(certificate); free(cn_buf); return 1; } X509_NAME_free(xname); X509_free(certificate); free(cn_buf); return 0; }
void Nlsrc::withdrawName() { ndn::Name name = commandLineArguments[0]; ndn::Name::Component verb("withdraw"); std::string info = "(Withdraw: " + name.toUri() + ")"; sendNamePrefixUpdate(name, verb, info); }
void Nlsrc::advertiseName() { ndn::Name name = commandLineArguments[0]; ndn::Name::Component verb("advertise"); std::string info = "(Advertise: " + name.toUri() + ")"; sendNamePrefixUpdate(name, verb, info); }
void no_new_privs(void) { #ifdef TARGET_OS_LINUX #ifdef HAVE_PRCTL // XXX: Make this specific to PR_SET_NO_NEW_PRIVS // Check to see if we're already set PR_SET_NO_NEW_PRIVS // This happens in tlsdated earlier than when tlsdate-helper drops // privileges. if (0 == prctl (PR_GET_NO_NEW_PRIVS)) { // Remove the ability to regain privilegess if (0 != prctl (PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0)); die ("Failed to PR_SET_NO_NEW_PRIVS"); } else { verb ("V: Parent process has already set PR_SET_NO_NEW_PRIVS"); } #else verb ("V: we are unwilling to set PR_SET_NO_NEW_PRIVS"); #endif #endif }
/** This extracts the first commonName and checks it against hostname. */ uint32_t check_cn (SSL *ssl, const char *hostname) { int ok = 0; int ret; char *cn_buf; X509 *certificate; X509_NAME *xname; // We cast this to cast away g++ complaining about the following: // error: invalid conversion from ‘void*’ to ‘char*’ cn_buf = (char *) xmalloc(TLSDATE_HOST_NAME_MAX + 1); certificate = SSL_get_peer_certificate(ssl); if (NULL == certificate) { die ("Unable to extract certificate"); } memset(cn_buf, '\0', (TLSDATE_HOST_NAME_MAX + 1)); xname = X509_get_subject_name(certificate); ret = X509_NAME_get_text_by_NID(xname, NID_commonName, cn_buf, TLSDATE_HOST_NAME_MAX); if (-1 == ret || ret != (int) strlen(cn_buf)) { die ("Unable to extract commonName"); } if (strcasecmp(cn_buf, hostname)) { verb ("V: commonName mismatch! Expected: %s - received: %s", hostname, cn_buf); } else { verb ("V: commonName matched: %s", cn_buf); ok = 1; } X509_NAME_free(xname); X509_free(certificate); xfree(cn_buf); return ok; }
void ScaledAray::write(){ char bf[1024]; sprintf(bf,"%s.wig",outFile); FILE *outWigFile=xopen(bf,"wt"); verb("\nwrite WIG correlations"); ScoredRange pos, pos0; min=1.e+128; max=-1.e+128; for(int i=0; i<profileLength; i++){ if(min > array[i]) min = array[i]; if(max < array[i]) max = array[i]; } double lmax=-1000; fprintf(outWigFile,"track type=wiggle_0 "); char *s=strrchr(outFile,'/'); if(s==0) s=outFile; else s++; fprintf(outWigFile,"description=\"correlation: %s\" \n",s); fprintf(outWigFile,"#Param "); if((outWIG & WIG_BASE) == WIG_BASE ) fprintf(outWigFile,"BASE " ); if((outWIG & WIG_CENTER)== WIG_CENTER) fprintf(outWigFile,"CENTER "); if((outWIG & WIG_SUM) == WIG_SUM ) fprintf(outWigFile,"SUM " ); if((outWIG & WIG_MULT) == WIG_MULT ) fprintf(outWigFile,"MULT " ); fprintf(outWigFile,"\n"); fprintf(outWigFile,"#Scale data: min=%.4f; max=%.4f; LOG scale: x=1000*log(a*array[i]+b); a=(e-1)/(max-min); b=1-min*a\n", min,max); fprintf(outWigFile,"#Source statstics: av1=%.4f; av2=%.4f; sd1=%.4f; sd2=%.4f\n", bTrack1.av0,bTrack2.av0, bTrack1.sd0,bTrack2.sd0); int kmin=1000, kmax=0; double a=(2.718281828-1)/(max-min), b=1-min*a; for(int i=0; i<profileLength; i++){ double z=a*array[i]+b; // double z=(array[i]+max-2*min)/(max-min); if(lmax < z) lmax=z; int k=(int)(log(z)*1000); if(kmin > k) kmin=k; if(kmax < k) kmax=k; //if(k > 998) deb("maxPos=%i k=%i",i,kmax); double v1=bTrack1.getValue(i,0), v2=bTrack2.getValue(i,0); if(k>=outThreshold && v1*v2!=0){ filePos2Pos(i,&pos,stepSize); if(pos.chrom != pos0.chrom || pos.beg-pos0.beg > stepSize){ fprintf(outWigFile,"fixedStep chrom=%s start=%li step=%i span=%i\n", pos.chrom,pos.beg,stepSize,stepSize); } pos0.chrom=pos.chrom; pos0.beg=pos.beg; fprintf(outWigFile,"%i\n",k); //int bb1=bTrack1.bytes[i], bb2=bTrack2.bytes[i]; //double cc=(v1-bTrack1.av0)*(v2-bTrack2.av0)/bTrack1.sd0/bTrack2.sd0; // fprintf(outWigFile,"%i\t%.3f\t%.4f\tv1=%.2f\tv2=%.2f\t%i\t%i\n",k,array[i],cc,v1,v2,bb1,bb2); //if(cc>10000){ // deb("%i\t%.3f\t%.4f\tv1=%.2f\tv2=%.2f\t%i\t%i",k,array[i],cc,v1,v2,bb1,bb2); //} } } //deb("\nkmin=%i kmax=%i lmax=%f",kmin, kmax,lmax); fclose(outWigFile); }
void LinearPDEConstrainedObj::initEquations( const Array<Expr>& stateVars, const Array<Expr>& adjointVars, const Array<Array<Expr> >& fixedVarsInStateEqns, const Array<Array<Expr> >& fixedVarsInStateEqnsVals, const Array<Array<Expr> >& fixedVarsInAdjointEqns, const Array<Array<Expr> >& fixedVarsInAdjointEqnsVals ) { Tabs tab(0); PLAYA_MSG2(verb(), tab << "setting up linear equations"); for (int i=0; i<stateVars.size(); i++) { Tabs tab1; PLAYA_MSG3(verb(), tab1 << "setting up state equation #" << i); Expr fixedVars = new ListExpr(fixedVarsInStateEqns[i]); Expr fixedVarVals = new ListExpr(fixedVarsInStateEqnsVals[i]); LinearProblem stateProb = Lagrangian().linearVariationalProb(adjointVars[i], adjointVarVals(i), stateVars[i], fixedVars, fixedVarVals); stateProbs_.append(stateProb); } for (int i=0; i<adjointVars.size(); i++) { Tabs tab1; PLAYA_MSG3(verb(), tab1 << "setting up adjoint equation #" << i); Expr fixedVars = new ListExpr(fixedVarsInAdjointEqns[i]); Expr fixedVarVals = new ListExpr(fixedVarsInAdjointEqnsVals[i]); LinearProblem adjointProb = Lagrangian().linearVariationalProb(stateVars[i], stateVarVals(i), adjointVars[i], fixedVars, fixedVarVals); adjointProbs_.append(adjointProb); } PLAYA_MSG2(verb(), tab << "done setting up linear equations"); }
//===================== Write the local correlation into the bedGraph file ===== void writeLC(){ char bf[1024]; LCExists=outLC && dHist.n[0] && dHist.n[1]; if(dHist.n[0]==0 || dHist.n[1]==0){ verb("\nLocal Correlations contains no data\n"); writeLog("\nLocal Correlations contains no data\n"); return; } verb("\nwrite Local Correlations\n"); renormDistrib(); writeBedGr(outFile, lcProfile, L_lcTreshold,R_lcTreshold); //========================================== Write histograms =============== if(writeDistr) { sprintf(bf,"%s.LChist",outFile); FILE *lcHistF=fopen(bf,"wt"); NormWHist.print(lcHistF); fclose(lcHistF); } dHist.clear(); NormWHist.clear(); }
void bTrack::makeBinTrack(){ Timer tm; verb ("****** Make binary track <%s> ******\n", name); writeLog(" Make binary track <%s>\n",name); //===================================================== prepare track file name if (pcorProfile!=0) verb("=== pcorProfile= <%s>\n",pcorProfile); trackType=getTrackType(name); //===================================================================================== initProfile(); //============ Allocate arrays char pfil[4096]; readInputTrack(makeFileName(pfil,trackPath,name)); //============ Read tracks //====================================================================== verb("Finalize profiles... \n"); finProfile(); //============ Calculate min,max,average; convert to bytes verb("Write profiles... \n"); writeProfilePrm(); writeByteProfile(); //============ write binary profiles writeLog(" Make binary track -> OK. Time=%s\n",tm.getTime()); return; }
void print_bytes(char* data, int length, int output_line_len) { char asciiStr[TMP_STR_SIZE], hexStr[TMP_STR_SIZE], tmpChar[TMP_CHAR_SIZE]; int i; if ( output_line_len > (TMP_STR_SIZE - 1) / 2 ) { output_line_len = (TMP_STR_SIZE - 1) / 2; } verb(VERB_2, "[%s] printing buffer of len %d at %x", __func__, length, data); while (length > 0 ) { memset(asciiStr, '\0', TMP_STR_SIZE); memset(hexStr, '\0', TMP_STR_SIZE); memset(tmpChar, '\0', 8); for (i = 0; i < output_line_len; i++ ) { if ( length > 0 ) { if ( (data[i] > 31) && (data[i] != 127) ) { snprintf(tmpChar, TMP_CHAR_SIZE, " %c", data[i]); } else { snprintf(tmpChar, TMP_CHAR_SIZE, " "); } strncat(asciiStr, tmpChar, TMP_CHAR_SIZE); snprintf(tmpChar, TMP_CHAR_SIZE, "%02X ", (unsigned char)data[i]); strncat(hexStr, tmpChar, TMP_CHAR_SIZE); length--; } else { snprintf(tmpChar, TMP_CHAR_SIZE, " "); strncat(asciiStr, tmpChar, TMP_CHAR_SIZE); snprintf(tmpChar, TMP_CHAR_SIZE, "-- "); strncat(hexStr, tmpChar, TMP_CHAR_SIZE); } } data += output_line_len; verb(VERB_2, "%s *** %s", hexStr, asciiStr); } }
uint32_t check_name (SSL *ssl, const char *hostname) { uint32_t ret; ret = check_cn(ssl, hostname); ret += check_san(ssl, hostname); if (0 != ret && 0 < ret) { verb ("V: hostname verification passed"); } else { die ("hostname verification failed for host %s!", host); } return ret; }
QNetworkReply* QWebDAV::mkdir(QString dirName) { // Make sure the user has already initialized this instance! if (!mInitialized) return 0; // This is the URL of the webdav server + the file we want to get QUrl url(mHostname+dirName); // Finally send this to the WebDAV server QByteArray verb("MKCOL"); QNetworkReply *reply = sendWebdavRequest(url,DAVMKCOL,verb); return reply; }