static int parseCommandLine( int argc, const char ** argv ) { int c; const char * optarg; while(( c = tr_getopt( getUsage( ), argc, argv, options, &optarg ))) { switch( c ) { case 'a': add = optarg; break; case 'd': deleteme = optarg; break; case 'r': replace[0] = optarg; c = tr_getopt( getUsage( ), argc, argv, options, &optarg ); if( c != TR_OPT_UNK ) return 1; replace[1] = optarg; break; case TR_OPT_UNK: files[fileCount++] = optarg; break; default: return 1; } } return 0; }
int main(int argc, char *argv[]) { try { libmaus2::util::ArgInfo const arginfo(argc,argv); libmaus2::util::ArgParser const arg(argc,argv); if ( arg.argPresent("h") || arg.argPresent("help") ) { std::cerr << getUsage(arg); return EXIT_SUCCESS; } else if ( arg.argPresent("version") ) { std::cerr << "This is " << PACKAGE_NAME << " version " << PACKAGE_VERSION << std::endl; return EXIT_SUCCESS; } else if ( arg.size() < 2 ) { std::cerr << getUsage(arg); return EXIT_FAILURE; } return lassort(arg,arginfo); } catch(std::exception const & ex) { std::cerr << ex.what() << std::endl; return EXIT_FAILURE; } }
void GLBuffer::unmapStream() { // "orphan" current buffer to avoid implicit synchronisation on the GPU: // http://www.seas.upenn.edu/~pcozzi/OpenGLInsights/OpenGLInsights-AsynchronousBufferTransfers.pdf glBufferData(getTarget(), (GLsizeiptr) getSize(), nullptr, getUsage()); glBufferData(getTarget(), (GLsizeiptr) getSize(), memory_map, getUsage()); }
const std::string& CmdWriteOSGFile::execute( const std::vector< std::string >& arguments ) { bool hasinputfile = false; if ( arguments.size() < 1 ) { _cmdResult = getUsage(); return _cmdResult; } else if ( ( arguments.size() > 2 ) && ( arguments[ 0 ] == "-i" ) ) { hasinputfile = true; } else { _cmdResult = getUsage(); return _cmdResult; } EnConsole* p_console = static_cast< EnConsole* >( yaf3d::EntityManager::get()->findEntity( ENTITY_NAME_CONSOLE ) ); assert( p_console && "CmdWriteOSGFile::execute: console entity could not be found!" ); std::string cwd = yaf3d::Application::get()->getMediaPath() + p_console->getCWD() + "/"; if ( !hasinputfile ) { osg::Group* grp = yaf3d::Application::get()->getSceneRootNode(); if ( grp ) { _cmdResult = "writing scene to osg file '" + arguments[ 0 ] + "\n"; std::string filename = cwd + arguments[ 0 ]; if ( !osgDB::writeNodeFile( *grp, filename ) ) { _cmdResult += " warning: problem writing file '" + filename + "\n"; } } } else { _cmdResult = "reading scene file " + arguments[ 1 ] + " ...\n"; std::string infilename = cwd + arguments[ 1 ]; osg::ref_ptr< osg::Node > node = osgDB::readNodeFile( infilename ); if ( node.get() ) { std::string outfilename = cwd + arguments[ 2 ]; _cmdResult += "writing scene to file " + outfilename + "\n"; if ( !osgDB::writeNodeFile( *( node.get() ), outfilename ) ) { _cmdResult += " warning: problem writing file " + outfilename + "\n"; } } else { _cmdResult += "cannot read scene file " + infilename + "\n"; } } return _cmdResult; }
void VBO::unmap() { if (!is_mapped) return; // "orphan" current buffer to avoid implicit synchronisation on the gpu: // http://www.seas.upenn.edu/~pcozzi/OpenGLInsights/OpenGLInsights-AsynchronousBufferTransfers.pdf glBufferDataARB(getTarget(), getSize(), NULL, getUsage()); glBufferDataARB(getTarget(), getSize(), memory_map, getUsage()); is_mapped = false; }
int RespondTemplate::execute(int argc, char* argv[]) { int status = CommandProcessor::COMMAND_FAILED; UtlString usage; //printf("no operation command with %d arguments\n", argc); if(argc == 1) { status = CommandProcessor::COMMAND_SUCCESS; messageProcessor->stopResponding(); } else if(argc == 2) { { UtlString fileName; fileName = argv[1]; messageProcessor->startResponding(fileName.data(), -1 ); status = CommandProcessor::COMMAND_SUCCESS; } } else { UtlString usage; getUsage(argv[0], &usage); printf("%s", usage.data()); status = CommandProcessor::COMMAND_BAD_SYNTAX; } return(status); }
void nuVertexBuffer::update(void) { if(!isInitialized()) { CHECK_GL_ERROR(glGenBuffers(1, &mVertexBufferID)); NU_ASSERT(mVertexBufferID != 0, "Cannot generate vertex buffer object.\n"); CHECK_GL_ERROR(glBindBuffer(GL_ARRAY_BUFFER, mVertexBufferID)); CHECK_GL_ERROR(glBufferData(GL_ARRAY_BUFFER, mSize, mpBuffer, getResourceUsage())); if(getUsage() == nuGResource::STATIC_RESOURCE) releaseBuffer(); mCommitSize = 0; setInitialized(true); } else { CHECK_GL_ERROR(glBindBuffer(GL_ARRAY_BUFFER, mVertexBufferID)); if(mCommitSize > VERTEX_BUFFER_MAP_THRESHOLD) { void* p_buffer; CHECK_GL_ERROR(p_buffer = glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY)); memcpy(p_buffer, mpBuffer, mCommitSize); CHECK_GL_ERROR(glUnmapBuffer(GL_ARRAY_BUFFER)); } else { CHECK_GL_ERROR(glBufferSubData(GL_ARRAY_BUFFER, 0, mCommitSize, mpBuffer)); } mCommitSize = 0; } }
string Clocker::readResetDetailed() { ostringstream str; long dsec, usec; double utime, stime; end(); double diff = getTimediff(); unsigned long usage = getUsage(); double timeUsed = usage / 1E6; dsec = r_usageEnd.ru_utime.tv_sec - r_usageStart.ru_utime.tv_sec; usec = r_usageEnd.ru_utime.tv_usec - r_usageStart.ru_utime.tv_usec; utime = (1000000* dsec + usec) / 1E6; dsec = r_usageEnd.ru_stime.tv_sec - r_usageStart.ru_stime.tv_sec; usec = r_usageEnd.ru_stime.tv_usec - r_usageStart.ru_stime.tv_usec; stime = (1000000* dsec + usec) / 1E6; long maxrss = r_usageEnd.ru_maxrss; long nvcsw = r_usageEnd.ru_nvcsw ; long nivcsw = r_usageEnd.ru_nivcsw; str << ":: " << now << " :: " << setfill('0') << setprecision(6) << setw(10) << diff << " sec elapsed"; str << " (since " << since << ")" << endl; str << ":: " << now << " :: time(user) " << setfill(' ') << setprecision(4) << utime; str << " :: time(system) " << setfill(' ') << setprecision(4) << stime; str << " :: time(total) " << setfill(' ') << setprecision(4) << timeUsed; str << "\n:: " << now << " :: maxRss=" << maxrss << " :: cntxSwitch(user)=" << nvcsw << " :: cntxSwitch(forc)=" << nivcsw; begin(); return str.str(); }
void Options::parseFromCommandLine(int argc, char **argv) { po::variables_map options; po::command_line_parser parser { argc, argv }; auto usage = getUsage(); auto positional = getPositional(); try { po::store( parser.options(usage) .positional(positional) .run(), options ); if (options.count("help")) { std::cerr << usage << std::endl; exit(0); } po::notify(options); } catch (const po::error & exception) { std::cerr << exception.what() << std::endl << std::endl; std::cerr << usage << std::endl; exit(1); } }
static int parseCommandLine( int argc, const char ** argv ) { int c; const char * optarg; while(( c = tr_getopt( getUsage( ), argc, argv, options, &optarg ))) { switch( c ) { case 'p': isPrivate = TRUE; break; case 'o': outfile = optarg; break; case 'c': comment = optarg; break; case 't': if( trackerCount + 1 < MAX_TRACKERS ) { trackers[trackerCount].tier = trackerCount; trackers[trackerCount].announce = (char*) optarg; ++trackerCount; } break; case TR_OPT_UNK: infile = optarg; break; default: return 1; } } return 0; }
const std::string& CmdEntityAttributeSet::execute( const std::vector< std::string >& arguments ) { _cmdResult = ""; if ( arguments.size() < 3 ) { _cmdResult = getUsage(); return _cmdResult; } yaf3d::BaseEntity* p_entity = yaf3d::EntityManager::get()->findInstance( arguments[ 0 ] ); if ( ! p_entity ) { _cmdResult = "* entity instance '" + arguments[ 0 ] + "' does not exist"; return _cmdResult; } // set attribute value using value string if ( !p_entity->getAttributeManager().setAttributeValueByString( arguments[ 1 ], arguments[ 2 ] ) ) { _cmdResult = "* error setting attribute value, check the value format!"; } else { // now send out a notification to the entity this way letting it know that we changed an attribute value // the entity can decide itself if an appropriate action is necessary in this case yaf3d::EntityNotification notification( YAF3D_NOTIFY_ENTITY_ATTRIBUTE_CHANGED ); yaf3d::EntityManager::get()->sendNotification( notification, p_entity ); } return _cmdResult; }
HRESULT IDirect3DDevice9New::CreateIndexBuffer(UINT Length,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DIndexBuffer9** ppIndexBuffer,HANDLE* pSharedHandle) { dbgf("dev: CreateIndexBuffer %s %s", getUsage(Usage), getPool(Pool)); if(config.debug.compatibleIB) { // Compatible index buffer mode - do not use emulated IB, set dynamic memory instead if(Pool == D3DPOOL_MANAGED) { ONCE dbg("DEBUG: using compatible index buffers (manage-emulation disabled)"); Pool = D3DPOOL_DEFAULT; Usage |= D3DUSAGE_DYNAMIC; } return dev->CreateIndexBuffer(Length, Usage, Format, Pool, ppIndexBuffer, pSharedHandle); } #if USE_D3DEX || MANAGE_DEBUG_IB /*if(Pool == D3DPOOL_MANAGED && Usage == D3DUSAGE_WRITEONLY) Pool = D3DPOOL_DEFAULT; // No need for manage-emulation for writeonly buffers, just set pool to default*/ if(Pool == D3DPOOL_MANAGED) { *ppIndexBuffer = new IDirect3DIndexBuffer9Managed((IDirect3DDevice9Ex*)dev, this, Length, Usage, Format, Pool, pSharedHandle); // TODO: check for failure return D3D_OK; } #endif return dev->CreateIndexBuffer(Length, Usage, Format, Pool, ppIndexBuffer, pSharedHandle); }
int KeyCommand::execute(int argc, char* argv[]) { int commandStatus = CommandProcessor::COMMAND_FAILED; if(argc == 1) { printf("\t\t\t Shortcut Keys\n"); printf("al ---------> addline\t\t\taacc ---------> autoaccept\n"); printf("aans ---------> autoanswer\t\tarej ---------> autoreject\n"); printf("cacc ---------> callaccept\t\tcans ---------> callanswer\n"); printf("cco ---------> callconnect\t\tccr --------->callcreate\n"); printf("cd ---------> calldestroy\t\tch ---------> callhold\n"); printf("pf ---------> callplayfile\t\tcr ---------> callredirect\n"); printf("si ---------> callsendinfo\t\tst ---------> callstarttone\n"); printf("csub ---------> callsubscribe\t\tcu ---------> callunhold\n"); printf("cfa ---------> conferenceadd\t\tcfcr ---------> conferencecreate\n"); printf("cfd ---------> conferencedestroy\tcfgc ---------> conferencegetcalls\n"); printf("cfh ---------> conferencehold\t\tcfj ---------> conferencejoin\n"); printf("cfu ---------> conferenceunhold\t\tcp ---------> createpublisher\n"); printf("dp ---------> destroypublisher\t\tup ---------> updatepublisher\n"); printf("es ---------> enablestun\t\ter ---------> enablerport\n"); printf("\t\t\thi ---------> history\n"); } else { UtlString usage; getUsage(argv[0], &usage); printf("%s", usage.data()); commandStatus = CommandProcessor::COMMAND_BAD_SYNTAX; } return commandStatus; }
const std::string& CmdEntityAttributeList::execute( const std::vector< std::string >& arguments ) { if ( arguments.size() < 1 ) { _cmdResult = getUsage(); return _cmdResult; } _cmdResult = "list of entity attributes:\n"; yaf3d::BaseEntity* p_entity = yaf3d::EntityManager::get()->findInstance( arguments[ 0 ] ); if ( ! p_entity ) { _cmdResult = "* entity instance '" + arguments[ 0 ] + "' does not exist"; return _cmdResult; } std::vector< std::vector< std::string > > attributes; p_entity->getAttributeManager().getAttributesAsString( attributes ); std::string info; std::vector< std::vector< std::string > >::iterator p_beg = attributes.begin(), p_end = attributes.end(); for ( ; p_beg != p_end; ++p_beg ) { info += ( *p_beg )[ 0 ] + " [ " + ( *p_beg )[ 1 ] + " ] \n"; } _cmdResult = info; return _cmdResult; }
static char const* getConfigDir(int argc, char const* const* argv) { int c; char const* configDir = NULL; char const* optarg; int const ind = tr_optind; while ((c = tr_getopt(getUsage(), argc, argv, options, &optarg)) != TR_OPT_DONE) { if (c == 'g') { configDir = optarg; break; } } tr_optind = ind; if (configDir == NULL) { configDir = tr_getDefaultConfigDir(MY_NAME); } return configDir; }
TextureStorage9_2D::TextureStorage9_2D(Renderer *renderer, GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, int levels) : TextureStorage9(renderer, GetTextureUsage(internalformat, renderTarget)) { mTexture = NULL; mRenderTarget = NULL; // if the width or height is not positive this should be treated as an incomplete texture // we handle that here by skipping the d3d texture creation if (width > 0 && height > 0) { IDirect3DDevice9 *device = mRenderer->getDevice(); const d3d9::TextureFormat &d3dFormatInfo = d3d9::GetTextureFormatInfo(internalformat); d3d9::MakeValidSize(false, d3dFormatInfo.texFormat, &width, &height, &mTopLevel); UINT creationLevels = (levels == 0) ? 0 : mTopLevel + levels; HRESULT result = device->CreateTexture(width, height, creationLevels, getUsage(), d3dFormatInfo.texFormat, getPool(), &mTexture, NULL); if (FAILED(result)) { ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY); gl::error(GL_OUT_OF_MEMORY); } } initializeRenderTarget(); }
const std::string& CmdServerStart::execute( const std::vector< std::string >& arguments ) { _cmdResult = ""; if ( arguments.size() < 1 ) { _cmdResult = getUsage(); return _cmdResult; } // get the full binary path std::string cmd = yaf3d::Application::get()->getFullBinPath(); std::string levelfile = arguments[ 0 ]; std::string arg1( "-server" ); std::string arg2( "-level" ); std::string arg3( levelfile ); // use utility function to start the server std::string args = arg1 + " " + arg2 + " " + arg3; YAF3D_SPAWN_PROC_ID serverProcHandle = yaf3d::spawnApplication( cmd, args ); if ( serverProcHandle ) _cmdResult = "trying to start server with level file '" + levelfile + "'."; else _cmdResult = "* error starting server with level file '" + levelfile + "'."; return _cmdResult; }
int CallSubscribeCommand::execute(int argc, char* argv[]) { int commandStatus = CommandProcessor::COMMAND_FAILED; if(argc == 4) { if(sipxCallSubscribe(atoi(argv[1]), argv[2], argv[3], subHandle) == SIPX_RESULT_SUCCESS) { printf("Subscription successful with call id: %d and subscription id: %d\n", atoi(argv[1]), *subHandle); } else { printf("Subscription unsuccessful.\n"); } } else { UtlString usage; getUsage(argv[0], &usage); printf("%s", usage.data()); commandStatus = CommandProcessor::COMMAND_BAD_SYNTAX; } return commandStatus; }
static int parseCommandLine (int argc, const char * const * argv) { int c; const char * optarg; while ((c = tr_getopt (getUsage (), argc, argv, options, &optarg))) { switch (c) { case 'm': magnetFlag = true; break; case 's': scrapeFlag = true; break; case 'V': showVersion = true; break; case TR_OPT_UNK: filename = optarg; break; default: return 1; } } return 0; }
int SipLogCommand::execute(int argc, char* argv[]) { //printf("no operation command with %d arguments\n", argc); //printf("exiting with status: %d\n", CommandProcessor::COMMAND_SUCCESS_EXIT); int commandStatus = CommandProcessor::COMMAND_FAILED; if(argc == 2) { UtlString logOperations(argv[1]); commandStatus = CommandProcessor::COMMAND_SUCCESS; if(logOperations.compareTo("stop") == 0) { mSipUserAgent->stopMessageLog(); osPrintf("SIP logging Stopped\n"); } else if(logOperations.compareTo("start") == 0) { mSipUserAgent->clearMessageLog(); mSipUserAgent->startMessageLog(); osPrintf("SIP logging Started\n"); } else if(logOperations.compareTo("dump") == 0) { UtlString log; mSipUserAgent->getMessageLog(log); osPrintf("\n============>\n%s\n============>\n", log.data()); } else if(logOperations.compareTo("clear") == 0) { mSipUserAgent->clearMessageLog(); osPrintf("SIP log cleared\n"); } else { argc = 1; } } if(argc != 2) { UtlString usage; getUsage(argv[0], &usage); printf("%s", usage.data()); commandStatus = CommandProcessor::COMMAND_BAD_SYNTAX; } else { } return(commandStatus); }
int ConferenceGetCallsCommand::execute(int argc, char* argv[]) { int commandStatus = CommandProcessor::COMMAND_FAILED; if(argc == 2) { SIPX_CALL calls[CONF_MAX_CONNECTIONS]; size_t numCalls; if(sipxConferenceGetCalls(atoi(argv[1]), calls, CONF_MAX_CONNECTIONS, numCalls) == SIPX_RESULT_SUCCESS) { printf("The %d call handles in the conference with id: %d are:\n", numCalls, atoi(argv[1])); for(unsigned int i = 0; i < numCalls; i++) { printf("%d ", calls[i]); } printf("\n"); } } else { UtlString usage; getUsage(argv[0], &usage); printf("%s", usage.data()); commandStatus = CommandProcessor::COMMAND_BAD_SYNTAX; } return commandStatus; }
TextureStorage9_Cube::TextureStorage9_Cube(Renderer *renderer, GLenum internalformat, bool renderTarget, int size, int levels) : TextureStorage9(renderer, GetTextureUsage(internalformat, Renderer9::makeRenderer9(renderer), renderTarget)) { mTexture = NULL; for (int i = 0; i < 6; ++i) { mRenderTarget[i] = NULL; } // if the size is not positive this should be treated as an incomplete texture // we handle that here by skipping the d3d texture creation if (size > 0) { IDirect3DDevice9 *device = mRenderer->getDevice(); int height = size; D3DFORMAT format = gl_d3d9::GetTextureFormat(internalformat, mRenderer); d3d9::MakeValidSize(false, format, &size, &height, &mTopLevel); UINT creationLevels = (levels == 0) ? 0 : mTopLevel + levels; HRESULT result = device->CreateCubeTexture(size, creationLevels, getUsage(), format, getPool(), &mTexture, NULL); if (FAILED(result)) { ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY); gl::error(GL_OUT_OF_MEMORY); } } initializeRenderTarget(); }
void CReactionInterface::initMapping() { mpParameters = new CFunctionParameters(mpFunction->getVariables()); //make sure mpParameters is deleted! (e.g. in copyMapping()) mNameMap.resize(size()); mValues.resize(size()); mIsLocal.resize(size()); size_t i, imax = size(); for (i = 0; i < imax; ++i) { if (isVector(i)) mNameMap[i].resize(0); else { mNameMap[i].resize(1); mNameMap[i][0] = "unknown"; } if (getUsage(i) == CFunctionParameter::PARAMETER) mIsLocal[i] = true; else mIsLocal[i] = false; mValues[i] = 0.1; } }
MojErr MojDbQuotaEngine::applyOffset(const MojString& kindId, MojInt64 offset, MojDbStorageTxn* txn) { MojAssert(txn); // get old value MojRefCountedPtr<MojDbStorageItem> item; MojInt64 usage = 0; MojErr err = getUsage(kindId, txn, true, usage, item); MojErrCheck(err); if (item.get()) { MojInt64 newUsage = offset + usage; MojAssert(newUsage >= 0); MojObject newVal(newUsage); MojBuffer buf; err = newVal.toBytes(buf); MojErrCheck(err); // insert new record txn->quotaEnabled(false); err = m_usageDb->update(kindId, buf, item.get(), txn); MojErrCheck(err); txn->quotaEnabled(true); } else { err = insertUsage(kindId, offset, txn); MojErrCheck(err); } return MojErrNone; }
const std::string& CmdShadowPolygonOffset::execute( const std::vector< std::string >& arguments ) { _cmdResult = ""; if ( !arguments.size() ) { _cmdResult += getUsage(); return _cmdResult; } bool shadow; yaf3d::Configuration::get()->getSettingValue( YAF3D_GS_SHADOW_ENABLE, shadow ); if ( !shadow ) { _cmdResult += "dynamic shadows are not enabled! this command has no effect."; return _cmdResult; } if ( arguments[ 0 ] == "info" ) { std::stringstream str; float factor = 0.0f; float units = 0.0f; yaf3d::ShadowManager::get()->getPolygonOffset( factor, units ); str << "factor: " << factor << " " << "units: " << units; _cmdResult = str.str(); return _cmdResult; } else if ( arguments[ 0 ] == "set" ) { if ( arguments.size() < 2 ) { _cmdResult += getUsage(); return _cmdResult; } std::stringstream str; float factor = 0.0f; float units = 0.0f; str << arguments[ 1 ]; str >> factor >> units; yaf3d::ShadowManager::get()->setPolygonOffset( factor, units ); } else {
static int parseCommandLine (int argc, const char ** argv) { int c; const char * optarg; while ((c = tr_getopt (getUsage (), argc, argv, options, &optarg))) { switch (c) { case 'V': showVersion = true; break; case 'p': isPrivate = true; break; case 'o': outfile = optarg; break; case 'c': comment = optarg; break; case 't': if (trackerCount + 1 < MAX_TRACKERS) { trackers[trackerCount].tier = trackerCount; trackers[trackerCount].announce = (char*) optarg; ++trackerCount; } break; case 's': if (optarg) { char * endptr = NULL; piecesize_kib = strtoul (optarg, &endptr, 10); if (endptr && *endptr=='M') piecesize_kib *= KiB; } break; case TR_OPT_UNK: infile = optarg; break; default: return 1; } } return 0; }
string Clocker::readReset() { ostringstream str; end(); double diff = getTimediff(); double timeUsed = getUsage() / 1E6; str << ":: " << tod(&now) << " :: " << setfill('0') << setprecision(6) << setw(10) << diff << " sec elapsed; " << setfill(' ') << setprecision(4) << timeUsed << " cpu sec used" ; begin(); return str.str(); }
void CReactionInterface::updateModifiersInChemEq() { mChemEqI.clearModifiers(); size_t j, jmax = size(); for (j = 0; j < jmax; ++j) if (getUsage(j) == CFunctionParameter::MODIFIER) //all the modifiers in the table if (getMapping(j) != "unknown") mChemEqI.addModifier(getMapping(j)); }
int main (int argc, char *argv[]) { static const char *args = "/dev/hidrawX page"; auto mem_type = HIDPP20::IOnboardProfiles::MemoryType::Writeable; HIDPP::DeviceIndex device_index = HIDPP::DefaultDevice; std::vector<Option> options = { DeviceIndexOption (device_index), VerboseOption (), Option ('r', "rom", Option::NoArgument, "", "Read data from ROM", [&mem_type] (const char *) -> bool { mem_type = HIDPP20::IOnboardProfiles::MemoryType::ROM; return true; }), }; Option help = HelpOption (argv[0], args, &options); options.push_back (help); int first_arg; if (!Option::processOptions (argc, argv, options, first_arg)) return EXIT_FAILURE; if (argc-first_arg != 2) { fprintf (stderr, "%s", getUsage (argv[0], args, &options).c_str ()); return EXIT_FAILURE; } const char *path = argv[first_arg]; char *endptr; unsigned int page = strtol (argv[first_arg+1], &endptr, 0); if (*endptr != '\0') { fprintf (stderr, "Invalid page number.\n"); return EXIT_FAILURE; } try { HIDPP20::Device dev (path, device_index); HIDPP20::IOnboardProfiles iop (&dev); auto desc = iop.getDescription (); unsigned int i = 0; while (i < desc.sector_size) { auto data = iop.memoryRead (mem_type, page, i); write (1, data.data (), data.size ()); i += data.size (); } } catch (HIDPP20::Error e) { fprintf (stderr, "HID++2 error %d: %s\n", e.errorCode (), e.what ()); return e.errorCode (); } return EXIT_SUCCESS; }
MojErr MojDbQuotaEngine::kindUsage(const MojChar* kindId, MojInt64& usageOut, MojDbStorageTxn* txn) { MojLogTrace(s_log); MojString kindStr; MojErr err = kindStr.assign(kindId); MojErrCheck(err); MojRefCountedPtr<MojDbStorageItem> item; err = getUsage(kindStr, txn, false, usageOut, item); MojErrCheck(err); return MojErrNone; }