コード例 #1
0
ファイル: agi.cpp プロジェクト: Templier/scummvm-test
int AgiEngine::agiInit() {
	int ec, i;

	debug(2, "initializing");
	debug(2, "game version = 0x%x", getVersion());

	// initialize with adj.ego.move.to.x.y(0, 0) so to speak
	_game.adjMouseX = _game.adjMouseY = 0;

	// reset all flags to false and all variables to 0
	for (i = 0; i < MAX_FLAGS; i++)
		_game.flags[i] = 0;
	for (i = 0; i < MAX_VARS; i++)
		_game.vars[i] = 0;

	// clear all resources and events
	for (i = 0; i < MAX_DIRS; i++) {
		memset(&_game.views[i], 0, sizeof(struct AgiView));
		memset(&_game.pictures[i], 0, sizeof(struct AgiPicture));
		memset(&_game.logics[i], 0, sizeof(struct AgiLogic));
		memset(&_game.sounds[i], 0, sizeof(class AgiSound *)); // _game.sounds contains pointers now
		memset(&_game.dirView[i], 0, sizeof(struct AgiDir));
		memset(&_game.dirPic[i], 0, sizeof(struct AgiDir));
		memset(&_game.dirLogic[i], 0, sizeof(struct AgiDir));
		memset(&_game.dirSound[i], 0, sizeof(struct AgiDir));
	}

	// clear view table
	for (i = 0; i < MAX_VIEWTABLE; i++)
		memset(&_game.viewTable[i], 0, sizeof(struct VtEntry));

	initWords();

	if (!_menu)
		_menu = new Menu(this, _gfx, _picture);

	initPriTable();

	// clear string buffer
	for (i = 0; i < MAX_STRINGS; i++)
		_game.strings[i][0] = 0;

	// setup emulation

	switch (getVersion() >> 12) {
	case 2:
		debug("Emulating Sierra AGI v%x.%03x\n",
				(int)(getVersion() >> 12) & 0xF,
				(int)(getVersion()) & 0xFFF);
		break;
	case 3:
		debug("Emulating Sierra AGI v%x.002.%03x\n",
				(int)(getVersion() >> 12) & 0xF,
				(int)(getVersion()) & 0xFFF);
		break;
	}

	if (getPlatform() == Common::kPlatformAmiga)
		_game.gameFlags |= ID_AMIGA;

	if (getFeatures() & GF_AGDS)
		_game.gameFlags |= ID_AGDS;

	// Make the 256 color AGI screen the default AGI screen when AGI256 or AGI256-2 is used
	if (getFeatures() & (GF_AGI256 | GF_AGI256_2))
		_game.sbuf = _game.sbuf256c;

	if (_game.gameFlags & ID_AMIGA)
		debug(1, "Amiga padded game detected.");

	if (_game.gameFlags & ID_AGDS)
		debug(1, "AGDS mode enabled.");

	ec = _loader->init();	// load vol files, etc

	if (ec == errOK)
		ec = _loader->loadObjects(OBJECTS);

	// note: demogs has no words.tok
	if (ec == errOK)
		ec = _loader->loadWords(WORDS);

	// FIXME: load IIgs instruments and samples
	// load_instruments("kq.sys16");

	// Load logic 0 into memory
	if (ec == errOK)
		ec = _loader->loadResource(rLOGIC, 0);

#ifdef __DS__
	// Normally, the engine loads the predictive text dictionary when the predictive dialog
	// is shown.  On the DS version, the word completion feature needs the dictionary too.
	loadDict();
#endif

	_egoHoldKey = false;

	_game.mouseFence.setWidth(0); // Reset

	return ec;
}
コード例 #2
0
/** @cond doxygenLibsbmlInternal */
void TextGlyph::readAttributes (const XMLAttributes& attributes,
                                const ExpectedAttributes& expectedAttributes)
{
	const unsigned int sbmlLevel   = getLevel  ();
	const unsigned int sbmlVersion = getVersion();

	unsigned int numErrs;

	/* look to see whether an unknown attribute error was logged
	 * during the read of the listOfTextGlyphs - which will have
	 * happened immediately prior to this read
	*/

  bool loSubGlyphs = false;
  if (getParentSBMLObject() != NULL
    && getParentSBMLObject()->getElementName() == "listOfSubGlyphs")
  {
    loSubGlyphs = true;
  }

	if (getErrorLog() != NULL &&
	    static_cast<ListOfTextGlyphs*>(getParentSBMLObject())->size() < 2)
	{
		numErrs = getErrorLog()->getNumErrors();
		for (int n = numErrs-1; n >= 0; n--)
		{
			if (getErrorLog()->getError(n)->getErrorId() == UnknownPackageAttribute)
			{
				const std::string details =
				      getErrorLog()->getError(n)->getMessage();
				getErrorLog()->remove(UnknownPackageAttribute);
        if (loSubGlyphs == true)
        {
				  getErrorLog()->logPackageError("layout", 
                                    LayoutLOSubGlyphAllowedAttribs,
				            getPackageVersion(), sbmlLevel, sbmlVersion, details);
        }
        else
        {
				  getErrorLog()->logPackageError("layout", 
                                    LayoutLOTextGlyphAllowedAttributes,
				            getPackageVersion(), sbmlLevel, sbmlVersion, details);
        }
			}
			else if (getErrorLog()->getError(n)->getErrorId() == UnknownCoreAttribute)
			{
				const std::string details =
				           getErrorLog()->getError(n)->getMessage();
				getErrorLog()->remove(UnknownCoreAttribute);
        if (loSubGlyphs == true)
        {
				  getErrorLog()->logPackageError("layout", 
                                    LayoutLOSubGlyphAllowedAttribs,
				            getPackageVersion(), sbmlLevel, sbmlVersion, details);
        }
        else
        {
				  getErrorLog()->logPackageError("layout", 
                                    LayoutLOTextGlyphAllowedAttributes,
				            getPackageVersion(), sbmlLevel, sbmlVersion, details);
        }
			}
		}
	}

	GraphicalObject::readAttributes(attributes, expectedAttributes);

	// look to see whether an unknown attribute error was logged
	if (getErrorLog() != NULL)
	{
		numErrs = getErrorLog()->getNumErrors();
		for (int n = numErrs-1; n >= 0; n--)
		{
			if (getErrorLog()->getError(n)->getErrorId() == UnknownPackageAttribute)
			{
				const std::string details =
				                  getErrorLog()->getError(n)->getMessage();
				getErrorLog()->remove(UnknownPackageAttribute);
				getErrorLog()->logPackageError("layout", LayoutTGAllowedAttributes,
				               getPackageVersion(), sbmlLevel, sbmlVersion, details);
			}
			else if (getErrorLog()->getError(n)->getErrorId() == UnknownCoreAttribute)
			{
				const std::string details =
				                  getErrorLog()->getError(n)->getMessage();
				getErrorLog()->remove(UnknownCoreAttribute);
				getErrorLog()->logPackageError("layout", LayoutTGAllowedCoreAttributes,
				               getPackageVersion(), sbmlLevel, sbmlVersion, details);
			}
		}
	}

	bool assigned = false;

	//
	// graphicalObject SIdRef   ( use = "optional" )
	//
	assigned = attributes.readInto("graphicalObject", mGraphicalObject);

	if (assigned == true && getErrorLog() != NULL)
	{
		// check string is not empty and correct syntax

		if (mGraphicalObject.empty() == true)
		{
			logEmptyString(mGraphicalObject, getLevel(), getVersion(), "<TextGlyph>");
		}
		else if (SyntaxChecker::isValidSBMLSId(mGraphicalObject) == false)
		{
			getErrorLog()->logPackageError("layout", LayoutTGGraphicalObjectSyntax,
				             getPackageVersion(), sbmlLevel, sbmlVersion);
		}
	}

	//
	// text string   ( use = "optional" )
	//
	assigned = attributes.readInto("text", mText);

	if (assigned == true && getErrorLog() != NULL)
	{
		// check string is not empty

		if (mText.empty() == true)
		{
			logEmptyString(mText, getLevel(), getVersion(), "<TextGlyph>");
		}
	}

	//
	// originOfText SIdRef   ( use = "optional" )
	//
	assigned = attributes.readInto("originOfText", mOriginOfText);

	if (assigned == true && getErrorLog() != NULL)
	{
		// check string is not empty and correct syntax

		if (mOriginOfText.empty() == true)
		{
			logEmptyString(mOriginOfText, getLevel(), getVersion(), "<TextGlyph>");
		}
		else if (SyntaxChecker::isValidSBMLSId(mOriginOfText) == false)
		{
			getErrorLog()->logPackageError("layout", LayoutTGOriginOfTextSyntax,
				             getPackageVersion(), sbmlLevel, sbmlVersion);
		}
	}

}
コード例 #3
0
ファイル: run.c プロジェクト: bertoncelj1/MC_tester
//na lokacijo (x, y) izpise verzijo programa
void drawVersion(int x, int y){
  GrX = x; GrY = y;
  printf("%s", getVersion());
  LCD_sendC();
}
コード例 #4
0
/** @cond doxygenLibsbmlInternal */
void ReactionGlyph::readAttributes (const XMLAttributes& attributes,
                                    const ExpectedAttributes& expectedAttributes)
{
  const unsigned int sbmlLevel   = getLevel  ();
  const unsigned int sbmlVersion = getVersion();

  unsigned int numErrs;

  /* look to see whether an unknown attribute error was logged
  * during the read of the listOfReactionGlyphs - which will have
  * happened immediately prior to this read
  */

  bool loSubGlyphs = false;
  if (getParentSBMLObject() != NULL
    && getParentSBMLObject()->getElementName() == "listOfSubGlyphs")
  {
    loSubGlyphs = true;
  }

  if (getErrorLog() != NULL &&
    static_cast<ListOfReactionGlyphs*>(getParentSBMLObject())->size() < 2)
  {
    numErrs = getErrorLog()->getNumErrors();
    for (int n = (int)numErrs-1; n >= 0; n--)
    {
      if (getErrorLog()->getError((unsigned int)n)->getErrorId() == UnknownPackageAttribute)
      {
        const std::string details =
          getErrorLog()->getError((unsigned int)n)->getMessage();
        getErrorLog()->remove(UnknownPackageAttribute);
        if (loSubGlyphs == true)
        {
          getErrorLog()->logPackageError("layout", 
            LayoutLOSubGlyphAllowedAttribs,
            getPackageVersion(), sbmlLevel, sbmlVersion, details, getLine(), getColumn());
        }
        else
        {
          getErrorLog()->logPackageError("layout", 
            LayoutLORnGlyphAllowedAttributes,
            getPackageVersion(), sbmlLevel, sbmlVersion, details, getLine(), getColumn());
        }
      }
      else if (getErrorLog()->getError((unsigned int)n)->getErrorId() == UnknownCoreAttribute)
      {
        const std::string details =
          getErrorLog()->getError((unsigned int)n)->getMessage();
        getErrorLog()->remove(UnknownCoreAttribute);
        if (loSubGlyphs == true)
        {
          getErrorLog()->logPackageError("layout", 
            LayoutLOSubGlyphAllowedAttribs,
            getPackageVersion(), sbmlLevel, sbmlVersion, details, getLine(), getColumn());
        }
        else
        {
          getErrorLog()->logPackageError("layout", 
            LayoutLORnGlyphAllowedAttributes,
            getPackageVersion(), sbmlLevel, sbmlVersion, details, getLine(), getColumn());
        }
      }
    }
  }

  GraphicalObject::readAttributes(attributes, expectedAttributes);

  // look to see whether an unknown attribute error was logged
  if (getErrorLog() != NULL)
  {
    numErrs = getErrorLog()->getNumErrors();
    for (int n = (int)numErrs-1; n >= 0; n--)
    {
      if (getErrorLog()->getError((unsigned int)n)->getErrorId() == UnknownPackageAttribute)
      {
        const std::string details =
          getErrorLog()->getError((unsigned int)n)->getMessage();
        getErrorLog()->remove(UnknownPackageAttribute);
        getErrorLog()->logPackageError("layout", LayoutRGAllowedAttributes,
          getPackageVersion(), sbmlLevel, sbmlVersion, details, getLine(), getColumn());
      }
      else if (getErrorLog()->getError((unsigned int)n)->getErrorId() == UnknownCoreAttribute)
      {
        const std::string details =
          getErrorLog()->getError((unsigned int)n)->getMessage();
        getErrorLog()->remove(UnknownCoreAttribute);
        getErrorLog()->logPackageError("layout", LayoutRGAllowedCoreAttributes,
          getPackageVersion(), sbmlLevel, sbmlVersion, details, getLine(), getColumn());
      }
    }
  }

  bool assigned = false;

  //
  // reaction SIdRef   ( use = "optional" )
  //
  assigned = attributes.readInto("reaction", mReaction);

  if (assigned == true && getErrorLog() != NULL)
  {
    // check string is not empty and correct syntax

    if (mReaction.empty() == true)
    {
      logEmptyString(mReaction, getLevel(), getVersion(), "<ReactionGlyph>");
    }
    else if (SyntaxChecker::isValidSBMLSId(mReaction) == false)
    {
      getErrorLog()->logPackageError("layout", LayoutRGReactionSyntax,
        getPackageVersion(), sbmlLevel, sbmlVersion, "The reaction on the <" 
        + getElementName() + "> is '" + mReaction + "', which does not conform to the syntax.", getLine(), getColumn());
    }
  }

}
コード例 #5
0
ファイル: agi.cpp プロジェクト: AReim1982/scummvm
void AgiEngine::initialize() {
	// TODO: Some sound emulation modes do not fit our current music
	//       drivers, and I'm not sure what they are. For now, they might
	//       as well be called "PC Speaker" and "Not PC Speaker".

	// If used platform is Apple IIGS then we must use Apple IIGS sound emulation
	// because Apple IIGS AGI games use only Apple IIGS specific sound resources.
	if (getPlatform() == Common::kPlatformApple2GS) {
		_soundemu = SOUND_EMU_APPLE2GS;
	} else if (getPlatform() == Common::kPlatformCoCo3) {
		_soundemu = SOUND_EMU_COCO3;
	} else if (ConfMan.get("music_driver") == "auto") {
		// Default sound is the proper PCJr emulation
		_soundemu = SOUND_EMU_PCJR;
	} else {
		switch (MidiDriver::getMusicType(MidiDriver::detectDevice(MDT_PCSPK | MDT_AMIGA | MDT_ADLIB | MDT_PCJR | MDT_MIDI))) {
		case MT_PCSPK:
			_soundemu = SOUND_EMU_PC;
			break;
		case MT_ADLIB:
			_soundemu = SOUND_EMU_NONE;
			break;
		case MT_PCJR:
			_soundemu = SOUND_EMU_PCJR;
			break;
		case MT_AMIGA:
			_soundemu = SOUND_EMU_AMIGA;
			break;
		default:
			debug(0, "DEF");
			_soundemu = SOUND_EMU_MIDI;
			break;
		}
	}

	initRenderMode();

	_console = new Console(this);
	_words = new Words(this);
	_font = new GfxFont(this);
	_gfx = new GfxMgr(this, _font);
	_sound = new SoundMgr(this, _mixer);
	_picture = new PictureMgr(this, _gfx);
	_sprites = new SpritesMgr(this, _gfx);
	_text = new TextMgr(this, _words, _gfx);
	_systemUI = new SystemUI(this, _gfx, _text);
	_inventory = new InventoryMgr(this, _gfx, _text, _systemUI);

	_font->init();
	_gfx->initVideo();

	_text->init(_systemUI);

	_game.gameFlags = 0;

	_text->charAttrib_Set(15, 0);

	_game.name[0] = '\0';

	_lastSaveTime = 0;

	debugC(2, kDebugLevelMain, "Detect game");

	if (agiDetectGame() == errOK) {
		debugC(2, kDebugLevelMain, "game loaded");
	} else {
		warning("Could not open AGI game");
	}
	// finally set up actual VM opcodes, because we should now have figured out the right AGI version
	setupOpCodes(getVersion());

	debugC(2, kDebugLevelMain, "Init sound");
}
コード例 #6
0
MainWindow::MainWindow( QWidget *parent ) : QMainWindow( parent )
{
//  QObject::connect( this, SIGNAL( finishedBuildFilelist( bool ) ), this, SLOT( doIt( bool ) ) );

// **********************************************************************************************

    setWaitCursor();

// **********************************************************************************************
// init

    gi_ActionNumber  = 1;
    gi_Extension     = _TXT_;

    gs_Version       = "unknown";

    gsl_FilenameList.clear();

// **********************************************************************************************

    #if defined(Q_OS_LINUX)
        gb_showProgressBar = true;
    #endif

    #if defined(Q_OS_MAC)
        gb_showProgressBar = false;
    #endif

    #if defined(Q_OS_WIN)
        gb_showProgressBar = true;
    #endif

// **********************************************************************************************

    Model		= new QStringListModel( this );
    ListView	= new QListView;

    ListView->setModel( Model );
    ListView->setEditTriggers( QAbstractItemView::NoEditTriggers );

    setCentralWidget( ListView );

    setAcceptDrops( true );

// **********************************************************************************************

    loadPreferences();

    if ( gi_NumOfProgramStarts++ < 1 )
        savePreferences();

    gs_Version = getVersion();

// **********************************************************************************************

    createActions();
    createMenus();
    createStatusBar( gb_showProgressBar );

// **********************************************************************************************

    this->resize( sizeWindow );
    this->move( posWindow );
    this->show();

// **********************************************************************************************

    gsl_FilenameList = expandCommandline();

// **********************************************************************************************

    setGeocodeRangeFlagAction->setChecked( gb_setGeocode );

    setWTitle( gi_ActionNumber, gs_FilenameFormat, gi_Extension, gsl_FilenameList );
    setStatusBar( tr( "Ready" ), 2 );
    setNormalCursor();
}
コード例 #7
0
ファイル: object.cpp プロジェクト: tribal-tec/Collage
    return impl_->cm->sync( version );
}

uint128_t Object::getHeadVersion() const
{
    return impl_->cm->getHeadVersion();
}

uint128_t Object::getVersion() const
{
    return impl_->cm->getVersion();
}

void Object::notifyNewHeadVersion( const uint128_t& version LB_UNUSED )
{
    LBASSERTINFO( getVersion() == VERSION_NONE ||
                  version < getVersion() + 100,
                  lunchbox::className( this ));
}

CompressorInfo Object::chooseCompressor() const
{
    return pression::data::Registry::getInstance().choose();
}

uint32_t Object::getMasterInstanceID() const
{
    return impl_->cm->getMasterInstanceID();
}

NodePtr Object::getMasterNode()
コード例 #8
0
ファイル: op_cmd.cpp プロジェクト: CatalystG/scummvm
void cmdPopScript(AgiGame *state, uint8 *p) {
	if (getVersion() >= 0x2915) {
		debug(0, "pop.script");
	}
}
コード例 #9
0
ファイル: op_cmd.cpp プロジェクト: CatalystG/scummvm
void cmdHoldKey(AgiGame *state, uint8 *p) {
	if (getVersion() >= 0x3098) {
		state->_vm->_egoHoldKey = true;
	}
}
コード例 #10
0
ファイル: d_logic.cpp プロジェクト: fes/mongo
        bool run(const char *cmdns, BSONObj& cmdObj, string& errmsg, BSONObjBuilder& result, bool){
            
            string configdb = cmdObj["configdb"].valuestrsafe();
            { // configdb checking
                if ( configdb.size() == 0 ){
                    errmsg = "no configdb";
                    return false;
                }
                
                if ( shardConfigServer.size() == 0 ){
                    if ( ! cmdObj.getBoolField( "authoritative" ) ){
                        result.appendBool( "need_authoritative" , true );
                        errmsg = "first setShardVersion";
                        return false;
                    }
                    shardConfigServer = configdb;
                }
                else if ( shardConfigServer != configdb ){
                    errmsg = "specified a different configdb!";
                    return false;
                }
            }
            
            { // setting up ids
                if ( cmdObj["serverID"].type() != jstOID ){
                    // TODO: fix this
                    //errmsg = "need serverID to be an OID";
                    //return 0;
                }
                else {
                    OID clientId = cmdObj["serverID"].__oid();
                    if ( ! clientServerIds.get() ){
                        string s = clientId.str();
                        
                        OID * nid = new OID();
                        nid->init( s );
                        clientServerIds.reset( nid );
                        
                        if ( ! clientQueues[s] )
                            clientQueues[s] = new BlockingQueue<BSONObj>();
                    }
                    else if ( clientId != *clientServerIds.get() ){
                        errmsg = "server id has changed!";
                        return 0;
                    }
                }
            }
            
            unsigned long long version = getVersion( cmdObj["version"] , errmsg );
            if ( ! version )
                return false;

            NSVersions * versions = clientShardVersions.get();
            
            if ( ! versions ){
                log(1) << "entering shard mode for connection" << endl;
                versions = new NSVersions();
                clientShardVersions.reset( versions );
            }
            
            string ns = cmdObj["setShardVersion"].valuestrsafe();
            if ( ns.size() == 0 ){
                errmsg = "need to speciy fully namespace";
                return false;
            }

            unsigned long long& oldVersion = (*versions)[ns];
            if ( version < oldVersion ){
                errmsg = "you already have a newer version";
                result.appendTimestamp( "oldVersion" , oldVersion );
                result.appendTimestamp( "newVersion" , version );
                return false;
            }

            unsigned long long& myVersion = myVersions[ns];
            if ( version < myVersion ){
                errmsg = "going to older version for global";
                return false;
            }
            
            if ( myVersion == 0 && ! cmdObj.getBoolField( "authoritative" ) ){
                // need authoritative for first look
                result.appendBool( "need_authoritative" , true );
                result.append( "ns" , ns );
                errmsg = "first time for this ns";
                return false;
            }

            result.appendTimestamp( "oldVersion" , oldVersion );
            oldVersion = version;
            myVersion = version;

            result.append( "ok" , 1 );
            return 1;
        }
コード例 #11
0
ファイル: d_logic.cpp プロジェクト: fes/mongo
        bool run(const char *cmdns, BSONObj& cmdObj, string& errmsg, BSONObjBuilder& result, bool){
            // see MoveShardStartCommand::run
            
            string ns = cmdObj["moveshard.finish"].valuestrsafe();
            if ( ns.size() == 0 ){
                errmsg = "need ns as cmd value";
                return false;
            }

            string to = cmdObj["to"].valuestrsafe();
            if ( to.size() == 0 ){
                errmsg = "need to specify server to move shard to";
                return false;
            }


            unsigned long long newVersion = getVersion( cmdObj["newVersion"] , errmsg );
            if ( newVersion == 0 ){
                errmsg = "have to specify new version number";
                return false;
            }
                                                        
            BSONObj finishToken = cmdObj.getObjectField( "finishToken" );
            if ( finishToken.isEmpty() ){
                errmsg = "need finishToken";
                return false;
            }
            
            if ( ns != finishToken["collection"].valuestrsafe() ){
                errmsg = "namespaced don't match";
                return false;
            }
            
            // now we're locked
            myVersions[ns] = newVersion;
            NSVersions * versions = clientShardVersions.get();
            if ( ! versions ){
                versions = new NSVersions();
                clientShardVersions.reset( versions );
            }
            (*versions)[ns] = newVersion;
            
            BSONObj res;
            bool ok;
            
            {
                dbtemprelease unlock;
                
                ScopedDbConnection conn( to );
                ok = conn->runCommand( "admin" , 
                                       BSON( "finishCloneCollection" << finishToken ) ,
                                       res );
                conn.done();
            }
            
            if ( ! ok ){
                // uh oh
                errmsg = "finishCloneCollection failed!";
                result << "finishError" << res;
                return false;
            }
            
            // wait until cursors are clean
            cerr << "WARNING: deleting data before ensuring no more cursors TODO" << endl;
            
            dbtemprelease unlock;

            DBDirectClient client;
            BSONObj removeFilter = finishToken.getObjectField( "query" );
            client.remove( ns , removeFilter );

            return true;
        }
コード例 #12
0
ファイル: nfseg.c プロジェクト: Hao-HUST/NBIS
/***********************************************************************
************************************************************************
#cat: procargs - Process command line arguments, setting various
#cat:              static variables with file scope as appropriate.

   Input:
     argc        - standard argument count
     argv        - standard argument array

   Return Code:
     none        - return on success
     no return   - exit if invalid arguments are detected
************************************************************************/
static void procargs(int argc, char **argv)
{
   int opt, output_images_flag = 0;
   const char *const option_spec = "vbc:rRf:i:n:q:";
   const char *rest;
   REC_SEL *fgp_sel = NULL, *imp_sel = NULL, *idc_sel = NULL,
      *lrt_sel = NULL, *nqm_sel = NULL;

   if ((argc == 2) && (strcmp(argv[1], "-version") == 0)) {
      getVersion();
      exit(0);
   }

   program = strrchr(argv[0], '/');
   if (NULL == program)
      program = argv[0];
   else
      ++program;

   if (argc < 2)
      usage();

   /* The following section handles the deprecated old-style arguments. --jck */
   old_style_args_flag = ((7 == argc) && ('-' != argv[1][0]));
   if (old_style_args_flag) {
      fgp =        parse_num_arg(argv[1], "FGP");
      bthr_adj =   parse_num_arg(argv[2], "BTHR_ADJ");
      rot_search = parse_num_arg(argv[3], "ROT_SEARCH");
      comp =       parse_num_arg(argv[4], "COMP_SEG");
      rot_seg =    parse_num_arg(argv[5], "ROT_SEG");
      ifile = argv[6];
      optind = 7;
      /* End of old-style deprecated argument handling. --jck */
   } else {
      /* Processing exclusive to new-style argument handling... -- jck */
      while (-1 != (opt = getopt(argc, argv, option_spec))) {
	 switch(opt) {
	    
	 case 'v':
	    verbose = 1;
	    break;

	 case 'b':
	    bthr_adj = 1;
	    break;
	    
	 case 'c':
	    output_images_flag = 1;
	    comp = parse_num_arg(optarg, "-c <COMP_SEG>");
	    break;
	    
	 case 'r':
	    rot_search = 1;
	    break;
	    
	 case 'R':
	    rot_seg = 1;
	    break;
	    
	 case 'f':
	    if (parse_rec_sel_option(rs_fgp, optarg, &rest, &fgp_sel, verbose))
	       usage();
	    if (parse_rec_sel_option(rs_imp, rest, NULL, &imp_sel, verbose))
	       usage();
	    break;
	    
	 case 'i':
	    if (parse_rec_sel_option(rs_imp, optarg, NULL, &imp_sel, verbose))
	       usage();
	    break;
	    
	 case 'n':
	    if (parse_rec_sel_option(rs_idc, optarg, NULL, &idc_sel, verbose))
	       usage();
	    break;
	    
	 case 't':
	    if (parse_rec_sel_option(rs_lrt, optarg, NULL, &lrt_sel, verbose))
	       usage();
	    break;
	    
	 case 'q':
	    if (parse_rec_sel_option(rs_nqm, optarg, NULL, &nqm_sel, verbose))
	       usage();
	    break;
	    
	 case '?':
	    usage();
	    break;
	    
	 default:
	    fprintf(stderr, "Programming error: "
		    "incompletely implemented option: '%c'\n", opt);
	    exit(EXIT_FAILURE);
	 }
      }

      /* ANSI/NIST input file, required */
      if (optind < argc) 
	 ifile = argv[optind++];
      else
	 usage();
      
      ansi_nist_flag = is_ANSI_NIST_file(ifile);
      if (ansi_nist_flag < 0)
	 exit(EXIT_FAILURE);
      else if ( 0 == ansi_nist_flag ) {
	 fprintf(stderr, "Input is not an ANSI/NIST file: '%s'.\n", ifile);
	 usage();
      }

      /* ANSI/NIST output file, optional */
      if (optind < argc)
	 ofile = argv[optind++];
      
      if (new_rec_sel(&opt_rec_sel, rs_and, 5,
		      fgp_sel, imp_sel, idc_sel, lrt_sel, nqm_sel) < 0)
	 exit(EXIT_FAILURE);

   }

   /* This processing applies to both old- and new-style arguments. */
   if (optind < argc) {
      fprintf(stderr, "WARNING : procargs : extra arguments ignored: %s",
	      argv[optind++]);
      for (/* empty */; optind < argc; optind++)
	 fprintf(stderr, ", %s", argv[optind]);
      fprintf(stderr, "\n");
   }

   output_images = (ofile == NULL || output_images_flag);
   
   if (comp != UNSET && (comp < 0 || comp > 3)) {
      fprintf(stderr, "Invalid COMP (%d)\n", comp);
      fprintf(stderr, "0=JPEGL | 1=WSQ5:1 | 2=WSQ15:1 | 3=NONE\n");
      exit(EXIT_FAILURE);
   }

   check_tristate_value(bthr_adj, "BTHR_ADJ");
   check_tristate_value(rot_search, "ROT_SEARCH");
   check_tristate_value(rot_seg, "ROT_SEG");

   return;
}
コード例 #13
0
ファイル: scr_server.cpp プロジェクト: chagge/gym_torcs
/* Start a new race. */
static void
newrace(int index, tCarElt* car, tSituation *s)
{

    total_tics[index]=0;

    /***********************************************************************************
    ************************* UDP client identification ********************************
    ***********************************************************************************/

    bool identified=false;
    char line[UDP_MSGLEN];

    // Set timeout
    if (getTimeout()>0)
    	UDP_TIMEOUT = getTimeout();

    //Set sensor range
    if (strcmp(getVersion(),"2009")==0)
    {
    	__SENSORS_RANGE__ = 100;
    	printf("*****2009*****\n");
    }
    else if (strcmp(getVersion(),"2010")==0 || strcmp(getVersion(),"2011")==0)
        __SENSORS_RANGE__ = 200;
    else
    {
    	printf("%s is not a recognized version",getVersion());
    	exit(0);
    }

    listenSocket[index] = socket(AF_INET, SOCK_DGRAM, 0);
    if (listenSocket[index] < 0)
    {
        std::cerr << "Error: cannot create listenSocket!";
        exit(1);
    }

    srand(time(NULL));

    // Bind listen socket to listen port.
    serverAddress[index].sin_family = AF_INET;
    serverAddress[index].sin_addr.s_addr = htonl(INADDR_ANY);
    serverAddress[index].sin_port = htons(getUDPListenPort()+index);

    if (bind(listenSocket[index],
             (struct sockaddr *) &serverAddress[index],
             sizeof(serverAddress[index])) < 0)
    {
        std::cerr << "cannot bind socket";
        exit(1);
    }

    // Wait for connections from clients.
    listen(listenSocket[index], 5);

    std::cout << "Waiting for request on port " << getUDPListenPort()+index << "\n";

    // Loop until a client identifies correctly
    while (!identified)
    {

        clientAddressLength[index] = sizeof(clientAddress[index]);

        // Set line to all zeroes
        memset(line, 0x0, UDP_MSGLEN);
        if (recvfrom(listenSocket[index], line, UDP_MSGLEN, 0,
                     (struct sockaddr *) &clientAddress[index],
                     &clientAddressLength[index]) < 0)
        {
            std::cerr << "Error: problem in receiving from the listen socket";
            exit(1);
        }

#ifdef __UDP_SERVER_VERBOSE__
        // show the client's IP address
        std::cout << "  from " << inet_ntoa(clientAddress[index].sin_addr);

        // show the client's port number.
        std::cout << ":" << ntohs(clientAddress[index].sin_port) << "\n";

        // Show the line
        std::cout << "  Received: " << line << "\n";
#endif

        // compare received string with the ID
        if (strncmp(line,UDP_ID,3)==0)
        {
#ifdef __UDP_SERVER_VERBOSE__
            std::cout << "IDENTIFIED" << std::endl;
#endif
            std::string initStr(line);
            if (SimpleParser::parse(initStr,std::string("init"),trackSensAngle[index],19)==false)
            {
            	for (int i = 0; i < 19; ++i) {
            		trackSensAngle[index][i] =-90 + 10*i;
				}
            }
//            char line[UDP_MSGLEN];
            sprintf(line,"***identified***");
            // Sending the car state to the client
            if (sendto(listenSocket[index], line, strlen(line) + 1, 0,
                       (struct sockaddr *) &clientAddress[index],
                       sizeof(clientAddress[index])) < 0)
                std::cerr << "Error: cannot send identification message";
            identified=true;
        }
    }

	focusSens[index] = new Sensors(car, 5);//ML
	for (int i = 0; i < 5; ++i) {//ML
		focusSens[index]->setSensor(i,(car->_focusCmd)+i-2,200);//ML
	}//ML

    // Initialization of track sensors
    trackSens[index] = new Sensors(car, 19);
    for (int i = 0; i < 19; ++i) {
    	trackSens[index]->setSensor(i,trackSensAngle[index][i],__SENSORS_RANGE__);
#ifdef __UDP_SERVER_VERBOSE__
    	std::cout << "Set Track Sensors " << i+1 << " at angle " << trackSensAngle[index][i] << std::endl;
#endif
	}
    // Initialization of opponents sensors
    oppSens[index] = new ObstacleSensors(36, curTrack, car, s, __SENSORS_RANGE__);

    prevDist[index]=-1;
}
コード例 #14
0
void xml::lex::getXMLDecl(xml::token *tok)
{
	static const char* s_version = "version";
	static const char* s_encoding = "encoding";
	static const char* s_standalone = "standalone";
	static const char* s_endXMLDecl = "?>";

xmlDecl:;

	switch (m_sstate)
	{
		case _xml_decl_version :
			if (handleWhitespace() == false)
			{
				throw GException("XML Parser", 20, m_line, m_byte);
			}
			if (handleReserved(s_version) == false)
			{
				throw GException("XML Parser", 13, m_line, m_byte);
			}
			getEqual();
			getQuote();
			tok->m_type = xml::_version;
			if (getVersion(tok) == false)
			{
				throw GException("XML Parser", 13, m_line, m_byte);
			}
			getQuote();
			m_sstate = xml::_xml_decl_encoding;
			break;
		case _xml_decl_encoding :
			handleWhitespace();
			if (handleReserved(s_encoding) != false)
			{
				getEqual();
				getQuote();
				tok->m_type = xml::_encoding;
				if (getEncoding(tok) == false)
				{
					throw GException("XML Parser", 14, m_line, m_byte);
				}
				getQuote();
			}
			else
			{
				m_sstate = xml::_xml_decl_standalone;
				goto xmlDecl;
			}
			m_sstate = xml::_xml_decl_standalone;
			break;
		case _xml_decl_standalone :
			handleWhitespace();
			if (handleReserved(s_standalone) != false)
			{
				getEqual();
				getQuote();
				tok->m_type = xml::_standalone;
				if (getStandalone(tok) == false)
				{
					throw GException("XML Parser", 15, m_line, m_byte);
				}
				getQuote();
			}
			handleWhitespace();
			if (handleReserved(s_endXMLDecl) == false)
			{
				throw GException("XML Parser", 3, m_line, m_byte);
			}
			m_state = xml::_misc;
	}
}
コード例 #15
0
void rspfNitfFileHeaderV2_X::setDate(const rspfLocalTm& d)
{
   memcpy(theDateTime, formatDate(getVersion(), d).c_str(), 14);
}
コード例 #16
0
ファイル: op_cmd.cpp プロジェクト: CatalystG/scummvm
void cmdDiscardSound(AgiGame *state, uint8 *p) {
	if (getVersion() >= 0x2936) {
		debug(0, "discard.sound");
	}
}
コード例 #17
0
rspfRefPtr<rspfProperty> rspfNitfFileHeaderV2_X::getProperty(const rspfString& name)const
{
   rspfRefPtr<rspfProperty> property = 0;
   
   if(name == FHDR_KW)
   {
      property = new rspfStringProperty(name, rspfString(theFileTypeVersion));
   }
   else if(name == VERSION_KW)
   {
      property = new rspfStringProperty(name, rspfString(getVersion()));
   }
   else if(name == FILE_TYPE_KW)
   {
      property = new rspfStringProperty(name, "NITF");
   }
   else if(name == CLEVEL_KW)
   {
      rspfNumericProperty* numericProperty =
         new rspfNumericProperty(name,
                                  getComplexityLevel(),
                                  1,
                                  99);
      numericProperty->setNumericType(rspfNumericProperty::rspfNumericPropertyType_INT);
      property = numericProperty;
      
   }
   else if(name == STYPE_KW)
   {
      property = new rspfStringProperty(name, getSystemType().trim());
   }
   else if(name == OSTAID_KW)
   {
      property = new rspfStringProperty(name, getOriginatingStationId().trim());
   }
   else if(name == FDT_KW)
   {
      property = new rspfStringProperty(name, getDate());
   }
   else if(name == FTITLE_KW)
   {
      property = new rspfStringProperty(name, getTitle().trim());
   }
   else if(name == FSCLAS_KW)
   {
      rspfStringProperty* stringProperty =
         new rspfStringProperty(name,
                                 getSecurityClassification().trim(),
                                 false);
      
      stringProperty->addConstraint("");
      stringProperty->addConstraint("T");
      stringProperty->addConstraint("S");
      stringProperty->addConstraint("C");
      stringProperty->addConstraint("R");
      stringProperty->addConstraint("U");
      
      property = stringProperty;
   }
   else if(name == FSCODE_KW)
   {
      property = new rspfStringProperty(name,
                                         getCodeWords().trim());
   }
   else if(name == FSCTLH_KW)
   {
      property = new rspfStringProperty(name,
                                         getControlAndHandling().trim());
   }
   else if(name == FSREL_KW)
   {
      property = new rspfStringProperty(name,
                                         getReleasingInstructions().trim());
   }
   else if(name == FSCAUT_KW)
   {
      property = new rspfStringProperty(name,
                                         getClassificationAuthority().trim());
   }
   else if(name == FSCTLN_KW)
   {
      property = new rspfStringProperty(name,
                                         getSecurityControlNumber().trim());
      
   }
   else if(name == FSCOP_KW)
   {
      property = new rspfStringProperty(name,
                                         getCopyNumber().trim());
   }
   else if(name == FSCPYS_KW)
   {
      property = new rspfStringProperty(name,
                                         getNumberOfCopies().trim());
   }
   else if(name == ENCRYP_KW)
   {
      property = new rspfStringProperty(name,
                                         getEncryption().trim(),
                                         false);
   }
   else
   {
      property = rspfNitfFileHeader::getProperty(name).get();
   }
   
   return property;
}
コード例 #18
0
ファイル: op_cmd.cpp プロジェクト: CatalystG/scummvm
void cmdAllowMenu(AgiGame *state, uint8 *p) {
	if (getVersion() >= 0x3098) {
		setflag(fMenusWork, ((p0 != 0) ? true : false));
	}
}
コード例 #19
0
ファイル: object.cpp プロジェクト: MichaelVlad/Equalizer
void Object::notifyNewHeadVersion( const uint128_t& version )
{ 
    EQASSERTINFO( getVersion() == VERSION_NONE || 
                  version < getVersion() + 100, 
                  base::className( this ));
}
コード例 #20
0
ファイル: op_cmd.cpp プロジェクト: CatalystG/scummvm
void cmdReleaseKey(AgiGame *state, uint8 *p) {
	if (getVersion() >= 0x3098) {
		state->_vm->_egoHoldKey = false;
	}
}
コード例 #21
0
ファイル: object.cpp プロジェクト: tribal-tec/Collage
uint128_t Object::sync( const uint128_t& version )
{
    if( version == VERSION_NONE )
        return getVersion();
    return impl_->cm->sync( version );
}
コード例 #22
0
ファイル: LuaMSDK.cpp プロジェクト: fengqk/Art
static int lua_msdk_getVersion(lua_State * L)
{
		PUSHDELETESTRING(getVersion());
    return 1;
}
コード例 #23
0
/***************************************************************************

   Function:   CheckFileVersion

   Purpose:    Check the version information of a given file

   Input:      File name
               File location (Windows dir, System dir, Current dir or none)
               Reference to Major number 
               Reference to Minor number 
               Reference to Build number 

   Output:     TRUE only if successful

   Remarks:    Trashes original file name

****************************************************************************/
BOOL CDLLVersion::CheckFileVersion (LPSTR szFileName, int FileLoc, 
                                    DWORD &dwMajor, DWORD &dwMinor, 
                                    DWORD &dwBuildNumber)
{
LPSTR   lpVersion;                        // String pointer to 'version' text
//UINT    uVersionLen;
DWORD   dwVerHnd=0;                        // An 'ignored' parameter, always '0'
//VS_FIXEDFILEINFO vsFileInfo;

    FixFilePath (szFileName, FileLoc);  // Add necessary path prefix to file name

    DWORD dwVerInfoSize = GetFileVersionInfoSize (szFileName, &dwVerHnd);
    if (!dwVerInfoSize)     // Cannot reach the DLL file
        return FALSE;

    LPSTR lpstrVffInfo = (LPSTR) malloc (dwVerInfoSize);  // Alloc memory for file info
    if (lpstrVffInfo == NULL)
        return FALSE;   // Allocation failed

        // Try to get the info
    if (!GetFileVersionInfo(szFileName, dwVerHnd, dwVerInfoSize, lpstrVffInfo)) 
    {
        free (lpstrVffInfo);
        return FALSE;   // Cannot read the file information - 
                        // wierd, since we could read the information size
    }

    /* The below 'hex' value looks a little confusing, but
       essentially what it is, is the hexidecimal representation
       of a couple different values that represent the language
       and character set that we are wanting string values for.
       040904E4 is a very common one, because it means:
       US English, Windows MultiLingual characterset
       Or to pull it all apart:
       04------        = SUBLANG_ENGLISH_USA
       --09----        = LANG_ENGLISH
       ----04E4 = 1252 = Codepage for Windows:Multilingual
    */
    /*static char fileVersion[256];
    LPVOID version=NULL;
    DWORD vLen,langD;
    BOOL retVal;

    sprintf(fileVersion,"\\VarFileInfo\\Translation");
    retVal = VerQueryValue ( lpstrVffInfo,  
                             fileVersion, &version, (UINT *)&uVersionLen);
    if (retVal && vLen==4)
    {
        memcpy(&langD,version,4);
        sprintf(fileVersion, "\\StringFileInfo\\%02X%02X%02X%02X\\FileVersion",
                (langD & 0xff00)>>8,langD & 0xff,(langD & 0xff000000)>>24, 
                (langD & 0xff0000)>>16);            
    }
    else 
        sprintf(fileVersion,"\\StringFileInfo\\%04X04B0\\FileVersion",GetUserDefaultLangID());

    if (!VerQueryValue (    lpstrVffInfo, fileVersion, 
                (LPVOID *)&lpVersion, (UINT *)&uVersionLen))
        {    
        free (lpstrVffInfo);
        return FALSE;     // Query was unsuccessful    
        }
    */
    // Now we have a string that looks like this :
    // "MajorVersion.MinorVersion.BuildNumber", so let's parse it
    lpVersion = getVersion(szFileName);
    m_stFullVersion = getVersion(szFileName);
    BOOL bRes = ParseVersionString (lpVersion, dwMajor, dwMinor, dwBuildNumber);
    if(!bRes)
        // Lets try for commas
        bRes = ParseVersionString1 (lpVersion, dwMajor, dwMinor, dwBuildNumber);
    free (lpstrVffInfo);
    return bRes;
}
コード例 #24
0
void EspNewIncomingConnectionStream::actOnReceive(IpcConnection *connection)
{
  // check for OS errors
  if (getState() == ERROR_STATE)
  {
    ex_assert(FALSE,"Error while receiving first message from client");
  }

  // check for protocol errors
  bool willPassTheAssertion = 
             (getType() == IPC_MSG_SQLESP_DATA_REQUEST OR
              getType() == IPC_MSG_SQLESP_CANCEL_REQUEST) AND
              getVersion() == CurrEspRequestMessageVersion AND
              moreObjects();
  if (!willPassTheAssertion)
  {
    char *doCatchBugCRx = getenv("ESP_BUGCATCHER_CR_NONUMBER");
    if (!doCatchBugCRx ||
        *doCatchBugCRx != '0')
    {
      connection->dumpAndStopOtherEnd(true, false);
      environment_->getControlConnection()->
        castToGuaReceiveControlConnection()->
        getConnection()->dumpAndStopOtherEnd(true, false);
    }
  }

  ex_assert((getType() == IPC_MSG_SQLESP_DATA_REQUEST OR
             getType() == IPC_MSG_SQLESP_CANCEL_REQUEST) AND
	    getVersion() == CurrEspRequestMessageVersion AND
	    moreObjects(),
	    "Invalid first message from client");

  // take a look at the type of the first object in the message
  IpcMessageObjType nextObjType = getNextObjType();
  switch (nextObjType)
  {
    case ESP_OPEN_HDR:
    case ESP_LATE_CANCEL_HDR:
      {
        ExFragKey key;
        Lng32 remoteInstNum;
        NABoolean isParallelExtract = false; 

        // peek at the message header to see for whom it is
        if (nextObjType == ESP_OPEN_HDR)
        {
          ExEspOpenReqHeader reqHdr((NAMemory *) NULL);
	   
	  *this >> reqHdr;
	  key = reqHdr.key_;
	  remoteInstNum = reqHdr.myInstanceNum_;
	  if (reqHdr.getOpenType() == ExEspOpenReqHeader::PARALLEL_EXTRACT) 
          {
            isParallelExtract = true;
	  }
	}
        else
	{
          // note that the late cancel request may or may not
	  // arrive as the first request (only in the former case
	  // will we reach here)
	  ExEspLateCancelReqHeader reqHdr((NAMemory *) NULL);
	   
	  *this >> reqHdr;
	  key = reqHdr.key_;
	  remoteInstNum = reqHdr.myInstanceNum_;
	}

        if (!isParallelExtract) 
        {
          ExFragInstanceHandle handle =
	    espFragInstanceDir_->findHandle(key);

	  if (handle != NullFragInstanceHandle)
	  {
            // the send bottom node # myInstanceNum of this downloaded fragment
            // is the true recipient of this open request
            ex_split_bottom_tcb * receivingTcb =
              espFragInstanceDir_->getTopTcb(handle);
            ex_send_bottom_tcb *receivingSendTcb =
              receivingTcb->getSendNode(remoteInstNum);

            // Check the connection for a co-located client, and if so,
            // tell the split bottom, because it may prefer this send 
            // bottom when using skew buster uniform distribution.
            if (espFragInstanceDir_->
                  getEnvironment()->
                  getMyOwnProcessId(IPC_DOM_GUA_PHANDLE).match(
                    connection->getOtherEnd().getNodeName(),
                    connection->getOtherEnd().getCpuNum()))
              receivingTcb->setLocalSendBottom(remoteInstNum);

            // Portability note for the code above: we pass IPC_DOM_GUA_PHANDLE
            // for IpcEnvironment::getMyOwnProcessId, even though that method
            // can be called with the default param (IpcNetworkDomain 
            // IPC_DOM_INVALID).  In fact it would  probably be better 
            // to call the object without specifying the IpcNetworkDomain so
            // that it can decide for itself what domain it is using.
            // But there is a problem with the Windows implementation
            // of IpcEnvironment::getMyOwnProcessId, it seems to assume
            // that its domain is IPC_DOM_INTERNET and so this will 
            // cause the botch of an assertion that its control connection 
            // (which is type EspGuaControlConnection) can be cast to a 
            // SockControlConnection.  When this problem is fixed, the 
            // IPC_DOM_GUA_PHANDLE param above can be removed.  Also,
            // when this code is ported to run it a domain other than
            // "guardian", it will be necessary to fix this and to
            // fix IpcEnvironment::getMyOwnProcessId to work properly on
            // windows.

            receivingSendTcb->setClient(connection);
            receivingSendTcb->routeMsg(*this);
          }
	  else
	  {
            connection->dumpAndStopOtherEnd(true, false);
	    ex_assert(FALSE,"entry not found, set diagnostics area and reply");
	  }

        } // normal case, not parallel extract

        else 
        {
          // The OPEN request is from a parallel extract consumer. The
          // incoming request contains a user ID which we will compare
          // against the current user ID for this ESP.

          // NOTE: The user ID for the extract security check is
          // currently sent and compared as a C string. On Linux it is
          // possible to send and compare integers which would lead to
          // simpler code. The code to send/compare strings is still
          // used because it works on all platforms.

          char errorStr[150];

	  // check if next msg is of securityInfo type. 
          ex_assert(moreObjects(), "expected object not received");
          ex_assert(getNextObjType() == ESP_SECURITY_INFO,
	            "received message for unknown message type");
          
	  // unpack security info
	  ExMsgSecurityInfo secInfo(environment_->getHeap());
	  *this >> secInfo;

          // Get the auth ID of this ESP in text form and compare it
          // to the auth ID that arrived in the message. Skip this
          // step in the debug build if an environment variable is
          // set.
          NABoolean doAuthIdCheck = TRUE;
          Int32 status = 0;
#ifdef _DEBUG
          const char *envvar = getenv("NO_EXTRACT_AUTHID_CHECK");
          if (envvar && envvar[0])
            doAuthIdCheck = FALSE;
#endif
          if (doAuthIdCheck)
          {
            // Get user ID from ExMsgSecurityInfo -> (secUserID)
            // the user ID is the integer value made into a string
            // Convert it back into its integer value
            short userIDLen = (short) str_len(secInfo.getAuthID());
            Int32 secUserID = str_atoi(secInfo.getAuthID(), userIDLen);

            // Get the current user ID
            Int32 curUserID = ComUser::getSessionUser(); 

            // Report an error if the user ID is not valid
            if (curUserID == NA_UserIdDefault || secUserID == NA_UserIdDefault)
            {
              str_cpy_c(errorStr,
                        "Producer ESP could not authenticate the consumer, "
                        "no valid current user.");
              status = -1;
            }

            // Make sure user id passed in ExMsgSecurityInfo matches
            // the user id associated with the current session

#if defined(_DEBUG)
            NABoolean doDebug = (getenv("DBUSER_DEBUG") ? TRUE : FALSE);
            if (doDebug)
              printf("[DBUSER:%d] ESP extract user ID: "
                     "local [%d], msg [%d]\n",
                     (int) getpid(), curUserID, secUserID);
#endif

              // Compare user ID, Report an error, if comparison fails
              if (curUserID != secUserID)
              {
                str_cpy_c(errorStr,
                          "Producer ESP could not authenticate the consumer, "
                          "user named passed in ExMsgSecurityInfo is not the "
                          "current user");
                status = -1;
              }

          } // if (doAuthIdCheck)
		   
          // get the split bottom TCB that matches the securityKey
          ex_split_bottom_tcb *receivingTcb = NULL;
          if (status == 0) 
          {
            receivingTcb = espFragInstanceDir_->getExtractTop(secInfo.getSecurityKey());
            if (receivingTcb == NULL) 
            {
              str_cpy_c(errorStr, "Producer ESP could not locate extract node");
              status = -1;
            }
          }

	  // get the sendBottom TCB if not already connected to a client
	  ex_send_bottom_tcb *receivingSendTcb = NULL;
	  if (status == 0)
	  {
	    receivingSendTcb = receivingTcb->getConsumerSendBottom();
	    if (receivingSendTcb == NULL) 
	    {
	      str_cpy_c(errorStr, "Producer ESP already connected to a client");
	      status = -1;
	    }
	  }

          // send the error message to the consumer 
	  if (status != 0) 
	  {
            clearAllObjects();
            setType(IPC_MSG_SQLESP_DATA_REPLY);

            NAMemory *heap = environment_->getHeap();

	    IpcMessageObj* baseObj =
	      new(heap)IpcMessageObj(IPC_SQL_DIAG_AREA, CurrEspReplyMessageVersion);
	    *this << *baseObj;

	    // prepare proper error message
	    char phandle[100];
	    MyGuaProcessHandle myHandle;
            myHandle.toAscii(phandle, 100);

	    ComDiagsArea *diags = ComDiagsArea::allocate(heap);
            *diags << DgSqlCode(-EXE_PARALLEL_EXTRACT_OPEN_ERROR)
                   << DgString0(phandle)
                   << DgString1(errorStr);
	    *this  << *diags;

	    diags->decrRefCount();

            send(TRUE /* TRUE indicates waited */);
          }

          // if everything okay, then make the connection
	  if (status == 0) 
          {
            receivingSendTcb->setClient(connection);
            receivingSendTcb->routeMsg(*this);
          }
        } // parallel extract case
      } // open or cancel header
コード例 #25
0
ファイル: agi.cpp プロジェクト: AReim1982/scummvm
int AgiEngine::agiInit() {
	int ec, i;

	debug(2, "initializing");
	debug(2, "game version = 0x%x", getVersion());

	// initialize with adj.ego.move.to.x.y(0, 0) so to speak
	_game.adjMouseX = _game.adjMouseY = 0;

	// reset all flags to false and all variables to 0
	memset(_game.flags, 0, sizeof(_game.flags));
	memset(_game.vars, 0, sizeof(_game.vars));

	// clear all resources and events
	for (i = 0; i < MAX_DIRECTORY_ENTRIES; i++) {
		memset(&_game.views[i], 0, sizeof(struct AgiView));
		memset(&_game.pictures[i], 0, sizeof(struct AgiPicture));
		memset(&_game.logics[i], 0, sizeof(struct AgiLogic));
		memset(&_game.sounds[i], 0, sizeof(class AgiSound *)); // _game.sounds contains pointers now
		memset(&_game.dirView[i], 0, sizeof(struct AgiDir));
		memset(&_game.dirPic[i], 0, sizeof(struct AgiDir));
		memset(&_game.dirLogic[i], 0, sizeof(struct AgiDir));
		memset(&_game.dirSound[i], 0, sizeof(struct AgiDir));
	}

	// clear view table
	for (i = 0; i < SCREENOBJECTS_MAX; i++)
		memset(&_game.screenObjTable[i], 0, sizeof(struct ScreenObjEntry));

	memset(&_game.addToPicView, 0, sizeof(struct ScreenObjEntry));

	_words->clearEgoWords();

	if (!_menu)
		_menu = new GfxMenu(this, _gfx, _picture, _text);

	_gfx->initPriorityTable();

	// Clear the string buffer on startup, but not when the game restarts, as
	// some scripts expect that the game strings remain unaffected after a
	// restart. An example is script 98 in SQ2, which is not invoked on restart
	// to ask Ego's name again. The name is supposed to be maintained in string 1.
	// Fixes bug #3292784.
	if (!_restartGame) {
		for (i = 0; i < MAX_STRINGS; i++)
			_game.strings[i][0] = 0;
	}

	// setup emulation

	switch (getVersion() >> 12) {
	case 2:
		debug("Emulating Sierra AGI v%x.%03x",
		      (int)(getVersion() >> 12) & 0xF,
		      (int)(getVersion()) & 0xFFF);
		break;
	case 3:
		debug("Emulating Sierra AGI v%x.002.%03x",
		      (int)(getVersion() >> 12) & 0xF,
		      (int)(getVersion()) & 0xFFF);
		break;
	}

	if (getPlatform() == Common::kPlatformAmiga)
		_game.gameFlags |= ID_AMIGA;

	if (getFeatures() & GF_AGDS)
		_game.gameFlags |= ID_AGDS;

	if (_game.gameFlags & ID_AMIGA)
		debug(1, "Amiga padded game detected.");

	if (_game.gameFlags & ID_AGDS)
		debug(1, "AGDS mode enabled.");

	ec = _loader->init();   // load vol files, etc

	if (ec == errOK)
		ec = _loader->loadObjects(OBJECTS);

	// note: demogs has no words.tok
	if (ec == errOK)
		ec = _loader->loadWords(WORDS);

	// Load logic 0 into memory
	if (ec == errOK)
		ec = _loader->loadResource(RESOURCETYPE_LOGIC, 0);

#ifdef __DS__
	// Normally, the engine loads the predictive text dictionary when the predictive dialog
	// is shown.  On the DS version, the word completion feature needs the dictionary too.

	// FIXME - loadDict() no long exists in AGI as this has been moved to within the
	// GUI Predictive Dialog, but DS Word Completion is probably broken due to this...
#endif

	_keyHoldMode = false;
	_keyHoldModeLastKey = Common::KEYCODE_INVALID;

	_game.mouseFence.setWidth(0); // Reset

	// Reset in-game timer
	inGameTimerReset();

	// Sync volume settings from ScummVM system settings
	setVolumeViaSystemSetting();

	return ec;
}
コード例 #26
0
/*---------------------------------------------------------------------------*/
int main(int argc, char**argv)
{
	int i;
	int fd = 0;
	uint16_t trial = 0;
	char* portPath = NULL;
	char* rx_addressString = NULL;
	char* tx_addressString = NULL;

	printf("> Simple message listener for tea-bootloader compatible nodes\n");        
	
	/*-----------------------------------------------------------------------*/
	
	if(argc == 4)
	{
		portPath = argv[1];		
		rx_addressString = argv[2];
		sscanf(rx_addressString,"%X:%X:%X:%X:%X",rx_addressBuffer,rx_addressBuffer+1,rx_addressBuffer+2,rx_addressBuffer+3,rx_addressBuffer+4);
		tx_addressString = argv[3];
		sscanf(tx_addressString,"%X:%X:%X:%X:%X",tx_addressBuffer,tx_addressBuffer+1,tx_addressBuffer+2,tx_addressBuffer+3,tx_addressBuffer+4);
	}
	else
	{
		printf("> Argument parsing error!\n");
		printf("> Usage: [port path] [dongle RX address] [node RX address]\n");
		printf("> Example: ./main /dev/tty.usbserial-A900cbrd 0xE7:0xE7:0xE7:0xE7:0x00 0xD7:0xD7:0xD7:0xD7:0xD7\n");
		return 0;
	}			

	/*-----------------------------------------------------------------------*/	   

    fd = serialport_init(portPath,115200,'n');

    if(fd < 0)
    {
        printf("[err]: Connection error.\n");
        return 0;
    }
    else
   	{
        printf("> Conection OK.\n");
        serialport_flush(fd);
        printf("> Serial port flush OK.\n");   

        if(loopbackTest(fd) != 0)
        {
        	printf("> Loopback test failed!\r\n");
        	return 0;
        }
        else
        {        	
        	uint8_t version = getVersion(fd);
        	printf("> Dongle version: %d.%d\r\n",(version>>4),(version&0x0F));
        }                    
    }   

    printf("> Setting the TX address ...\n");
    setTXAddress(fd,tx_addressBuffer);

    printf("> Setting the RX address ...\n");
    setRXAddress(fd,rx_addressBuffer);

    while(1)
    {
    	uint8_t thisBuffer[1024];
    	char sendBuffer[256];
    	uint8_t len;
    	int temp;
    	float realval;
    	if(getRxFifoCount(fd))
    	{
			len = getRxFifoCount(fd);
			printf("> ---------------------------------------------------------------------------\n");
			printf("> New message!\n");
			printf("> Length: %d\n",len);
			pullDataFromFifo(fd,len,thisBuffer);

			hexDump("> Dump",thisBuffer,len);			

			temp = (thisBuffer[0]<<8)+thisBuffer[1];
			realval  = ((float)temp * 1100.0) / 1024.0;              
			realval -= 500;
			realval /= 10.0;

			printf("> Raw: %d\n",temp);
			printf("> Readout: %f\n",realval);
			sprintf(sendBuffer,"./phant_client.rb %f",realval);
			system(sendBuffer);
			printf("> Phant.io send process done.\n");
    	}
    }


}
コード例 #27
0
void HTTPServerResponseImpl::sendContinue()
{
	HTTPHeaderOutputStream hs(_session);
	hs << getVersion() << " 100 Continue\r\n\r\n";
}
コード例 #28
0
ファイル: packs_tests.cpp プロジェクト: kk9599/osquery
TEST_F(PacksTests, test_version) {
  auto fpack = Pack("foobar", getPackWithDiscovery());
  EXPECT_EQ(fpack.getVersion(), "1.5.0");
}
コード例 #29
0
ファイル: chunk_manager.cpp プロジェクト: Jonekee/mongo
bool ChunkManager::compatibleWith(const ChunkManager& other, const string& shardName) const {
    // Return true if the shard version is the same in the two chunk managers
    // TODO: This doesn't need to be so strong, just major vs
    return other.getVersion(shardName).equals(getVersion(shardName));
}
コード例 #30
0
ファイル: Dictionary.cpp プロジェクト: bq/cervantes
Dictionary::Dictionary() {
    
    loadSemantixLib(SEMANTIX_LIB_PATH);

    if (!initialized)
	return;
    QString dictPath = Storage::getInstance()->getDataPartition()->getMountPoint() + QDir::separator() + "dictionaries" + QDir::separator();

    QDir dirPrivateDictionaries(Storage::getInstance()->getPrivatePartition()->getMountPoint() + QDir::separator());
    if(!dirPrivateDictionaries.exists( "dictionaries/"))
        dirPrivateDictionaries.mkdir( "dictionaries");

    QString dictPrivatePath = dirPrivateDictionaries.absolutePath() + QDir::separator() + "dictionaries" + QDir::separator();
    QString repositories = dictPath + QString(":") + dictPrivatePath;
    qDebug() << Q_FUNC_INFO << "repositories " << repositories;
    initialize(dictPath.toUtf8().constData(),repositories.toUtf8().constData());
    qDebug() << Q_FUNC_INFO << "Dictionaires lib initialized. Version: " << QString::fromUtf8(getVersion().c_str());
}