Ejemplo n.º 1
0
int main(int argc, char **argv)
{
  unsigned int s;
  unsigned long long m1,m2;
  unsigned int p[6];
  char string[100];
  int sizeofll = sizeof(m1);
  char answerinreturn = 0;
 
  if(sizeofll < 6){
    printf("longlong to small on this system to contain a macaddress");
    return 0;
  }

  if(argc<4){
    displayOptions(argv[0]);
    return 0;
  }

 if(argc>4 ){
   answerinreturn=argv[4][0]-'0';
 }

  strcpy(string,argv[1]);
  stringtolower(string); 

  if(sscanf(string,"%x:%x:%x:%x:%x:%x",&p[0],&p[1],&p[2],&p[3],&p[4],&p[5]) != 6){
    printf("format error\r\n");
    displayOptions(argv[0]);
    return 0;
  }
 

  m1 = ((unsigned long long)p[0]<<(5*8))+((unsigned long long)p[1]<<(4*8))+((unsigned long long)p[2]<<(3*8))+((unsigned long long)p[3]<<(2*8))+((unsigned long long)p[4]<<(1*8))+((unsigned long long)p[5]<<(0*8));

  strcpy(string,argv[2]);
  stringtolower(string);

  if(sscanf(string,"%x:%x:%x:%x:%x:%x",&p[0],&p[1],&p[2],&p[3],&p[4],&p[5]) != 6){
    printf("format error\r\n");
    displayOptions(argv[0]);
    return 0;
  }
  m2 = ((unsigned long long)p[0]<<(5*8))+((unsigned long long)p[1]<<(4*8))+((unsigned long long)p[2]<<(3*8))+((unsigned long long)p[3]<<(2*8))+((unsigned long long)p[4]<<(1*8))+((unsigned long long)p[5]<<(0*8));

  s  = (unsigned int)strtol(argv[3], (char **)NULL,0);

  if(!answerinreturn)
  {
    printf("%02X:%02X:%02X:%02X:%02X:%02X",(unsigned int)(m2>>(5*8))&0xFF,(unsigned int)(m2>>(4*8))&0xFF,(unsigned int)(m2>>(3*8))&0xFF,(unsigned int)(m2>>(2*8))&0xFF,(unsigned int)(m2>>(1*8))&0xFF,(unsigned int)(m2>>(0*8))&0xFF);
    printf(" xor ");
    printf("%02X:%02X:%02X:%02X:%02X:%02X",(unsigned int)(m1>>(5*8))&0xFF,(unsigned int)(m1>>(4*8))&0xFF,((unsigned int)m1>>(3*8))&0xFF,(unsigned int)(m1>>(2*8))&0xFF,(unsigned int)(m1>>(1*8))&0xFF,(unsigned int)(m1>>(0*8))&0xFF); 
    printf(" mod %d = ",s);
    printf("%d",((unsigned int)(m1^m2))%s); 
    printf("\r\n");
    return 0;
  }else{
Ejemplo n.º 2
0
void CBibleReadWindow::applyProfileSettings(const QString & windowGroup) {
    CLexiconReadWindow::applyProfileSettings(windowGroup);

    BtConfig & conf = btConfig();
    conf.beginGroup(windowGroup);
    filterOptions() = conf.getFilterOptions();
    displayOptions() = conf.getDisplayOptions();
    conf.endGroup();

    emit sigFilterOptionsChanged(filterOptions());
    emit sigDisplayOptionsChanged(displayOptions());

    // Apply settings to display:
    lookup();
}
Ejemplo n.º 3
0
MainWindow::MainWindow( GameEngine * currentEngine) :
 isGameLaunched(false),keystate()
{
  currentGameEngine = currentEngine ;

  // menubar creation
  menuBar = new QMenuBar();
  QMenu * gameMenu = menuBar->addMenu("Game");
  gameMenu->addAction("New Game",this,SLOT(diplayNewGame()));
  gameMenu->addAction("Stop Game",currentGameEngine, SLOT(stop()));
  gameMenu->addAction("Options",this, SLOT(displayOptions()));
  gameMenu->addSeparator();
  gameMenu->addAction("Quit",qApp,SLOT(quit()));
  QMenu * helpMenu = menuBar->addMenu("Help");
  helpMenu->addAction("About chmeup",this,SLOT(displayAbout()));

  setFixedSize(screenWidthGlobal + 2 * BORDER_WIDTH ,screenHeightGlobal + menuBar->sizeHint().height() + 2* BORDER_HEIGHT);

  // central widget
  setCentralWidget(&screen);

  connect(currentGameEngine, SIGNAL(updateUI()), this, SLOT(update())) ;
  connect(currentGameEngine, SIGNAL(requestKeyUI()),this,SLOT(keysNeeded()));
  connect(currentGameEngine, SIGNAL(displayGameOverScreen()), this, SLOT(gameOverDisplay()));
  connect(currentGameEngine, SIGNAL(displayGameWonScreen()),this,SLOT(gameWonDisplay()));
  connect(this,SIGNAL(sendKeys(KeyPressedFrame * )),currentGameEngine,SLOT(getKeyFrame(KeyPressedFrame *)));
  connect(this,SIGNAL(sendPause()), currentGameEngine, SLOT(pause()));

  setMenuBar(menuBar);

}
Ejemplo n.º 4
0
void CBibleReadWindow::storeProfileSettings(const QString & windowGroup) {
    BtConfig & conf = btConfig();
    conf.beginGroup(windowGroup);
    conf.setFilterOptions(filterOptions());
    conf.setDisplayOptions(displayOptions());
    conf.endGroup();

    CLexiconReadWindow::storeProfileSettings(windowGroup);
}
Ejemplo n.º 5
0
//--------------------------------------------------------------
// Purpose	: This main loop calls functions to get input, 
//			update and render the game at a specific frame rate
// Input	: void
// Output	: void
//--------------------------------------------------------------
void mainLoop( void )
{
    g_Timer.startTimer();    // Start timer to calculate how long it takes to render this frame
    while (!g_bQuitGame)      // run this loop until user wants to quit 
	{        
        getInput();                         // get keyboard input
        update(g_Timer.getElapsedTime());   // update the game
        render();                           // render the graphics output to screen
        g_Timer.waitUntil(gc_uFrameTime);   // Frame rate limiter. Limits each frame to a specified time in ms.   
        displayOptions();
	}    
}
Ejemplo n.º 6
0
/** Copies the current chapter into the clipboard. */
void CBibleReadWindow::copyDisplayedText() {
    CSwordVerseKey dummy(*verseKey());
    dummy.setVerse(1);

    CSwordVerseKey vk(*verseKey());
    vk.setLowerBound(dummy);

    const CSwordBibleModuleInfo* bible = dynamic_cast<const CSwordBibleModuleInfo*>(modules().first());
    dummy.setVerse(bible->verseCount(dummy.book(), dummy.getChapter()));
    vk.setUpperBound(dummy);

    CExportManager mgr(false, tr("Copying"), filterOptions(), displayOptions());
    mgr.copyKey(&vk, CExportManager::Text, true);
}
Ejemplo n.º 7
0
/** Saves the chapter as valid HTML page. */
void CBibleReadWindow::saveChapterPlain() {
    //saves the complete chapter to disk

    CSwordVerseKey vk(*verseKey());
    CSwordVerseKey dummy(*verseKey());

    dummy.setVerse(1);
    vk.setLowerBound(dummy);

    const CSwordBibleModuleInfo* bible = dynamic_cast<const CSwordBibleModuleInfo*>(modules().first());
    dummy.setVerse(bible->verseCount(dummy.book(), dummy.getChapter()));
    vk.setUpperBound(dummy);

    CExportManager mgr(true, tr("Saving"), filterOptions(), displayOptions());
    mgr.saveKey(&vk, CExportManager::Text, true);
}
void CLexiconReadWindow::initToolbars() {
    //main toolbar
    Q_ASSERT(m_actions.backInHistory);
    mainToolBar()->addAction(m_actions.backInHistory); //1st button
    mainToolBar()->addAction(m_actions.forwardInHistory); //2nd button

    //buttons toolbar
    QAction* action = qobject_cast<QAction*>(actionCollection()->action(
                          CResMgr::displaywindows::general::search::actionName));
    Q_ASSERT( action );
    if (action) {
        buttonsToolBar()->addAction(action);
    }
    setDisplaySettingsButton( new CDisplaySettingsButton( &displayOptions(), &filterOptions(), modules(), buttonsToolBar()) );

    /// \todo find the right place for the button
    buttonsToolBar()->addWidget(displaySettingsButton());
}
/** This function saves the entry as html using the CExportMgr class. */
void CLexiconReadWindow::saveAsPlain() {
    CExportManager mgr(tr("Saving entry ..."), true, tr("Saving"), filterOptions(), displayOptions());
    mgr.saveKey(key(), CExportManager::Text, true);
}
Ejemplo n.º 10
0
ITEM* TOOL_BASE::pickSingleItem( const VECTOR2I& aWhere, int aNet, int aLayer, bool aIgnorePads,
								 const std::vector<ITEM*> aAvoidItems)
{
    int tl = getView()->GetTopLayer();

    if( aLayer > 0 )
        tl = aLayer;

    static const int candidateCount = 5;
    ITEM* prioritized[candidateCount];
    int dist[candidateCount];

    for( int i = 0; i < candidateCount; i++ )
    {
        prioritized[i] = 0;
        dist[i] = std::numeric_limits<int>::max();
    }

    ITEM_SET candidates = m_router->QueryHoverItems( aWhere );

    for( ITEM* item : candidates.Items() )
    {
        if( !item->IsRoutable() )
            continue;

        if( !IsCopperLayer( item->Layers().Start() ) )
            continue;

        if( std::find( aAvoidItems.begin(), aAvoidItems.end(), item ) != aAvoidItems.end() )
            continue;

        // fixme: this causes flicker with live loop removal...
        //if( item->Parent() && !item->Parent()->ViewIsVisible() )
        //    continue;

        if( aNet <= 0 || item->Net() == aNet )
        {
            if( item->OfKind( ITEM::VIA_T | ITEM::SOLID_T ) )
            {
                if( item->OfKind( ITEM::SOLID_T ) && aIgnorePads )
                    continue;

                int itemDist = ( item->Shape()->Centre() - aWhere ).SquaredEuclideanNorm();

                if( !prioritized[2] || itemDist < dist[2] )
                {
                    prioritized[2] = item;
                    dist[2] = itemDist;
                }
                if( item->Layers().Overlaps( tl ) &&  itemDist < dist[0] )
                {
                    prioritized[0] = item;
                    dist[0] = itemDist;
                }
            }
            else
            {
                if( !prioritized[3] )
                    prioritized[3] = item;
                if( item->Layers().Overlaps( tl ) )
                    prioritized[1] = item;
            }
        }
        // Allow unconnected items as last resort in RM_MarkObstacles mode
        else if ( item->Net() == 0 && m_router->Settings().Mode() == RM_MarkObstacles )
        {
            if( item->OfKind( ITEM::SOLID_T ) && aIgnorePads )
                continue;

            if( item->Layers().Overlaps( tl ) )
                prioritized[4] = item;
        }
    }

    ITEM* rv = NULL;

    for( int i = 0; i < candidateCount; i++ )
    {
        ITEM* item = prioritized[i];

        if( displayOptions()->m_ContrastModeDisplay )
            if( item && !item->Layers().Overlaps( tl ) )
                item = NULL;

        if( item && ( aLayer < 0 || item->Layers().Overlaps( aLayer ) ) )
        {
            rv = item;
            break;
        }
    }

    if( rv )
    {
        wxLogTrace( "PNS", "%s, layer : %d, tl: %d", rv->KindStr().c_str(), rv->Layers().Start(), tl );
    }

    return rv;
}
Ejemplo n.º 11
0
int main(int argc, char **argv)
#endif
{
  int expectedMods = 0;
  
#ifdef macintosh
  doSiouxStuff();
  argc = ccommand(&argv);
#endif
 
  /* Added by Bob Goode/Tam Ngo, 5/21/97, for WINSOCK option. */
#ifdef OS2
  sock_init();
#elif defined(_WINSOCK_)
  startWinsock();
#endif /* Winsock DLL loading */

  x_ipcModuleInitialize();
#ifdef VXWORKS
  /* Do this only after the socket is set up (in case there is an
     old central lying around that needs killed */
  centralTID = taskIdSelf();
#endif
  globalSInit();
  
#if !defined(THINK_C) && !defined(macintosh) && !defined(__TURBOC__) && !defined(OS2) && !defined(_WIN95_MSC_) && !defined(WINNT) && !defined(WIN32)
  (void)signal(SIGINT, abortCentral);
  (void)signal(SIGBUS, abortCentral);
  (void)signal(SIGSEGV, abortCentral);
  (void)signal(SIGPIPE, pipeClosedHnd);
  (void)signal(SIGTERM, abortCentral);
#endif /* !THINK_C && !macintosh */
  
#ifndef VXWORKS
  if ((argc > 1) && (STREQ(argv[1], "-v")))
    displayVersion();
  else if ((argc > 1) && (STREQ(argv[1], "-h"))) {
    displayOptions(argv[0]);
#ifdef macintosh
  SIOUXSettings.autocloseonquit = FALSE;
#endif
  } else {
    parseExpectedMods(argc, argv, &expectedMods);
    parseCommandLineOptions(argc, argv);
#else
  if ((options!= NULL) && (strstr(options, "-v") || strstr(options, "-V"))) {
    displayVersion();
  } else if ((options!= NULL) && 
	     (strstr(options, "-h") || strstr(options, "-H"))) {
    displayOptions("central");
  } else {
    parseOpsFromStr(options, &expectedMods, FALSE);
#endif
      
    if (expectedMods < 1)
      expectedMods = 1;
      
    if (!serverInitialize(expectedMods)) {
      X_IPC_ERROR("ERROR: Unable to start server, Is one already running?\n");
    }
      
#ifndef VXWORKS
    /* Register a method for freeing memory in an emergency. */
    x_ipcRegisterFreeMemHnd(centralFreeMemory,3);
      
    if (GET_S_GLOBAL(listenToStdin))
      printPrompt();
#endif

#ifndef DEFAULT_OPTIONS
    fprintf(stderr, "central running...\n");
#endif

    listenLoop();
  }
#ifdef _WINSOCK_
  WSACleanup();
  printf("Socket cleaned up.");
#endif /* Unload Winsock DLL */
#ifndef VXWORKS
  return 1;
#endif
}
Ejemplo n.º 12
0
void parseArguments(int argc, char **argv)
{
	int	opt, temp_int, option_index = 0;
	bool bOptionHelp = false;
	
	/* Parse the commandline for commandline parameters */
	while ((opt = getopt_long(argc, argv, OPTION_LIST, option_list, &option_index)) != -1)
	{
		switch (opt)
		{
				/* Set the request to use a despawn list based off the spawn alert list. */
				
				/* Set the interface */
			case 'i':
				pSEQPrefs->setPrefString("Device", "Network", optarg, XMLPreferences::Runtime);
				break;
				
				/* Set pcap thread to realtime */
			case 'r':
				pSEQPrefs->setPrefBool("RealTimeThread", "Network", true, XMLPreferences::Runtime);
				break;
				
				/* Set the spawn filter file */
			case 'f':
				pSEQPrefs->setPrefString("FilterFile", "Filters", optarg, XMLPreferences::Runtime);
				break;
				
				/* Packet playback mode */
			case 'j':
				if (optarg)
					pSEQPrefs->setPrefString("Filename", "VPacket", optarg, XMLPreferences::Runtime);
				pSEQPrefs->setPrefInt("Playback", "VPacket", PLAYBACK_FORMAT_SEQ, XMLPreferences::Runtime);
				pSEQPrefs->setPrefBool("Record", "VPacket", false, XMLPreferences::Runtime);
				break;
				
				/* Packet record mode */
			case 'g':
				if (optarg)
					pSEQPrefs->setPrefString("Filename", "VPacket", optarg, XMLPreferences::Runtime);
				pSEQPrefs->setPrefInt("Playback", "VPacket", PLAYBACK_OFF, XMLPreferences::Runtime);
				pSEQPrefs->setPrefBool("Record", "VPacket", true, XMLPreferences::Runtime);
				break;
				
				/* Config file was already taken care of, ignore */
			case 'o':
				break;
				
				/* Make filter case sensitive */
			case 'C':
				pSEQPrefs->setPrefBool("IsCaseSensitive", "Filters", true, XMLPreferences::Runtime);
				break;
				
				/* Use retarded coordinate system yxz */
			case 'c':
				showeq_params->retarded_coords = 1;
				break;
				
				/* Fast machine updates.. framerate vs packet based */
			case 'F':
				showeq_params->fast_machine = 1;
				break;
				
				/* Show unknown spawns */
			case 'K':
				showeq_params->createUnknownSpawns = 1;
				break;
				
				/* Select spawn on 'Consider' */
			case 'S':
				pSEQPrefs->setPrefBool("SelectOnCon", "Interface", true, XMLPreferences::Runtime);
				break;
				
				/* Select spawn on 'Target' */
			case 'e':
				pSEQPrefs->setPrefBool("SelectOnTarget", "Interface", true, XMLPreferences::Runtime);
				break;
				
				/* Show net info */
			case 'N':
				pSEQPrefs->getPrefBool("ShowNetStats", "Interface", true, XMLPreferences::Runtime);
				break;
				
				/* track pathing for mobs */
			case 't':
				showeq_params->walkpathrecord = 1;
				break;
				
				/* Maximum spawn path tracking length  */
			case 'L':
				showeq_params->walkpathlength = atoi(optarg);
				break;
				
				/* Log spawns! */
			case 'x':
				pSEQPrefs->setPrefBool("LogSpawns", "Misc", true, XMLPreferences::Runtime);
				break;
				
				/* Display the version info... */
			case 'V':
			case 'v':
				exit(0);
				break;
				
				/* Don't autodetect character settings */
			case 'W':
				pSEQPrefs->getPrefBool("AutoDetectCharSettings", "Defaults", false, XMLPreferences::Runtime);
				break;
				
				/* Set default player level */
			case 'X':
				temp_int = atoi(optarg);
				
				if (temp_int < 1 || temp_int > 85)
				{
					printf ("Invalid default level.  Valid range is 1 - 85.\n");
					exit(0);
				}
				pSEQPrefs->setPrefInt("DefaultLevel", "Defaults", temp_int, XMLPreferences::Runtime);
				break;
				
				/* Set default player race */
			case 'Y':
				temp_int = atoi(optarg);
				
				if ((temp_int < 1 || temp_int > 12) &&
					(temp_int != 128) &&
					(temp_int != 130) &&
					(temp_int != 26) &&
					(temp_int != 330))
				{
					printf ("Invalid default race, please use showeq -h to list valid race options.\n");
					exit(0);
				}
				
				pSEQPrefs->setPrefInt("DefaultRace", "Defaults", temp_int, XMLPreferences::Runtime);
				break;
				
				/* Set default player class */
			case 'Z':
				temp_int = atoi(optarg);
				
				if (temp_int < 1 || temp_int > 16)
				{
					printf ("Invalid default class, please use showeq -h to list valid class options.\n");
					exit(0);
				}
				pSEQPrefs->setPrefInt("DefaultClass", "Defaults", temp_int);
				break;
				
				/* IP address to track */
			case IPADDR_OPTION:
				pSEQPrefs->setPrefString("IP", "Network", optarg, XMLPreferences::Runtime);
				break;
				
				/* MAC address to track for those on DHCP */
			case MACADDR_OPTION:
				pSEQPrefs->setPrefString("MAC", "Network", optarg, XMLPreferences::Runtime);
				break;
				
				/* Filename for logging all packets */
			case GLOBAL_LOG_FILENAME_OPTION:
				pSEQPrefs->setPrefString("GlobalLogFilename", "PacketLogging", optarg, XMLPreferences::Runtime);
				break;
				
				/* Filename for logging world change packets */
			case WORLD_LOG_FILENAME_OPTION:
				pSEQPrefs->setPrefString("WorldLogFilename", "PacketLogging", optarg, XMLPreferences::Runtime);
				break;
				
				/* Filename for logging zone change packets */
			case ZONE_LOG_FILENAME_OPTION:
				pSEQPrefs->setPrefString("ZoneLogFilename", "PacketLogging", optarg, XMLPreferences::Runtime);
				break;
				
				/* Filename for logging unknown zone change packets */
			case UNKNOWN_LOG_FILENAME_OPTION:
				pSEQPrefs->setPrefString("UnknownZoneLogFilename", "PacketLogging", optarg, XMLPreferences::Runtime);
				break;
				
				/* Log everything */
			case GLOBAL_LOG_OPTION:
				pSEQPrefs->setPrefBool("LogAllPackets", "PacketLogging", true, XMLPreferences::Runtime);
				break;
				
				/* Log all zone change packets */
			case ZONE_LOG_OPTION:
				pSEQPrefs->setPrefBool("LogZonePackets", "PacketLogging", true, XMLPreferences::Runtime);
				break;
				
				/* Log world packets */
			case WORLD_LOG_OPTION:
				pSEQPrefs->setPrefBool("LogWorldPackets", "PacketLogging", true, XMLPreferences::Runtime);
				break;
				
				/* Log only unfamiliar zone change packets */
			case UNKNOWN_ZONE_LOG_OPTION:
				pSEQPrefs->setPrefBool("LogUnknownZonePackets", "PacketLogging", true, XMLPreferences::Runtime);
				break;
				
				/* TCPDump playback file */
			case PLAYBACK_TCPDUMP_FILE_OPTION:
				pSEQPrefs->setPrefString("Filename", "VPacket", optarg, XMLPreferences::Runtime);
				pSEQPrefs->setPrefInt("Playback", "VPacket", PLAYBACK_FORMAT_TCPDUMP, XMLPreferences::Runtime);
				pSEQPrefs->setPrefBool("Record", "VPacket", false,  XMLPreferences::Runtime);
				break;
				
			case PLAYBACK_SPEED_OPTION:
				pSEQPrefs->setPrefInt("PlaybackRate", "VPacket", atoi(optarg),  XMLPreferences::Runtime);
				break;
				
				/* Enable logging of raw packets... */
			case RAW_LOG_OPTION:
				pSEQPrefs->setPrefBool("LogRawPackets", "PacketLogging", true, XMLPreferences::Runtime);
				break;
				
				/* Display spawntime in UNIX time (time_t) instead of hh:mm format */
			case SYSTIME_SPAWNTIME_OPTION:
				showeq_params->systime_spawntime = 1;
				break;
				
			case SPAWNLOG_FILENAME_OPTION:
				pSEQPrefs->setPrefString("SpawnLogFilename", "Misc", optarg, XMLPreferences::Runtime);
				break;
				
			case ITEMDB_DATA_FILENAME_OPTION:
				pSEQPrefs->setPrefString("DataDBFilename", "ItemDB", optarg, XMLPreferences::Runtime);
				break;
				
			case ITEMDB_RAW_FILENAME_OPTION:
				pSEQPrefs->setPrefString("RawDataDBFilename", "ItemDB", optarg, XMLPreferences::Runtime);
				break;
				
			case ITEMDB_DATABASES_ENABLED:
				pSEQPrefs->setPrefInt("DatabasesEnabled", "ItemDB", atoi(optarg), XMLPreferences::Runtime);
				break;
				
			case ITEMDB_DISABLE:
				pSEQPrefs->setPrefBool("Enabled", "ItemDB", false,  XMLPreferences::Runtime);
				break;
				
			case ITEMDB_ENABLE:
				pSEQPrefs->setPrefBool("Enabled", "ItemDB", true, XMLPreferences::Runtime);
				break;
				
			case RESTORE_PLAYER_STATE:
				showeq_params->restorePlayerState = true;
				break;
				
			case RESTORE_ZONE_STATE:
				showeq_params->restoreZoneState = true;
				break;
				
			case RESTORE_SPAWNS:
				showeq_params->restoreSpawns = true;
				break;
				
			case RESTORE_ALL:
				showeq_params->restorePlayerState = true;
				showeq_params->restoreZoneState = true;
				showeq_params->restoreSpawns = true;
				break;
				
			case REMOTE_PACKET_OPTION:
				pSEQPrefs->setPrefBool("Enabled", "RemotePacketServer", true, XMLPreferences::Runtime);
				if (optarg)
					pSEQPrefs->setPrefInt("Port", "RemotePacketServer", atoi(optarg), XMLPreferences::Runtime);
				break;
				
				/* Spit out the help */
			case 'h': /* Fall through */
			default:
				bOptionHelp = true;
				break;
		}
	}
	
	if (bOptionHelp) {
		displayOptions(argv[0]);
		exit (0);
	}	
}
Ejemplo n.º 13
0
void AddNew::displayMenu()
{
    clearScreen();
    displayOptions();
}
Ejemplo n.º 14
0
void AddNew::startInterface()
{
    Menu::startInterface();
    displayActions();
    displayOptions();
}
Ejemplo n.º 15
0
void selectOption(unsigned char menuOpt)
{
	char init2_msg[16];
	printSPIHeader(GPIOA,RESET_OFF|0x3); //choose both Chip Selects
	printSPIHeader(GPIOB,0b00111111); //turn display ON
	glcdStrobe(0x3);
//	initSPI();
	//clearScreen();
	if(menuOpt>0)
	{
		if(menuOpt!=lastOpt)
		{	
			lastOpt=menuOpt;
		}
		else if(lastOpt>0&&menuOpt>0)
		{
			switch(menuDepth)
			{			
				case 0:
				{
					//draw menu options
					if(selected>0)
					{
						chosenName=menuOpt;
						displayOptions(0);
						menuDepth=1;
						lastOpt=0;
						selected=0;
					}
					else
					{
						displayAccounts(storeList, menuOpt);
						selected=1;
					}
					break;
				};
				case 1:
				{
					if(selected>0)
					{
					//display choices
					chosenState=menuOpt;
					menuDepth=2;
					lastOpt=0;
					selected=0;
					}
					else
					{
						
						displayOptions(menuOpt);
						selected=1;
					}
					break;
				};
				case 2://reset
				{
					displayDebug();
					
					menuDepth=0;
					lastOpt=0;
					selected=0;
					break;
				};
				default:
				{
					displayAccounts(storeList,0);
					menuDepth=0;
					break;
				};	
			}
		}
	}
	else 
	{
		lastOpt=0;
		if(menuDepth==0)
		{
			displayAccounts(storeList,0);
		}
		else if(menuDepth==1)
		{	
			displayOptions(0);
		}else if(menuDepth==2)
		{
			displayDebug();	
		}
	}

//	CloseSPI1();
}
Ejemplo n.º 16
0
int main (int argc, char **argv)
{
   int           opt;
   int           temp_int;
   int           option_index = 0;
   
   bool          bOptionHelp = false;
        
   /* Create application instance */
   //   QApplication::setStyle( new QWindowsStyle );
   QApplication qapp (argc, argv);

   /* Print the version number */
   displayVersion();

   // create the data location manager (with user data under ~/.showeq
   DataLocationMgr dataLocMgr(".showeq");

   /* Initialize the parameters with default values */
   QFileInfo configFileDefInfo = dataLocMgr.findExistingFile(".", "seqdef.xml",
							     true, false);
   
   if (!configFileDefInfo.exists())
   {
     fprintf(stderr, 
	     "Fatal: Couldn't find seqdef.xml!\n"
	     "\tDid you remember to do 'make install'\n");
     exit(-1);
   }

   QString configFileDef = configFileDefInfo.absFilePath();

   QFileInfo configFileInfo = dataLocMgr.findWriteFile(".", "showeq.xml",
						       true, true);

   // deal with funky border case since we may be running setuid
   QString configFile;
   if (configFileInfo.dir() != QDir::root())
     configFile = configFileInfo.absFilePath();
   else
     configFile = QFileInfo(dataLocMgr.userDataDir(".").absPath(),
			    "showeq.xml").absFilePath();

   // scan command line arguments for a specified config file
   int i = 1;
   while (i < argc)
   {
      if ((argv[i][0] == '-') && (argv[i][1] == 'o'))
         configFile = argv[i + 1];

      i ++;
   }

   /* NOTE: See preferencefile.cpp for info on how to use prefrences class */
   printf("Using config file '%s'\n", (const char*)configFile);
   pSEQPrefs = new XMLPreferences(configFileDef, configFile);

   showeq_params = new ShowEQParams;

   QString section;

   section = "Interface";
   /* Allow map depth filtering */
   showeq_params->retarded_coords  = pSEQPrefs->getPrefBool("RetardedCoords", section, 0);
   showeq_params->systime_spawntime = pSEQPrefs->getPrefBool("SystimeSpawntime", section, false);
   showeq_params->pvp = pSEQPrefs->getPrefBool("PvPTeamColoring", section, false);
   showeq_params->deitypvp = pSEQPrefs->getPrefBool("DeityPvPTeamColoring", section, false);
   showeq_params->keep_selected_visible = pSEQPrefs->getPrefBool("KeepSelected", section, true);

   section = "Misc";
   showeq_params->fast_machine = pSEQPrefs->getPrefBool("FastMachine", section, true);
   showeq_params->createUnknownSpawns = pSEQPrefs->getPrefBool("CreateUnknownSpawns", section, true);

   showeq_params->walkpathrecord = pSEQPrefs->getPrefBool("WalkPathRecording", section, false);
   showeq_params->walkpathlength = pSEQPrefs->getPrefInt("WalkPathLength", section, 25);
   /* Tells SEQ whether or not to display casting messages (Turn this off if you're on a big raid) */

   section = "SpawnList";
   showeq_params->showRealName = pSEQPrefs->getPrefBool("ShowRealName", section, false);

   /* Different files for different kinds of raw data */

   section = "SaveState";
   showeq_params->saveZoneState = 
     pSEQPrefs->getPrefBool("ZoneState", section, 1);
   showeq_params->savePlayerState = 
     pSEQPrefs->getPrefBool("PlayerState", section, 1);
   showeq_params->saveSpawns = pSEQPrefs->getPrefBool("Spawns", section, false);
   showeq_params->saveSpawnsFrequency = 
     pSEQPrefs->getPrefInt("SpawnsFrequency", section, (120 * 1000));
   showeq_params->restorePlayerState = false;
   showeq_params->restoreZoneState = false;
   showeq_params->restoreSpawns = false;
   showeq_params->saveRestoreBaseFilename = dataLocMgr.findWriteFile("tmp", pSEQPrefs->getPrefString("BaseFilename", section, "last")).absFilePath();

   /* Parse the commandline for commandline parameters */
   while ((opt = getopt_long( argc,
                              argv,
                              OPTION_LIST,
                              option_list,
                              &option_index
                             ))               != -1
          )
   {
      switch (opt)
      {
         /* Set the request to use a despawn list based off the spawn alert list. */

         /* Set the interface */
         case 'i':
         {            
	   pSEQPrefs->setPrefString("Device", "Network", optarg, 
				    XMLPreferences::Runtime);
	   break;
         }


         /* Set pcap thread to realtime */
         case 'r':
         {  
	   pSEQPrefs->setPrefBool("RealTimeThread", "Network", true, 
				  XMLPreferences::Runtime);
				  
            break;
         }


         /* Set the spawn filter file */
         case 'f':
         {
	   pSEQPrefs->setPrefString("FilterFile", "Filters", optarg, 
				    XMLPreferences::Runtime);
            
	   break;
         }


         /* Packet playback mode */
         case 'j':
         {            
            if (optarg)
               pSEQPrefs->setPrefString("Filename", "VPacket", optarg, 
					XMLPreferences::Runtime);

	    pSEQPrefs->setPrefBool("Playback", "VPacket", true, 
				   XMLPreferences::Runtime);
	    pSEQPrefs->setPrefBool("Record", "VPacket", false, 
				   XMLPreferences::Runtime);
            
            break;
         }

         /* Packet record mode */
         case 'g':
         {
            if (optarg)
               pSEQPrefs->setPrefString("Filename", "VPacket", optarg, 
					XMLPreferences::Runtime);

	    pSEQPrefs->setPrefBool("Playback", "VPacket", false, 
				   XMLPreferences::Runtime);
	    pSEQPrefs->setPrefBool("Record", "VPacket", true, 
				   XMLPreferences::Runtime);
            
            break;
         }


         /* Config file was already taken care of, ignore */
         case 'o':
            break;


         /* Make filter case sensitive */
         case 'C':
         {
	   pSEQPrefs->setPrefBool("IsCaseSensitive", "Filters", true,
				  XMLPreferences::Runtime);
	   break;
         }

         /* Use retarded coordinate system yxz */
         case 'c':
         {
            showeq_params->retarded_coords = 1;
            break;
         }


         /* Fast machine updates.. framerate vs packet based */
         case 'F':
         {
            showeq_params->fast_machine = 1;
            break;
         }


         /* Show unknown spawns */
         case 'K':
         {
            showeq_params->createUnknownSpawns = 1;
            break;
         }


         /* Select spawn on 'Consider' */
         case 'S':
         {
	   pSEQPrefs->setPrefBool("SelectOnCon", "Interface", true,
				  XMLPreferences::Runtime);
	   break;
         }


         /* Select spawn on 'Target' */
         case 'e':
         {
	   pSEQPrefs->setPrefBool("SelectOnTarget", "Interface", true, 
				  XMLPreferences::Runtime);
	   break;
         }


         /* Show net info */
         case 'N':
         {
	   pSEQPrefs->getPrefBool("ShowNetStats", section, true, 
				  XMLPreferences::Runtime);
	   break;
         }


         /* 't'rack pathing for mobs */
         case 't':
         {
            showeq_params->walkpathrecord = 1;
            break;
         }


         /* Maximum spawn path tracking length  */
         case 'L':
         {
            showeq_params->walkpathlength = atoi(optarg);
            break;
         }

         
         /* Log spawns! */
         case 'x':
         {
	   pSEQPrefs->setPrefBool("LogSpawns", "Misc", true, 
				  XMLPreferences::Runtime);
	   break;
         }


         /* Display the version info... */
         case 'V':
         case 'v':
         {
  	   exit(0);
	   break;
         }

         /* Don't autodetect character settings */
         case 'W':
         {
	   pSEQPrefs->getPrefBool("AutoDetectCharSettings", "Defaults", 
				  false, XMLPreferences::Runtime);
	   break;
         }


         /* Set default player level */
         case 'X':
         {
            temp_int = atoi(optarg);
            
            if (temp_int < 1 || temp_int > 70)
            {
               printf ("Invalid default level.  Valid range is 1 - 70.\n");
               exit(0);
            }

	    pSEQPrefs->setPrefInt("DefaultLevel", "Defaults", temp_int,
				  XMLPreferences::Runtime);
            break;
         }


         /* Set default player race */
         case 'Y':
         {
            temp_int = atoi(optarg);
            
            if ((temp_int < 1 || temp_int > 12) && 
		(temp_int != 128) &&
		(temp_int != 130) &&
		(temp_int != 26) &&
		(temp_int != 330))
            {
               printf ("Invalid default race, please use showeq -h to list valid race options.\n");
               exit(0);
            }
            
	    pSEQPrefs->setPrefInt("DefaultRace", "Defaults", temp_int,
				  XMLPreferences::Runtime);

            break;
         }


         /* Set default player class */
         case 'Z':
         {
            temp_int = atoi(optarg);
            
            if (temp_int < 1 || temp_int > 16)
            {
               printf ("Invalid default class, please use showeq -h to list valid class options.\n");
               exit(0);
            }

	    pSEQPrefs->setPrefInt("DefaultClass", "Defaults", temp_int);
            break;
         }

         /* IP address to track */
         case IPADDR_OPTION:
         {
	   pSEQPrefs->setPrefString("IP", "Network", optarg, 
				    XMLPreferences::Runtime);

	   break;
         }


         /* MAC address to track for those on DHCP */
         case MACADDR_OPTION:
         {
	   pSEQPrefs->setPrefString("MAC", "Network", optarg, 
				    XMLPreferences::Runtime);

	   break;
         }


         /* Filename for logging all packets */
         case GLOBAL_LOG_FILENAME_OPTION:
         {
	   pSEQPrefs->setPrefString("GlobalLogFilename", "PacketLogging", 
				    optarg, XMLPreferences::Runtime);
	   break;
         }


         /* Filename for logging world change packets */
         case WORLD_LOG_FILENAME_OPTION:
         {
	   pSEQPrefs->setPrefString("WorldLogFilename", "PacketLogging", 
				    optarg, XMLPreferences::Runtime);
	   break;
         }

         /* Filename for logging zone change packets */
         case ZONE_LOG_FILENAME_OPTION:
         {
	   pSEQPrefs->setPrefString("ZoneLogFilename", "PacketLogging", 
				    optarg, XMLPreferences::Runtime);
	   break;
         }


         /* Filename for logging unknown zone change packets */
         case UNKNOWN_LOG_FILENAME_OPTION:
         {
	   pSEQPrefs->setPrefString("UnknownZoneLogFilename", 
				    "PacketLogging", optarg, 
				    XMLPreferences::Runtime);
	   break;
         }


         /* Log everything */
         case GLOBAL_LOG_OPTION:
         {
	   pSEQPrefs->setPrefBool("LogAllPackets", "PacketLogging", true,
				  XMLPreferences::Runtime);
	   break;
         }


         /* Log all zone change packets */
         case ZONE_LOG_OPTION:
         {
	   pSEQPrefs->setPrefBool("LogZonePackets", "PacketLogging", true,
				  XMLPreferences::Runtime);
	   break;
         }


         /* Log only unfamiliar zone change packets */
         case UNKNOWN_ZONE_LOG_OPTION:
         {
	   pSEQPrefs->setPrefBool("LogUnknownZonePackets", "PacketLogging", true,
				  XMLPreferences::Runtime);
	   break;
         }


         case PLAYBACK_SPEED_OPTION:
         {
	   pSEQPrefs->setPrefInt("PlaybackRate", "VPacket", atoi(optarg), 
				 XMLPreferences::Runtime);
            break;
         }


         /* Enable logging of raw packets... */
         case RAW_LOG_OPTION:
         {
	   pSEQPrefs->setPrefBool("LogRawPackets", "PacketLogging", true,
				  XMLPreferences::Runtime);
	   break;
         }

         /* Display spawntime in UNIX time (time_t) instead of hh:mm format */
         case SYSTIME_SPAWNTIME_OPTION:
         { 
            showeq_params->systime_spawntime = 1;
            break;
         }

         case SPAWNLOG_FILENAME_OPTION:
         {
	   pSEQPrefs->setPrefString("SpawnLogFilename", "Misc", optarg,
				  XMLPreferences::Runtime);
	   break;
         }
         
         case ITEMDB_DATA_FILENAME_OPTION:
	   {
	     pSEQPrefs->setPrefString("DataDBFilename", "ItemDB", optarg,
				      XMLPreferences::Runtime);
	     break;
         }
         
         case ITEMDB_RAW_FILENAME_OPTION:
         {
	     pSEQPrefs->setPrefString("RawDataDBFilename", "ItemDB", optarg,
				      XMLPreferences::Runtime);
            break;
         }

         case ITEMDB_DATABASES_ENABLED:
         {
	   pSEQPrefs->setPrefInt("DatabasesEnabled", "ItemDB", atoi(optarg),
				 XMLPreferences::Runtime);
	   break;
         }
	 
         case ITEMDB_DISABLE:
	 {
	   pSEQPrefs->setPrefBool("Enabled", "ItemDB", false, 
				 XMLPreferences::Runtime);
	   break;
	 }

         case ITEMDB_ENABLE:
	 {
	   pSEQPrefs->setPrefBool("Enabled", "ItemDB", true, 
				 XMLPreferences::Runtime);
	   break;
	 }

         case RESTORE_PLAYER_STATE:
	 {
	   showeq_params->restorePlayerState = true;
	   break;
	 }
         case RESTORE_ZONE_STATE:
	 {
	   showeq_params->restoreZoneState = true;
	   break;
	 }
         case RESTORE_SPAWNS:
	 {
	   showeq_params->restoreSpawns = true;
	   break;
	 }
         case RESTORE_ALL:
	 {
	   showeq_params->restorePlayerState = true;
	   showeq_params->restoreZoneState = true;
	   showeq_params->restoreSpawns = true;
	   break;
	 }


         /* Spit out the help */
         case 'h': /* Fall through */
         default:
         {
            bOptionHelp = true;
            break;
         }
      }
   }

   if (bOptionHelp)
   {
     displayOptions(argv[0]);
     exit (0);
   }

   /* Set up individual files for logging selected packet types based on
      a common filename base.   The types to log were found by following
      where pre_worked was a precondition for further analysis.
   */

   int ret;

   // just to add a scope to better control when the main interface gets 
   // destroyed
   if  (1)
   {
     /* The main interface widget */
     EQInterface intf(&dataLocMgr, 0, "interface");
     qapp.setMainWidget (&intf);
   
     /* Start the main loop */
     ret = qapp.exec ();
   }

   // delete the preferences data
   delete pSEQPrefs;

   // delete the showeq_params data
   delete showeq_params;

   return ret;
}
Ejemplo n.º 17
0
static void rebuildSelector(struct htmlTag *sel, jsobjtype oa, int len2)
{
	int i1, i2, len1;
	bool check2;
	char *s;
	const char *selname;
	bool changed = false;
	struct htmlTag *t;
	jsobjtype oo;		/* option object */

	len1 = cw->numTags;
	i1 = i2 = 0;
	selname = sel->name;
	if (!selname)
		selname = "?";
	debugPrint(4, "testing selector %s %d %d", selname, len1, len2);

	sel->lic = (sel->multiple ? 0 : -1);

	while (i1 < len1 && i2 < len2) {
/* there is more to both lists */
		t = tagList[i1++];
		if (t->action != TAGACT_OPTION)
			continue;
		if (t->controller != sel)
			continue;

/* find the corresponding option object */
		if ((oo = get_array_element_object(oa, i2)) == NULL) {
/* Wow this shouldn't happen. */
/* Guess I'll just pretend the array stops here. */
			len2 = i2;
			--i1;
			break;
		}

		t->jv = oo;	/* should already equal oo */
		t->rchecked = get_property_bool(oo, "defaultSelected");
		check2 = get_property_bool(oo, "selected");
		if (check2) {
			if (sel->multiple)
				++sel->lic;
			else
				sel->lic = i2;
		}
		++i2;
		if (t->checked != check2)
			changed = true;
		t->checked = check2;
		s = get_property_string(oo, "text");
		if (s && !t->textval || !stringEqual(t->textval, s)) {
			nzFree(t->textval);
			t->textval = s;
			changed = true;
		} else
			nzFree(s);
		s = get_property_string(oo, "value");
		if (s && !t->value || !stringEqual(t->value, s)) {
			nzFree(t->value);
			t->value = s;
		} else
			nzFree(s);
	}

/* one list or the other or both has run to the end */
	if (i2 == len2) {
		for (; i1 < len1; ++i1) {
			t = tagList[i1];
			if (t->action != TAGACT_OPTION)
				continue;
			if (t->controller != sel)
				continue;
/* option is gone in js, disconnect this option tag from its select */
			t->jv = 0;
			t->controller = 0;
			t->action = TAGACT_NOP;
			changed = true;
		}
	} else if (i1 == len1) {
		for (; i2 < len2; ++i2) {
			if ((oo = get_array_element_object(oa, i2)) == NULL)
				break;
			t = newTag("option");
			t->lic = i2;
			t->controller = sel;
			t->jv = oo;
			t->step = 2;	// already decorated
			t->textval = get_property_string(oo, "text");
			t->value = get_property_string(oo, "value");
			t->checked = get_property_bool(oo, "selected");
			if (t->checked) {
				if (sel->multiple)
					++sel->lic;
				else
					sel->lic = i2;
			}
			t->rchecked = get_property_bool(oo, "defaultSelected");
			changed = true;
		}
	}

	if (!changed)
		return;
	debugPrint(4, "selector %s has changed", selname);

/* If js change the menu, it should have also changed select.value
 * according to the checked options, but did it?
 * Don't know, so I'm going to do it here. */
	s = displayOptions(sel);
	if (!s)
		s = emptyString;
	set_property_string(sel->jv, "value", s);
	javaSetsTagVar(sel->jv, s);
	nzFree(s);

	if (!sel->multiple)
		set_property_number(sel->jv, "selectedIndex", sel->lic);
}				/* rebuildSelector */