static void dbgbuf(unsigned int cmd, struct video_device *vfd, struct v4l2_buffer *p) { struct v4l2_timecode *tc=&p->timecode; dbgarg (cmd, "%02ld:%02d:%02d.%08ld index=%d, type=%s, " "bytesused=%d, flags=0x%08d, " "field=%0d, sequence=%d, memory=%s, offset/userptr=0x%08lx, length=%d\n", (p->timestamp.tv_sec/3600), (int)(p->timestamp.tv_sec/60)%60, (int)(p->timestamp.tv_sec%60), p->timestamp.tv_usec, p->index, prt_names(p->type,v4l2_type_names_FIXME), p->bytesused,p->flags, p->field,p->sequence, prt_names(p->memory,v4l2_memory_names), p->m.userptr, p->length); dbgarg2 ("timecode= %02d:%02d:%02d type=%d, " "flags=0x%08d, frames=%d, userbits=0x%08x\n", tc->hours,tc->minutes,tc->seconds, tc->type, tc->flags, tc->frames, *(__u32 *) tc->userbits); }
/** Read command line args. */ Cpptraj::Mode Cpptraj::ProcessCmdLineArgs(int argc, char** argv) { bool hasInput = false; bool interactive = false; Sarray inputFiles; Sarray topFiles; Sarray trajinFiles; Sarray trajoutFiles; Sarray refFiles; for (int i = 1; i < argc; i++) { std::string arg(argv[i]); if ( arg == "--help" || arg == "-h" ) { // --help, -help: Print usage and exit SetWorldSilent(true); Usage(); return QUIT; } if ( arg == "-V" || arg == "--version" ) { // -V, --version: Print version number and exit SetWorldSilent( true ); loudPrintf("CPPTRAJ: Version %s\n", CPPTRAJ_VERSION_STRING); return QUIT; } if ( arg == "--internal-version" ) { // --internal-version: Print internal version number and quit. SetWorldSilent( true ); loudPrintf("CPPTRAJ: Internal version # %s\n", CPPTRAJ_INTERNAL_VERSION); return QUIT; } if ( arg == "--defines" ) { // --defines: Print information on compiler defines used and exit SetWorldSilent( true ); loudPrintf("Compiled with:"); loudPrintf("%s\n", Cpptraj::Defines().c_str()); return QUIT; } if (arg == "-tl") { // -tl: Trajectory length if (topFiles.empty()) { mprinterr("Error: No topology file specified.\n"); return ERROR; } SetWorldSilent( true ); if (State_.TrajLength( topFiles[0], trajinFiles )) return ERROR; return QUIT; } if ( arg == "--interactive" ) interactive = true; else if ( arg == "-debug" && i+1 != argc) { // -debug: Set overall debug level ArgList dbgarg( argv[++i] ); State_.SetListDebug( dbgarg ); } else if ( arg == "--log" && i+1 != argc) // --log: Set up log file for interactive mode logfilename_ = argv[++i]; else if ( arg == "-p" && i+1 != argc) { // -p: Topology file topFiles.push_back( argv[++i] ); } else if ( arg == "-y" && i+1 != argc) { // -y: Trajectory file in trajinFiles.push_back( argv[++i] ); } else if ( arg == "-x" && i+1 != argc) { // -x: Trajectory file out trajoutFiles.push_back( argv[++i] ); } else if ( arg == "-c" && i+1 != argc) { // -c: Reference file refFiles.push_back( argv[++i] ); } else if (arg == "-i" && i+1 != argc) { // -i: Input file(s) inputFiles.push_back( argv[++i] ); } else if (arg == "-ms" && i+1 != argc) { // -ms: Parse mask string, print selected atom #s if (ProcessMask( topFiles, refFiles, std::string(argv[++i]), false, false )) return ERROR; return QUIT; } else if (arg == "-mr" && i+1 != argc) { // -mr: Parse mask string, print selected res #s if (ProcessMask( topFiles, refFiles, std::string(argv[++i]), false, true )) return ERROR; return QUIT; } else if (arg == "--mask" && i+1 != argc) { // --mask: Parse mask string, print selected atom details if (ProcessMask( topFiles, refFiles, std::string(argv[++i]), true, false )) return ERROR; return QUIT; } else if (arg == "--resmask" && i+1 != argc) { // --resmask: Parse mask string, print selected residue details if (ProcessMask( topFiles, refFiles, std::string(argv[++i]), true, true )) return ERROR; return QUIT; } else if ( i == 1 ) { // For backwards compatibility with PTRAJ; Position 1 = TOP file topFiles.push_back( argv[i] ); } else if ( i == 2 ) { // For backwards compatibility with PTRAJ; Position 2 = INPUT file inputFiles.push_back( argv[i] ); } else { // Unrecognized mprintf(" Unrecognized input on command line: %i: %s\n", i,argv[i]); Usage(); return ERROR; } } Cpptraj::Intro(); // Add all topology files specified on command line. for (Sarray::const_iterator topFilename = topFiles.begin(); topFilename != topFiles.end(); ++topFilename) if (State_.AddTopology( *topFilename, ArgList() )) return ERROR; // Add all reference trajectories specified on command line. for (Sarray::const_iterator refName = refFiles.begin(); refName != refFiles.end(); ++refName) if (State_.AddReference( *refName )) return ERROR; // Add all input trajectories specified on command line. for (Sarray::const_iterator trajinName = trajinFiles.begin(); trajinName != trajinFiles.end(); ++trajinName) if (State_.AddTrajin( *trajinName )) return ERROR; // Add all output trajectories specified on command line. if (!trajoutFiles.empty()) { hasInput = true; // This allows direct traj conversion with no other input for (Sarray::const_iterator trajoutName = trajoutFiles.begin(); trajoutName != trajoutFiles.end(); ++trajoutName) if (State_.AddOutputTrajectory( *trajoutName )) return ERROR; } // Process all input files specified on command line. if ( !inputFiles.empty() ) { hasInput = true; for (Sarray::const_iterator inputFilename = inputFiles.begin(); inputFilename != inputFiles.end(); ++inputFilename) { Command::RetType c_err = Command::ProcessInput( State_, *inputFilename ); if (c_err == Command::C_ERR && State_.ExitOnError()) return ERROR; if (c_err == Command::C_QUIT) return QUIT; } } // Determine whether to enter interactive mode if (!hasInput || interactive) { // Test if input is really from a console if ( isatty(fileno(stdin)) ) return INTERACTIVE; else { // "" means read from STDIN Command::RetType c_err = Command::ProcessInput( State_, "" ); if (c_err == Command::C_ERR && State_.ExitOnError()) return ERROR; if (c_err == Command::C_QUIT) return QUIT; } } return BATCH; }