Example #1
0
status_t
WinampSkinThemesAddon::SPSkin(BString *to, bool preffile)
{
	if (preffile) {
		status_t err;
		BMessage settings;
		BPath SPSPath;
		
		if (find_directory(B_USER_SETTINGS_DIRECTORY, &SPSPath) < B_OK)
			return B_ERROR;
		BString leaf(SP_SETTINGS_NAME);
		BString user(getenv("USER"));
		user.RemoveFirst("USER="******"$USER", user.String());
		SPSPath.Append(leaf.String());
		PRINT(("SPP %s\n", SPSPath.Path()));
		BFile SPSettings(SPSPath.Path(), B_READ_ONLY);
		if (SPSettings.InitCheck() < B_OK)
			return SPSettings.InitCheck();
		if (settings.Unflatten(&SPSettings) < B_OK)
			return EIO;
		err = settings.FindString("skinname", to);
		StripPath(to);
		return err;
	}
	BMessenger msgr(SP_APP_SIG);
	BMessage msg('skin');
	BMessage reply;
	msgr.SendMessage(&msg, (BHandler *)NULL, 500000);
	if (reply.FindString("result", to) >= B_OK) {
		StripPath(to);
		return B_OK;
	}
	return B_ERROR;
}
Example #2
0
status_t
WinampSkinThemesAddon::CLSkin(BString *to, bool preffile)
{
	if (preffile) {
		BPath CLSPath;
		char buffer[B_FILE_NAME_LENGTH+1];
		
		if (!to)
			return EINVAL;
		buffer[B_FILE_NAME_LENGTH] = '\0';
		
		if (find_directory(B_USER_SETTINGS_DIRECTORY, &CLSPath) < B_OK)
			return B_ERROR;
		CLSPath.Append(CL_SETTINGS_NAME);
		BFile CLSettings(CLSPath.Path(), B_READ_ONLY);
		if (CLSettings.InitCheck() < B_OK)
			return CLSettings.InitCheck();
		ssize_t got = CLSettings.ReadAt(0x8LL, buffer, B_FILE_NAME_LENGTH);
		if (got < B_FILE_NAME_LENGTH)
			return EIO;
		*to = buffer;
		StripPath(to);
		return B_ERROR;
	}
	BMessenger msgr(CL_APP_SIG);
	BMessage msg('skin');
	BMessage reply;
	msgr.SendMessage(&msg, &reply, 500000, 500000);
	if (reply.FindString("result", to) >= B_OK) {
		StripPath(to);
		return B_OK;
	}
	return B_ERROR;
}
void AddMissionsToTree(char *path, GtkWidget *tree, int is_parent) {
	glob_t *search;
	unsigned int length;
	int count, max;
	char *file, *filename;
	GtkWidget *subtree, *item;

	// First we check for sub directories. stick them at the top
	// For some reason, glob(,,GLOB_ONLYDIR,) doesn't seem to only match directories,
	// so FindDirs() currently returns everything. Check the last char for a /
	// That will be the directory.

	search = FindDirs(path);
	max = search->gl_pathc - 1;	// search->gl_pathc is a uint. If there's no files, it's 0.
	for (count = 0; count <= max; count++) {
		file = search->gl_pathv[count];
		length = strlen(file);
		if (file[length-1] != SEPERATOR) { continue; }	// Verify it's a directory and not a file

		filename = strdup(file);
		filename = StripPath(filename);
		if (strcmp("CVS", filename) == 0) { continue; }	// Don't need to display this directory

		item = AddItem(tree, filename, "dir");

		subtree = gtk_tree_new();
		gtk_signal_connect(GTK_OBJECT(subtree), "select_child", GTK_SIGNAL_FUNC(cb_select_child), subtree);
		gtk_signal_connect(GTK_OBJECT(subtree), "unselect_child", GTK_SIGNAL_FUNC(cb_unselect_child), subtree);

		gtk_tree_set_selection_mode(GTK_TREE(subtree), GTK_SELECTION_SINGLE);
		gtk_tree_set_view_mode(GTK_TREE(subtree), GTK_TREE_VIEW_ITEM);
		gtk_tree_item_set_subtree(GTK_TREE_ITEM(item), subtree);		

		AddMissionsToTree(file, subtree, 0);

	}

	search = FindFiles(path, EXT_MISSION);
	max = search->gl_pathc - 1;
	for (count = 0; count <= max; count++) {
		file = search->gl_pathv[count];
		length = strlen(file);
		if (file[length-1] == SEPERATOR) { continue; }

		filename = strdup(file);
		filename = StripPath(filename);
		StripExtension(filename);

		AddItem(tree, filename, file);
	}
	return;
}
Example #4
0
QStandardItem *ResultsTree::EnsureFileItem(const QString &fullpath, const QString &file0, bool hide)
{
    QString name = StripPath(fullpath, false);
    // Since item has path with native separators we must use path with
    // native separators to find it.
    QStandardItem *item = FindFileItem(QDir::toNativeSeparators(name));

    if (item) {
        return item;
    }

    // Ensure shown path is with native separators
    name = QDir::toNativeSeparators(name);
    item = CreateNormalItem(name);
    item->setIcon(QIcon(":images/text-x-generic.png"));

    //Add user data to that item
    QMap<QString, QVariant> data;
    data["file"] = fullpath;
    data["file0"] = file0;
    item->setData(QVariant(data));
    mModel.appendRow(item);

    setRowHidden(mModel.rowCount() - 1, QModelIndex(), hide);

    return item;
}
Example #5
0
HRESULT GetAddInName(std::wstring& addInName)
{
	HRESULT hr;
	std::wstring header;
	std::wstring clrVersion;
	bool shadowCopyFiles;
	std::wstring createSandboxedAppDomainValue;

	hr = GetDnaHeader(false, header);	// Don't show errors here.
	if (!FAILED(hr))
	{
		hr = ParseDnaHeader(header, addInName, clrVersion, shadowCopyFiles, createSandboxedAppDomainValue); // No errors yet.
		if (FAILED(hr))
		{
			return E_FAIL;
		}
		if (addInName.empty())
		{
			std::wstring xllPath(GetAddInFullPath());
			StripPath(xllPath);
			RemoveExtension(xllPath);
			addInName = xllPath;
		}
	}
	return hr;
}
Example #6
0
// Pin calls this function every time a new rtn is executed
VOID Routine(RTN rtn, VOID *v)
{
    
    // Allocate a counter for this routine
    RTN_COUNT * rc = new RTN_COUNT;

    // The RTN goes away when the image is unloaded, so save it now
    // because we need it in the fini
    rc->_name = RTN_Name(rtn);
    rc->_image = StripPath(IMG_Name(SEC_Img(RTN_Sec(rtn))).c_str());
    rc->_address = RTN_Address(rtn);
    rc->_icount = 0;
    rc->_rtnCount = 0;

    // Add to list of routines
    rc->_next = RtnList;
    RtnList = rc;
            
    RTN_Open(rtn);
            
    // Insert a call at the entry point of a routine to increment the call count
    RTN_InsertCall(rtn, IPOINT_BEFORE, (AFUNPTR)docount, IARG_PTR, &(rc->_rtnCount), IARG_END);
    
    // For each instruction of the routine
    for (INS ins = RTN_InsHead(rtn); INS_Valid(ins); ins = INS_Next(ins))
    {
        // Insert a call to docount to increment the instruction counter for this rtn
        INS_InsertCall(ins, IPOINT_BEFORE, (AFUNPTR)docount, IARG_PTR, &(rc->_icount), IARG_END);
    }

    
    RTN_Close(rtn);
}
char *TDataAscii::MakeIndexFileName(char *name, char *type)
{
  char *fname = StripPath(name);
  int nameLen = strlen(Init::WorkDir()) + 1 + strlen(fname) + 1;
  char *fn = new char [nameLen];
  sprintf(fn, "%s/%s", Init::WorkDir(), fname);
  return fn;
}
Example #8
0
bool Texture::Load(const std::string& filename)
{
    unsigned int w = 0;
    unsigned int h = 0;
    unsigned char* data = 0;
    unsigned int bpp = 3; // bytes per pixel

#ifdef AMJU_USE_SDL_IMG

    SDL_Surface* surf = IMG_Load(filename.c_str());
    if (!surf)
    {
        ReportError("Failed to load texture " + filename);
        return false;
    }
    w = surf->w;
    h = surf->h;
    data = (unsigned char*)surf->pixels;
    bpp = surf->format->BytesPerPixel;

#else

    std::string ext = ToLower(GetFileExt(filename));
    if (ext == "bmp")
    {
        data = LoadDIBitmap(filename.c_str(), &w, &h);
    }
    else if (ext == "png")
    {
        data = LoadPng(filename.c_str(), &w, &h, &bpp);
        // TODO I think bmps are upside down, but the rest of the code compensates.. sigh
        FlipBmp(data, w, h, bpp);
    }

    if (!data)
    {
        ReportError("Failed to load texture " + filename);
        return false;
    }

#endif

    Create(data, w, h, bpp);

#ifdef AMJU_USE_SDL_IMAGE
    SDL_FreeSurface(surf);
#else
    delete [] data;
#endif

#ifdef _DEBUG
    m_name = StripPath(filename);
#endif

    return true;
}
bool LevelWorkerAddRoom::Save(File* pf)
{
  int numRooms = m_roomNames.size();
  pf->WriteInteger(numRooms);
  for (int i = 0; i < numRooms; i++)
  {
    pf->Write(StripPath(m_roomNames[i]));
  }
  return true;
}
Example #10
0
BOOL wbSysDlgSave(PWBOBJ pwboParent, LPCTSTR pszTitle, LPCTSTR pszFilter, LPCTSTR pszPath, LPTSTR pszFileName, LPCTSTR lpstrDefExt)
{
	OPENFILENAME ofn;
	BOOL bRet;
	TCHAR *pszCopy;

	if(!pszFileName)
		return FALSE;

	if(pszPath && *pszPath)
		pszCopy = MakeWinPath(_wcsdup(pszPath));
	else
		pszCopy = NULL;

	ofn.lStructSize = sizeof(OPENFILENAME);
	ofn.hwndOwner = pwboParent ? (HWND)pwboParent->hwnd : NULL;
	ofn.hInstance = NULL;
	ofn.lpstrFilter = pszFilter && *pszFilter ? pszFilter : TEXT("All files (*.*)\0*.*\0\0");
	ofn.lpstrCustomFilter = NULL;
	ofn.nMaxCustFilter = 0;
	ofn.nFilterIndex = 0;
	ofn.lpstrFile = StripPath(MakeWinPath(pszFileName));
	ofn.nMaxFile = MAX_PATH;
	ofn.lpstrFileTitle = NULL;
	ofn.nMaxFileTitle = MAX_PATH;
	ofn.lpstrInitialDir = pszCopy;
	ofn.lpstrTitle = (pszTitle && * pszTitle) ? pszTitle : NULL;
	ofn.Flags = OFN_HIDEREADONLY | OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT;
	ofn.nFileOffset = 0;
	ofn.nFileExtension = 0;

	// The lpstrDefExt member (below) does not seem to behave like described
	// in the Windows API documentation. If rather behaves like this:
	// If lpstrFilter is NULL, lpstrDefExt indeed sets the default extension.
	// If lpstrFilter is not NULL, however, the default extension will always
	// be set to the first extension contained in lpstrFilter (which is the
	// desired behavior in most cases), regardless of the contents of the buffer
	// pointed by lpstrDefExt. As expected, if lpstrDefExt is NULL, then a
	// default extension is not appended to the file name.

	ofn.lpstrDefExt = (lpstrDefExt && *lpstrDefExt) ? lpstrDefExt : NULL;

	ofn.lCustData = 0;
	ofn.lpfnHook = NULL;
	ofn.lpTemplateName = NULL;

	bRet = GetSaveFileName(&ofn);
	if(!bRet && pszFileName)
		*pszFileName = '\0';

	if(pszCopy)
		free(pszCopy);
	return bRet;
}
Example #11
0
/*******************************************************
 * print usage
 ******************************************************/
void PrintUsage(FILE * stream, char * progname)
{
    if(!(progname = StripPath(progname))) progname = DEFAULT_NAME;
    fprintf(stream,"\n"
"%s process dispatcher (version " VERSION "); usage:\n\n"
"  %s <dispatch file>\n"
" \n"
"  where <dispatch file> is list of process parameters \n\n",        
    progname,progname);

    exit(127);
}
Example #12
0
void ResultsTree::Clear(const QString &filename)
{
    const QString stripped = StripPath(filename, false);

    for (int i = 0; i < mModel.rowCount(); ++i) {
        const QStandardItem *item = mModel.item(i, 0);
        if (!item)
            continue;

        QVariantMap data = item->data().toMap();
        if (stripped == data["file"].toString() ||
            filename == data["file0"].toString()) {
            mModel.removeRow(i);
            break;
        }
    }
}
Example #13
0
BOOL IsRunningOnCluster()
{
	// Our check is to see if the current process is called Excel.exe.
	// Hopefully this doen't change soon.
	
	TCHAR hostPathName[MAX_PATH];
	DWORD count = GetModuleFileName(NULL, hostPathName, MAX_PATH);

	std::wstring hostPath = hostPathName;
	StripPath(hostPath);

	if (CompareNoCase(hostPath, L"EXCEL.EXE") == 0)
	{
		return false;
	}
	
	return true;
}
Example #14
0
void PrintUsage(char * pgmName)
{
    char * actualName;
   
    if (!(actualName = StripPath(pgmName))) actualName = DEFAULT_NAME;
   
    printf("\n"
           "  program: %s - trap and report process control signals\n\n"
           "    usage:\n\n"
           "      %s [seconds]\n\n"
           "      where [seconds] is the lifetime of the program - default = 20s.\n\n"
           "    the program sleeps for a second, reports process id and tick count\n"
           "    before sleeping again. any process control signals: SIGINT, SIGQUIT\n"
           "    SIGHUP, SIGTERM, SIGABRT, SIGCONT, SIGTSTP, are trapped and\n"
           "    reported before being actioned.\n\n",
           actualName, actualName );
    exit(127);
}
Example #15
0
int main(int argc, char *argv[] )
{
	GtkWidget *window, *vbox;
	char applName[256];

	// Initialisations
	gtk_init (&argc, &argv);
	StripPath (argv[0], applName);
	CheckMidiShare (applName);
	gRefNum = MidiOpen(applName);
	MidiSetRcvAlarm (gRefNum,rcv_alarm);
	MidiConnect(gRefNum,0,1);
	MidiConnect(0,gRefNum,1);

	// Window definition
	window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
	gtk_window_set_title(GTK_WINDOW(window), applName);
	gtk_container_set_border_width(GTK_CONTAINER(window), 10);

	vbox = gtk_vbox_new (FALSE, 10);
	
	// Add controllers
	add_time (vbox);
	add(vbox, gtk_hseparator_new());
	add_buttons (vbox);
	
	gtk_container_add(GTK_CONTAINER(window), vbox);	
	gtk_widget_show_all (window);
	
	gtk_signal_connect(GTK_OBJECT(gRun), "clicked", GTK_SIGNAL_FUNC(start_stop_action), NULL);
	gtk_signal_connect(GTK_OBJECT(gReset), "clicked", GTK_SIGNAL_FUNC(reset_action), NULL);

	// Connexion of signals	
	gtk_signal_connect(
			GTK_OBJECT(window), "destroy", 
			GTK_SIGNAL_FUNC(my_delete_action), NULL
	);
	
	gtk_main ();

	return(0);
}
Example #16
0
int main(int argc, char *argv[] )
{
	GtkWidget *window, *hbox;
	char applName[256];

	// Initialisations
	gtk_init (&argc, &argv);
	StripPath (argv[0], applName);
	
	CheckMidiShare (applName);
	gRefNum = MidiOpen(applName);

	// User interface construction
	window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
	gtk_window_set_title(GTK_WINDOW(window), applName);
	gtk_container_set_border_width(GTK_CONTAINER(window), 10);

	hbox = gtk_hbox_new (FALSE, 10);
	add(hbox, makelist(&gSrcList, "Sources ->", GTK_SELECTION_MULTIPLE, GTK_SIGNAL_FUNC(select_src), GTK_SIGNAL_FUNC(unselect_src)));
	add(hbox, makelist(&gAppList, "Applications", GTK_SELECTION_BROWSE, GTK_SIGNAL_FUNC(select_appl), NULL));
	add(hbox, makelist(&gDstList, "-> Destinations",GTK_SELECTION_MULTIPLE, GTK_SIGNAL_FUNC(select_dst), GTK_SIGNAL_FUNC(unselect_dst)));
	
	initLists();
	
	gtk_container_add(GTK_CONTAINER(window), hbox);	
	gtk_widget_show_all (window);
	
	// signal connexion
	
	gtk_signal_connect(
			GTK_OBJECT(window), "destroy", 
			GTK_SIGNAL_FUNC(my_delete_action), NULL
	);
	
	// MidiShare applAlarm initialisation
	MidiSetApplAlarm(gRefNum, MyApplAlarm);
	gtk_timeout_add( 100, check_update, NULL);

	gtk_main ();

	return(0);
}
Example #17
0
bool SolidComposite::Save(bool recursive)
{
  if (IsDirty())
  {
    File jf;
    // Write name, but strip off the path if any.
    if (!jf.OpenWrite(GetName()))
    {
      return false;
    }
    // Write number of components
    jf.WriteComment("// Number of components");
    int numComponents = m_children.size();
    jf.WriteInteger(numComponents);
    jf.WriteComment(File::SEPARATOR);

    // For each component, write the name and orientation.
    for (int i = 0; i < numComponents; i++)
    {
      SolidComponent* pComp = m_children[i].GetPtr();
      char buf[200];
      sprintf(buf, "// Component %d follows.", i);
      jf.WriteComment(buf);
      // Strip off any path info in name of composite.
      jf.Write(StripPath(pComp->GetName()));
      pComp->SaveOrientation(&jf);
      jf.WriteComment(File::SEPARATOR);
    }
  }

  if (recursive)
  {
    int numComponents = m_children.size();
    for (int i = 0; i < numComponents; i++)
    {
      SolidComponent* pComp = m_children[i].GetPtr();
      pComp->Save(true);
    }
  }

  return true;
}
Example #18
0
VOID Routine(RTN rtn, VOID *v)
{
    
  // Allocate a counter for this routine
  RTN_COUNT * rc = new RTN_COUNT;

  // The RTN goes away when the image is unloaded, so save it now
  // because we need it in the fini
  rc->_name = RTN_Name(rtn);
  rc->_image = StripPath(IMG_Name(SEC_Img(RTN_Sec(rtn))).c_str());
  rc->_address = RTN_Address(rtn);
  rc->_next = RtnList;
  RtnList = rc;



  if(!startSymbolAddress && rc->_name == start_symbol) {
    startSymbolAddress = rc->_address;
  }
  if(!stopSymbolAddress && rc->_name == stop_symbol) {
    stopSymbolAddress = rc->_address;
  }


    RTN_Open(rtn);
            
    if (rc->_address == startSymbolAddress || rc->_address == stopSymbolAddress) {
      if (rc->_address == startSymbolAddress) {
	RTN_InsertCall(rtn, IPOINT_BEFORE, (AFUNPTR)startRoutineEnter, IARG_FAST_ANALYSIS_CALL, IARG_PTR, reinterpret_cast<UINT64*>(rc), IARG_THREAD_ID,  IARG_END);
	LOG("Instrumented start symbol\n");
      } else {
	RTN_InsertCall(rtn, IPOINT_BEFORE, (AFUNPTR)stopRoutineEnter, IARG_FAST_ANALYSIS_CALL, IARG_PTR, reinterpret_cast<UINT64*>(rc), IARG_THREAD_ID, IARG_END);
	LOG("Instrumented stop symbol\n");
      }
    }else {
      RTN_InsertCall(rtn, IPOINT_BEFORE, (AFUNPTR)routineEnter, IARG_FAST_ANALYSIS_CALL, IARG_PTR, reinterpret_cast<UINT64*>(rc), IARG_THREAD_ID,  IARG_END);
    }

    RTN_InsertCall(rtn, IPOINT_AFTER, (AFUNPTR)routineExit, IARG_FAST_ANALYSIS_CALL, IARG_PTR, reinterpret_cast<UINT64*>(rc), IARG_THREAD_ID, IARG_END);
    
    RTN_Close(rtn);
}
Example #19
0
Resource* FontLoader(const std::string& fontName)
{
  // Font name is e.g. "cheri.font"
  // The ".font" is so the ResourceManager knows what loader to use - it doesn't
  //  have to be the file extension.
  // TODO Overload GetRes so you can specify the loader ?
  std::string fontFilename = GetFileNoExt(fontName) + ".txt";
  Font* font = new Font(StripPath(fontFilename));
  File file;
  if (!file.OpenRead(fontFilename))
  {
    Assert(0);
    return 0;
  }
  if (!font->Load(&file))
  {
    Assert(0);
    return 0;
  }
  return font;
}
Example #20
0
// Injects the dll specified by dllPath after creating the target process
int CInjector::InjectAuto(std::wstring dllPath, std::wstring processPath)
{
	STARTUPINFOW si;
	PROCESS_INFORMATION pi;

	ZeroMemory(&pi, sizeof(pi));
	ZeroMemory(&si, sizeof(si));

	si.cb = sizeof(si);

	try {
		std::wstring exeDirectory = StripFile(processPath);
		SetCurrentDirectoryW(exeDirectory.c_str());

		// Create the process
		if (!CreateProcessW(0,
			const_cast<LPWSTR>(processPath.c_str()),
			0,
			0,
			false,
			CREATE_SUSPENDED,
			0,
			0,
			&si,
			&pi)) throw std::exception("Could not create process");

		// Inject the dll by specific process Id
		std::wstring processName = StripPath(processPath);
		int bInjected = Inject(dllPath, processName, pi.dwProcessId);

		// Resume
		ResumeThread(pi.hThread);

		return bInjected;
	}
	catch (std::exception e) {
		TerminateProcess(pi.hProcess, 0);
		throw;
	}
}
Example #21
0
CString CPlaylistItem::GetLabel(int i)
{
	CString str;

	if(i == 0)
	{
		if(!m_label.IsEmpty()) str = m_label;
		else if(!m_fns.IsEmpty()) str = StripPath(m_fns.GetHead());
	}
	else if(i == 1)
	{
		if(m_fInvalid) return _T("Invalid");

		if(m_type == file)
		{
			REFERENCE_TIME rt = m_duration;

			if(rt > 0)
			{
				rt /= 10000000;
				int ss = int(rt%60);
				rt /= 60;
				int mm = int(rt%60);
				rt /= 60;
				int hh = int(rt);

				str.Format(_T("%02d:%02d:%02d"), hh, mm, ss);
			}
		}
		else if(m_type == device)
		{
			// TODO
		}

	}

	return str;
}
Example #22
0
//==============================
// BitmapFontLocal::Load
bool BitmapFontLocal::Load( char const * languagePackageName, char const * fontInfoFileName )
{
	OvrApkFile languagePackageFile( ovr_OpenOtherApplicationPackage( languagePackageName ) );
	if ( !FontInfo.Load( languagePackageFile, fontInfoFileName ) )
	{
		return false;
	}

	// strip any path from the image file name path and prepend the path from the .fnt file -- i.e. always
	// require them to be loaded from the same directory.
	String baseName = FontInfo.ImageFileName.GetFilename();
	LOG( "fontInfoFileName = %s", fontInfoFileName );
	LOG( "image baseName = %s", baseName.ToCStr() );
	
	char imagePath[512];
	StripFileName( fontInfoFileName, imagePath, sizeof( imagePath ) );
	LOG( "imagePath = %s", imagePath );
	
	char imageFileName[512];
	StripPath( fontInfoFileName, imageFileName, sizeof( imageFileName ) );
	LOG( "imageFileName = %s", imageFileName );
	
	AppendPath( imagePath, sizeof( imagePath ), baseName.ToCStr() );
	if ( !LoadImage( languagePackageFile, imagePath ) )
	{
		return false;
	}

    // create the shaders for font rendering if not already created
    if ( FontProgram.vertexShader == 0 || FontProgram.fragmentShader == 0 )
    {
        FontProgram = BuildProgram( FontSingleTextureVertexShaderSrc, SDFFontFragmentShaderSrc );//SingleTextureFragmentShaderSrc );
    }

	return true;
}
Example #23
0
void ShowMessage(int headerId, int bodyId, int footerId, HRESULT hr)
{
	if (IsRunningOnCluster())
	{
		// TODO: Consider what to do in cluster context?
		return;
	}

	HWND hwndExcel = FindCurrentExcelWindow();
	try
	{
		std::wstring  addInFullPath = GetAddInFullPath();
		std::wstring  addInFileName = addInFullPath;
		StripPath(addInFileName);

		std::wstring msgTitle = FormatString(LoadStringFromResource(hModuleCurrent, IDS_MSG_TITLE), addInFileName.c_str());

		std::wstring header = LoadStringFromResource(hModuleCurrent, headerId);
		std::wstring body = LoadStringFromResource(hModuleCurrent, bodyId);
		std::wstring footer = LoadStringFromResource(hModuleCurrent, footerId);

		std::wstring hresult = L"";
		if (hr != S_OK)
		{
			_com_error error(hr);
			hresult = FormatString(LoadStringFromResource(hModuleCurrent, IDS_MSG_HRESULT), error.ErrorMessage());
		}

		std::wstring msg = FormatString(LoadStringFromResource(hModuleCurrent, IDS_MSG_TEMPLATE), header.c_str(), body.c_str(), footer.c_str(), hresult.c_str(), addInFullPath.c_str());
		MessageBox(hwndExcel, msg.c_str(), msgTitle.c_str(), MB_ICONEXCLAMATION);
	}
	catch (...)
	{
		ShowMessageError(hwndExcel);
	}
}
Example #24
0
bool ResultsTree::AddErrorItem(const ErrorItem &item)
{
    if (item.files.isEmpty()) {
        return false;
    }

    QString realfile = StripPath(item.files[0], false);

    if (realfile.isEmpty()) {
        realfile = tr("Undefined file");
    }

    bool hide = !mShowSeverities.isShown(item.severity);
    //bool hide = !mShowTypes[SeverityToShowType(item.severity)];

    //If specified, filter on summary, message, filename, and id
    if (!hide && !mFilter.isEmpty()) {
        if (!item.summary.contains(mFilter, Qt::CaseInsensitive) &&
            !item.message.contains(mFilter, Qt::CaseInsensitive) &&
            !item.file.contains(mFilter, Qt::CaseInsensitive) &&
            !item.errorId.contains(mFilter, Qt::CaseInsensitive)) {
            hide = true;
        }
    }

    //if there is at least one error that is not hidden, we have a visible error
    if (!hide) {
        mVisibleErrors = true;
    }

    ErrorLine line;
    line.file = realfile;
    line.errorId = item.errorId;
    line.inconclusive = item.inconclusive;
    line.line = item.lines[0];
    line.summary = item.summary;
    line.message = item.message;
    line.severity = item.severity;
    //Create the base item for the error and ensure it has a proper
    //file item as a parent
    QStandardItem *stditem = AddBacktraceFiles(EnsureFileItem(item.files[0], item.file0, hide),
                             line,
                             hide,
                             SeverityToIcon(line.severity));

    if (!stditem)
        return false;

    //Add user data to that item
    QMap<QString, QVariant> data;
    data["hide"] = false;
    data["severity"]  = ShowTypes::SeverityToShowType(item.severity);
    data["summary"] = item.summary;
    data["message"]  = item.message;
    data["file"]  = item.files[0];
    data["line"]  = item.lines[0];
    data["id"]  = item.errorId;
    data["inconclusive"] = item.inconclusive;
    data["file0"] = item.file0;
    stditem->setData(QVariant(data));

    //Add backtrace files as children
    for (int i = 1; i < item.files.size(); i++) {
        line.file = StripPath(item.files[i], false);
        line.line = item.lines[i];
        QStandardItem *child_item;
        child_item = AddBacktraceFiles(stditem,
                                       line,
                                       hide,
                                       ":images/go-down.png");

        //Add user data to that item
        QMap<QString, QVariant> child_data;
        child_data["severity"]  = ShowTypes::SeverityToShowType(line.severity);
        child_data["summary"] = line.summary;
        child_data["message"]  = line.message;
        child_data["file"]  = item.files[i];
        child_data["line"]  = line.line;
        child_data["id"]  = line.errorId;
        child_data["inconclusive"] = line.inconclusive;
        child_item->setData(QVariant(child_data));
    }

    //TODO just hide/show current error and it's file
    //since this does a lot of unnecessary work
    if (!hide) {
        ShowFileItem(realfile);
    }
    return true;
}
Example #25
0
int main(int argc, const char *argv[]) {
  program_name = argv[0];
  flatbuffers::Parser parser;
  flatbuffers::GeneratorOptions opts;
  std::string output_path;
  const size_t num_generators = sizeof(generators) / sizeof(generators[0]);
  bool generator_enabled[num_generators] = { false };
  bool any_generator = false;
  std::vector<std::string> filenames;
  size_t binary_files_from = std::numeric_limits<size_t>::max();
  for (int i = 1; i < argc; i++) {
    const char *arg = argv[i];
    if (arg[0] == '-') {
      if (filenames.size() && arg[1] != '-')
        Error("invalid option location", arg, true);
      if (strlen(arg) != 2)
        Error("invalid commandline argument", arg, true);
      switch (arg[1]) {
        case 'o':
          if (++i >= argc) Error("missing path following", arg, true);
          output_path = argv[i];
          if (!(output_path.back() == flatbuffers::kPathSeparator ||
                output_path.back() == flatbuffers::kPosixPathSeparator)) {
            output_path += flatbuffers::kPathSeparator;
          }
          break;
        case 'S':
          opts.strict_json = true;
          break;
        case '-':  // Separator between text and binary input files.
          binary_files_from = filenames.size();
          break;
        default:
          for (size_t i = 0; i < num_generators; ++i) {
            if(!strcmp(arg+1, generators[i].extension)) {
              generator_enabled[i] = true;
              any_generator = true;
              goto found;
            }
          }
          Error("unknown commandline argument", arg, true);
          found:
          break;
      }
    } else {
      filenames.push_back(argv[i]);
    }
  }

  if (!filenames.size()) Error("missing input files", nullptr, true);

  if (!any_generator)
    Error("no options: no output files generated.",
          "specify one of -c -g -j -t -b etc.", true);

  // Now process the files:
  for (auto file_it = filenames.begin();
            file_it != filenames.end();
          ++file_it) {
      std::string contents;
      if (!flatbuffers::LoadFile(file_it->c_str(), true, &contents))
        Error("unable to load file", file_it->c_str());

      bool is_binary = static_cast<size_t>(file_it - filenames.begin()) >=
                       binary_files_from;
      if (is_binary) {
        parser.builder_.Clear();
        parser.builder_.PushBytes(
          reinterpret_cast<const uint8_t *>(contents.c_str()),
          contents.length());
      } else {
        if (!parser.Parse(contents.c_str()))
          Error(parser.error_.c_str());
      }

      std::string filebase = StripPath(StripExtension(*file_it));

      for (size_t i = 0; i < num_generators; ++i) {
        if (generator_enabled[i]) {
          if (!generators[i].generate(parser, output_path, filebase, opts)) {
            Error((std::string("Unable to generate ") +
                   generators[i].name +
                   " for " +
                   filebase).c_str());
          }
        }
      }

      // Since the Parser object retains definitions across files, we must
      // ensure we only output code for these once, in the file they are first
      // declared:
      for (auto it = parser.enums_.vec.begin();
               it != parser.enums_.vec.end(); ++it) {
        (*it)->generated = true;
      }
      for (auto it = parser.structs_.vec.begin();
               it != parser.structs_.vec.end(); ++it) {
        (*it)->generated = true;
      }
  }

  return 0;
}
Example #26
0
/*
 * FTSEnd - done with this filetypesource entry
 */
vi_rc FTSEnd( void )
{
    EditFlags.FileTypeSource = FALSE;
    return( ERR_NO_ERR );

} /* FTSEnd */

static ft_src *searchFT( const char *name )
{
    template_ll *template;
    ft_src      *fts;

    name = StripPath( name );
    if( name != NULL ) {
        for( fts = ftsHead; fts != NULL; fts = fts->next ) {
            for( template = fts->template_head; template != NULL; template = template->next ) {
                if( FileTemplateMatch( name, template->data ) ) {
                    return( fts );
                }
            }
        }
    }
    return( NULL );
}

/*
 * FTSSearchFTIndex - search if 'name' has a registered file type
 */
Example #27
0
int ComposeFileName (
  char *inName,			/* in: input filename */
  int forceDefault,		/* in: 0=keep input path and/or extension if */
				/*       available, otherwise use default(s) */
				/*     1=force usage of default */
				/*       path and extension */
  char *defaultPath,		/* in: default path */
				/*     or NULL */
  char *defaultExt,		/* in: default extension */
				/*     or NULL */
  char *fileName,		/* out: composed filename */
  unsigned int fileNameMaxLen)	/* in: fileName max length */
				/* returns: */
				/*  0=OK  1=result too long */
{
  char *name,*dot,*tmp;
  char pathChar;

  if (CLdebugLevel >= 1)
    printf("ComposeFileName: in=\"%s\"  forceDef=%d  path=\"%s\"  ext=\"%s\""
	   "  len=%d\n",
	   inName,forceDefault,
	   (defaultPath!=NULL)?defaultPath:"(NULL)",
	   (defaultExt!=NULL)?defaultExt:"(NULL)",
	   fileNameMaxLen);

  if (strcmp(inName,"-")==0) {
    if (fileNameMaxLen<2)
      return 1;
    strcpy(fileName,inName);
    return 0;
  }

  /* compose path */
  name = StripPath(inName);
  if (name==inName || forceDefault) {
    /* use default path */
    if (defaultPath==NULL || *defaultPath=='\0')
      *fileName = '\0';
    else
      if (strlen(defaultPath)+1 >= fileNameMaxLen)
	return 1;
      else {
	strcpy(fileName,defaultPath);
	tmp = fileName+strlen(fileName)-1;
	if (strchr(fileName,'/')!=NULL || strchr(inName,'/')!=NULL)
	  pathChar = '/';
	else
	  if (strchr(fileName,'\\')!=NULL || strchr(inName,'\\')!=NULL)
	    pathChar = '\\';
	  else
	    pathChar = '/';
	if (*tmp!=pathChar) {
	  /* append pathChar to default path */
	  *(++tmp) = pathChar;
	  *(++tmp) = '\0';
	}
      }
    if (strlen(fileName)+strlen(name) >= fileNameMaxLen)
      return 1;
    else
      strcat(fileName,name);
  }
  else {
    /* use input path */
    if (strlen(inName) >= fileNameMaxLen)
      return 1;
    else
      strcpy(fileName,inName);
  }

  /* compose extension */
  dot = strchr(StripPath(fileName),'.');
  if (dot!=NULL && forceDefault) {
    /* remove input extension */
    *dot = '\0';
    dot = NULL;
  }
  if (dot==NULL && defaultExt!=NULL && *defaultExt!='\0') {
    /* use default extension */
    if (strlen(fileName)+strlen(defaultExt)+1 >= fileNameMaxLen)
      return 1;
    else {
      if (strchr(defaultExt,'.') == NULL)
	/* insert '.' before extension */
	strcat(fileName,".");
      strcat(fileName,defaultExt);
    }
  }
  
  if (CLdebugLevel >= 1)
    printf("ComposeFileName: fileName=\"%s\"\n",fileName);

  return 0;
}
Example #28
0
int CmdLineEval (
  int argc,			/* in: num command line args */
  char *argv[],			/* in: command line args */
  CmdLinePara *paraList,	/* in: parameter info list */
				/*     or NULL */
  CmdLineSwitch *switchList,	/* in: switch info list */
				/*     or NULL */
  int setDefault,		/* in: 0 = leave switch used flags and args */
				/*         unchanged */
				/*     1 = init switch used flags and args */
				/*         with defaultValue */
  char **progNamePtr)		/* out: program name */
				/*      or NULL */
				/* returns: */
				/*  0=OK  1=help switch  2=error */
{
  char *progName;
  char *tmpProgName;
  int i;
  int minusFlag;
  char *minusChar;
  CmdLinePara *paraPtr;
  CmdLineSwitch *switchPtr;
  int tmpVarArgIdx[MAX_TOKEN_NUM];
  int count;  
  int *varArgIdx;

  /* extract program name from argv[0] if command line mode */
  if (progNamePtr != NULL) {
    progName = StripPath(argv[0]);
    if ((tmpProgName=strchr(progName,'.'))!=NULL)
      *tmpProgName = '\0';
    *progNamePtr = progName;
    CommonProgName(progName);
  }
  else	/* progNamePtr==NULL */
    progName = NULL;

  /* set minusFlag if switches are preceded by '-' */
  minusFlag = (progNamePtr!=NULL || paraList!=NULL);
  minusChar = (minusFlag) ? "-" : "";
    
  if (CLdebugLevel >= 1)
    printf("CmdLineEval: argc=%d  mode=%s  minusChar=\"%s\"\n",
	   argc,(progNamePtr!=NULL)?"cmd line":"token list",minusChar);

  if (setDefault) {
    /* reset switch used flags and evaluate default values */
    switchPtr = switchList;
    while (switchPtr != NULL && switchPtr->switchName != NULL) {
      if (switchPtr->argument != NULL) {
	if (switchPtr->usedFlag != NULL)
	  *((int*)switchPtr->usedFlag) = 0;
	if (switchPtr->format == NULL)
	  *((int*)switchPtr->argument) = 0;
	else
	  if (switchPtr->defaultValue != NULL) {
	    if (strcmp(switchPtr->format,"%s") == 0)
	      *((char**)switchPtr->argument) = switchPtr->defaultValue;
	    else
	      if (sscanf(switchPtr->defaultValue,switchPtr->format,
			 switchPtr->argument) != 1) {
		CommonWarning("CmdLineEval: "
			      "switch %s%s default argument format error",
			      minusChar,switchPtr->switchName);
		return 2;
	      }
	  }
      }
      switchPtr++;
    }
  }

  /* scan arguments  */
  i = (progNamePtr==NULL) ? 0 : 1;	/* skip program name */
					/* if command line mode */
  paraPtr = paraList;
  count = 0;

  while (i < argc) {
    if ((*argv[i] == '-' && *(argv[i]+1) != '\0') ||
	(minusFlag == 0 && *argv[i] != '\0')) {
      /* evaluate cmdline switch */
      switchPtr = switchList;
      while (switchPtr != NULL && switchPtr->switchName != NULL) {
	if (strcmp(argv[i]+minusFlag,switchPtr->switchName) == 0) {
	  /* switchList entry found */
	  if (switchPtr->argument == NULL) {
	    /* help switch found */
	    return 1;
	  }
	  if (switchPtr->format != NULL) {
	    /* read switch argument */
	    if (++i >= argc) {
	      CommonWarning("CmdLineEval: switch %s%s has no argument",
			    minusChar,switchPtr->switchName);
	      return 2;
	    }
	    else
	      if (strcmp(switchPtr->format,"%s") == 0)
		*((char**)switchPtr->argument) = argv[i];
	      else
		if (sscanf(argv[i],switchPtr->format,switchPtr->argument)
		    != 1) {
		  CommonWarning("CmdLineEval: "
				"switch %s%s argument format error",
				minusChar,switchPtr->switchName);
		  return 2;
		}
	  }
	  else
	    /* switch without argument */
	    *((int*)switchPtr->argument) = 1;
	  /* set switch used flag */
	  if (switchPtr->usedFlag != NULL)
	    *((int*)switchPtr->usedFlag) = 1;
	  break;	/* while (switchPtr ...) */
	}
	switchPtr++;
      }		/* while (switchPtr ...) */

      if (switchPtr == NULL || switchPtr->switchName == NULL) {
	CommonWarning("CmdLineEval: switch %s unknown",argv[i]);
	return 2;
      }
    }

    else {	/* if (*argv[i] == '-' && ...) */
      /* evaluate cmdline argument */
      if (paraPtr == NULL || paraPtr->argument == NULL) {
	CommonWarning("CmdLineEval: too many arguments",argv[i]);
	return 2;
      }
      if (paraPtr->format == NULL) {
	/* variable length argument list */
	if (count+1 >= MAX_TOKEN_NUM) {
	  CommonWarning("CmdLineEval: argument list %s too long",
			paraPtr->help);
	  return 2;
	}
	tmpVarArgIdx[count++] = i;
      }
      else {
	if (strcmp(paraPtr->format,"%s") == 0)
	  *((char**)paraPtr->argument) = argv[i];
	else
	  if (sscanf(argv[i],paraPtr->format,paraPtr->argument) != 1) {
	    CommonWarning("CmdLineEval: argument %s format error",
			  paraPtr->help);
	    return 2;
	  }
	paraPtr++;
      }
    }
    
    i++;
  }		/* while (i < argc) */
    
  if (paraPtr != NULL && paraPtr->argument != NULL &&
      paraPtr->format == NULL) {
    /* variable length argument list */
    if ((varArgIdx = (int*)malloc((count+1)*sizeof(int))) == NULL)
      CommonExit(1,"CmdLineEval: memory allocation error (varArgIdx)");
    for (i=0; i<count; i++)
      varArgIdx[i] = tmpVarArgIdx[i];
    varArgIdx[count] = -1;
    *((int**)paraPtr->argument) = varArgIdx;
    paraPtr++;
  }

  if (paraPtr != NULL && paraPtr->argument != NULL) {
    CommonWarning("CmdLineEval: argument %s is missing",
		  paraPtr->help);
    return 2;
  }

  return 0;
}
Example #29
0
VOID Image(IMG img, VOID *v)
{
    // Find main. We won't do anything before main starts.
    RTN rtn = RTN_FindByName(img, "main");
    if (RTN_Valid(rtn))
    {
        RTN_Open(rtn);
        RTN_InsertCall(rtn, IPOINT_BEFORE, (AFUNPTR)callBeforeMain, IARG_END);
        // RTN_InsertCall(rtn, IPOINT_AFTER, (AFUNPTR)callAfterMain, IARG_END);
        RTN_Close(rtn);
    }

    // iterate all rtn
    for (SEC sec = IMG_SecHead(img); SEC_Valid(sec); sec = SEC_Next(sec))
    {     
        for (RTN rtn = SEC_RtnHead(sec); RTN_Valid(rtn); rtn = RTN_Next(rtn))
        {
            // printf ("  Rtn: %s\n", RTN_Name(rtn).c_str());
            RTN_Open(rtn);
            const char * rtnName = StripPath(RTN_Name(rtn).c_str());
            RTN_InsertCall(rtn, IPOINT_BEFORE, (AFUNPTR)RTNEntry,
                       IARG_ADDRINT, rtnName, IARG_END);
            RTN_InsertCall(rtn, IPOINT_AFTER, (AFUNPTR)RTNExit,
                       IARG_ADDRINT, rtnName, IARG_END);
            RTN_Close(rtn);
        } 
    }

    // Instrument the malloc() and free() functions.  Print the input argument
    // of each malloc() or free(), and the return value of malloc().
    //
    //  Find the malloc() function.
    RTN mallocRtn = RTN_FindByName(img, MALLOC);
    if (RTN_Valid(mallocRtn))
    {
        RTN_Open(mallocRtn);

        const char * imageName = StripPath(IMG_Name(SEC_Img(RTN_Sec(mallocRtn))).c_str());
        // Instrument malloc() to print the input argument value and the return value.
        RTN_InsertCall(mallocRtn, IPOINT_BEFORE, (AFUNPTR)MallocBefore,
                       IARG_FUNCARG_ENTRYPOINT_VALUE, 0,
                       IARG_ADDRINT, imageName,
                       IARG_END);
        RTN_InsertCall(mallocRtn, IPOINT_AFTER, (AFUNPTR)MallocAfter,
                       IARG_FUNCRET_EXITPOINT_VALUE, IARG_END);

        RTN_Close(mallocRtn);
    }

    // Find the free() function.
    RTN freeRtn = RTN_FindByName(img, FREE);
    if (RTN_Valid(freeRtn))
    {
        RTN_Open(freeRtn);
        // Instrument free() to print the input argument value.
        RTN_InsertCall(freeRtn, IPOINT_BEFORE, (AFUNPTR)FreeBefore,
                       IARG_FUNCARG_ENTRYPOINT_VALUE, 0,
                       IARG_END);
        RTN_Close(freeRtn);
    }
}
Example #30
0
// AddPathPart():
//  Adds the new path to the end of the output path.  Directory
//   slashes will be added as needed.  If the new path contains
//   leading /'s (forward slashes) or ..\'s (dot-dot-backward slash),
//   one dir level will be stripped off of the output path, if they
//   exist.  If the input put contains a drive designation, then it
//   will replace the ouput path.  Note that the Windows UNC \\ is
//   considered a drive designator.
char * DirStrings::AddPathPart( char *output, const char *new_part ) {
  if( strchr( new_part, ':' ) ) {                // Test for full path
    strcpy( output, new_part );
    return output;
  }

  int len = strlen( new_part );
  if( len == 0 )
    return output;

  // Check for a full path (replace existing)
  if( strchr( new_part, ':' ) ) {                // New Part has a :, so it must be a full path.
    strcpy( output, new_part );
    return output;
  }

#ifdef WIN32
  if( (new_part[0] == '\\') && (new_part[1] == '\\') ) {
    strcpy( output, new_part );
    return output;
  }
#endif

  // Handle partial paths (add to existing)
  int   first_char = 0;                          // Handle / and ..\ (go back X directories)
  int   strip_count = 0;
  bool  keep_searching = false;
  len = strlen( new_part );

  while( first_char < len ) {
    keep_searching = false;
    if( new_part[ first_char ] == '/' ) {                        // Find a /
      first_char++;
      keep_searching = true;
      strip_count++;
    }
    
    if( strncmp( &new_part[ first_char ], "..\\", 3 ) == 0 ) {   // Find a ..\ 
      first_char += 3;
      keep_searching = true;
      strip_count++;
    }

    if( !keep_searching )                                   // No more go-backs; stop
      break;
  }

  if( strip_count > 0 )
    StripPath( output, strip_count );

  int outlen = strlen(output);
  if( outlen > 0 ) {                                        // Add a trailing / or \ if needed
    if( (output[ outlen-1 ] != '/'  ) &&
        (output[ outlen-1 ] != '\\' ) )
#ifdef WIN32
      strcat( output, "\\");
#endif
#ifdef AMIGA
      strcat( output, "/");    
#endif
  }
  strcat( output, new_part );
  return output;
}