コード例 #1
0
ファイル: vic20.c プロジェクト: SavourySnaX/EDL
void UpdateCassette()
{
#if 1
	if (CheckKey(GLFW_KEY_PAGE_UP))
	{
		playDown=1;
		recDown=playDown;
		ClearKey(GLFW_KEY_PAGE_UP);
		cntPos=0;
		casCount=0;
		casLevel=0;		
	}
#endif
	if (CheckKey(GLFW_KEY_PAGE_DOWN))
	{
		playDown=1;
		recDown=0;
		ClearKey(GLFW_KEY_PAGE_DOWN);
		cntPos=0;
		casCount=0;
		casLevel=0;
	}
	if (CheckKey(GLFW_KEY_END))
	{
		playDown=0;
		recDown=0;
		ClearKey(GLFW_KEY_END);
		cntPos=0;
		casCount=0;
		casLevel=0;		
	}

	// Cassette deck
	if (playDown)
	{
		VIA0_PinSetPIN_PA(VIA0_PinGetPIN_PA()&0xBF);
	}
	if (playDown && recDown && (!VIA0_PinGetPIN_CA2())) // SAVING
	{
		uint8_t newRecLevel = (VIA1_PinGetPIN_PB()&0x08)>>3;
		casCount++;
		if (newRecLevel!=casLevel)
		{
			//printf("Level Changed %08X\n",casCount);
			cntMax=cntPos;
			cntBuffer[cntPos++]=casCount;
			casCount=0;
			casLevel=newRecLevel;
		}
	}
コード例 #2
0
ファイル: SVMap.hpp プロジェクト: pwais/oarphkit
 inline
 void MoveKeyTo(const std::string &k, SVMap &other) {
   if (OK_LIKELY(HasKey(k))) {
     other.entrymap_[k] = std::move(this->entrymap_.at(k));
     ClearKey(k);
   }
 }
コード例 #3
0
ファイル: Keypad.cpp プロジェクト: dogtwelve/newsiderpg
CKeypad::CKeypad()
#ifdef KEY_SUPPORT_DOUBLEPRESS
	:m_doublePressInterval(5)
#endif
{
	ClearKey();
#ifdef KEY_SUPPORT_DOUBLEPRESS
	MEMSET(m_pressLastTime, 0, sizeof(m_pressLastTime));
	MEMSET(m_pressInterval, 0, sizeof(m_pressInterval));
#endif
}
コード例 #4
0
ファイル: eeconfigfactory.cpp プロジェクト: Afshintm/coreclr
//---------------------------------------------------------------------------
HRESULT STDMETHODCALLTYPE EEConfigFactory::EndChildren( 
    /* [in] */ IXMLNodeSource __RPC_FAR *pSource,
    /* [in] */ BOOL fEmptyNode,
    /* [in] */ XML_NODE_INFO __RPC_FAR *pNodeInfo)
{
    LIMITED_METHOD_CONTRACT;
    if ( fEmptyNode ) { 
        m_fDeveloperSettings = FALSE;        
    }
    else {
        m_dwDepth--;
    }

    if (m_pActiveFactory != NULL)
    {
        HRESULT hr = S_OK;
        IfFailRet(m_pActiveFactory->EndChildren(pSource, fEmptyNode, pNodeInfo));


        if(m_dwDepth == 2) // when generalizing: use the current active factory depth
        {
            m_pActiveFactory = NULL;
        }
        
    }

    if (m_fUnderRuntimeElement && wcscmp(pNodeInfo->pwcText, W("runtime")) == 0) {
        m_fUnderRuntimeElement = FALSE;
        m_fVersionedRuntime = FALSE;
        ClearKey();
        // CLR_STARTUP_OPT:
        // Early out if we only need to read <runtime> section.
        //
        if (m_parseCtl == stopAfterRuntimeSection)
            pSource->Abort(NULL/*unused*/);
    }
    
    return S_OK;
}
コード例 #5
0
ファイル: Registry.cpp プロジェクト: pyq881120/urltraveler
Registry::~Registry()
{
	ClearKey();
}
コード例 #6
0
ファイル: invaders.c プロジェクト: Godzil/EDL
int main(int argc,char**argv)
{
	double	atStart,now,remain;

	/// Initialize GLFW 
	glfwInit(); 

	// Open registers OpenGL window 
	if( !(windows[REGISTER_WINDOW]=glfwCreateWindow( REGISTER_WIDTH, REGISTER_HEIGHT, "cpu",NULL,NULL)) ) 
	{ 
		glfwTerminate(); 
		return 1; 
	} 

	glfwSetWindowPos(windows[REGISTER_WINDOW],600,740);

	glfwMakeContextCurrent(windows[REGISTER_WINDOW]);
	setupGL(REGISTER_WINDOW,REGISTER_WIDTH,REGISTER_HEIGHT);

	// Open timing OpenGL window 
	if( !(windows[TIMING_WINDOW]=glfwCreateWindow( TIMING_WIDTH, TIMING_HEIGHT, "timing",NULL,NULL)) ) 
	{ 
		glfwTerminate(); 
		return 1; 
	} 

	glfwSetWindowPos(windows[TIMING_WINDOW],600,300);

	glfwMakeContextCurrent(windows[TIMING_WINDOW]);
	setupGL(TIMING_WINDOW,TIMING_WIDTH,TIMING_HEIGHT);

	// Open invaders OpenGL window 
	if( !(windows[MAIN_WINDOW]=glfwCreateWindow( WIDTH, HEIGHT, "invaders",NULL,NULL)) ) 
	{ 
		glfwTerminate(); 
		return 1; 
	} 

	glfwSetWindowPos(windows[MAIN_WINDOW],300,300);
	
	glfwMakeContextCurrent(windows[MAIN_WINDOW]);
	setupGL(MAIN_WINDOW,WIDTH,HEIGHT);

	glfwSwapInterval(0);			// Disable VSYNC

	glfwSetKeyCallback(windows[MAIN_WINDOW],kbHandler);
	glfwSetScrollCallback(windows[TIMING_WINDOW],mwHandler);

	atStart=glfwGetTime();
	//////////////////

	if (InitialiseMemory())
		return -1;
	
	PinSetRESET(1);
	PIN_BUFFER_RESET=1;
	PinSetO1(1);			// Run with reset high for a few cycles to perform a full cpu reset
	PinSetO1(0);
	PinSetO2(1);
	PinSetO2(0);
	PinSetO1(1);
	PinSetO1(0);
	PinSetO2(1);
	PinSetO2(0);
	PinSetO1(1);
	PinSetO1(0);
	PinSetO2(1);
	PinSetO2(0);
	PinSetRESET(0);			// RESET CPU
	PIN_BUFFER_RESET=0;

	//dumpInstruction=100000;

	int stopTheClock=0;
	while (!glfwGetKey(windows[MAIN_WINDOW],GLFW_KEY_ESCAPE))
	{
		
		if (!stopTheClock)
		{
			masterClock++;
			if ((masterClock%4)==0)
				pixelClock++;

			if ((masterClock%10)==0)
			{
								// I8080 emulation works off positive edge trigger. So we need to supply the same sort of
								// clock.
				PIN_BUFFER_O2=0;
				PIN_BUFFER_O1=1;
				PinSetO1(1);		// Execute a cpu step
				if (bTimingEnabled)
					RecordPins();
				PIN_BUFFER_O1=0;
				PinSetO1(0);
				if (bTimingEnabled)
					RecordPins();
				PIN_BUFFER_O2=1;
				PinSetO2(1);
				if (bTimingEnabled)
					RecordPins();
				PIN_BUFFER_O2=0;
				PinSetO2(0);

				if (!MEM_Handler())
				{
					stopTheClock=1;
				}
				if (bTimingEnabled)
					RecordPins();

				PinSetINT(0);		// clear interrupt state
				PIN_BUFFER_INT=0;
				cpuClock++;
			}
			if (pixelClock==30432+10161)		// Based on 19968000 Mhz master clock + mame notes
			{
				NEXTINT=0xCF;
				PinSetINT(1);
				PIN_BUFFER_INT=1;
			}
			if (pixelClock==71008+10161)
			{
				NEXTINT=0xD7;
				PinSetINT(1);
				PIN_BUFFER_INT=1;
			}
		}
		if (pixelClock>=83200 || stopTheClock)
		{
			if (pixelClock>=83200)
				pixelClock=0;

			if (glfwWindowShouldClose(windows[TIMING_WINDOW]))
			{
				bTimingEnabled=0;
				glfwHideWindow(windows[TIMING_WINDOW]);
			}
			if (glfwWindowShouldClose(windows[REGISTER_WINDOW]))
			{
				bRegisterEnabled=0;
				glfwHideWindow(windows[REGISTER_WINDOW]);
			}

            		glfwMakeContextCurrent(windows[MAIN_WINDOW]);
			ShowScreen(MAIN_WINDOW,WIDTH,HEIGHT);
			glfwSwapBuffers(windows[MAIN_WINDOW]);
				
			if (bTimingEnabled)
			{
				glfwMakeContextCurrent(windows[TIMING_WINDOW]);
				DrawTiming(videoMemory[TIMING_WINDOW],TIMING_WIDTH);
				ShowScreen(TIMING_WINDOW,TIMING_WIDTH,TIMING_HEIGHT);
				glfwSwapBuffers(windows[TIMING_WINDOW]);
			}
			if (bRegisterEnabled)
			{
				glfwMakeContextCurrent(windows[REGISTER_WINDOW]);
				DrawRegister(videoMemory[REGISTER_WINDOW],REGISTER_WIDTH);
				ShowScreen(REGISTER_WINDOW,REGISTER_WIDTH,REGISTER_HEIGHT);
				glfwSwapBuffers(windows[REGISTER_WINDOW]);
			}
        
			glfwPollEvents();
			
			g_traceStep=0;
			if (CheckKey(GLFW_KEY_PAUSE))
			{
				g_instructionStep^=1;
				if (stopTheClock && !g_instructionStep)
					stopTheClock=0;
				ClearKey(GLFW_KEY_PAUSE);
			}
			if (stopTheClock && CheckKey('S'))
			{
				stopTheClock=0;
				ClearKey('S');
			}
			if (stopTheClock && CheckKey('T'))
			{
				stopTheClock=0;
				g_traceStep=1;
				ClearKey('T');
			}

			now=glfwGetTime();

			remain = now-atStart;

			while ((remain<0.02f))
			{
				now=glfwGetTime();

				remain = now-atStart;
			}
			atStart=glfwGetTime();
		}
	}
	
	return 0;

}
コード例 #7
0
ファイル: HRIMAGE.C プロジェクト: hex-ci/Hyper-Reader
void image()
{int i;
 randomize();
 settextstyle(1,HORIZ_DIR,9);
 for (i=-250;i<10;i+=5)
 {setcolor(BLACK);
  outtextxy(i-5,0,*Title);// "Hyper"
  setcolor(LIGHTBLUE);
  outtextxy(i,0,*Title);// "Hyper"
  Delay(1);
 }
 Delay(300);
 setcolor(LIGHTRED);
 settextstyle(3,HORIZ_DIR,16);
 for (i=1;i<7;i++)
 {outtextxy(210+i*60,60,*(Title+i));// "Reader"
  Delay(400);
 }
 Delay(100);
 for (i=1;i<7;i++)
 {settextstyle(4,0,i);
  setcolor(LIGHTCYAN);
  outtextxy(450,190,*(Title+7));// "2000"
  Delay(300);
  setcolor(BLACK);
  settextstyle(4,HORIZ_DIR,i);
  outtextxy(450,190,*(Title+7));// "2000"
 }
 setcolor(LIGHTCYAN);
 settextstyle(4,HORIZ_DIR,i);
 outtextxy(450,190,*(Title+7));// "2000"
 Delay(400);
 setcolor(BLUE);
 line(10,140,250,140);
 line(250,140,250,200);
 line(250,200,400,200);
 line(400,200,400,280);
 line(400,280,600,280);
 Delay(800);
 setcolor(LIGHTGREEN);
 settextstyle(2,0,7);
 outtextxy(20,200,*(Title+8));// "Produced by Zhao Chang."
 Delay(500);
 outtextxy(40,225,*(Title+9));// "Copyright (C)  2000"
 Delay(500);
 outtextxy(37,250,*(Title+10));// "ALL RIGHTS RESERVED."
 Delay(500);
 setcolor(LIGHTMAGENTA);
 settextstyle(1,0,2);
 outtextxy(340,350,*(Title+11));// "Press any key . . ."
 setcolor(WHITE);
 settextstyle(2,0,5);
 outtextxy(142,450,"Version");
 outtextxy(205,450,Version);
 outtextxy(377,450,"Update:");
 outtextxy(435,450,Update);
 people();
 book();
 Delay(2000);
 ClearKey();
 while (!kbhit())
 {ChangeColor();
  book();
  people();
  delaykey(30);
 }
 getch();
 restorecrtmode();
}
コード例 #8
0
ファイル: commands.cpp プロジェクト: Akscan/QtWeb
QString MenuCommands::Get(int ind, What w) const
{
    int cur = 0;

    if (cur++ == ind)
        return (w == Key ? FileKey() : (w == Title? FileTitle() : ""));

    if (cur++ == ind)
        return (w == Key ? NewWinKey() : (w == Title? NewWinTitle() : GetStr(NewWinShortcuts())));

    if (cur++ == ind)
        return (w == Key ? OpenFileKey() : (w == Title? OpenFileTitle() : GetStr(OpenFileShortcuts())));

    if (cur++ == ind)
        return (w == Key ? OpenLocKey() : (w == Title? OpenLocTitle() : GetStr(OpenLocShortcuts())));

    if (cur++ == ind)
        return (w == Key ? SaveAsKey() : (w == Title? SaveAsTitle() : GetStr(SaveAsShortcuts())));

    if (cur++ == ind)
        return (w == Key ? SavePdfKey() : (w == Title? SavePdfTitle() : GetStr(SavePdfShortcuts())));

    if (cur++ == ind)
        return (w == Key ? ImportKey() : (w == Title? ImportTitle() : ""));

    if (cur++ == ind)
        return (w == Key ? ImportIEKey() : (w == Title? ImportIETitle() : GetStr(ImportIEShortcuts())));

    if (cur++ == ind)
        return (w == Key ? ImportFFKey() : (w == Title? ImportFFTitle() : GetStr(ImportFFShortcuts())));

    if (cur++ == ind)
        return (w == Key ? ImportHtmlKey() : (w == Title? ImportHtmlTitle() : GetStr(ImportHtmlShortcuts())));

    if (cur++ == ind)
        return (w == Key ? ImportXmlKey() : (w == Title? ImportXmlTitle() : GetStr(ImportXmlShortcuts())));

    if (cur++ == ind)
        return (w == Key ? ExportKey() : (w == Title? ExportTitle() : GetStr(ExportShortcuts())));

    if (cur++ == ind)
        return (w == Key ? PrintKey() : (w == Title? PrintTitle() : GetStr(PrintShortcuts())));

    if (cur++ == ind)
        return (w == Key ? PreviewKey() : (w == Title? PreviewTitle() : GetStr(PreviewShortcuts())));

    if (cur++ == ind)
        return (w == Key ? QuitKey() : (w == Title? QuitTitle() : GetStr(QuitShortcuts())));

    if (cur++ == ind)
        return (w == Key ? EditKey() : (w == Title? EditTitle() : ""));

    if (cur++ == ind)
        return (w == Key ? UndoKey() : (w == Title? UndoTitle() : GetStr(UndoShortcuts())));

    if (cur++ == ind)
        return (w == Key ? RedoKey() : (w == Title? RedoTitle() : GetStr(RedoShortcuts())));

    if (cur++ == ind)
        return (w == Key ? CutKey() : (w == Title? CutTitle() : GetStr(CutShortcuts())));

    if (cur++ == ind)
        return (w == Key ? CopyKey() : (w == Title? CopyTitle() : GetStr(CopyShortcuts())));

    if (cur++ == ind)
        return (w == Key ? PasteKey() : (w == Title? PasteTitle() : GetStr(PasteShortcuts())));

    if (cur++ == ind)
        return (w == Key ? FindKey() : (w == Title? FindTitle() : GetStr(FindShortcuts())));

    if (cur++ == ind)
        return (w == Key ? NextKey() : (w == Title? NextTitle() : GetStr(NextShortcuts())));

    if (cur++ == ind)
        return (w == Key ? PrevKey() : (w == Title? PrevTitle() : GetStr(PrevShortcuts())));

    if (cur++ == ind)
        return (w == Key ? PrefsKey() : (w == Title? PrefsTitle() : GetStr(PrefsShortcuts())));

    if (cur++ == ind)
        return (w == Key ? ViewKey() : (w == Title? ViewTitle() : ""));

    if (cur++ == ind)
        return (w == Key ? AppStylesKey() : (w == Title? AppStylesTitle() : ""));

    if (cur++ == ind)
        return (w == Key ? StatusKey() : (w == Title? StatusTitle() : GetStr(StatusShortcuts())));

    if (cur++ == ind)
        return (w == Key ? MenuKey() : (w == Title? MenuTitle() : GetStr(MenuShortcuts())));

    if (cur++ == ind)
        return (w == Key ? TabKey() : (w == Title? TabTitle() : GetStr(TabShortcuts())));

    if (cur++ == ind)
        return (w == Key ? NavKey() : (w == Title? NavTitle() : GetStr(NavShortcuts())));

    if (cur++ == ind)
        return (w == Key ? BooksKey() : (w == Title? BooksTitle() : GetStr(BooksShortcuts())));

//  if (cur++ == ind)
//      return (w == Key ? Key() : (w == Title? Title() : GetStr(Shortcuts())));

    if (cur++ == ind)
        return (w == Key ? StopKey() : (w == Title? StopTitle() : GetStr(StopShortcuts())));

    if (cur++ == ind)
        return (w == Key ? ReloadKey() : (w == Title? ReloadTitle() : GetStr(ReloadShortcuts())));

    if (cur++ == ind)
        return (w == Key ? LargerKey() : (w == Title? LargerTitle() : GetStr(LargerShortcuts())));

    if (cur++ == ind)
        return (w == Key ? NormalKey() : (w == Title? NormalTitle() : GetStr(NormalShortcuts())));

    if (cur++ == ind)
        return (w == Key ? SmallerKey() : (w == Title? SmallerTitle() : GetStr(SmallerShortcuts())));

    if (cur++ == ind)
        return (w == Key ? TextOnlyKey() : (w == Title? TextOnlyTitle() : GetStr(TextOnlyShortcuts())));

    if (cur++ == ind)
        return (w == Key ? EncodeKey() : (w == Title? EncodeTitle() : ""));

    if (cur++ == ind)
        return (w == Key ? SourceKey() : (w == Title? SourceTitle() : GetStr(SourceShortcuts())));

    if (cur++ == ind)
        return (w == Key ? FullKey() : (w == Title? FullTitle() : GetStr(FullShortcuts())));

    if (cur++ == ind)
        return (w == Key ? HistoryKey() : (w == Title? HistoryTitle() : ""));

    if (cur++ == ind)
        return (w == Key ? BackKey() : (w == Title? BackTitle() : GetStr(BackShortcuts())));

    if (cur++ == ind)
        return (w == Key ? ForwKey() : (w == Title? ForwTitle() : GetStr(ForwShortcuts())));

    if (cur++ == ind)
        return (w == Key ? HomeKey() : (w == Title? HomeTitle() : GetStr(HomeShortcuts())));

    if (cur++ == ind)
        return (w == Key ? LastTabKey() : (w == Title? LastTabTitle() : GetStr(LastTabShortcuts())));

    if (cur++ == ind)
        return (w == Key ? LastTabsKey() : (w == Title? LastTabsTitle() : GetStr(LastTabsShortcuts())));

    if (cur++ == ind)
        return (w == Key ? SessionKey() : (w == Title? SessionTitle() : GetStr(SessionShortcuts())));

    if (cur++ == ind)
        return (w == Key ? AllHistKey() : (w == Title? AllHistTitle() : GetStr(AllHistShortcuts())));

    if (cur++ == ind)
        return (w == Key ? ClearKey() : (w == Title? ClearTitle() : GetStr(ClearShortcuts())));

    if (cur++ == ind)
        return (w == Key ? BookmarksKey() : (w == Title? BookmarksTitle() : ""));

    if (cur++ == ind)
        return (w == Key ? AllBooksKey() : (w == Title? AllBooksTitle() : GetStr(AllBooksShortcuts())));

    if (cur++ == ind)
        return (w == Key ? AddBookKey() : (w == Title? AddBookTitle() : GetStr(AddBookShortcuts())));
    
    if (cur++ == ind)
        return (w == Key ? PrivacyKey() : (w == Title? PrivacyTitle() : ""));
    
    if (cur++ == ind)
        return (w == Key ? PrivateKey() : (w == Title? PrivateTitle() : GetStr(PrivateShortcuts())));
    
    if (cur++ == ind)
        return (w == Key ? JavaScriptKey() : (w == Title? JavaScriptTitle() : GetStr(JavaScriptShortcuts())));
    
    if (cur++ == ind)
        return (w == Key ? ImagesKey() : (w == Title? ImagesTitle() : GetStr(ImagesShortcuts())));
    
    if (cur++ == ind)
        return (w == Key ? CookiesKey() : (w == Title? CookiesTitle() : GetStr(CookiesShortcuts())));
    
    if (cur++ == ind)
        return (w == Key ? PlugInsKey() : (w == Title? PlugInsTitle() : GetStr(PlugInsShortcuts())));
    
    if (cur++ == ind)
        return (w == Key ? AgentKey() : (w == Title? AgentTitle() : GetStr(AgentShortcuts())));
    
    if (cur++ == ind)
        return (w == Key ? PopUpsKey() : (w == Title? PopUpsTitle() : GetStr(PopUpsShortcuts())));

    if (cur++ == ind)
        return (w == Key ? ProxyKey() : (w == Title? ProxyTitle() : GetStr(ProxyShortcuts())));

    if (cur++ == ind)
        return (w == Key ? EmptyKey() : (w == Title? EmptyTitle() : GetStr(EmptyShortcuts())));

    if (cur++ == ind)
        return (w == Key ? ResetKey() : (w == Title? ResetTitle() : GetStr(ResetShortcuts())));

    if (cur++ == ind)
        return (w == Key ? FullResetKey() : (w == Title? FullResetTitle() : GetStr(FullResetShortcuts())));

    if (cur++ == ind)
        return (w == Key ? ToolsKey() : (w == Title? ToolsTitle() : ""));

    if (cur++ == ind)
        return (w == Key ? CompatKey() : (w == Title? CompatTitle() : ""));

    if (cur++ == ind)
        return (w == Key ? SearchKey() : (w == Title? SearchTitle() : GetStr(SearchShortcuts())));

    if (cur++ == ind)
        return (w == Key ? KeyboardKey() : (w == Title? KeyboardTitle() : GetStr(KeyboardShortcuts())));

    if (cur++ == ind)
        return (w == Key ? InspectorKey() : (w == Title? InspectorTitle() : GetStr(InspectorShortcuts())));

    if (cur++ == ind)
        return (w == Key ? InspectKey() : (w == Title? InspectTitle() : GetStr(InspectShortcuts())));

    if (cur++ == ind)
        return (w == Key ? OptionsKey() : (w == Title? OptionsTitle() : GetStr(OptionsShortcuts())));

    if (cur++ == ind)
        return (w == Key ? WindowKey() : (w == Title? WindowTitle() : ""));

    if (cur++ == ind)
        return (w == Key ? NextTabKey() : (w == Title? NextTabTitle() : GetStr(NextTabShortcuts())));

    if (cur++ == ind)
        return (w == Key ? PrevTabKey() : (w == Title? PrevTabTitle() : GetStr(PrevTabShortcuts())));

    if (cur++ == ind)
        return (w == Key ? NewTabKey() : (w == Title? NewTabTitle() : GetStr(NewTabShortcuts())));

    if (cur++ == ind)
        return (w == Key ? CloseTabKey() : (w == Title? CloseTabTitle() : GetStr(CloseTabShortcuts())));

    if (cur++ == ind)
        return (w == Key ? CloseOtherKey() : (w == Title? CloseOtherTitle() : GetStr(CloseOtherShortcuts())));

    if (cur++ == ind)
        return (w == Key ? CloneTabKey() : (w == Title? CloneTabTitle() : GetStr(CloneTabShortcuts())));

    if (cur++ == ind)
        return (w == Key ? ReloadTabKey() : (w == Title? ReloadTabTitle() : GetStr(ReloadTabShortcuts())));

    if (cur++ == ind)
        return (w == Key ? ReloadAllKey() : (w == Title? ReloadAllTitle() : GetStr(ReloadAllShortcuts())));

    if (cur++ == ind)
        return (w == Key ? OpenNewTabKey() : (w == Title? OpenNewTabTitle() : GetStr(OpenNewTabShortcuts())));

    if (cur++ == ind)
        return (w == Key ? OpenAdBlockKey() : (w == Title? OpenAdBlockTitle() : GetStr(OpenAdBlockShortcuts())));

    if (cur++ == ind)
        return (w == Key ? SwapFocusKey() : (w == Title? SwapFocusTitle() : GetStr(SwapFocusShortcuts())));

    if (cur++ == ind)
        return (w == Key ? CopyAddrKey() : (w == Title? CopyAddrTitle() : ""));

    if (cur++ == ind)
        return (w == Key ? DownsKey() : (w == Title? DownsTitle() : GetStr(DownsShortcuts())));

    if (cur++ == ind)
        return (w == Key ? TorrentsKey() : (w == Title? TorrentsTitle() : GetStr(TorrentsShortcuts())));

    if (cur++ == ind)
        return (w == Key ? HelpKey() : (w == Title? HelpTitle() : GetStr(HelpShortcuts())));

    if (cur++ == ind)
        return (w == Key ? OnlineKey() : (w == Title? OnlineTitle() : GetStr(OnlineShortcuts())));

    if (cur++ == ind)
        return (w == Key ? UpdatesKey() : (w == Title? UpdatesTitle() : GetStr(UpdatesShortcuts())));

    if (cur++ == ind)
        return (w == Key ? AboutKey() : (w == Title? AboutTitle() : GetStr(AboutShortcuts())));

    return "";
}
コード例 #9
0
ファイル: channelhandlers.c プロジェクト: quakenet/newserv
int handleclearmodemsg(void *source, int cargc, char **cargv) {
  channel *cp;
  void *harg[4];
  nick *np, *target;
  char *mcp;
  unsigned long usermask=0;
  int i;
  int changes=0;

  if (cargc<2) {
    return CMD_OK;
  }

  if ((cp=findchannel(cargv[0]))==NULL) {
    /* No channel, abort */
    Error("channel",ERR_WARNING,"Mode change on non-existent channel %s",cargv[0]);
    return CMD_OK;
  }

  if (((char *)source)[2]=='\0') {
    /* Server mode change? (I don't think servers are allowed to do CLEARMODE) */
    np=NULL;
  } else if ((np=getnickbynumericstr((char *)source))==NULL) {
    /* No sender, continue but moan */
    Error("channel",ERR_WARNING,"Mode change by non-existent user %s on channel %s",(char *)source,cp->index->name->content);
  }
             
  harg[0]=cp;
  harg[1]=np;
  harg[3]=(void *)(long)(cp->flags);

  for (mcp=cargv[1];*mcp;mcp++) {
    switch (*mcp) {
      case 'o':
        usermask |= CUMODE_OP;
	changes |= MODECHANGE_USERS;
        break;
      
      case 'v':
        usermask |= CUMODE_VOICE;
	changes |= MODECHANGE_USERS;
        break;
        
      case 'n':
        ClearNoExtMsg(cp);
	changes |= MODECHANGE_MODES;
        break;
        
      case 't':
        ClearTopicLimit(cp);
	changes |= MODECHANGE_MODES;
        break;
      
      case 's':
        ClearSecret(cp);
	changes |= MODECHANGE_MODES;
        break;
        
      case 'p':
        ClearPrivate(cp);
	changes |= MODECHANGE_MODES;
        break;
        
      case 'i':
        ClearInviteOnly(cp);
	changes |= MODECHANGE_MODES;
        break;
        
      case 'm':
        ClearModerated(cp);
	changes |= MODECHANGE_MODES;
        break;
        
      case 'c':
        ClearNoColour(cp);
	changes |= MODECHANGE_MODES;
        break;
        
      case 'C':
        ClearNoCTCP(cp);
	changes |= MODECHANGE_MODES;
        break;
        
      case 'r':
        ClearRegOnly(cp);
	changes |= MODECHANGE_MODES;
        break;
      
      case 'D':
        ClearDelJoins(cp);
	changes |= MODECHANGE_MODES;
        break;

      case 'u':
        ClearNoQuitMsg(cp);
        changes |= MODECHANGE_MODES;
	break;

      case 'N':
        ClearNoNotice(cp);
        changes |= MODECHANGE_MODES;
        break;
        
      case 'M':
        ClearModNoAuth(cp);
        changes |= MODECHANGE_MODES;
        break;
      
      case 'T':
        ClearSingleTarg(cp);
        changes |= MODECHANGE_MODES;
        break;

      case 'b':
        clearallbans(cp);
	changes |= MODECHANGE_BANS;
	break;
        
      case 'k':
        /* This is all safe even if there is no key atm */
        freesstring(cp->key);
        cp->key=NULL;
        ClearKey(cp);
	changes |= MODECHANGE_MODES;
        break;
        
      case 'l':
        cp->limit=0;
        ClearLimit(cp);
	changes |= MODECHANGE_MODES;
        break;
    }
  }
   
  if (usermask) {
    /* We have to strip something off each user */
    for (i=0;i<cp->users->hashsize;i++) {
      if (cp->users->content[i]!=nouser && (cp->users->content[i] & usermask)) {
        /* This user exists and has at least one of the modes we're clearing */
        if ((target=getnickbynumeric(cp->users->content[i]))==NULL) {
          /* This really is a fuckup, we found them on the channel but there isn't a user with that numeric */
          /* This means there's a serious bug in the nick/channel tracking code */
          Error("channel",ERR_ERROR,"CLEARMODE failed: user on channel who doesn't exist?");
        } else {
          harg[2]=target;                                  
          /* Yes, these are deliberate three way bitwise ANDs.. */
          if (cp->users->content[i] & usermask & CUMODE_OP)
            triggerhook(HOOK_CHANNEL_DEOPPED, harg);
          if (cp->users->content[i] & usermask & CUMODE_VOICE)
            triggerhook(HOOK_CHANNEL_DEVOICED, harg);          
          cp->users->content[i] &= ~usermask;
        }
      }
    }
  }

  harg[2]=(void *)((long)changes);
  triggerhook(HOOK_CHANNEL_MODECHANGE, harg);
  return CMD_OK;
}
コード例 #10
0
ファイル: channelhandlers.c プロジェクト: quakenet/newserv
int handlemodemsg(void *source, int cargc, char **cargv) {
  channel *cp;
  int dir=1;
  int arg=2;
  char *modestr;
  unsigned long *lp;
  void *harg[4];
  nick *np, *target;
  int hooknum;
  int changes=0;

  if (cargc<2) {
    return CMD_OK;
  }

  if (cargv[0][0]!='#' && cargv[0][0]!='+') {
    /* Not a channel, ignore */
    return CMD_OK;
  }

  if ((cp=findchannel(cargv[0]))==NULL) {
    /* No channel, abort */
    Error("channel",ERR_WARNING,"Mode change on non-existent channel %s",cargv[0]);
    return CMD_OK;
  }
  
  if (((char *)source)[2]=='\0') {
    /* Server mode change, treat as divine intervention */
    np=NULL;
  } else if ((np=getnickbynumericstr((char *)source))==NULL) {
    /* No sender, continue but moan */
    Error("channel",ERR_WARNING,"Mode change by non-existent user %s on channel %s",(char *)source,cp->index->name->content);
  }
  
  /* Set up the hook data */
  harg[0]=cp;
  harg[1]=np;
  harg[3]=(void *)(long)(cp->flags);
  
  /* Process the mode string one character at a time */
  /* Maybe I'll write this more intelligently one day if I can comprehend the ircu code that does this */
  for (modestr=cargv[1];*modestr;modestr++) {
    switch(*modestr) {
      /* Set whether we are adding or removing modes */
      
      case '+': 
        dir=1;
        break;
        
      case '-':
        dir=0;
        break;
      
      /* Simple modes: just set or clear based on value of dir */
      
      case 'n':
        if (dir) { SetNoExtMsg(cp); } else { ClearNoExtMsg(cp); }
	changes |= MODECHANGE_MODES;
        break;
      
      case 't':
        if (dir) { SetTopicLimit(cp); } else { ClearTopicLimit(cp); }
	changes |= MODECHANGE_MODES;
        break;
      
      case 's':
        if (dir) { SetSecret(cp); ClearPrivate(cp); } else { ClearSecret(cp); }
	changes |= MODECHANGE_MODES;
        break;
        
      case 'p':
        if (dir) { SetPrivate(cp); ClearSecret(cp); } else { ClearPrivate(cp); }
	changes |= MODECHANGE_MODES;
        break;
        
      case 'i':
        if (dir) { SetInviteOnly(cp); } else { ClearInviteOnly(cp); }
	changes |= MODECHANGE_MODES;
        break;
        
      case 'm':
        if (dir) { SetModerated(cp); } else { ClearModerated(cp); }
	changes |= MODECHANGE_MODES;
        break;
        
      case 'c':
        if (dir) { SetNoColour(cp); } else { ClearNoColour(cp); }
	changes |= MODECHANGE_MODES;
        break;
        
      case 'C':
        if (dir) { SetNoCTCP(cp); } else { ClearNoCTCP(cp); }
	changes |= MODECHANGE_MODES;
        break;
      
      case 'r':
        if (dir) { SetRegOnly(cp); } else { ClearRegOnly(cp); }
	changes |= MODECHANGE_MODES;
        break;
        
      case 'D':
        if (dir) { SetDelJoins(cp); } else { ClearDelJoins(cp); }
	changes |= MODECHANGE_MODES;
        break;

      case 'u':
        if (dir) { SetNoQuitMsg(cp); } else { ClearNoQuitMsg(cp); }
        changes |= MODECHANGE_MODES;
        break;
      
      case 'N':
        if (dir) { SetNoNotice(cp); } else { ClearNoNotice(cp); }
        changes |= MODECHANGE_MODES;
        break;
        
      case 'M':
        if (dir) { SetModNoAuth(cp); } else { ClearModNoAuth(cp); }
        changes |= MODECHANGE_MODES;
        break;
      
      case 'T':
        if (dir) { SetSingleTarg(cp); } else { ClearSingleTarg(cp); }
        changes |= MODECHANGE_MODES;
        break;
        
      /* Parameter modes: advance parameter and possibly read it in */    
    
      case 'l':
        if (dir) {
          /* +l uses a parameter, but -l does not.
           * If there is no parameter, don't set the mode.
           * I guess we should moan too in that case, but 
           * they might be even nastier to us if we do ;) */
          if (arg<cargc) {
            cp->limit=strtol(cargv[arg++],NULL,10);
            SetLimit(cp);
          }      
        } else {
          ClearLimit(cp);
          cp->limit=0;
        }
	changes |= MODECHANGE_MODES;
        break;
        
      case 'k':
        if (dir) {
          /* +k uses a parameter in both directions */
          if (arg<cargc) {
            freesstring(cp->key); /* It's probably NULL, but be safe */
            cp->key=getsstring(cargv[arg++],KEYLEN);
            SetKey(cp);
          }
        } else {
          freesstring(cp->key);
          cp->key=NULL;
          ClearKey(cp);
          arg++; /* Eat the arg without looking at it, even if it's not there */
        }
	changes |= MODECHANGE_MODES;
        break;
        
      /* Op/Voice */
      
      case 'o':
      case 'v': 
        if (arg<cargc) {
          if((lp=getnumerichandlefromchanhash(cp->users,numerictolong(cargv[arg++],5)))==NULL) {
            /* They're not on the channel; MODE crossed with part/kill/kick/blah */
            Error("channel",ERR_DEBUG,"Mode change for user %s not on channel %s",cargv[arg-1],cp->index->name->content);
          } else { 
            if ((target=getnickbynumeric(*lp))==NULL) {
              /* This really is a fuckup, we found them on the channel but there isn't a user with that numeric */
              /* This means there's a serious bug in the nick/channel tracking code */
              Error("channel",ERR_ERROR,"Mode change for user %s on channel %s who doesn't exist",cargv[arg-1],cp->index->name->content);
            } else { /* Do the mode change whilst admiring the beautiful code layout */
              harg[2]=target;
              if (*modestr=='o') { if (dir) { *lp |= CUMODE_OP;     hooknum=HOOK_CHANNEL_OPPED;    } else 
                                            { *lp &= ~CUMODE_OP;    hooknum=HOOK_CHANNEL_DEOPPED;  } }
                            else { if (dir) { *lp |= CUMODE_VOICE;  hooknum=HOOK_CHANNEL_VOICED;   } else 
                                            { *lp &= ~CUMODE_VOICE; hooknum=HOOK_CHANNEL_DEVOICED; } } 
              triggerhook(hooknum,harg);
            }
          }
        }
	changes |= MODECHANGE_USERS;
        break;
        
      case 'b':
        if (arg<cargc) {
          if (dir) {
            setban(cp,cargv[arg++]);
            triggerhook(HOOK_CHANNEL_BANSET,harg);
          } else {
            clearban(cp,cargv[arg++],0);
            triggerhook(HOOK_CHANNEL_BANCLEAR,harg);
          }
        }
	changes |= MODECHANGE_BANS;
        break;
        
      default:
        Error("channel",ERR_DEBUG,"Unknown mode char '%c' %s on %s",*modestr,dir?"set":"cleared",cp->index->name->content);
        break;
    }
  }

  harg[2]=(void *)((long)changes);
  triggerhook(HOOK_CHANNEL_MODECHANGE,(void *)harg);  
  return CMD_OK;
}
コード例 #11
0
ファイル: channelhandlers.c プロジェクト: quakenet/newserv
int handleburstmsg(void *source, int cargc, char **cargv) {
  channel *cp;
  time_t timestamp;
  int wipeout=0;
  int i;
  int arg=0;
  char *charp;
  int newlimit;
  int waslimit,waskeyed;
  char *nextnum;
  unsigned long currentmode;
  int isnewchan;
  
  /* (we don't see the first 2 params in cargc) */
  /* AK B #+lod+ 1017561154 +tnk eits ATJWu:o,AiW1a,Ag3lV,AiWnl,AE6oI :%*[email protected] */
  
  if (cargc<2) {
    Error("channel",ERR_WARNING,"Burst message with only %d parameters",cargc);
    return CMD_OK;
  }
  
  timestamp=strtol(cargv[1],NULL,10);
  
  if ((cp=findchannel(cargv[0]))==NULL) {
    /* We don't have this channel already */
    cp=createchannel(cargv[0]);
    cp->timestamp=timestamp;
    isnewchan=1;
  } else {
    isnewchan=0;
    if (timestamp<cp->timestamp) {
      /* The incoming timestamp is older.  Erase all our current channel modes, and the topic. */
      cp->timestamp=timestamp;
      freesstring(cp->topic);
      cp->topic=NULL;
      cp->topictime=0;
      freesstring(cp->key);
      cp->key=NULL;
      cp->limit=0;
      cp->flags=0;
      clearallbans(cp);
      /* Remove all +v, +o we currently have */
      for(i=0;i<cp->users->hashsize;i++) {
        if (cp->users->content[i]!=nouser) {
          cp->users->content[i]&=CU_NUMERICMASK;
        }
      }
    } else if (timestamp>cp->timestamp) {
      /* The incoming timestamp is greater.  Ignore any incoming modes they may happen to set */
      wipeout=1;
    }
  }

  /* OK, dealt with the name and timestamp. 
   * Loop over the remaining args */
  for (arg=2;arg<cargc;arg++) {
    if (cargv[arg][0]=='+') {
      /* Channel modes */
      if (wipeout) {
        /* We ignore the modes, but we need to see if they include +l or +k 
         * so that we can ignore their corresponding values */
        for (charp=cargv[arg];*charp;charp++) {
          if (*charp=='k' || *charp=='l') {
            arg++;
          }
        }
      } else {
        /* Clear off the limit and key flags before calling setflags so we can see if the burst tried to set them */
        /* If the burst doesn't set them, we restore them afterwards */
        waslimit=IsLimit(cp); ClearLimit(cp);
        waskeyed=IsKey(cp);   ClearKey(cp);
        /* We can then use the flag function for these modes */
        setflags(&(cp->flags),CHANMODE_ALL,cargv[arg],cmodeflags,REJECT_NONE);
        /* Pick up the limit and key, if they were set.  Note that the limit comes first */
        if (IsLimit(cp)) { /* A limit was SET by the burst */
          if (++arg>=cargc) {
            /* Ran out of args -- damn ircd is spewing out crap again */
            Error("channel",ERR_WARNING,"Burst +l with no argument");
            break; /* "break" being the operative word */
          } else {
            newlimit=strtol(cargv[arg],NULL,10);
          }
          if (cp->limit>0 && waslimit) {
            /* We had a limit before -- we now have the lowest one of the two */
            if (newlimit<cp->limit) {
              cp->limit=newlimit;
            }
          } else {
            /* No limit before -- we just have the new one */
            cp->limit=newlimit;
          }
        } else if (waslimit) {
          SetLimit(cp); /* We had a limit before, but the burst didn't set one.  Restore flag. */
        }
        
        if (IsKey(cp)) { /* A key was SET by the burst */
          if (++arg>=cargc) {
            /* Ran out of args -- oopsie! */
            Error("channel",ERR_WARNING,"Burst +k with no argument");
            break;
          }
          if (waskeyed) {
            /* We had a key before -- alphabetically first wins */
            if (ircd_strcmp(cargv[arg],cp->key->content)<0) {
              /* Replace our key */
              freesstring(cp->key);
              cp->key=getsstring(cargv[arg],KEYLEN);
            }
          } else {
            /* No key before -- just the new one */
            cp->key=getsstring(cargv[arg],KEYLEN);
          }
        } else if (waskeyed) {
          SetKey(cp); /* We had a key before, but the burst didn't set one.  Restore flag. */
        }
      }       
    } else if (cargv[arg][0]=='%') {
      /* We have one or more bans here */
      nextnum=cargv[arg]+1;
      while (*nextnum) {
        /* Split off the next ban */
        for (charp=nextnum;*charp;charp++) {
          if (*charp==' ') {
            *charp='\0';
            charp++;
            break;
          }
        }        
        setban(cp,nextnum);
        nextnum=charp;
      }
    } else {
      /* List of numerics */
      nextnum=charp=cargv[arg];
      currentmode=0;
      while (*nextnum!='\0') {
        /* Step over the next numeric */
        for (i=0;i<5;i++) {
          if (*charp++=='\0')
            break;
        }
        if (i<5) {
          break;
        }
        if (*charp==',') {
          *charp='\0';
          charp++;
        } else if (*charp==':') {
          *charp='\0';
          charp++;
          currentmode=0;
          /* Look for modes */
          for (;*charp;charp++) {
            if (*charp=='v') {
              currentmode|=CUMODE_VOICE;
            } else if (*charp=='o') {
              currentmode|=CUMODE_OP;
            } else if (*charp==',') {
              charp++;
              break;
            }
          }
          /* If we're ignore incoming modes, zap it to zero again */
          if (wipeout) {
            currentmode=0;
          }
        }
        /* OK.  At this point charp points to either '\0' if we're at the end,
         * or the start of the next numeric otherwise.  nextnum points at a valid numeric
         * we need to add, and currentmode reflects the correct mode */
        addnicktochannel(cp,(numerictolong(nextnum,5)|currentmode));
        nextnum=charp;
      }
    }
  }
  if (cp->users->totalusers==0) {
    /* Oh dear, the channel is now empty.  Perhaps one of those 
     * charming empty burst messages you get sometimes.. */
    if (!isnewchan) {
      /* I really don't think this can happen, can it..? */
      /* Only send the LOSTCHANNEL if the channel existed before */
      triggerhook(HOOK_CHANNEL_LOSTCHANNEL,cp);
    }
    delchannel(cp);
  } else {
    /* If this is a new channel, we do the NEWCHANNEL hook also */
    if (isnewchan) {
      triggerhook(HOOK_CHANNEL_NEWCHANNEL,cp);
    }
    /* Just one hook to say "something happened to this channel" */
    triggerhook(HOOK_CHANNEL_BURST,cp);       
  }
   
  return CMD_OK;     
}