예제 #1
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();
}
예제 #2
0
//---------------------------------------------------------------------------
void __fastcall TChatRoomForm::ProxyButtonClick(TObject *Sender)
{

  TDSJavaScriptProxyWriter *JSProxy;
  String OutputFile;

  OutputFile = ExpandFileName(ServerContainerForm->ChatRoomFileDispatcher->RootDirectory);

  JSProxy = new TDSJavaScriptProxyWriter();

  try
  {
    if (!DirectoryExists(OutputFile))
      ForceDirectories(OutputFile);

    if ( !AnsiEndsStr("\\", OutputFile) &&
      !AnsiEndsStr("/", OutputFile))
      OutputFile = OutputFile + Sysutils::PathDelim;

    //put the proxy file in a subdirectory of the root folder
    OutputFile = OutputFile + Sysutils::PathDelim + "webfiles" + Sysutils::PathDelim;

    //name the proxy file
    OutputFile = OutputFile + "JSProxy.js";

    ProxyConnection->Connected = true;
    JSProxy->UpdateJSProxyFile(ProxyConnection->DBXConnection, OutputFile);
    ProxyConnection->Close();
  }
  __finally
  {
    JSProxy->Free();
  }
}
예제 #3
0
CString FileSystem::GetExeFileName(const char* argv0)
{
	CString exename;
	exename.Reserve(1024 - 1);
	exename[1024 - 1] = '\0';

#ifdef WIN32
	GetModuleFileName(nullptr, exename, 1024);
#else
	// Linux
	int r = readlink("/proc/self/exe", exename, 1024 - 1);
	if (r > 0)
	{
		exename[r] = '\0';
		return exename;
	}
	// FreeBSD
	r = readlink("/proc/curproc/file", exename, 1024 - 1);
	if (r > 0)
	{
		exename[r] = '\0';
		return exename;
	}

	exename = ExpandFileName(argv0);
#endif

	return exename;
}
예제 #4
0
//---------------------------------------------------------------------------
void __fastcall SynchronizeDirectories(TTerminal * Terminal,
                                       TStrings * CommandParams,
                                       UnicodeString & LocalDirectory, UnicodeString & RemoteDirectory)
{
    if (CommandParams->Count >= 1)
    {
        LocalDirectory = CommandParams->Strings[0];
    }
    else if (!Terminal->SessionData->LocalDirectory.IsEmpty())
    {
        LocalDirectory = ExpandFileName(Terminal->SessionData->LocalDirectory);
    }
    else
    {
        LocalDirectory = WinConfiguration->ScpExplorer.LastLocalTargetDirectory;
    }

    if (CommandParams->Count >= 2)
    {
        RemoteDirectory = CommandParams->Strings[1];
    }
    else
    {
        RemoteDirectory = Terminal->CurrentDirectory;
    }
}
예제 #5
0
void MainOpenFile(HWND hWnd)
{
    CHAR FileName[MAX_PATH];
    CHAR Command[2048];

    if (ShowOpenFileDialog(hWnd, FileName)) {
	wsprintf(Command, ":load %s", ExpandFileName((String)FileName));
	FireCommand(Command);
    }
}
예제 #6
0
UnicodeString ExpandUNCFileName(const UnicodeString & FileName)
{
  UnicodeString Result = ExpandFileName(FileName);
  if ((Result.Length() >= 3) && (Result[1] == L':') && (::UpCase(Result[1]) >= 'A')
      && (::UpCase(Result[1]) <= 'Z'))
  {
    Result = GetUniversalName(Result);
  }
  return Result;
}
예제 #7
0
INIFile::INIFile( const std::string &name ) : fileLoaded( false ),   /*invalid( true ),*/ fileDirty( false )
{
   memset( &statbuf, 0, sizeof( struct stat ) );
   loadedFileName = ExpandFileName( trim( name ).c_str() ).c_str() ;
   if ( !FileExists( loadedFileName.c_str() ) )
   {
      ForceDirectories( ExtractFilePath( loadedFileName.c_str() ).c_str() );
      int fh = FileCreate( loadedFileName.c_str() );
      if ( fh != -1 )
         FileClose( fh );
   }
}
예제 #8
0
void MainDropFiles(HWND hWnd, HDROP hDrop)
{
    char Command[MAX_PATH], File[MAX_PATH];

    DragQueryFile(hDrop, 0, File, MAX_PATH);
    DragFinish(hDrop);

    //Move the current directory
    //Happens automatically if they use the open dialog
    //If they directly invoke :load then not necessary
    SetWorkingDir(File);

    wsprintf(Command, ":load %s", ExpandFileName((String)File));
    FireCommand(Command);
}
예제 #9
0
파일: WndMain.c 프로젝트: arcanelab/WinGHCi
VOID LoadFileExt(LPTSTR File, BOOL async)
{
	TCHAR Command[2*MAX_PATH], fName[MAX_PATH], fExt[MAX_PATH], Buffer[MAX_PATH];

	//Move the current directory
	SetWorkingDirToFileLoc(File,TRUE);
	
	AddMruFile(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));
	if(async)
		FireAsyncCommand(Command); //may be called from DragAndDrop
	else
		FireCommand(Command); 

}
예제 #10
0
파일: cdiroutl.cpp 프로젝트: stievie/Martis
void __fastcall TCDirectoryOutline::SetDirectory(const TFileName NewDir)
{
    if (NewDir.Length() > 0) {
        TFileName Path = ForceCase(ExpandFileName(NewDir));
        int n = Path.Length();

        if (n > 3 && Path.IsPathDelimiter(n))
            Path.SetLength(n - 1);

        if (Path != FDirectory) {
            FDirectory = Path;
            chdir(FDirectory.c_str());

            if (!SameLetter(Path[1], Drive))
                Drive = Path[1];
            else {
                WalkTree(Path);
                Change();
            }
        }
    }
}
예제 #11
0
//-----------------------------------------------------------------------------
// swTraceOpen()
//-----------------------------------------------------------------------------
// Lecture de la configuration en base de registre et ouverture du fichier trace
//-----------------------------------------------------------------------------
void swTraceOpen(void)
{
	HKEY hKey=NULL;
	int rc;
	char szValue[1024+1];
	DWORD dwValue,dwValueSize,dwValueType;
	int len;
	DWORD dw;

	rc=RegOpenKeyEx(HKEY_LOCAL_MACHINE,REGKEY_TRACE,0,KEY_READ,&hKey);
	if (rc==ERROR_SUCCESS)
	{
		dwValueType=REG_DWORD; dwValueSize=sizeof(dwValue);
		rc=RegQueryValueEx(hKey,REGVALUE_TRACE_LEVEL,NULL,&dwValueType,(LPBYTE)&dwValue,&dwValueSize);
		if (rc==ERROR_SUCCESS) giTraceLevel=dwValue; 

		dwValueType=REG_DWORD; dwValueSize=sizeof(dwValue);
		rc=RegQueryValueEx(hKey,REGVALUE_TRACE_FILESIZE,NULL,&dwValueType,(LPBYTE)&dwValue,&dwValueSize);
		if (rc==ERROR_SUCCESS) gdwTraceFileSize=dwValue*1000000; 

		dwValueType=REG_SZ; dwValueSize=sizeof(szValue);
		rc=RegQueryValueEx(hKey,REGVALUE_TRACE_FILENAME,NULL,&dwValueType,(LPBYTE)szValue,&dwValueSize);
		if (rc==ERROR_SUCCESS) ExpandFileName(szValue,gszTraceFileName,_MAX_PATH+1); // ISSUE#291
	}
	if (*gszTraceFileName==0) goto end; // pas de fichier spécifié, pas de traces
	if (giTraceLevel==0) goto end; // niveau trace 0 : pas de trace
	
	// ouverture du fichier (fermé uniquement sur appel de swTraceClose)
	ghfTrace=CreateFile(gszTraceFileName,GENERIC_READ|GENERIC_WRITE,FILE_SHARE_READ,NULL,OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
	if (ghfTrace==INVALID_HANDLE_VALUE) goto end;
	// se positionne à la fin du fichier
	SetFilePointer(ghfTrace,0,0,FILE_END);
	// entete
	len=wsprintf(gszTraceBuf,"=================== TRACES INITIALISEES : level=%d version=%s beta=%s ===================\r\n",giTraceLevel,gcszCurrentVersion,gcszCurrentBeta);
	WriteFile(ghfTrace,gszTraceBuf,len,&dw,NULL);
end:
	if (hKey!=NULL) RegCloseKey(hKey);
}
예제 #12
0
//---------------------------------------------------------------------------
void __fastcall Download(TTerminal * Terminal, const UnicodeString FileName,
                         bool UseDefaults)
{
    UnicodeString TargetDirectory;
    TGUICopyParamType CopyParam = GUIConfiguration->DefaultCopyParam;
    TStrings * FileList = NULL;

    try
    {
        FileList = new TStringList();
        TRemoteFile * File = Terminal->Files->FindFile(FileName);
        if (File == NULL)
        {
            throw Exception(FMTLOAD(FILE_NOT_EXISTS, (FileName)));
        }
        FileList->AddObject(FileName, File);
        UnicodeString LocalDirectory = ExpandFileName(Terminal->SessionData->LocalDirectory);
        if (LocalDirectory.IsEmpty())
        {
            LocalDirectory = GetPersonalFolder();
        }
        TargetDirectory = IncludeTrailingBackslash(LocalDirectory);

        int Options = coDisableQueue;
        int CopyParamAttrs = Terminal->UsableCopyParamAttrs(0).Download;
        if (UseDefaults ||
                DoCopyDialog(false, false, FileList, TargetDirectory, &CopyParam,
                             Options, CopyParamAttrs, NULL))
        {
            Terminal->CopyToLocal(FileList, TargetDirectory, &CopyParam, 0);
        }
    }
    __finally
    {
        delete FileList;
    }
}
예제 #13
0
파일: WndMain.c 프로젝트: arcanelab/WinGHCi
VOID AddFileFromFileDialog(HWND hWnd)
{
	TCHAR FileName[MAX_PATH], RelPath[MAX_PATH], CurrentWorkingDir[MAX_PATH];
	TCHAR Command[2*MAX_PATH];

    GetCurrentDirectory(MAX_PATH,CurrentWorkingDir);

	if (ShowOpenFileDialog(hWnd, FileName)) {
		AddMruFile(FileName);
		

		PathRelativePathTo(RelPath,
                       CurrentWorkingDir,
                       FILE_ATTRIBUTE_DIRECTORY,
                       FileName,
                       FILE_ATTRIBUTE_NORMAL);


		wsprintf(Command, TEXT(":add %s"), ExpandFileName(RelPath));
		FireCommand(Command);
	}

    SetCurrentDirectory(CurrentWorkingDir);
}
예제 #14
0
//--------------------------------------------------------
//         INCLUDE directive (ck)
// Inserts specified source file into current file and assembles
// for (each line of new file) {
//   assemble this line
// }
int include(int size, char *label, char *fileName, int *errorPtr)
{
  char incLine[256], capLine[256];
  char *src, *dst;
  int error, i;
  int tempFP;                          // temporary File Pointer
  bool comment;                         // true when line is comment
  int value;
  bool backRef;
  FILE *incFile;
  FILE *tmpInFile;                      // save current file
  char quote;
  int lineNumInc;                       // line number for include file
  int lineNumSave;
  char fileNameSave[256];

  if (size) {                                   // if .size code specified
    NEWERROR(*errorPtr, INV_SIZE_CODE);         // error, invalid size code
    return NORMAL;
  }

  if (!*fileName) {
    NEWERROR(*errorPtr, FILE_ERROR);         // error, invalid syntax
    return NORMAL;
  }

  // Define the label attached to this include directive, if any
  if (*label)
    define(label, loc, pass2, true, errorPtr);

  strcap(capLine, fileName);

  // strip quotes from filename
  src = capLine;
  dst = capLine;
  src = skipSpace(src);         // skip leading spaces in filename

  if (*src == '\"' || *src == '\'') {       // *ck 12-9-2005
    quote = *src;
    src++;
  } else
    quote = '\0';
  while (*src && (*src != ' ' || quote) ) {
    if (*src == quote)
      break;
    else
      *dst++ = *src++;
  }

  // strip whitespace from end of filename
  dst--;
  while (dst > capLine && isspace(*dst))
    dst--;
  dst++;
  *dst = '\0';

  if (pass2 && listFlag) {   // if include directive should be listed
    listLine(line);
  }

  try {
    incFile = fopen(capLine, "r");     // attempt to open include file
    if (!incFile) {                    // if error opening file
      NEWERROR(*errorPtr, FILE_ERROR);     // error, invalid syntax
      return SEVERE;
    }
    tmpInFile = inFile;                 // save current input file
    inFile = incFile;                   // make include file input file
    strcpy(fileNameSave,includeFile);   // save current include file
    strcpy(includeFile,capLine);        // save new include file
    lineNumSave = lineNum;              // save current line number

    // check to see if the included file is already open
    AnsiString includeFileStr(includeFile);
    for(int i = Main->MDIChildCount-1; i >= 0; i--) {
      TextStuff = (TTextStuff*)Main->MDIChildren[i];
      //if(TextStuff->Project.CurrentFile == includeFileStr) { // if file already open
      if(ExpandFileName(TextStuff->Project.CurrentFile).AnsiCompareIC(ExpandFileName(includeFileStr)) == 0) {
        TextStuff->Messages->Height = 7;
        TextStuff->Messages->Items->Clear();
        TextStuff->Messages->Enabled = false;
      }
    }

    // assemble each line of the include file
    // until END directive or EOF
    includeNestLevel++;                 // count nest level of include directive
    lineNum = 1;
    while(!endFlag && fgets(line, 256, inFile)) {
      error = OK;
      skipList = false;
      continuation = false;
      printCond = false;           // true to print condition on listing line
      if(line[0] != '*' && line[1] != '~')      // don't assemble font info

        assemble(line, &error);
        lineNum++;
    }
    fclose(inFile);
    inFile = tmpInFile;                 // restore previous input file
    strcpy(includeFile,fileNameSave);   // restore previous include file
    lineNum = lineNumSave;              // restore line number

    includeNestLevel--;

    if (pass2 && listFlag) {
      skipList = true;      // don't list INCLUDE statement again
      listLine("-------------------- end include --------------------\n");
    }

  }
  catch( ... ) {
    sprintf(buffer, "ERROR: An exception occurred in routine 'include'. \n");
    printError(NULL, EXCEPTION, 0);
    return NULL;
  }
  return NORMAL;
}
예제 #15
0
파일: ERROR.CPP 프로젝트: fduhia/Easy68k
int printError(FILE *outFile, int errorCode, int lineNum)
{
  if (errorCode == OK)          // if no errors detected
    return NORMAL;
  // if there are only warnings and warnings are disabled
  if (errorCode < MINOR && errorCode > WARNING && WARflag == false)
    return NORMAL;

  if (lineNumL68 >= 0)
    sprintf(numBuf, "Line %d ", lineNumL68);
  else
    numBuf[0] = '\0';

  // ---------- display warning messages ----------
  switch (errorCode) {
    case NUMBER_TOO_BIG:
      sprintf(buffer, "WARNING: Numeric constant exceeds 32 bits\n");
      break;
    case ASCII_TOO_BIG:
      sprintf(buffer, "WARNING: ASCII constant exceeds 4 characters\n");
      break;
    case INCOMPLETE:
      sprintf(buffer, "WARNING: Evaluation of expression could not be completed\n");
      break;
    case FORCING_SHORT:
      sprintf(buffer, "WARNING: Forcing SHORT addressing disables range checking of extension word\n");
      break;
    case ODD_ADDRESS:
      sprintf(buffer, "WARNING: Origin value is odd (Location counter set to next highest address)\n");
      break;
    case END_MISSING:
      sprintf(buffer, "WARNING: END directive missing, starting address not set\n");
      break;
    case ADDRESS_MISSING:
      sprintf(buffer, "WARNING: Address expected\n");
      break;
    case THEN_EXPECTED:
      sprintf(buffer, "WARNING: THEN expected\n");
      break;
    case DO_EXPECTED:
      sprintf(buffer, "WARNING: DO expected\n");
      break;
    case FORWARD_REF:
      sprintf(buffer, "WARNING: Forward reference may cause 'Symbol value differs...' error\n");
      break;
    case LABEL_TOO_LONG:
      sprintf(buffer, "WARNING: Label too long\n");
      break;
    default :
      if (errorCode < MINOR && errorCode > WARNING)
        sprintf(buffer, "WARNING: No message defined\n");
  }

  // ---------- display error messages ----------
  switch (errorCode) {
    case SYNTAX:
      sprintf(buffer, "ERROR: Invalid syntax\n");
      break;
    case UNDEFINED:
      sprintf(buffer, "ERROR: Undefined symbol\n");
      break;
    case DIV_BY_ZERO:
      sprintf(buffer, "ERROR: Division by zero attempted\n");
      break;
    case INV_OPCODE:
      sprintf(buffer, "ERROR: Invalid opcode\n");
      break;
    case INV_SIZE_CODE:
      sprintf(buffer, "ERROR: Invalid size code\n");
      break;
    case INV_ADDR_MODE:
      sprintf(buffer, "ERROR: Invalid addressing mode\n");
      break;
    case MULTIPLE_DEFS:
      sprintf(buffer, "ERROR: Symbol defined more than once\n");
      break;
    case NO_ENDM:
      sprintf(buffer, "ERROR: ENDM expected\n");
      break;
    case TOO_MANY_ARGS:
      sprintf(buffer, "ERROR: Too many arguments\n");
      break;
    case INVALID_ARG:
      sprintf(buffer, "ERROR: Invalid argument\n");
      break;
    case PHASE_ERROR:
      sprintf(buffer, "ERROR: Symbol value differs between first and second pass\n");
      break;
    case INV_QUICK_CONST:
      sprintf(buffer, "ERROR: Quick immediate data range must be 1 to 8\n");
      break;
    case INV_MOVE_QUICK_CONST:
      sprintf(buffer, "ERROR: Quick immediate data range exceeds 1 byte\n");
      break;
    case INV_VECTOR_NUM:
      sprintf(buffer, "ERROR: Invalid vector number\n");
      break;
    case INV_BRANCH_DISP:
      sprintf(buffer, "ERROR: Branch instruction displacement is out of range or invalid\n");
      break;
    case LABEL_REQUIRED:
      sprintf(buffer, "ERROR: Label required with this directive\n");
      break;
    case INV_DISP:
      sprintf(buffer, "ERROR: Displacement out of range\n");
      break;
    case INV_ABS_ADDRESS:
      sprintf(buffer, "ERROR: Absolute address exceeds 16 bits\n");
      break;
    case INV_8_BIT_DATA:
      sprintf(buffer, "ERROR: Immediate data exceeds 8 bits\n");
      break;
    case INV_16_BIT_DATA:
      sprintf(buffer, "ERROR: Immediate data exceeds 16 bits\n");
      break;
    case NOT_REG_LIST:
      sprintf(buffer, "ERROR: Symbol is not a register list symbol\n");
      break;
    case REG_LIST_SPEC:
      sprintf(buffer, "ERROR: Register list symbol used in an expression\n");
      break;
    case REG_LIST_UNDEF:
      sprintf(buffer, "ERROR: Register list symbol not previously defined\n");
      break;
    case INV_SHIFT_COUNT:
      sprintf(buffer, "ERROR: Invalid constant shift count\n");
      break;
    case INV_OPERATOR:
      sprintf(buffer, "ERROR: Invalid operator\n");
      break;
    case INV_FORWARD_REF:
      sprintf(buffer, "ERROR: Forward references not allowed with this directive\n");
      break;
    case INV_LENGTH:
      sprintf(buffer, "ERROR: Invalid block length\n");
      break;
    case COMMA_EXPECTED:
      sprintf(buffer, "ERROR: Comma expected\n");
      break;
    case FAIL_ERROR:    // user defined error
      //the error message has already been written to buffer
      break;
    case EXCEPTION:     // an exception occurred
      //the error message has already been written to buffer
      break;
    case FILE_ERROR:
      sprintf(buffer, "ERROR: Unable to access specified file\n");
      break;
    case MACRO_NEST:    // possible recursive macro call
      sprintf(buffer, "ERROR: Nested Macro calls are too many levels deep\n");
      break;
    case NO_IF:
      sprintf(buffer, "ERROR: No matching IF statement was found\n");
      break;
    case NO_WHILE:
      sprintf(buffer, "ERROR: No matching WHILE statement was found\n");
      break;
    case NO_REPEAT:
      sprintf(buffer, "ERROR: No matching REPEAT statement was found\n");
      break;
    case NO_DBLOOP:
      sprintf(buffer, "ERROR: No matching DBLOOP statement was found\n");
      break;
    case NO_FOR:
      sprintf(buffer, "ERROR: No matching FOR statement was found\n");
      break;
    case ENDI_EXPECTED:
      sprintf(buffer, "ERROR: IF without ENDI\n");
      break;
    case ENDW_EXPECTED:
      sprintf(buffer, "ERROR: WHILE without ENDW\n");
      break;
    case ENDF_EXPECTED:
      sprintf(buffer, "ERROR: FOR without ENDF\n");
      break;
    case REPEAT_EXPECTED:
      sprintf(buffer, "ERROR: UNTIL without REPEAT\n");
      break;
    case DBLOOP_EXPECTED:
      sprintf(buffer, "ERROR: UNLESS without DBLOOP\n");
      break;
    case LABEL_ERROR:
      sprintf(buffer, "ERROR: Label is not allowed\n");
      break;
    case BAD_BITFIELD:
      sprintf(buffer, "ERROR: Invalid bitfield\n");
      break;
    default :
      if (errorCode > MINOR)
        sprintf(buffer, "ERROR: No message defined\n");
  } // end switch

  if (outFile)
    listError(numBuf, buffer);  // add error to listing file

  // display error messages in edit window

  // if include file then display error in proper window
  if (includeFile[0]) {         // if not NULL
    bool openIncFile = true;    // open included file when true
    AnsiString incFile(includeFile);

    // check to see if file is already open
    for(int i = Main->MDIChildCount-1; i >= 0; i--) {
      TextStuff = (TTextStuff*)Main->MDIChildren[i];
      //if(TextStuff->Project.CurrentFile == ExpandFileName(incFile)) { // if file already open
      if(ExpandFileName(TextStuff->Project.CurrentFile).AnsiCompareIC(ExpandFileName(incFile)) == 0) {
        if (TextStuff->Project.Modified) {         // if it is modified
          if (includedFileError == false) {
            AnsiString asBuffer = "An Error occurred in the included file " +
                          ExtractFileName(incFile) +
                          ".\nThe file is currently open and has been modified." +
                          "\nThe line numbers of errors may not be correct.";
            ShowMessage(asBuffer);
            includedFileError = true;   // prevent multiple messages
          }
        }
        openIncFile = false;
        TextStuff->BringToFront();
        break;
      }
    }
    if (openIncFile)
      Main->OpenFile(incFile);
  }

  //Grab the active Child Form
  TTextStuff *Active = (TTextStuff*)Main->ActiveMDIChild; //grab active mdi child

  Active->Messages->Enabled = true; //need to allow user to click errors
  if (Active->Messages->Height < 87)
    Active->Messages->Height = 87;
  ListItem = Active->Messages->Items->Add();
  if (lineNum >= 0)
    sprintf(numBuf, "Line %d ", lineNum);
  else
    numBuf[0] = '\0';
  ListItem->Caption = lineNum;        // display line number of error
  buffer[strlen(buffer)-1]='\0';      // trim off '\n'
  ListItem->SubItems->Add(buffer);    // add error message to edit window
  ListItem->SubItems->Add(Active->Project.CurrentFile);       // display file

  return NORMAL;
}
예제 #16
0
파일: Sct.c 프로젝트: jljusten/efi-sct
EFI_STATUS
ParseCommandLine (
  IN EFI_HANDLE                   ImageHandle
  )
/*++

Routine Description:

  Parse the command line.

Arguments:

  ImageHandle   - Handle of image for shell execution.

Returns:

  EFI_SUCCESS   - Successfully.
  OTHERS        - Something failed.

--*/
{
  EFI_STATUS  Status;
  UINTN       Index;
  UINTN       Argc;
  CHAR16      **Argv;

  //
  // Get the parameters from the shell interface
  //
  Argc = SI->Argc;
  Argv = SI->Argv;

  //
  // Check all parameters
  //
  for (Index = 1; Index < Argc; Index ++) {
    if ((Argv[Index][0] != L'-') || (Argv[Index][2] != L'\0')) {
      return EFI_INVALID_PARAMETER;
    }

    switch (Argv[Index][1]) {
    case L'a':
    case L'A':
      //
      // Execute all test cases
      //
      if ((gFT->Operations & EFI_SCT_OPERATIONS_LOW_MASK) != 0) {
        return EFI_INVALID_PARAMETER;
      }
      gFT->Operations |= EFI_SCT_OPERATIONS_ALL;
      break;

    case L'c':
    case L'C':
      //
      // Continue execute the test cases
      //
      if ((gFT->Operations & EFI_SCT_OPERATIONS_LOW_MASK) != 0) {
        return EFI_INVALID_PARAMETER;
      }
      gFT->Operations |= EFI_SCT_OPERATIONS_CONTINUE;
      break;

    case L'g':
    case L'G':
      //
      // Generate test report
      //
      if (((gFT->Operations & EFI_SCT_OPERATIONS_REPORT) != 0   ) ||
          (Index + 1                                     >= Argc)) {
        return EFI_INVALID_PARAMETER;
      }
      gFT->Operations |= EFI_SCT_OPERATIONS_REPORT;

      //
      // The current working directory is "Report"
      //
      Status = SctChangeDirectory (ImageHandle, EFI_SCT_PATH_REPORT);
      if (EFI_ERROR (Status)) {
        return Status;
      }

      Status = ExpandFileName (
                 Argv[Index + 1],
                 &gFT->RepDevicePath,
                 &gFT->RepFileName
                 );
      if (EFI_ERROR (Status)) {
        return Status;
      }

      //
      // Restore the current working directory
      //
      Status = SctChangeDirectory (ImageHandle, L"..");
      if (EFI_ERROR (Status)) {
        return Status;
      }

      Index ++;
      break;

    case L'r':
    case L'R':
      //
      // Reset all test results
      //
      if ((gFT->Operations & EFI_SCT_OPERATIONS_RESET) != 0) {
        return EFI_INVALID_PARAMETER;
      }
      gFT->Operations |= EFI_SCT_OPERATIONS_RESET;
      break;

    case L's':
    case L'S':
      //
      // Execute the test cases in the test sequence file
      //
      if (((gFT->Operations & EFI_SCT_OPERATIONS_LOW_MASK) != 0   ) ||
          (Index + 1                                       >= Argc)) {
        return EFI_INVALID_PARAMETER;
      }
      gFT->Operations |= EFI_SCT_OPERATIONS_SEQUENCE;

      //
      // The current working directory is "Sequence"
      //
      Status = SctChangeDirectory (ImageHandle, EFI_SCT_PATH_SEQUENCE);
      if (EFI_ERROR (Status)) {
        return Status;
      }

      Status = ExpandFileName (
                 Argv[Index + 1],
                 &gFT->SeqDevicePath,
                 &gFT->SeqFileName
                 );
      if (EFI_ERROR (Status)) {
        return Status;
      }

      //
      // Restore the current working directory
      //
      Status = SctChangeDirectory (ImageHandle, L"..");
      if (EFI_ERROR (Status)) {
        return Status;
      }

      Index ++;
      break;

    case L'u':
    case L'U':
      //
      // Turn into user-friendly interface
      //
      if ((gFT->Operations & EFI_SCT_OPERATIONS_LOW_MASK) != 0) {
        return EFI_INVALID_PARAMETER;
      }
      gFT->Operations |= EFI_SCT_OPERATIONS_UI;
      break;

    case L'x':
    case L'X':
      //
      // Run in extended mode (just for internal users)
      //
      if ((gFT->Operations & EFI_SCT_OPERATIONS_EXTENDED) != 0) {
        return EFI_INVALID_PARAMETER;
      }
      gFT->Operations |= EFI_SCT_OPERATIONS_EXTENDED;
      break;

    case L'h':
    case L'H':
    case L'?':
      //
      // Print the help information. Skip the other parameters
      //
      gFT->Operations  = EFI_SCT_OPERATIONS_NONE;
      return EFI_SUCCESS;

    default:
      return EFI_INVALID_PARAMETER;
    }
  }

  //
  // Done
  //
  return EFI_SUCCESS;
}
예제 #17
0
void MainCommand(HWND hWnd, int ID)
{
    switch (ID) {
	case IDCANCEL: EndDialog(hWnd, 0); break;
	case ID_OPEN: MainOpenFile(hWnd); break;
	case ID_SCRIPTMAN: ShowScriptMan(); break;
	case ID_EXIT: FireCommand(":quit\n"); break;

	/* Load one of the last 10 open files */
	case ID_MRU+0: case ID_MRU+1: case ID_MRU+2: case ID_MRU+3:
	case ID_MRU+4: case ID_MRU+5: case ID_MRU+6: case ID_MRU+7:
	case ID_MRU+8: case ID_MRU+9:
	    {
		char Command[1000];
		wsprintf(Command, ":load %s", ExpandFileName(MruGetItem(ID-ID_MRU)));
		FireCommand(Command);
	    }
	    break;

	// EDIT MENU
	case ID_CUT: RtfWindowClipboard(WM_CUT); break;
	case ID_COPY: RtfWindowClipboard(WM_COPY); break;
	case ID_PASTE: RtfWindowClipboard(WM_PASTE); break;
	case ID_CLEARSCREEN: RtfWindowClear(); break;
	case ID_DELETE: RtfWindowDelete(); break;
	case ID_SELECTALL: RtfWindowSelectAll(); break;
	case ID_GOPREVIOUS: RtfWindowHistory(-1); break;
	case ID_GONEXT: RtfWindowHistory(+1); break;


	// ACTIONS MENU
	// Reload script files
	case ID_COMPILE: case ID_MAKE: FireCommand(":reload"); break;
	case ID_CLEARALL: FireCommand(":load"); break;
	case ID_GOEDIT: FireCommand(":edit"); break;

	/* Stop program execution */
	case ID_STOP:
	    MessageBeep(0xFFFFFFFF);
	    AbortExecution();
	    break;

	/* Evaluate main expression */
	case ID_RUN:
	    {
		char Buffer[1000];
		RtfWindowGetCommand(Buffer);
		if (Buffer[0] == '\0')
			FireCommand(":main");
		else
		    FireCommand(Buffer);
	    }
	    break;

	/* Set interpreter options using dialog box */
	case ID_SETOPTIONS:
	    if (ShowOptionsDialog(hWnd))
		RtfWindowUpdateFont();
	    break;


	// BROWSE MENU
	case ID_BROWSEHIERARCHY: DrawClassesHierarchy(); break;
	case ID_BROWSECLASSES: DoBrowseClasses(); break;
	case ID_BROWSENAMES: DoBrowseNames(); break;
	case ID_BROWSETYCONS: DoBrowseTycons(); break;

	// HELP MENU
	case ID_HELPCONTENTS: ExecuteFileDocs("hugs98.chm"); break;
	case ID_HELPCOMMANDS: FireCommand(":?\n"); break;
	case ID_LIBRARIES: ExecuteFile("http://www.haskell.org/ghc/docs/latest/html/libraries/index.html"); break;
	case ID_WWWHASKELL: ExecuteFile("http://haskell.org/"); break;
	case ID_WWWHUGS: ExecuteFile("http://haskell.org/hugs/"); break;
	case ID_ABOUT: ShowAboutDialog(hWnd); break;
    }
}