bool UploadDump(const char* file, const char* user, int build, int branch, DelegateI<Prog_s>* progress) { Logger log; log.write("---------------------------------------\r\n"); time_t ltime; /* calendar time */ ltime=time(NULL); /* get current cal time */ #ifdef WIN32 char buff[255] = {0}; struct tm t; localtime_s(&t, <ime); asctime_s(buff, 255, &t); #else struct tm *t = localtime(<ime); char* buff = asctime(t); #endif log.write("%s\r\n", buff); log.write("---------------------------------------\r\n"); log.write("Uploaded crash dump: [%s]\r\n", file); gcString dump(file); if (PrepDumpForUpload(dump) == false) { log.write("Failed to prepare crash dump.\r\n"); return false; } else { log.write("Prepared crash dump to: [%s]\r\n", dump.c_str()); } std::string os = UTIL::OS::getOSString(); HttpHandle hh(DUMP_UPLOAD_URL); if (progress) hh->getProgressEvent() += progress; hh->setUserAgent(DUMP_UPLOAD_AGENT); hh->cleanUp(); hh->addPostText("os", os.c_str()); hh->addPostText("build", build); hh->addPostText("appid", branch); if (user) hh->addPostText("user", user); hh->addPostFile("crashfile", dump.c_str()); try { hh->postWeb(); } catch (gcException &except) { log.write("Failed to upload crash: %s [%d.%d].\r\n", except.getErrMsg(), except.getErrId(), except.getSecErrId()); return false; } TiXmlDocument doc; doc.LoadBuffer(const_cast<char*>(hh->getData()), hh->getDataSize()); try { XML::processStatus(doc, "crashupload"); log.write("Uploaded dump\r\n"); UTIL::FS::delFile(UTIL::FS::Path(dump, "", true)); } catch (gcException &) { log.write("Bad status returned from upload crash dump.\r\n"); gcString res; res.assign(hh->getData(), hh->getDataSize()); log.write("Result: \r\n\r\n%s\r\n\r\n", res.c_str()); return false; } return true; }
inline size_t hash_combine(size_t seed, const T& v) { hash<T> hh; auto h = hh(v); return hash_value_combine(h, seed); }
void Md5::transformBlock(const uint8_t *block) { uint32_t a = a0, b = b0, c = c0, d = d0, m[16]; const uint8_t *p = block; for (int i = 0; i < 16; ++i) { uint8_t b0 = p[0]; uint8_t b1 = p[1]; uint8_t b2 = p[2]; uint8_t b3 = p[3]; p += 4; m[i] = Convert::combineQuadBytes(b0, b1, b2, b3); } ff(a, b, c, d, m[ 0], S11, (uint32_t)K11); ff(d, a, b, c, m[ 1], S12, (uint32_t)K12); ff(c, d, a, b, m[ 2], S13, (uint32_t)K13); ff(b, c, d, a, m[ 3], S14, (uint32_t)K14); ff(a, b, c, d, m[ 4], S11, (uint32_t)K15); ff(d, a, b, c, m[ 5], S12, (uint32_t)K16); ff(c, d, a, b, m[ 6], S13, (uint32_t)K17); ff(b, c, d, a, m[ 7], S14, (uint32_t)K18); ff(a, b, c, d, m[ 8], S11, (uint32_t)K19); ff(d, a, b, c, m[ 9], S12, (uint32_t)K110); ff(c, d, a, b, m[10], S13, (uint32_t)K111); ff(b, c, d, a, m[11], S14, (uint32_t)K112); ff(a, b, c, d, m[12], S11, (uint32_t)K113); ff(d, a, b, c, m[13], S12, (uint32_t)K114); ff(c, d, a, b, m[14], S13, (uint32_t)K115); ff(b, c, d, a, m[15], S14, (uint32_t)K116); gg(a, b, c, d, m[ 1], S21, (uint32_t)K21); gg(d, a, b, c, m[ 6], S22, (uint32_t)K22); gg(c, d, a, b, m[11], S23, (uint32_t)K23); gg(b, c, d, a, m[ 0], S24, (uint32_t)K24); gg(a, b, c, d, m[ 5], S21, (uint32_t)K25); gg(d, a, b, c, m[10], S22, (uint32_t)K26); gg(c, d, a, b, m[15], S23, (uint32_t)K27); gg(b, c, d, a, m[ 4], S24, (uint32_t)K28); gg(a, b, c, d, m[ 9], S21, (uint32_t)K29); gg(d, a, b, c, m[14], S22, (uint32_t)K210); gg(c, d, a, b, m[ 3], S23, (uint32_t)K211); gg(b, c, d, a, m[ 8], S24, (uint32_t)K212); gg(a, b, c, d, m[13], S21, (uint32_t)K213); gg(d, a, b, c, m[ 2], S22, (uint32_t)K214); gg(c, d, a, b, m[ 7], S23, (uint32_t)K215); gg(b, c, d, a, m[12], S24, (uint32_t)K216); hh(a, b, c, d, m[ 5], S31, (uint32_t)K31); hh(d, a, b, c, m[ 8], S32, (uint32_t)K32); hh(c, d, a, b, m[11], S33, (uint32_t)K33); hh(b, c, d, a, m[14], S34, (uint32_t)K34); hh(a, b, c, d, m[ 1], S31, (uint32_t)K35); hh(d, a, b, c, m[ 4], S32, (uint32_t)K36); hh(c, d, a, b, m[ 7], S33, (uint32_t)K37); hh(b, c, d, a, m[10], S34, (uint32_t)K38); hh(a, b, c, d, m[13], S31, (uint32_t)K39); hh(d, a, b, c, m[ 0], S32, (uint32_t)K310); hh(c, d, a, b, m[ 3], S33, (uint32_t)K311); hh(b, c, d, a, m[ 6], S34, (uint32_t)K312); hh(a, b, c, d, m[ 9], S31, (uint32_t)K313); hh(d, a, b, c, m[12], S32, (uint32_t)K314); hh(c, d, a, b, m[15], S33, (uint32_t)K315); hh(b, c, d, a, m[ 2], S34, (uint32_t)K316); ii(a, b, c, d, m[ 0], S41, (uint32_t)K41); ii(d, a, b, c, m[ 7], S42, (uint32_t)K42); ii(c, d, a, b, m[14], S43, (uint32_t)K43); ii(b, c, d, a, m[ 5], S44, (uint32_t)K44); ii(a, b, c, d, m[12], S41, (uint32_t)K45); ii(d, a, b, c, m[ 3], S42, (uint32_t)K46); ii(c, d, a, b, m[10], S43, (uint32_t)K47); ii(b, c, d, a, m[ 1], S44, (uint32_t)K48); ii(a, b, c, d, m[ 8], S41, (uint32_t)K49); ii(d, a, b, c, m[15], S42, (uint32_t)K410); ii(c, d, a, b, m[ 6], S43, (uint32_t)K411); ii(b, c, d, a, m[13], S44, (uint32_t)K412); ii(a, b, c, d, m[ 4], S41, (uint32_t)K413); ii(d, a, b, c, m[11], S42, (uint32_t)K414); ii(c, d, a, b, m[ 2], S43, (uint32_t)K415); ii(b, c, d, a, m[ 9], S44, (uint32_t)K416); a0 += a; b0 += b; c0 += c; d0 += d; }
// specialization for foreach ... in (keys <hash>) {} int ForEachStatement::execKeys(QoreValue& return_value, ExceptionSink* xsink) { // instantiate local variables LVListInstantiator lvi(lvars, xsink); assert(get_node_type(list) == NT_TREE); QoreTreeNode* t = reinterpret_cast<QoreTreeNode*>(list); QoreHashNodeHolder hash(reinterpret_cast<QoreHashNode*>(t->left->eval(xsink)), xsink); if (*xsink || !code) return 0; qore_type_t hnt = get_node_type(*hash); // create an empty reference holder for a temporary hash in case the operand is an object ReferenceHolder<QoreHashNode> hh(xsink); const QoreHashNode* h; // if the result is not a hash, then return if (hnt == NT_OBJECT) { hh = reinterpret_cast<const QoreObject *>(*hash)->getRuntimeMemberHash(xsink); if (*xsink) return 0; h = *hh; } else if (hnt != NT_HASH) { return 0; } else h = reinterpret_cast<const QoreHashNode*>(*hash); ConstHashIterator hi(h); int rc = 0; int i = 0; while (hi.next()) { { LValueHelper n(var, xsink); if (!n) break; // assign variable to current key value in list if (n.assign(new QoreStringNode(hi.getKey()))) break; } // set offset in thread-local data for "$#" ImplicitElementHelper eh(i++); // execute "foreach" body if (((rc = code->execImpl(return_value, xsink)) == RC_BREAK) || *xsink) { rc = 0; break; } if (rc == RC_RETURN) break; else if (rc == RC_CONTINUE) rc = 0; } return rc; }
/* MDblock(MDp,X) * Update message digest buffer MDp->buffer using 16-word data block X. * Assumes all 16 words of X are full of data. * Does not update MDp->count. * This routine is not user-callable. */ static void MDblock(MD4_CTX *MDp, unsigned char *Xb) { register unsigned int tmp, A, B, C, D; unsigned int X[16]; int i; for (i = 0; i < 16; ++i) { X[i] = Xb[0] + (Xb[1] << 8) + (Xb[2] << 16) + (Xb[3] << 24); Xb += 4; } A = MDp->buffer[0]; B = MDp->buffer[1]; C = MDp->buffer[2]; D = MDp->buffer[3]; /* Update the message digest buffer */ ff(A, B, C, D, 0, fs1); /* Round 1 */ ff(D, A, B, C, 1, fs2); ff(C, D, A, B, 2, fs3); ff(B, C, D, A, 3, fs4); ff(A, B, C, D, 4, fs1); ff(D, A, B, C, 5, fs2); ff(C, D, A, B, 6, fs3); ff(B, C, D, A, 7, fs4); ff(A, B, C, D, 8, fs1); ff(D, A, B, C, 9, fs2); ff(C, D, A, B, 10, fs3); ff(B, C, D, A, 11, fs4); ff(A, B, C, D, 12, fs1); ff(D, A, B, C, 13, fs2); ff(C, D, A, B, 14, fs3); ff(B, C, D, A, 15, fs4); gg(A, B, C, D, 0, gs1); /* Round 2 */ gg(D, A, B, C, 4, gs2); gg(C, D, A, B, 8, gs3); gg(B, C, D, A, 12, gs4); gg(A, B, C, D, 1, gs1); gg(D, A, B, C, 5, gs2); gg(C, D, A, B, 9, gs3); gg(B, C, D, A, 13, gs4); gg(A, B, C, D, 2, gs1); gg(D, A, B, C, 6, gs2); gg(C, D, A, B, 10, gs3); gg(B, C, D, A, 14, gs4); gg(A, B, C, D, 3, gs1); gg(D, A, B, C, 7, gs2); gg(C, D, A, B, 11, gs3); gg(B, C, D, A, 15, gs4); hh(A, B, C, D, 0, hs1); /* Round 3 */ hh(D, A, B, C, 8, hs2); hh(C, D, A, B, 4, hs3); hh(B, C, D, A, 12, hs4); hh(A, B, C, D, 2, hs1); hh(D, A, B, C, 10, hs2); hh(C, D, A, B, 6, hs3); hh(B, C, D, A, 14, hs4); hh(A, B, C, D, 1, hs1); hh(D, A, B, C, 9, hs2); hh(C, D, A, B, 5, hs3); hh(B, C, D, A, 13, hs4); hh(A, B, C, D, 3, hs1); hh(D, A, B, C, 11, hs2); hh(C, D, A, B, 7, hs3); hh(B, C, D, A, 15, hs4); MDp->buffer[0] += A; MDp->buffer[1] += B; MDp->buffer[2] += C; MDp->buffer[3] += D; }
int main (int argc, char * argv[]) { std::string ifilename; std::string ofilename; po::options_description desc ("Allow options"); double refCellSize; int nx; double gap; desc.add_options() ("help,h", "print this message") ("refCellSize,n", po::value<double > (&refCellSize)->default_value (0.35), "ref") ("nx", po::value<int > (&nx)->default_value (10), "number of layers on x") ("gap,g", po::value<double > (&gap)->default_value (0.1), "gap between the wall and original the simulation box") ("output-file-name,o", po::value<std::string > (&ofilename)->default_value (std::string("out.gro"), "output conf file name")) ("input-file-name,f", po::value<std::string > (&ifilename)->default_value (std::string("conf.gro"), "input conf file name")); po::variables_map vm; po::store(po::parse_command_line(argc, argv, desc), vm); po::notify (vm); if (vm.count("help") || vm.count("h")){ std::cout << desc<< "\n"; return 0; } std::vector<int > resdindex; std::vector<std::string > resdname; std::vector<std::string > atomname; std::vector<int > atomindex; std::vector<std::vector<double > > posi; std::vector<std::vector<double > > velo; std::vector<double > boxsize; GroFileManager::read (ifilename, resdindex, resdname, atomname, atomindex, posi, velo, boxsize); std::vector<double > hh(3); hh[0] = refCellSize; int ny = boxsize[1] / refCellSize; int nz = boxsize[2] / refCellSize; hh[1] = boxsize[1] / double (ny); hh[2] = boxsize[2] / double (nz); regulateCoord (posi, boxsize); double shift1 = nx * hh[0] + gap; double shift2 = shift1 + boxsize[0] + gap; boxsize[0] += shift1 * 2; int natom = posi.size(); int naddHalf = nx * ny * nz * 2; int natomNew = natom + naddHalf + naddHalf; printf ("# %dx2 new atoms are added, number density is %f\n", naddHalf, 2 / (hh[0] * hh[1] * hh[2])); resdindex.resize(natomNew); resdname.resize(natomNew); atomindex.resize(natomNew); atomname.resize(natomNew); posi.resize(natomNew); velo.resize(natomNew); for (int i = 0; i < natom; ++i){ posi[i][0] += shift1; } int indexShift = 0; for (int ix = 0; ix < nx; ++ix){ for (int iy = 0; iy < ny; ++iy){ for (int iz = 0; iz < nz; ++iz){ resdindex[natom+indexShift] = resdindex[natom-1] + indexShift + 1; atomindex[natom+indexShift] = atomindex[natom-1] + indexShift + 1; resdname[natom+indexShift] = "WA"; atomname[natom+indexShift] = "C"; posi[natom+indexShift].resize(3); posi[natom+indexShift][0] = (ix+0.25) * hh[0]; posi[natom+indexShift][1] = (iy+0.25) * hh[1]; posi[natom+indexShift][2] = (iz+0.25) * hh[2]; velo[natom+indexShift].resize(3, 0.); indexShift ++; resdindex[natom+indexShift] = resdindex[natom-1] + indexShift + 1; atomindex[natom+indexShift] = atomindex[natom-1] + indexShift + 1; resdname[natom+indexShift] = "WA"; atomname[natom+indexShift] = "C"; posi[natom+indexShift].resize(3); posi[natom+indexShift][0] = (ix+0.25) * hh[0] + 0.5 * hh[0]; posi[natom+indexShift][1] = (iy+0.25) * hh[1] + 0.5 * hh[1]; posi[natom+indexShift][2] = (iz+0.25) * hh[2] + 0.5 * hh[2]; velo[natom+indexShift].resize(3, 0.); indexShift ++; } } } for (int ix = 0; ix < nx; ++ix){ for (int iy = 0; iy < ny; ++iy){ for (int iz = 0; iz < nz; ++iz){ resdindex[natom+indexShift] = resdindex[natom-1] + indexShift + 1; atomindex[natom+indexShift] = atomindex[natom-1] + indexShift + 1; resdname[natom+indexShift] = "WB"; atomname[natom+indexShift] = "C"; posi[natom+indexShift].resize(3); posi[natom+indexShift][0] = (ix+0.25) * hh[0] + shift2; posi[natom+indexShift][1] = (iy+0.25) * hh[1]; posi[natom+indexShift][2] = (iz+0.25) * hh[2]; velo[natom+indexShift].resize(3, 0.); indexShift ++; resdindex[natom+indexShift] = resdindex[natom-1] + indexShift + 1; atomindex[natom+indexShift] = atomindex[natom-1] + indexShift + 1; resdname[natom+indexShift] = "WB"; atomname[natom+indexShift] = "C"; posi[natom+indexShift].resize(3); posi[natom+indexShift][0] = (ix+0.25) * hh[0] + 0.5 * hh[0] + shift2; posi[natom+indexShift][1] = (iy+0.25) * hh[1] + 0.5 * hh[1]; posi[natom+indexShift][2] = (iz+0.25) * hh[2] + 0.5 * hh[2]; velo[natom+indexShift].resize(3, 0.); indexShift ++; } } } GroFileManager::write (ofilename, resdindex, resdname, atomname, atomindex, posi, velo, boxsize); FILE * fp = fopen ("topol.top", "w"); fprintf (fp, "#include \"system.itp\"\n[ molecules ]\nSOL %d\nTWALLA %d\nTWALLB %d\n", natom/3, naddHalf, naddHalf); fclose (fp); return 0; }
void XmlProxyCallback::_writeField(const int &iTag, const MCD_STR &sTagName, const MCD_STR &sData, taf::JceOutputStream<taf::BufferWriter> & os) { if (TC_Common::lower(sTagName) == "bool") { taf::Bool bValue = TC_Common::upper(sData) == "TRUE"; os.write(bValue, iTag); } else if (TC_Common::lower(sTagName) == "byte") { taf::Char cValue; if (sData.size() > 1) { cValue = TC_Common::x2c(sData); } os.write(cValue,iTag); } else if (TC_Common::lower(sTagName) == "short") { os.write(TC_Common::strto<taf::Short>(sData), iTag); } else if (TC_Common::lower(sTagName) == "int") { os.write(TC_Common::strto<taf::Int32>(sData), iTag); } else if (TC_Common::lower(sTagName) == "long") { os.write(TC_Common::strto<taf::Int64>(sData), iTag); } else if (TC_Common::lower(sTagName) == "float") { os.write(TC_Common::strto<taf::Float>(sData), iTag); } else if (TC_Common::lower(sTagName) == "double") { os.write(TC_Common::strto<taf::Double>(sData), iTag); } else if (TC_Common::lower(sTagName) == "string") { os.write(sData, iTag); } else if (TC_Common::lower(sTagName) == "enum") { os.write(TC_Common::strto<taf::Int32>(sData), iTag); } else if (TC_Common::lower(sTagName) == "struct") { DataHead h(DataHead::eStructBegin, iTag); h.writeTo(os); _xmlReq.IntoElem(); while (_xmlReq.FindElem()) { int iSubTag = TC_Common::strto<int>(_xmlReq.GetAttrib("tag")); _writeField(iSubTag, _xmlReq.GetTagName(), _xmlReq.GetData(), os); } _xmlReq.OutOfElem(); h.setType(DataHead::eStructEnd); h.setTag(0); h.writeTo(os); } else if (TC_Common::lower(sTagName) == "vector") { DataHead h(DataHead::eList, iTag); h.writeTo(os); _xmlReq.IntoElem(); int n = 0; taf::JceOutputStream<taf::BufferWriter> vectorCt; while (_xmlReq.FindElem()) { ++ n; int iSubTag = 0; _writeField(iSubTag, _xmlReq.GetTagName(), _xmlReq.GetData(), vectorCt); } _xmlReq.OutOfElem(); os.write(n, 0); os.writeBuf(vectorCt.getBuffer(), vectorCt.getLength()); } else if (TC_Common::lower(sTagName) == "vector_char") { DataHead h(DataHead::eSimpleList, iTag); h.writeTo(os); DataHead hh(DataHead::eChar, 0); hh.writeTo(os); string sBin = TC_Common::str2bin(_xmlReq.GetData()); os.write(sBin.length(), 0); os.writeBuf(sBin.c_str(), sBin.length()); } else if (TC_Common::lower(sTagName) == "map") { DataHead h(DataHead::eMap, iTag); h.writeTo(os); _xmlReq.IntoElem();//into map int n = 0 ; taf::JceOutputStream<taf::BufferWriter> mapCt; while (_xmlReq.FindElem())//find entry { ++ n; _xmlReq.IntoElem();//into entry for (int i = 0 ; i < 2; i++) { if (_xmlReq.FindElem())//find key or value { _writeField(i, _xmlReq.GetTagName(), _xmlReq.GetData(), mapCt); } } _xmlReq.OutOfElem();//out entry } _xmlReq.OutOfElem();//out map os.write(n,0); os.writeBuf(mapCt.getBuffer(), mapCt.getLength()); } }
/*********************************************************************************************** * 函数名称:void md5_ProChunk() * 函数功能:md5分组处理 ***********************************************************************************************/ void md5_ProChunk() { md5_a=md5_data[0]; md5_b=md5_data[1]; md5_c=md5_data[2]; md5_d=md5_data[3]; /* 第一轮运算 */ ff(md5_x[ 0], S11, 0xd76aa478); /* 1 */ ff(md5_x[ 1], S12, 0xe8c7b756); /* 2 */ ff(md5_x[ 2], S13, 0x242070db); /* 3 */ ff(md5_x[ 3], S14, 0xc1bdceee); /* 4 */ ff(md5_x[ 4], S11, 0xf57c0faf); /* 5 */ ff(md5_x[ 5], S12, 0x4787c62a); /* 6 */ ff(md5_x[ 6], S13, 0xa8304613); /* 7 */ ff(md5_x[ 7], S14, 0xfd469501); /* 8 */ ff(md5_x[ 8], S11, 0x698098d8); /* 9 */ ff(md5_x[ 9], S12, 0x8b44f7af); /* 10 */ ff(md5_x[10], S13, 0xffff5bb1); /* 11 */ ff(md5_x[11], S14, 0x895cd7be); /* 12 */ ff(md5_x[12], S11, 0x6b901122); /* 13 */ ff(md5_x[13], S12, 0xfd987193); /* 14 */ ff(md5_x[14], S13, 0xa679438e); /* 15 */ ff(md5_x[15], S14, 0x49b40821); /* 16 */ /* 第二轮运算 */ gg(md5_x[ 1], S21, 0xf61e2562); /* 17 */ gg(md5_x[ 6], S22, 0xc040b340); /* 18 */ gg(md5_x[11], S23, 0x265e5a51); /* 19 */ gg(md5_x[ 0], S24, 0xe9b6c7aa); /* 20 */ gg(md5_x[ 5], S21, 0xd62f105d); /* 21 */ gg(md5_x[10], S22, 0x2441453); /* 22 */ gg(md5_x[15], S23, 0xd8a1e681); /* 23 */ gg(md5_x[ 4], S24, 0xe7d3fbc8); /* 24 */ gg(md5_x[ 9], S21, 0x21e1cde6); /* 25 */ gg(md5_x[14], S22, 0xc33707d6); /* 26 */ gg(md5_x[ 3], S23, 0xf4d50d87); /* 27 */ gg(md5_x[ 8], S24, 0x455a14ed); /* 28 */ gg(md5_x[13], S21, 0xa9e3e905); /* 29 */ gg(md5_x[ 2], S22, 0xfcefa3f8); /* 30 */ gg(md5_x[ 7], S23, 0x676f02d9); /* 31 */ gg(md5_x[12], S24, 0x8d2a4c8a); /* 32 */ /* 第三轮运算 */ hh(md5_x[ 5], S31, 0xfffa3942); /* 33 */ hh(md5_x[ 8], S32, 0x8771f681); /* 34 */ hh(md5_x[11], S33, 0x6d9d6122); /* 35 */ hh(md5_x[14], S34, 0xfde5380c); /* 36 */ hh(md5_x[ 1], S31, 0xa4beea44); /* 37 */ hh(md5_x[ 4], S32, 0x4bdecfa9); /* 38 */ hh(md5_x[ 7], S33, 0xf6bb4b60); /* 39 */ hh(md5_x[10], S34, 0xbebfbc70); /* 40 */ hh(md5_x[13], S31, 0x289b7ec6); /* 41 */ hh(md5_x[ 0], S32, 0xeaa127fa); /* 42 */ hh(md5_x[ 3], S33, 0xd4ef3085); /* 43 */ hh(md5_x[ 6], S34, 0x4881d05); /* 44 */ hh(md5_x[ 9], S31, 0xd9d4d039); /* 45 */ hh(md5_x[12], S32, 0xe6db99e5); /* 46 */ hh(md5_x[15], S33, 0x1fa27cf8); /* 47 */ hh(md5_x[ 2], S34, 0xc4ac5665); /*48 */ /* 第四轮运算 */ ii(md5_x[ 0], S41, 0xf4292244); /* 49 */ ii(md5_x[ 7], S42, 0x432aff97); /* 50 */ ii(md5_x[14], S43, 0xab9423a7); /* 51 */ ii(md5_x[ 5], S44, 0xfc93a039); /* 52 */ ii(md5_x[12], S41, 0x655b59c3); /* 53 */ ii(md5_x[ 3], S42, 0x8f0ccc92); /* 54 */ ii(md5_x[10], S43, 0xffeff47d); /* 55 */ ii(md5_x[ 1], S44, 0x85845dd1); /* 56 */ ii(md5_x[ 8], S41, 0x6fa87e4f); /* 57 */ ii(md5_x[15], S42, 0xfe2ce6e0); /* 58 */ ii(md5_x[ 6], S43, 0xa3014314); /* 59 */ ii(md5_x[13], S44, 0x4e0811a1); /* 60 */ ii(md5_x[ 4], S41, 0xf7537e82); /* 61 */ ii(md5_x[11], S42, 0xbd3af235); /* 62 */ ii(md5_x[ 2], S43, 0x2ad7d2bb); /* 63 */ ii(md5_x[ 9], S44, 0xeb86d391); /* 64 */ md5_data[0] += md5_a; md5_data[1] += md5_b; md5_data[2] += md5_c; md5_data[3] += md5_d; }
bool UploadDump(const char* file, const char* user, int build, int branch, DelegateI<Prog_s&>* progress, const char* szTracer) { if (build == 0) build = 9999; if (branch == 0) branch = BUILDID_PUBLIC; g_Logger.write("---------------------------------------\r\n"); time_t ltime; /* calendar time */ ltime=time(nullptr); /* get current cal time */ #if defined(WIN32) && !defined(__MINGW32__) char buff[255] = {0}; struct tm t; localtime_s(&t, <ime); asctime_s(buff, 255, &t); #else struct tm *t = localtime(<ime); char* buff = asctime(t); #endif g_Logger.write("%s\r\n", buff); g_Logger.write("---------------------------------------\r\n"); g_Logger.write("Uploaded crash dump: [%s]\r\n", file); gcString dump(file); gcString tracer(szTracer); gcString log(dump + ".log"); if (PrepDumpForUpload(dump) == false) { g_Logger.write("Failed to prepare crash dump.\r\n"); return false; } else { g_Logger.write("Prepared crash dump to: [%s]\r\n", dump.c_str()); } if (!tracer.empty()) { try { auto valid = false; UTIL::FS::FileHandle fh; std::function<void(const char*, uint32)> write = [&fh, &valid, log](const char* szData, uint32 nSize) { if (!valid) fh.open(log.c_str(), UTIL::FS::FILE_WRITE); valid = true; fh.write(szData, nSize); }; DumpTracerToFile(tracer, write); if (!valid) log = ""; } catch (...) { log = ""; } if (!log.empty()) PrepDumpForUpload(log); #ifdef WIN32 //Let desura exit now. gcString tracerEventName("Global\\{0}Event", tracer); auto hHandle = OpenEvent(EVENT_MODIFY_STATE, FALSE, tracerEventName.c_str()); if (hHandle) { SetEvent(hHandle); CloseHandle(hHandle); } #endif } std::string os = UTIL::OS::getOSString(); HttpHandle hh(DUMP_UPLOAD_URL); if (progress) hh->getProgressEvent() += progress; hh->setUserAgent(DUMP_UPLOAD_AGENT); hh->cleanUp(); hh->addPostText("os", os.c_str()); hh->addPostText("build", build); hh->addPostText("appid", branch); if (user) hh->addPostText("user", user); hh->addPostFile("crashfile", dump.c_str()); if (!log.empty()) hh->addPostFile("crashlog", log.c_str()); try { hh->postWeb(); } catch (gcException &except) { g_Logger.write("Failed to upload crash: %s [%d.%d].\r\n", except.getErrMsg(), except.getErrId(), except.getSecErrId()); return false; } XML::gcXMLDocument doc(const_cast<char*>(hh->getData()), hh->getDataSize()); try { doc.ProcessStatus("crashupload"); g_Logger.write("Uploaded dump\r\n"); UTIL::FS::delFile(UTIL::FS::Path(dump, "", true)); } catch (gcException &) { g_Logger.write("Bad status returned from upload crash dump.\r\n"); gcString res; res.assign(hh->getData(), hh->getDataSize()); g_Logger.write("Result: \r\n\r\n%s\r\n\r\n", res.c_str()); return false; } return true; }
void cascade () { double h[7]; int i, n, k, h_len, hmin, hmax; // filter definition D4 h_len = 4; /* h[0] = (1+sqrt(3.0))/4; // H = 2h(n) h[1] = (3+sqrt(3.0))/4; h[2] = (3-sqrt(3.0))/4; h[3] = (1-sqrt(3.0))/4; h[0]=-1./16; h[1]=0; h[2]=9./16; h[3]=1.0; h[4]=9./16; h[5]=0; h[6]=-1./16; hmin = -3, hmax = 3; // offset = 3 */ /* this portion only applies to boundary and cannot be uniformly applied after first iteration ... */ h[0]=15./16; h[1]=1.0; h[2] = 9./16; h[3]=0.0; h[4]=-1./16; hmin=-1, hmax=3; // offset = 1 // copy old data for (i = 0; i < ndata; i++) oldy[i] = y[i]; // upsampling by two ndata *= 2; dx /= 2; for (i = 0; i < ndata; i++) { x[i] = i*dx; if (i%2) // i is odd; insert zero y[i] = 0; else y[i] = oldy[i/2]; } // for (i = 0; i < ndata; i++) // printf ("%lf\n", y[i]); //getchar(); // convolve with H for (i = 0; i < ndata; i++) oldy[i] = y[i]; for (n = 0; n < ndata+(-hmin-1); n++) { y[n] = 0; for (k = hmin; k <= hmax; k++) { y[n] += hh(k)*oldy[n-k]; } } for (i = 0; i < ndata; i++) printf ("%lf\n", y[i]); // do not plot outside ndata! }