예제 #1
0
void CHistory::AddHistory(int id,TCHAR* Buffer,TCHAR* time, int flag)
{
	std::map<int, std::vector<MsgData*> > ::iterator itBeg;
	std::map<int, std::vector<MsgData*> > ::iterator itEnd;
	if(flag)
	{
		itBeg = NewLoghis.begin();
		itEnd = NewLoghis.end();
	}
	else
	{
		itBeg = LocalLoghis.begin();
		itEnd = LocalLoghis.end();
	}

	if(Buffer)
	{
		while(itBeg != itEnd)
		{
			if(id == itBeg->first)
			{
				MsgData *stBuffer = new MsgData(); 
				stBuffer->buffer = new TCHAR[wcslen(Buffer)+1];
				if(stBuffer->buffer != NULL)
					wcscpy(stBuffer->buffer,Buffer);
				wcscpy(stBuffer->time,time);
				itBeg->second.push_back(stBuffer);
				//新的消息记录复制到LocalLoghis
				if(flag)
					AddHistory(id,Buffer,time,0);
				break;
			}
			itBeg++;
		}
		if(itBeg == itEnd)
		{
			std::vector<MsgData*>tmp;
			//TCHAR* szBuffer = new TCHAR[wcslen(Buffer)+1];
			MsgData *stBuffer = new MsgData(); 
			stBuffer->buffer = new TCHAR[wcslen(Buffer)+1];
			wcscpy(stBuffer->time,time);
			//swprintf(stBuffer.time,L"%04d:%02d:%02d",time.wYear,time.wHour,time.wMinute);
			if(stBuffer->buffer != NULL)
				wcscpy(stBuffer->buffer,Buffer);
			tmp.push_back(stBuffer);
			if(flag)
			{
				NewLoghis.insert(make_pair(id,tmp));
				//新的消息记录复制到LocalLoghis
				AddHistory(id,Buffer,time,0);
			}
			else
			{
				LocalLoghis.insert(make_pair(id,tmp));
			}
		}
	}
}
예제 #2
0
void Ide::GotoPos(String path, int line)
{
	LLOG("GotoPos " << path << ':' << line);
	if(path.GetCount()) {
		AddHistory();
		if(IsDesignerFile(path))
		DoEditAsText(path);
		EditFile(path);
	}
	editor.SetCursor(editor.GetPos(line - 1));
	editor.TopCursor(4);
	editor.SetFocus();
	AddHistory();
}
예제 #3
0
파일: save.c 프로젝트: jawb/isola
void Load(char * name){
	FILE * f;
	int r,t[7],w,h,i;
	f = fopen(name,"rb");
	
	fread(&game.numplayers,sizeof(int),1,f);
	fread(&game.width,sizeof(int),1,f);
	fread(&game.height,sizeof(int),1,f);
	NewGame();
	fread(&game.turn,sizeof(int),1,f);
	fread(&game.step,sizeof(int),1,f);

	w = game.width;
	h = game.height;
	for(i=0;i<w;i++)
	{
		fread(game.board[i],sizeof(Cell),h,f);	
	}
	
	fread(game.players,sizeof(Player),game.numplayers,f);

	r = fread(t,sizeof(int),7,f);
	while(r == 7){
		AddHistory();
		game.history->pid = t[0];
		game.history->fx = t[1];
		game.history->fy = t[2];
		game.history->tx = t[3];
		game.history->ty = t[4];
		game.history->dx = t[5];
		game.history->dy = t[6];
		r = fread(t,sizeof(int),7,f);
	}
	fclose(f);
}
예제 #4
0
void CHistory::LoadHistoryFromLocal(const char* path)
{
	std::ifstream file;
	file.open(path,std::ios::in);
	if(file == NULL)
		return;
	string line, id, buffer,time;
	while (getline(file, line)) 
	{
		std::stringstream liness(line);
		getline(liness, id,'\t');
		getline(liness, buffer,'\t');
		getline(liness, time);
		int iLength = MultiByteToWideChar(CP_ACP, 0, buffer.c_str(), strlen(buffer.c_str())+1, NULL, 0);  
		TCHAR* Tbuffer = new TCHAR[iLength];
		MultiByteToWideChar(CP_ACP, 0, buffer.c_str(), strlen(buffer.c_str())+1,Tbuffer,iLength);   

		iLength = MultiByteToWideChar(CP_ACP, 0, time.c_str(), strlen(time.c_str())+1, NULL, 0); 
		TCHAR* time_buffer = new TCHAR[iLength];
		MultiByteToWideChar(CP_ACP, 0, time.c_str(), strlen(time.c_str())+1,time_buffer,iLength);  

		AddHistory(atoi(id.c_str()),Tbuffer,time_buffer,0);
		delete []Tbuffer;
		delete []time_buffer;
		Tbuffer = NULL;
		time_buffer = NULL;
	}
	file.close();
}
예제 #5
0
파일: WndMain.c 프로젝트: arcanelab/WinGHCi
VOID LoadFile(LPTSTR File)
{
	TCHAR Command[2*MAX_PATH], fName[MAX_PATH], fExt[MAX_PATH], Buffer[MAX_PATH];

	//Move the current directory
	SetWorkingDirToFileLoc(File);

	

	// get file name and extension
	_tsplitpath (File, NULL, NULL, fName, fExt);
	wsprintf(Buffer,TEXT("%s%s"),fName,fExt);

	wsprintf(Command, TEXT(":load %s"), ExpandFileName(Buffer));
	AddMruFile(File);


	RtfWindowSetCommand(TEXT(":load "));
	StartOfInput += 6;	
	WinGHCiHyperlink(ExpandFileName(Buffer));
	StartOfInput += StringLen(ExpandFileName(Buffer));
	
	RtfWindowStartNextOutput();
	AddHistory(Command);
	SendToGHCiStdinLn(Command);

	Running = TRUE;
	EnableButtons();
	
	PrintGHCiOutputIfAvailable(hChildStderrRd, ErrorColor);
	PrintGHCiOutput(hChildStdoutRd, ForegroundColor);
	
	Running = FALSE;
	EnableButtons();
}
예제 #6
0
파일: std2.c 프로젝트: MattWherry/yorick
void Y_add_record(int nArgs)
{
  IOStream *file;
  HistoryInfo *history;
  Dimension *dims;
  double *time= 0;
  long *ncyc= 0, *address= 0;
  long nRecs= 0;
  int flags;
  Symbol *stack= sp-nArgs+1;
  if (nArgs<1 || nArgs>4)
    YError("add_record requires between one and four arguments");

  file= YGetFile(stack++);
  if (stack<=sp) {
    time= YGet_D(stack++, 1, &dims);
    if (time) nRecs= TotalNumber(dims);
    if (stack<=sp) {
      ncyc= YGet_L(stack++, 1, &dims);
      if (ncyc) {
        if (nRecs) {
          if (nRecs!=TotalNumber(dims))
            YError("inconsistent number of ncycs in add_record");
        } else {
          nRecs= TotalNumber(dims);
        }
      }
      if (stack<=sp) {
        address= YGet_L(stack++, 1, &dims);
        if (address) {
          if (nRecs) {
            if (nRecs!=TotalNumber(dims))
              YError("inconsistent number of addresses in add_record");
          } else {
            nRecs= TotalNumber(dims);
          }
        }
      }
    }
  }

  /* if this file has no history, add one */
  history= file->history;
  if (!history) history= AddHistory(file, 0L);

  /* if no records were specified, current record becomes none */
  if (!nRecs) history->recNumber= -1;

  /* add the specified records */
  flags= (time? 1 : 0)|(ncyc? 2 : 0);
  while (nRecs--) {
    AddRecord(history, flags, time? time[0]:0.0, ncyc? ncyc[0]:0L,
              (address && address[0]>=0)? address[0]:-1L);
    if (time) time++;
    if (ncyc) ncyc++;
    if (address) address++;
  }
  if (history->nRecords>0) JumpRecord(history, history->nRecords-1);
}
예제 #7
0
std::string Console::ShowCommands()
{
	AddHistory( "Showing all commands:" );
	StrList cmd_list = Settings::Get().GetSettings();
	for( StrList::iterator it = cmd_list.begin(); it != cmd_list.end(); ++it )
	{
		PushHistory( "* " + *it );
	}
	return "";
}
예제 #8
0
void ExitEmPingRspPage(void)
{
	history_t currHistory;
   
    currHistory.scrnID = EM_GPRS_PING_MENUID;
	currHistory.entryFuncPtr = EmPingCheckParam;
	pfnUnicodeStrcpy((S8*)currHistory.inputBuffer, (S8*)L"");
	GetCategory6History (currHistory.guiBuffer);
	AddHistory (currHistory);
}
예제 #9
0
파일: SP.c 프로젝트: jprothwell/sc-fix
void Sp_Exit_Explain_Screen(void)
{
    history_t	h;
    U16 inputBufferSize;

    h.scrnID = SCR_SP_EXPLAIN;
    h.entryFuncPtr = Sp_Entry_Explain_Screen;
    Get_Expalin_Screen_Inputbuffer(h.inputBuffer);
    AddHistory( h );
}
예제 #10
0
/**************************************************************

	FUNCTION NAME		: ExitSECSETFDNListReload(void)
  	PURPOSE				: 
	INPUT PARAMETERS	: nil
	OUTPUT PARAMETERS	: nil
	RETURNS				: void
  	Author				: Vanita Jain
 

**************************************************************/
void ExitSECSETFDNListReload(void)
{
	history_t   Scr;
	S16 nHistory = 0;	
	DeleteScreenIfPresent(SCR_ID_SECSET_FDN_LIST);
	Scr.scrnID = SCR_ID_SECSET_FDN_LIST;
	Scr.entryFuncPtr = EntryFdlList;
	pfnUnicodeStrcpy((S8*)Scr.inputBuffer, (S8*)&nHistory);
	GetCategoryHistory(Scr.guiBuffer);
	AddHistory(Scr);
}
예제 #11
0
std::string Console::ShowCommandsValues()
{
	AddHistory( "Showing all commands with values:" );
	StrMap cmd_map = Settings::Get().GetSettingsValues();
	for( StrMap::iterator it = cmd_map.begin(); it != cmd_map.end(); ++it )
	{
		if( !it->second.empty() ) {
			PushHistory( "* " + it->first + ' ' + it->second );
		}
	}
	return "";
}
예제 #12
0
void Ide::OpenLog()
{
	String p = GetLogPath();
	String path = NormalizePath(p);
	if(!designer && path == editfile) {
		History(-1);
		return;
	}
	AddHistory();
	if(FileExists(p))
		EditFile(p);
}
예제 #13
0
/*****************************************************************************
 * FUNCTION
 *  ExitScrCMErrMsg
 * DESCRIPTION
 *  Exit handler for the error pop up screen
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void ExitScrCMErrMsg(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    MMI_TRACE(MMI_TRACE_G5_CM, MMI_CM_FUNC_ExitScrCMErrMsg);

    if (GetErrorToneFlag() > 0)
    {
        stopRequestedTone(GetErrorToneFlag());
        SetErrorToneFlag(0);
    }
    StopTimer(CM_NOTIFYDURATION_TIMER);

    if (cm_p->redial_info.RedialState == TRUE)
    {
        /* in redial process */
        if (cm_p->redial_info.ErrRedialScreen == TRUE)
        {
            /* error msg got interrupted */
            history Scr1009;
            S16 nHistory = 0;

            MMI_TRACE(MMI_TRACE_G5_CM, MMI_CM_INFO_ExitScrCMErrMsgRedial);

            Scr1009.scrnID = CM_SCR_RDL_TIME;
            Scr1009.entryFuncPtr = EntryScrShowUserTimeToRedial;
            mmi_ucs2cpy((S8*) Scr1009.inputBuffer, (S8*) & nHistory);
            GetCategoryHistory(Scr1009.guiBuffer);
            AddHistory(Scr1009);
            cm_p->redial_info.ErrRedialScreen = FALSE;
            return;
        }
        else
        {
            /* error msg timer expire => going to Notify Redial Screen */
            return;
        }
    }

    /* SetRedialScreen(FALSE); */

    if (GetPOPUpFlag())
    {
        SetPOPUpFlag(FALSE);
        AdjustHistoryForCM();
    }
}
예제 #14
0
/**************************************************************

	FUNCTION NAME		: ExitInputMethodSelectScreen

  	PURPOSE				: Exit function for input method screen

	INPUT PARAMETERS	: nil

	OUTPUT PARAMETERS	: nil

	RETURNS				: void



**************************************************************/
void ExitInputMethodSelectScreen(void)
{
    history_t   Scr; /* Variable to hold the history data*/
    S16 nHistory = 0;
    /* getting details of the current screen (to be added to history) */
    Scr.scrnID = SCR_INPUT_METHOD_SELECTION;
    Scr.entryFuncPtr = EntryScrPreferedInputMethodList;
    pfnUnicodeStrcpy((S8*)Scr.inputBuffer, ( S8*)&nHistory);
    GetCategoryHistory(Scr.guiBuffer);
    /* add the screen to history */
    AddHistory(Scr);
    return;
}
예제 #15
0
/** Get next input line with readline. Lines terminated with a backslash
  * will be concatenated. Comments will be ignored.
  */
int ReadLine::GetInput() {
  input_.Clear();
  char* line = readline("> ");
  if (line == 0) return 1; // EOF
  bool moreInput = input_.AddInput( line );
  while ( moreInput ) {
    free( line );
    line = readline("");
    moreInput = input_.AddInput( line );
  }
  // Add line to history
  if (!input_.Empty()) AddHistory(input_.str());
  if (line != 0) free( line );
  return 0;
}
예제 #16
0
파일: DlgMain.c 프로젝트: chrisdone/hugs
void FireCommand(LPCSTR Command)
{
    RtfWindowSetCommand(Command);
    RtfWindowStartOutput();
    AddHistory(Command);

    Running = TRUE;
    EnableButtons();

    stringInput((LPSTR) Command);
    input(BREAK);
    IORemapBegin();
    if (doCommand())
	SendMessage(hThisWindow, WM_CLOSE, 0, 0);

    longjmp(catch_error, 1);
}
예제 #17
0
파일: WndMain.c 프로젝트: arcanelab/WinGHCi
VOID FireCommandAux(LPCTSTR Command, BOOL WaitForResponse, BOOL startThread, BOOL StopStdoutPrinterThread, BOOL WantPreprocess, FireCommandThreadArgs *pArgs) 
{

	#define MAXLEN    (3*1024)

	TCHAR NewCommand[MAXLEN];

	if(StopStdoutPrinterThread)
		//stop StdoutPrinterThread
		SignalObjectAndWait( hSigSuspendStdoutPrinterThread
			                ,hSigStdoutPrinterThreadSuspended, INFINITE, FALSE);


	RtfWindowSetCommand(Command);
	RtfWindowStartNextOutput();
	AddHistory(Command);

	if(WantPreprocess) {
		PreprocessCommand(Command, NewCommand);
		SendToGHCiStdinLn(NewCommand);
	}
	else
		SendToGHCiStdinLn(Command);


	if(WaitForResponse) {
		Running = TRUE;
		EnableButtons();
		
		PrintGHCiOutput(hChildStdoutRd, ForegroundColor);
		
		Running = FALSE;
		EnableButtons();

	}

	// resume StdoutPrinterThread
	if(StopStdoutPrinterThread)
		SetEvent(hSigResumeStdoutPrinterThread);

	if(startThread) {
		// free arguments
		free((LPTSTR)Command);
		free(pArgs);
	}
}
예제 #18
0
BOOL RtfNotify(HWND hDlg, NMHDR* nmhdr)
{
    static BOOL FindFirst = TRUE;
#define BUFF_LEN 2048
    static TCHAR FindWhat[BUFF_LEN];

    if (nmhdr->code == EN_PROTECTED && !PuttingChar) {
        //block
        ENPROTECTED* enp = (ENPROTECTED*) nmhdr;
        CHARRANGE cr;
        INT TextLen = RtfWindowTextLength();
        BOOL Reset = FALSE, Disallow = FALSE;


        // just let it go ahead anyway
        if (enp->msg == WM_COPY)
            return FALSE;

        // they hit backspace
        if (enp->wParam == VK_BACK) {
            if ((DWORD) enp->chrg.cpMin < StartOfInput ||
                    ((DWORD) enp->chrg.cpMin == StartOfInput &&
                     enp->chrg.cpMin == enp->chrg.cpMax)) {
                Reset = TRUE;
                Disallow = TRUE;
            }
        } else if ((DWORD) enp->chrg.cpMin < StartOfInput) {
            Reset = TRUE;
            Disallow = (enp->wParam == VK_DELETE);
        }

        if (Reset) {
            cr.cpMin = TextLen;
            cr.cpMax = cr.cpMin;
            SendMessage(hWndRtf, EM_EXSETSEL, 0, (LPARAM) &cr);
        }

        // we don't want to paste rich text, as that makes it look weird
        // so send only plain text paste commands
        if ((enp->msg == WM_PASTE) && !Disallow) {
            LPTSTR Buffer = NULL;
            Disallow = TRUE;
#if defined _UNICODE
#define CLIP_FORMAT  CF_UNICODETEXT
#else
#define CLIP_FORMAT  CF_TEXT
#endif
            if (IsClipboardFormatAvailable(CLIP_FORMAT) &&
                    OpenClipboard(hWndMain)) {
                HGLOBAL hGlb;
                LPTSTR str;

                if ((hGlb = GetClipboardData(CLIP_FORMAT)) != NULL &&
                        (str = GlobalLock(hGlb)) != NULL) {
                    Buffer = StringDup(str);
                    GlobalUnlock(hGlb);
                }
                CloseClipboard();
            }

            if (Buffer != NULL) {
                // strip trailing new line characters
                INT i;
                for (i = StringLen(Buffer)-1;
                        i >= 0 && (Buffer[i] == TEXT('\r') || Buffer[i] == TEXT('\n'));
                        i--)
                    Buffer[i] = 0;

#if defined _UNICODE
                {
                    SETTEXTEX stt;

                    stt.codepage = CP_UNICODE;
                    stt.flags = ST_SELECTION;
                    SendMessage(hWndRtf,EM_SETTEXTEX,(WPARAM)&stt,(LPARAM)Buffer);
                }
#else
                SendMessage(hWndRtf, EM_REPLACESEL, FALSE, (LPARAM)Buffer);
#endif


                free(Buffer);
            }
        }

        return (Disallow ? TRUE : FALSE);
    } else if (nmhdr->code == EN_LINK) {
        // should really fire on up
        // but that screws up the cursor position

        ENLINK* enl = (ENLINK*) nmhdr;
        if (enl->msg == WM_LBUTTONDOWN) {
            TEXTRANGE tr;
            TCHAR Buffer[1000];
            tr.lpstrText = Buffer;
            tr.chrg.cpMin = enl->chrg.cpMin;
            tr.chrg.cpMax = enl->chrg.cpMax;

            SendMessage(hWndRtf, EM_GETTEXTRANGE, 0, (LPARAM) &tr);
            ExecuteFile(Buffer);

            return TRUE;
        }
    } else if (nmhdr->code == EN_MSGFILTER) {
        MSGFILTER* mf = (MSGFILTER*) nmhdr;
#if 0
        //if (mf->msg == WM_CHAR && Running) {
        if (mf->msg == WM_CHAR && 0) {
            WinGHCiReceiveC((TCHAR)mf->wParam == TEXT('\r') ? TEXT('\n') : mf->wParam);
            SetWindowLong(hDlg, DWL_MSGRESULT, 1);
            return FALSE;
        } //else if (Running && mf->msg == WM_KEYDOWN) {
        else if (0) {
            SHORT n = GetKeyState(VK_CONTROL);
            BOOL Control = (n & (1 << 16));
            if(((CHAR)(mf->wParam) ==(CHAR)TEXT('C')) && Control)
                AbortExecution();
            else
                SetWindowLong(hDlg, DWL_MSGRESULT, 1);
            return FALSE;
        } //else if (mf->msg == WM_KEYDOWN && !Running) {
        else
#endif


            if (mf->msg == WM_CHAR) {

                if (mf->wParam == VK_TAB) {

                    INT pos;

                    if(FindFirst) {
                        RtfWindowGetCommand(FindWhat,BUFF_LEN);
                        pos = FindFirstHistory(FindWhat);
                        FindFirst = FALSE;
                    } else
                        pos = FindNextHistory();

                    if(pos>=0)
                        RtfWindowSetCommand(GoToHistory(pos));
                    else
                        MessageBeep((UINT)-1);

                    return TRUE;

                } else {
                    // any other key resets search
                    FindFirst = TRUE;

                    if (mf->wParam == VK_ESCAPE) {

                        //Clear current command
                        RtfWindowSetCommand(TEXT(""));
                        // Go to last item in history
                        AddHistory(TEXT(""));
                        return TRUE;
                    } else {
                        return FALSE;
                    }
                }


            } else if (mf->msg == WM_KEYDOWN) {
                BOOL History = (mf->wParam == VK_UP || mf->wParam == VK_DOWN);
                SHORT n = GetKeyState(VK_CONTROL);
                BOOL Control = (n & (1 << 16));

                if(((CHAR)(mf->wParam) ==(CHAR)TEXT('C')) && Control) {
                    if(RtfWindowCanCutCopy() && DROPEFFECT_COPY)
                        RtfWindowClipboard(WM_COPY);
                    else
                        AbortExecution();
                } else if (History && (mf->lParam & (1 << 24))) {
                    CHARRANGE cr;
                    SendMessage(hWndRtf, EM_EXGETSEL, 0, (LPARAM) &cr);
                    if ((DWORD) cr.cpMin >= StartOfInput) {
                        RtfWindowRelativeHistory(mf->wParam == VK_UP ? -1 : +1);
                        return TRUE;
                    }
                } else if (mf->wParam == VK_RETURN) {
#define BUFF_LEN 2048
                    TCHAR Buffer[BUFF_LEN];


                    RtfWindowGetCommand(Buffer,BUFF_LEN);

                    if(Running) {
                        if(!(mf->lParam & (1<<30))) //avoid repetition
                            FireCommandExt(Buffer,FALSE,TRUE,FALSE,FALSE);
                    }
                    else
                        //if(!(mf->lParam & (1<<30)))
                        FireAsyncCommand(Buffer);
                    return TRUE;
                } else if (mf->wParam == VK_HOME) {
                    CHARRANGE cr;
                    SendMessage(hWndRtf, EM_EXGETSEL, 0, (LPARAM) &cr);
                    if ((DWORD) cr.cpMin >= StartOfInput) {
                        SHORT n = GetKeyState(VK_SHIFT);
                        BOOL Shift = (n & (1 << 16));

                        cr.cpMin = StartOfInput;
                        cr.cpMax = (Shift ? cr.cpMax : StartOfInput);
                        SendMessage(hWndRtf, EM_EXSETSEL, 0, (LPARAM) &cr);
                        return TRUE;
                    }
                }
            }
    } else if (nmhdr->code == EN_SELCHANGE) {
        EnableButtons();
        return FALSE;
    }

    return FALSE;
}
예제 #19
0
void Console::HearSetting( std::string str )
{
	if( str.size() > 0 ) {
		AddHistory( str );
	}
}
예제 #20
0
void Console::PushCmd( std::string str )
{
	AddHistory( str );
}
예제 #21
0
파일: shell.c 프로젝트: GYGit/reactos
void
CommandShell(void)
{
	int tUsed, bUsed;
	ArgvInfo ai;
	char prompt[64];
	char *lineRead;
#if defined(WIN32) || defined(_WINDOWS)
#else
	int sj;
#endif
	time_t cmdStart, cmdStop;

	/* Execution may jump back to this point to restart the shell. */
#if defined(WIN32) || defined(_WINDOWS)

#elif defined(HAVE_SIGSETJMP)
	sj = sigsetjmp(gBackToTopJmp, 1);
#else	/* HAVE_SIGSETJMP */
	sj = setjmp(gBackToTopJmp);
#endif	/* HAVE_SIGSETJMP */

#if defined(WIN32) || defined(_WINDOWS)
#else
	if (sj != 0) {
		Trace(0, "Caught signal %d, back at top.\n", gGotSig);
		if (gGotSig == SIGALRM) {
			(void) printf("\nRemote host was not responding, closing down the session.");
			FTPShutdownHost(&gConn);
		} else{
			(void) printf("\nInterrupted.\n");
			if (gCancelCtrl != 0) {
				gCancelCtrl = 0;
				(void) printf("Closing down the current FTP session: ");
				FTPShutdownHost(&gConn);
				(void) sleep(1);
				(void) printf("done.\n");
			}
		}
	}

	gMayBackToTopJmp = 1;
#endif


	++gEventNumber;

	while (gDoneApplication == 0) {
#if defined(WIN32) || defined(_WINDOWS)
#else
		(void) NcSignal(SIGINT, BackToTop);
		(void) NcSignal(SIGPIPE, BackToTop);
		(void) NcSignal(SIGALRM, BackToTop);
#endif

		MakePrompt(prompt, sizeof(prompt));

		if (gConn.connected == 0) {
			SetXtermTitle("DEFAULT");
		} else {
			SetXtermTitle("%s - NcFTP", gConn.host);
		}

		lineRead = Readline(prompt);
		if (lineRead == NULL) {
			/* EOF, Control-D */
			(void) printf("\n");
			break;
		}
		Trace(0, "> %s\n", lineRead);
		AddHistory(lineRead);
		for (tUsed = 0;;) {
			(void) memset(&ai, 0, sizeof(ai));
			bUsed = MakeArgv(lineRead + tUsed, &ai.cargc, ai.cargv,
				(int) (sizeof(ai.cargv) / sizeof(char *)),
				ai.argbuf, sizeof(ai.argbuf),
				ai.noglobargv, 0);
			if (bUsed <= 0)
				break;
			tUsed += bUsed;
			if (ai.cargc == 0)
				continue;
			gRunningCommand = 1;
			(void) time(&cmdStart);
			if (DoCommand(&ai) < 0) {
				(void) time(&cmdStop);
				gRunningCommand = 0;
				break;
			}
			(void) time(&cmdStop);
			gRunningCommand = 0;
			if ((cmdStop - cmdStart) > kBeepAfterCmdTime) {
				/* Let the user know that a time-consuming
				 * operation has completed.
				 */
#if defined(WIN32) || defined(_WINDOWS)
				MessageBeep(MB_OK);
#else
				(void) fprintf(stderr, "\007");
#endif
			}
			++gEventNumber;
		}

		free(lineRead);
	}

	CloseHost();
	gMayBackToTopJmp = 0;
}	/* Shell */
예제 #22
0
static void UpdateList(openfile* p, bool_t Silent, int ListMode)
{
	streamdir DirItem;
	stream* Stream;
	int Result;
	openitem New;
	LVITEM Item;
	int No=0;
	int Pos=0;
	int State = LVIS_FOCUSED;
	int Len;
	const tchar_t* s;
	bool_t HasHost;

	if (!p->Multiple || (p->Flags & OPENFLAG_SINGLE))
		State |= LVIS_SELECTED; 

	Len = tcslen(p->Path);
	if (Len && (p->Path[Len-1] == '\\' || p->Path[Len-1] == '/'))
		p->Path[--Len] = 0;

	tcscpy_s(p->Base,TSIZEOF(p->Base),p->Path);
	s = p->Path[0] ? p->Path : T("\\");
	AddHistory(p,s);

	if (!ListMode)
		return;

	++p->InUpdate;
	WaitBegin();

	ShowWindow(p->WndList,SW_HIDE);
	ClearList(p);

	Item.mask=LVIF_TEXT|LVIF_IMAGE|LVIF_PARAM;
	Item.pszText=T("");
	Item.cchTextMax=1;
	Item.iSubItem=0;

	Stream = GetStream(p->Path,Silent);

	if (Stream)
	{
		s = GetMime(p->Path,NULL,0,&HasHost);
		if (*s)
		{
			Item.iImage=IMG_DIRUP;
			Item.iItem = No;
			Item.lParam = 0;

			ListView_InsertItem(p->WndList,&Item);
			ListView_SetItemText(p->WndList,No,0,T(".."));
			ListView_SetItemText(p->WndList,No,1,(tchar_t*)LangStr(OPENFILE_ID,OPENFILE_UP));
			++No;
		}

		Result = Stream->EnumDir(Stream,p->Path,p->Exts,*p->CurrentFileType!=-1,&DirItem);

		if (ListMode==2 && Result == ERR_FILE_NOT_FOUND && UpperPath(p->Path,p->Last,TSIZEOF(p->Last)))
		{
			WaitEnd();
			--p->InUpdate;

			p->LastClick = -1;
			UpdateList(p,Silent,ListMode);
			return;
		}

		if (Result == ERR_NOT_DIRECTORY && !Silent)
		{
			New.FileName[0] = 0;
			New.Ext[0] = 0;
			New.Image = IMG_FILE;
			New.Size = 0;

			Item.lParam = (DWORD)malloc(sizeof(openitem));
			if (Item.lParam)
			{
				p->Last[0] = 0;
				Pos = No;
				State = LVIS_SELECTED;
				PostMessage(p->Win.Wnd,WM_COMMAND,PLATFORM_OK,0);

				*(openitem*)Item.lParam = New;
				Item.iItem = No;
				Item.iImage = New.Image;
				ListView_InsertItem(p->WndList,&Item);
				++No;
			}
		}

		if (Result == ERR_NONE)
			Stream->Get(Stream,STREAM_BASE,p->Base,sizeof(p->Base));

		while (Result == ERR_NONE)
		{
			tchar_t Size[32];
			tchar_t Date[32];

			int i;
			for (i=0;i<No;++i)
			{
				LVITEM Item;
				Item.iItem=i;
				Item.iSubItem = 0;
				Item.mask=LVIF_PARAM;
				ListView_GetItem(p->WndList,&Item);

				if (Item.lParam && tcscmp(((openitem*)Item.lParam)->FileName,DirItem.FileName)==0)
					break;
			}

			if (i==No)
			{
				tchar_t DisplayName[MAXPATH];
				tcscpy_s(New.FileName,TSIZEOF(New.FileName),DirItem.FileName);
				New.DisplayName = DirItem.DisplayName[0] != 0;
				tcscpy_s(DisplayName,TSIZEOF(DisplayName),New.DisplayName?DirItem.DisplayName:DirItem.FileName);
				Size[0] = 0;
				Date[0] = 0;

				if (DirItem.Size < 0)
				{
					New.Image = IMG_DIR;
					New.Size = 0;
					New.Date = 0;
					tcscpy_s(New.Ext,TSIZEOF(New.Ext),LangStr(OPENFILE_ID,OPENFILE_DIR));
					tcscpy_s(New.Name,TSIZEOF(New.Name),DisplayName); //keep extension
				}
				else
				{
					switch (DirItem.Type)
					{
					case FTYPE_AUDIO: New.Image = IMG_AUDIO; break;
					case FTYPE_PLAYLIST: New.Image = IMG_PLAYLIST; break;
					case FTYPE_VIDEO: New.Image = IMG_VIDEO; break;
					default: New.Image = IMG_FILE; break;
					}
					New.Size = DirItem.Size;
					New.Date = DirItem.Date;

					SplitURL(DisplayName,NULL,0,NULL,0,New.Name,TSIZEOF(New.Name),New.Ext,TSIZEOF(New.Ext));
					tcsupr(New.Ext);
					if (New.Size >= 0)
					{
						if (New.Size < 10000*1024)
							stprintf_s(Size,TSIZEOF(Size),T("%d KB"),New.Size/1024);
						else
							stprintf_s(Size,TSIZEOF(Size),T("%d MB"),New.Size/(1024*1024));
					}
					if (New.Date >= 0)
					{
						FILETIME Time;
						SYSTEMTIME SysTime;
						Time.dwHighDateTime = (DWORD)(New.Date >> 32);
						Time.dwLowDateTime = (DWORD)(New.Date);
						if (FileTimeToSystemTime(&Time,&SysTime))
							GetDateFormat(LOCALE_USER_DEFAULT,DATE_SHORTDATE,&SysTime,NULL,Date,TSIZEOF(Date));
					}
				}
		
				Item.lParam = (DWORD)malloc(sizeof(openitem));
				if (Item.lParam)
				{
					*(openitem*)Item.lParam = New;
					Item.iItem = No;
					Item.iImage = New.Image;
					ListView_InsertItem(p->WndList,&Item);
					ListView_SetItemText(p->WndList,No,0,New.Name);
					ListView_SetItemText(p->WndList,No,1,New.Ext);
					ListView_SetItemText(p->WndList,No,2,Size);
					ListView_SetItemText(p->WndList,No,3,Date);
					++No;
				}
			}

			Result = Stream->EnumDir(Stream,NULL,NULL,0,&DirItem);
		}
예제 #23
0
BOOL CCLITerminal::CommandTask(CLISESSION *pSession, BOOL bComplete, BOOL bAddHistory)
{
	CLIHANDLER	*pHandler;
	char		szCommand[256] = "";
	int			nResult, nDepts=0, nCommand;
	int			i, nIndex, argc, nParam, nPos;

	// Make New Line
	WriteStream(pSession, "\n\r");
	pSession->szCommand[pSession->nCmdLength] = '\0';

	if (pSession->nMode == CLIMODE_USER)
	{
		nCommand = atoi(pSession->szCommand);
		pSession->nCmdLength = 0;
		pSession->szCommand[0] = '\0';
		
		switch(nCommand) {
		  case 1 :
			   FirmwareDownload(pSession);
			   WriteStream(pSession, "\n\r");
			   break;
		  case 2 : 
			   pSession->nMode = CLIMODE_COMMAND;
			   DisplayPrompt(pSession);
			   return TRUE; 
		}
		DisplaySplash(pSession);
		return TRUE;
	}

	// Check Login State
	if (!pSession->bLogined)
	{
		if (pSession->bNeedUser)
		{
			if (!CheckUser(pSession))
			{
				// Display Login Error Message
				WriteStream(pSession, "Invalid User.\r\n");
			}

			// Clear Command Buffer
			pSession->nCmdLength 	= 0;
			pSession->szCommand[0]	= '\0';
			DisplayPrompt(pSession);
			return TRUE;

		}
		else if (!CheckLogin(pSession))
		{
			// Clear Command Buffer
			pSession->nCmdLength 	= 0;
			pSession->szCommand[0]	= '\0';
			pSession->bNeedUser		= TRUE;

			// Display Login Error Message
			WriteStream(pSession, "Invalid account or password.\r\n\r\n");
			strcpy(pSession->szPrompt, m_pCLIService->m_szUserPrompt);
			pSession->nLoginRetry++;
			if (pSession->nLoginRetry >= 3)
			{
				if (pSession->nType == CLITYPE_SERIAL)
					sleep(3);
				return FALSE;
			}

			DisplayPrompt(pSession);
			return TRUE;
		}

		// Clear Command Buffer
		pSession->nCmdLength 	= 0;
		pSession->szCommand[0]	= '\0';

		// Callback Login
		if (m_pCLIService->m_pConstruct &&
			m_pCLIService->m_pConstruct->pfnOnLogin)
			m_pCLIService->m_pConstruct->pfnOnLogin(pSession);

		// Login Complete
		pSession->bLogined = TRUE;
		WriteStream(pSession, "\n\r");
		strcpy(pSession->szPrompt, m_pCLIService->m_szDefaultPrompt);
		DisplayPrompt(pSession);
		return TRUE;
	}

	if (pSession->nCmdLength > 0)
	{
		// Find Command
		nResult = CLIERR_OK;
		pSession->szCommand[pSession->nCmdLength] = '\0';

		if (pSession->szCommand[0] == '!')
		{
			if (strcmp(pSession->szCommand, "!!") == 0)
			{
				strcpy(pSession->szCommand, pSession->pszHistory[pSession->nHistoryCount-1]);
				pSession->nCmdLength = strlen(pSession->szCommand);
			}
			else
			{
				nIndex = atoi(&pSession->szCommand[1]);
				if ((nIndex > 0) && (nIndex <= pSession->nHistoryCount))
				{
					strcpy(pSession->szCommand, pSession->pszHistory[nIndex-1]);
					pSession->nCmdLength = strlen(pSession->szCommand);
				}
			}
		}

		pSession->pszArgString = strdup(pSession->szCommand);
		if (bAddHistory)
			AddHistory(pSession, pSession->szCommand);

		SpliteParameter(pSession);
		pHandler = FindCommandHandler(pSession, nDepts, szCommand);
		if (pHandler != NULL)
		{
			// Execute Command
			nParam = GetParamCount(pHandler);
			argc = pSession->argc - (nDepts + 1);
			for(i=0; i<argc; i++)
				pSession->argv[i] = pSession->argv[nDepts+i+1];

			// 파라메터의 갯수가 더 많은 경우를 막을때, add apn 명령 때문에 허용하도록 변경 2007/9/5
			// if ((nParam == argc) || (pHandler->pszParam && (argc >= GetMinParamCount(pHandler)) && (argc <= nParam)))

			if ((nParam == argc) || (pHandler->pszParam && (argc >= GetMinParamCount(pHandler))))
			{
				nPos = ValidateParameter(pSession, pHandler);
				if (nPos == -1)
				{
					pSession->nCmdLength 	= 0;
					pSession->szCommand[0]	= '\0';

					if (m_pCLIService->m_pConstruct &&
						m_pCLIService->m_pConstruct->pfnOnCommand)
						m_pCLIService->m_pConstruct->pfnOnCommand(pSession, argc, pSession->argv, pHandler);

					if (pHandler->nGroup >= pSession->nGroup)
					{
						if (m_pCLIService->m_bEnableLog && pHandler->bLogFlag)
							m_pCLIService->AddLog(pSession->szUser, pSession->szCommand);

						nResult = pHandler->pfnCommand(pSession, argc, pSession->argv, (void *)pHandler);
						WriteStream(pSession, "\xd\xa");
					}
					else
					{
						WriteStream(pSession, "Permission Denied.");					
						WriteStream(pSession, "\xd\xa");
					}
				}
				else
				{
					WriteStream(pSession, "Invalid parameter : '");					
					WriteStream(pSession, pSession->argv[nPos]);					
					WriteStream(pSession, "'\xd\xa");
					WriteStream(pSession, "\xd\xa");
				}
			}
			else
			{
				WriteStream(pSession, "usage: ");
				WriteStream(pSession, szCommand);
				DisplayWideParameter(pSession, pHandler);
				DisplayAllParameter(pSession, pHandler);
				WriteStream(pSession, "\xd\xa");
			}
		}

		if (pSession->pszArgString)
			FREE(pSession->pszArgString);
		pSession->pszArgString = NULL;

		if (nResult == CLIERR_ERROR)
			return FALSE;
	}

	// Clear Command Buffer
	pSession->nCmdLength 	= 0;
	pSession->szCommand[0]	= '\0';

	// Display Prompt
	DisplayPrompt(pSession);
	return TRUE;
}
예제 #24
0
파일: ide.cpp 프로젝트: kolyden/mirror
void Ide::EditorEdit()
{
	AddHistory();
	TouchFile(editfile);
}