globalafraentry AFRA::getGlobalEntry(uint32_t no) { globalafraentry ret; int offset = 13 + 12 * getEntryCount() + 4; if (getLongOffsets()) { offset = 13 + 16 * getEntryCount() + 4; } int entrysize = 20; if (getLongIDs()) { entrysize += 4; } if (getLongOffsets()) { entrysize += 8; } ret.time = getInt64(offset + entrysize * no); if (getLongIDs()) { ret.segment = getInt32(offset + entrysize * no + 8); ret.fragment = getInt32(offset + entrysize * no + 12); } else { ret.segment = getInt16(offset + entrysize * no + 8); ret.fragment = getInt16(offset + entrysize * no + 10); } if (getLongOffsets()) { ret.afraoffset = getInt64(offset + entrysize * no + entrysize - 16); ret.offsetfromafra = getInt64(offset + entrysize * no + entrysize - 8); } else { ret.afraoffset = getInt32(offset + entrysize * no + entrysize - 8); ret.offsetfromafra = getInt32(offset + entrysize * no + entrysize - 4); } return ret; }
int TraderApi::queryTrades(dict req, uint64_t sessionid, int reqid) { XTPQueryTraderReq myreq = XTPQueryTraderReq(); memset(&myreq, 0, sizeof(myreq)); getStr(req, "ticker", myreq.ticker); getInt64(req, "end_time", &myreq.end_time); getInt64(req, "begin_time", &myreq.begin_time); return this->api->QueryTrades(&myreq, sessionid, reqid); };
afraentry AFRA::getEntry(uint32_t no) { afraentry ret; int entrysize = 12; if (getLongOffsets()) { entrysize = 16; } ret.time = getInt64(13 + entrysize * no); if (getLongOffsets()) { ret.offset = getInt64(21 + entrysize * no); } else { ret.offset = getInt32(21 + entrysize * no); } return ret; }
uint64_t UUID_TFXD::getDuration() { if (getVersion() == 0) { return getInt32(24); } else { return getInt64(28); } }
Int64List* MtpDataPacket::getAInt64() { Int64List* result = new Int64List; int count = getUInt32(); for (int i = 0; i < count; i++) result->push_back(getInt64()); return result; }
uint64_t UUID_TrackFragmentReference::getDuration(size_t num) { if (getVersion() == 0) { return getInt32(21 + (num * 8) + 4); } else { return getInt64(21 + (num * 16) + 8); } }
const char * htmInterface::lookupNameCmd(char *str) { cmd_ = str; if(t_)delete t_; t_ = new VarStrToken(cmd_); float64 v[3]; cmdCode code = getCode(); if(code == ID) { uint64 id = getInt64(); index_->nameById(id, name_); } else { getDepth(); if(! parseVec(code, v) ) throw SpatialInterfaceError("htmInterface:lookupNameCmd: Expect vector in Command. ", cmd_.data()); if( code == J2000 ) index_->nameByPoint(v[0], v[1], name_); else { SpatialVector tv(v[0], v[1], v[2]); index_->nameByPoint(tv, name_); } } return name_; }
uint64_t TraderApi::insertOrder(dict req, uint64_t sessionid) { XTPOrderInsertInfo myreq = XTPOrderInsertInfo(); memset(&myreq, 0, sizeof(myreq)); getDouble(req, "stop_price", &myreq.stop_price); getDouble(req, "price", &myreq.price); getStr(req, "ticker", myreq.ticker); getUint32(req, "order_client_id", &myreq.order_client_id); getUint64(req, "order_xtp_id", &myreq.order_xtp_id); getInt64(req, "quantity", &myreq.quantity); int price_type; int side; int market; int business_type; getInt(req, "price_type", &price_type); getInt(req, "side", &side); getInt(req, "market", &market); getInt(req, "business_type", &business_type); myreq.price_type = (XTP_PRICE_TYPE)price_type; myreq.side = (XTP_SIDE_TYPE)side; myreq.market = (XTP_MARKET_TYPE)market; myreq.business_type = (XTP_BUSINESS_TYPE)business_type; return this->api->InsertOrder(&myreq, sessionid); };
ConstantInt* Variables::getAlignmentInBits(Type *type) { ConstantInt *alignment = NULL; ArrayType *arrayType = dyn_cast<ArrayType>(type); switch (arrayType->getElementType()->getTypeID()) { case Type::FloatTyID: alignment = getInt64(32); break; case Type::DoubleTyID: alignment = getInt64(64); break; default: errs() << "WARNING: Unhandled type @ getAlignmentInBits\n"; exit(1); } return alignment; }
afrt_runtable AFRT::getFragmentRun(uint32_t no) { afrt_runtable res; if (no > getFragmentRunCount()) { return res; } int tempLoc = 9; for (unsigned int i = 0; i < getQualityEntryCount(); i++) { tempLoc += getStringLen(tempLoc) + 1; } tempLoc += 4; for (unsigned int i = 0; i < no; i++) { if (getInt32(tempLoc + 12) == 0) { tempLoc += 17; } else { tempLoc += 16; } } res.firstFragment = getInt32(tempLoc); res.firstTimestamp = getInt64(tempLoc + 4); res.duration = getInt32(tempLoc + 12); if (res.duration) { res.discontinuity = getInt8(tempLoc + 16); } else { res.discontinuity = 0; } return res; }
uint64_t UUID_TFXD::getTime() { if (getVersion() == 0) { return getInt32(20); } else { return getInt64(20); } }
ConstantInt* Variables::getSizeInBits(Type *type) { ConstantInt *size = NULL; ArrayType *arrayType = dyn_cast<ArrayType>(type); switch (arrayType->getElementType()->getTypeID()) { case Type::FloatTyID: { int isize = arrayType->getNumElements() * 32; size = getInt64(isize); break; } case Type::DoubleTyID: { int isize = arrayType->getNumElements() * 64; size = getInt64(isize); break; } default: errs() << "WARNING: Unhandled type @ getSizeInBits\n"; exit(1); } return size; }
int main(int argc, char** argv) { FILE* fp; char str[MAX_CHARS]; char eqn[MAX_LEN]; int ops[MAX_CHARS]; // none, '-' or '+' int numC, numPossible, numLoc; int i, eLen, numU; int64 val; if(argc != 2) { printf("USAGE: UglyNumbers <fileContainingTestVectors>\n"); return 1; } fp = fopen(argv[1], "r"); if(fp == NULL) { printf("Failed to open the input file '%s' for reading!\n", argv[1]); return 2; } while(!feof(fp)) { str[0] = '\0'; fgets(str, MAX_CHARS, fp); numC = stringLen(str, MAX_CHARS); if(str[0] == '\0') { continue; } if(numC <= 0) { continue; } // special case if(numC == 1) { printf("%d\n", (isUgly(getInt64(str, 0, 1)))? 1 : 0); continue; } numLoc = numC - 1; numU = 0; // number of possibilities numPossible = 1; for(i=1;i<numC;++i,numPossible*=3); // enumerate all of them! for(i=0;i<numPossible;++i) { int2tertiary(ops, numLoc, i); eLen = generateEqn(eqn, ops, str, numC); val = evaluateEqn(eqn, eLen); if(isUgly(val)) { ++numU; } //printf("%s %ld %d %d\n", eqn, val, numU, i); } printf("%d\n", numU); } fclose(fp); return 0; }
void Bytecode::dump(ostream& out) const { for (size_t bci = 0; bci < length();) { size_t length; Instruction insn = getInsn(bci); out << bci << ": "; const char* name = bcName(insn, length); switch (insn) { case BC_DLOAD: out << name << " " << getDouble(bci + 1); break; case BC_ILOAD: out << name << " " << getInt64(bci + 1); break; case BC_SLOAD: out << name << " @" << getUInt16(bci + 1); break; case BC_CALL: case BC_CALLNATIVE: out << name << " *" << getUInt16(bci + 1); break; case BC_LOADDVAR: case BC_STOREDVAR: case BC_LOADIVAR: case BC_STOREIVAR: case BC_LOADSVAR: case BC_STORESVAR: out << name << " @" << getUInt16(bci + 1); break; case BC_LOADCTXDVAR: case BC_STORECTXDVAR: case BC_LOADCTXIVAR: case BC_STORECTXIVAR: case BC_LOADCTXSVAR: case BC_STORECTXSVAR: out << name << " @" << getUInt16(bci + 1) << ":" << getUInt16(bci + 3); break; case BC_IFICMPNE: case BC_IFICMPE: case BC_IFICMPG: case BC_IFICMPGE: case BC_IFICMPL: case BC_IFICMPLE: case BC_JA: out << name << " " << getInt16(bci + 1) + bci + 1; break; default: out << name; } out << endl; bci += length; } }
int64 evaluateEqn(char* eqn, int eLen) { int64 val; int s, i; char op = '0'; for(val=0,i=0,s=0;i<eLen;i++) { if(eqn[i] == '-') { if(op == '0') { val = getInt64(eqn, s, i); } else if(op == '-') { val -= getInt64(eqn, s, i); } else if(op == '+') { val += getInt64(eqn, s, i); } s = i + 1; op = '-'; } else if(eqn[i] == '+') { if(op == '0') { val = getInt64(eqn, s, i); } else if(op == '-') { val -= getInt64(eqn, s, i); } else if(op == '+') { val += getInt64(eqn, s, i); } s = i + 1; op = '+'; } } // remnant if(op == '0') { val = getInt64(eqn, s, i); } else if(op == '-') { val -= getInt64(eqn, s, i); } else if(op == '+') { val += getInt64(eqn, s, i); } return val; }
void CConfigFile::setInt64(const std::string & key, const int64_t val) { bool tmpUnknownKeyQueryedFlag = unknownKeyQueryedFlag; unknownKeyQueryedFlag = false; int64_t oldVal = getInt64(key); if ((oldVal != val) || (unknownKeyQueryedFlag)) { modifiedFlag = true; storeInt64(key, val); } unknownKeyQueryedFlag = tmpUnknownKeyQueryedFlag; }
uint32_t getPlayerBase() { uint32_t gClientConnection; uint32_t sCurMgr; uint32_t curObj; uint64_t playerGUID; uint32_t playerBase; uint32_t nextObj; uint64_t GUID; playerBase=0; gClientConnection=getInt32(ptr_ClientConnection); sCurMgr=getInt32(gClientConnection + off_ObjectManager); if (sCurMgr != 0) { playerGUID=getInt64(sCurMgr+0xC0); if (playerGUID != 0) { g_playerGUID = playerGUID; curObj=getInt32(sCurMgr+0xAC); while (curObj != 0) { nextObj=getInt32(curObj + 0x3C); GUID=getInt64(curObj + 0x30); if (playerGUID == GUID) { playerBase = curObj; break; } else if (curObj == nextObj) { break; } else { curObj = nextObj; } } } } return playerBase; }
Int64List* MtpDataPacket::getAInt64() { uint32_t count; if (!getUInt32(count)) return NULL; Int64List* result = new Int64List; for (uint32_t i = 0; i < count; i++) { int64_t value; if (!getInt64(value)) { delete result; return NULL; } result->push(value); } return result; }
IpfixPayloadWriterCfg::IpfixPayloadWriterCfg(XMLElement* elem) : CfgHelper<IpfixPayloadWriter, IpfixPayloadWriterCfg>(elem, "ipfixPayloadWriter"), noConnections(0), ignoreEmptyPayload(false), ignoreIncompleteTCP(false), startIdx(0) { if (!elem) return; bool noconnseen = false; XMLNode::XMLSet<XMLElement*> set = _elem->getElementChildren(); for (XMLNode::XMLSet<XMLElement*>::iterator it = set.begin(); it != set.end(); it++) { XMLElement* e = *it; if (e->matches("destPath")) { path = e->getFirstText(); } else if (e->matches("filenamePrefix")) { filenamePrefix = e->getFirstText(); } else if (e->matches("connNumber")) { noConnections = getInt("connNumber"); noconnseen = true; } else if (e->matches("ignoreEmptyPayload")) { ignoreEmptyPayload = getBool("ignoreEmptyPayload"); } else if (e->matches("ignoreIncompleteTCP")) { ignoreIncompleteTCP = getInt("ignoreIncompleteTCP"); } else if (e->matches("ignoreIncompleteTCP")) { ignoreIncompleteTCP = getInt("ignoreIncompleteTCP"); } else if (e->matches("startIndex")) { startIdx = getInt64("startIndex"); } else if (e->matches("next")) { // ignore next } else { msg(MSG_FATAL, "Unknown IpfixPayloadWriter config statement %s\n", e->getName().c_str()); continue; } } if (path=="") THROWEXCEPTION("IpfixPayloadWriterCfg: destPath not set in configuration!"); if (filenamePrefix=="") THROWEXCEPTION("IpfixPayloadWriterCfg: filenamePrefix not set in configuration!"); if (!noconnseen) THROWEXCEPTION("IpfixPayloadWriterCfg: connNumber not set in configuration!"); struct stat s; if (stat(path.c_str(), &s) != 0) THROWEXCEPTION("IpfixPayloadWriterCfg: failed to access destination path '%s', error: %s", path.c_str(), strerror(errno)); }
void printCell(Cell *cell){ switch(cell->ctype){ case INT32: printf("%d\t",getInt32(cell->value)); break; case UINT32: printf("%d\t",getUint32(cell->value)); break; case INT64: printf("%ld\t",getInt64(cell->value)); break; case UINT64: printf("%lu\t",getUint64(cell->value)); break; case INT8: printf("%d",getInt8(cell->value)); break; case INT16: printf("%d",getInt16(cell->value)); break; case FLOAT: printf("%f\t",getFloat(cell->value)); break; case DOUBLE: printf("%f\t",getDouble(cell->value)); break; case STRING: //MySQL type BINARY may be STRING { char *value =(char *) cell->value; printf("%s\t",(char*)value); break; } case BINARY: printf("BINARY\t"); break; default: printf("UNKNOW\t"); break; } }
/* {{{ MyVal::getBool() -I- */ bool MyVal::getBool() { static const double delta = 0.000001; switch (val_type) { case typeString: return getInt64() != 0; case typeDouble: return !(val.dval < delta && val.dval > -delta); case typeInt: case typeUInt: return val.lval != 0; case typeBool: return val.bval; case typePtr: return val.pval != NULL; } throw std::runtime_error("impossible"); }
void APCArray::add(APCHandle *key, APCHandle *val) { int pos = m.m_num; // NOTE: no check on duplication because we assume the original array has no // duplication Bucket* bucket = buckets() + pos; bucket->key = key; bucket->val = val; m.m_num++; int hash_pos; if (!isRefcountedType(key->type())) { auto const k = APCTypedValue::fromHandle(key); hash_pos = (key->type() == KindOfInt64 ? k->getInt64() : k->getStringData()->hash()) & m.m_capacity_mask; } else { assert(key->type() == KindOfString); auto const k = APCString::fromHandle(key); hash_pos = k->getStringData()->hash() & m.m_capacity_mask; } int& hp = hash()[hash_pos]; bucket->next = hp; hp = pos; }
int main(int argc, TCHAR **argv) { // _tprintf(_T("sizeof(long double):%s\n"), FSZ(sizeof(long double))); // _tprintf(_T("sizeof(Double80:%s\n"), FSZ(sizeof(Double80))); unsigned __int64 ui64max = _UI64_MAX; Double80 dui64 = ui64max; unsigned __int64 rui64 = getUint64(dui64); for (;;) { double x = inputDouble(_T("Enter x:")); // double y = inputDouble(_T("Enter y:")); Double80 x80 = x; // , y80 = y; // Double80 z80 = pow(x80, y80); Double80 z80 = exp2(x80); double z64 = getDouble(z80); _tprintf(_T("exp2(%lg)=%le\n"), x, z64); } Double80 x; Double80 y; unsigned long l1 = 1; x = 1; y = 2.3; Double80 z = x + y; double z64 = getDouble(z); _tprintf(_T("x+y:%le\n"), z64); x = 9.7; y = 4; z = fmod(x, y); z64 = getDouble(z); x = M_PI; x *= 2; x /= 3; double x64 = getDouble(x); Double80 c = x, s; sincos(c, s); double c64 = getDouble(c); double s64 = getDouble(s); z = cos(x); z64 = getDouble(z); double e10 = 9.999e20; Double80 d1080 = e10; int expo10 = Double80::getExpo10(d1080); Double80 exp80 = exp(z); double exp64 = getDouble(exp80); const long maxi32 = 0x7fffffff; Double80 zi32(maxi32); const long i32_1 = getInt(zi32); const unsigned long ui32_a1 = maxi32; Double80 dui32_a(ui32_a1); const unsigned long ui32_a2 = getUint(dui32_a); const unsigned long ui32_b1 = (unsigned long)maxi32 + 1; Double80 dui32_b(ui32_b1); const unsigned long ui32_b2 = getUint(dui32_b); const __int64 maxi64 = 0x7fffffffffffffffui64; Double80 di64(maxi64); const __int64 i64_1 = getInt64(di64); const unsigned __int64 ui64_a1 = maxi64; Double80 dui64_a(ui64_a1); const unsigned __int64 ui64_a2 = getUint64(dui64_a); const unsigned __int64 ui64_b1 = (unsigned __int64)maxi64 + 1; Double80 dui64_b(ui64_b1); const unsigned __int64 ui64_b2 = getUint64(dui64_b); const float f1 = 1.23456f; Double80 zf(f1); const float f2 = getFloat(zf); return 0; }
static int fetch(float *avatar_pos, float *avatar_front, float *avatar_top, float *camera_pos, float *camera_front, float *camera_top, std::string &context, std::wstring &identity) { /* clear position */ for (int i=0; i<3; i++) { avatar_pos[i]=avatar_front[i]=avatar_top[i]=camera_pos[i]=camera_front[i]=camera_top[i]=0.0; } /* are we still looking at the right object? */ uint64_t peekGUID, tempGUID; peekGUID=getInt64(p_playerBase+0x30); if (g_playerGUID != peekGUID) { /* no? Try to resynch to the new address. Happens when walking through portals quickly (aka no or short loading screen) */ tempGUID = g_playerGUID; p_playerBase=getPlayerBase(); if (tempGUID != g_playerGUID) { /* GUID of actor changed, likely a character and/or realm change */ wow.refresh(); } peekGUID=getInt64(p_playerBase+0x30); if (g_playerGUID != peekGUID) { /* no? we are still getting the expected GUID for our avatar, but we don't have it's current position */ return true; } } context.clear(); std::wstringstream identityStream; identityStream << wow.getNameAvatar(); identity = identityStream.str(); BOOL ok = true; // Wow stores as // North/South (+ North) // East/West (+ West) // Up/Down (+Up) // ... which isn't a right-hand coordinate system. float pos[3]; ok = ok && peekProc((BYTE *) p_playerBase + 0x798, pos, sizeof(float)*3); if (! ok) { if (g_playerGUID == 0xffffffffffffffff) { return false; } else if (g_playerGUID == 0) { return true; } else { /* FIXME need a better way to mark PlayerBase invalid */ g_playerGUID=0; return true; /* we got a good reference for an avatar, but no good position */ } } /* convert wow -> right hand coordinate system */ avatar_pos[0] = -pos[1]; avatar_pos[1] = pos[2]; avatar_pos[2] = pos[0]; float heading=0.0; ok = ok && peekProc((BYTE *) p_playerBase + 0x7A8, &heading, sizeof(heading)); if (! ok) return false; float pitch=0.0; ok = ok && peekProc((BYTE *) p_playerBase + 0x7AC, &pitch, sizeof(pitch)); if (! ok) return false; /* TODO use yaw (heading) and pitch angles */ /* FIXME sin/cos (heading) is right from the numbers, but (-heading) is right from the sound position */ avatar_front[0]=-sin(heading); avatar_front[1]=0.0; avatar_front[2]=cos(heading); // Dummy top vector, can't tilt your head sideways in wow. avatar_top[0]= 0.0; avatar_top[1]= 1.0; avatar_top[2]= 0.0; getCamera(camera_pos, camera_front, camera_top); if (! ok) return false; // printf("P %f %f %f -- %f %f %f \n", avatar_pos[0], avatar_pos[1], avatar_pos[2], avatar_front[0], avatar_front[1], avatar_front[2]); // is it a unit length vector? if (fabs((avatar_front[0]*avatar_front[0]+avatar_front[1]*avatar_front[1]+avatar_front[2]*avatar_front[2])-1.0)>0.5) { // printf("F %f %f %f\n", front[0], front[1], front[2]); return false; } // are we around 0/0/0 if ((fabs(avatar_pos[0])<0.1) && (fabs(avatar_pos[1])<0.1) && (fabs(avatar_pos[2])<0.1)) { // printf("P %f %f %f\n", avatar_pos[0], avatar_pos[1], avatar_pos[2]); return false; } return true; }
// Return the unsigned integer value of the column specified by its index starting at 0 unsigned Column::getUInt() const noexcept // nothrow { return static_cast<unsigned>(getInt64()); }
int Hdf::compare(int64_t v2) const { int64_t v1 = getInt64(); if (v1 == v2) return 0; return v1 > v2 ? 1 : -1; }
int64_t CConfigFile::getInt64(const char * const key, const int64_t defaultVal) { return getInt64(std::string(key), defaultVal); }
/* {{{ MySQL_ArtResultSet::getInt() -I- */ int32_t MySQL_ArtResultSet::getInt(uint32_t columnIndex) const { CPP_ENTER("MySQL_ArtResultSet::getInt(int)"); return static_cast<int32_t>(getInt64(columnIndex)); }
/* {{{ MySQL_ArtResultSet::getInt64() -I- */ int64_t MySQL_ArtResultSet::getInt64(const sql::SQLString& columnLabel) const { CPP_ENTER("MySQL_ArtResultSet::getInt64(string)"); return getInt64(findColumn(columnLabel)); }
int64_t ClientMessage::get() { return getInt64(); }