예제 #1
0
bool cTriggerConsole::CheckData(cfBase *cmd, cTrigger &data)
{
	if(data.mDefinition.empty()) {
		*cmd->mOS << _("The definition is empty or not specified. Please define it with -d option.");
		return false;
	}
	size_t pos = data.mDefinition.rfind("dbconfig");
	if(pos != string::npos) {
		*cmd->mOS << _("It's not allowed to define dbconfig file as trigger.") << "\n";
		cConnDC *conn = (cConnDC *) cmd->mConn;
		ostringstream message;
		message << autosprintf(_("User '%s' tried to define dbconfig as trigger"), conn->mpUser->mNick.c_str());
		mOwner->mServer->ReportUserToOpchat(conn, message.str());
		return false;
	}
	FilterPath(data.mDefinition);
	string vPath(mOwner->mServer->mConfigBaseDir), triggerPath, triggerName;
	ExpandPath(vPath);
	GetPath(data.mDefinition, triggerPath, triggerName);
	ReplaceVarInString(triggerPath, "CFG", triggerPath, vPath);
	ExpandPath(triggerPath);

	if ((triggerPath.substr(0, vPath.length()) != vPath)) {
		(*cmd->mOS) << autosprintf(_("The file %s for the trigger %s must be located in %s configuration folder, use %%[CFG] variable, for example: %%[CFG]/%s"), data.mDefinition.c_str(), data.mCommand.c_str(), HUB_VERSION_NAME, triggerName.c_str());
		return false;
	}

	return true;
}
예제 #2
0
파일: parse.c 프로젝트: Nehamkin/jwm
/** Get tokens from a menu include (either dynamic or static). */
TokenNode *ParseMenuIncludeHelper(const TokenNode *tp, const char *command)
{
   FILE *fd;
   char *path;
   char *buffer;
   TokenNode *start;

   buffer = NULL;
   if(!strncmp(command, "exec:", 5)) {

      path = Allocate(strlen(command) - 5 + 1);
      strcpy(path, command + 5);
      ExpandPath(&path);

      fd = popen(path, "r");
      if(JLIKELY(fd)) {
         buffer = ReadFile(fd);
         pclose(fd);
      } else {
         ParseError(tp, "could not execute included program: %s", path);
      }

   } else {

      path = CopyString(command);
      ExpandPath(&path);

      fd = fopen(path, "r");
      if(JLIKELY(fd)) {
         buffer = ReadFile(fd);
         fclose(fd);
      } else {
         ParseError(NULL, "could not open include: %s", path);
      }

   }

   if(JUNLIKELY(!buffer)) {
      Release(path);
      return NULL;
   }

   start = Tokenize(buffer, path);
   Release(buffer);
   Release(path);

   if(JUNLIKELY(!start || start->type != TOK_JWM))
   {
      ParseError(tp, "invalid include: %s", command);
      ReleaseTokens(start);
      return NULL;
   }

   return start;
}
예제 #3
0
int CFolderItem::FolderCreateDirectory(int showFolder)
{
	int res = FOLDER_SUCCESS;
	if (IsUnicode())
		{
			wchar_t buffer[MAX_FOLDER_SIZE];
			if (szFormatW)
				{
					ExpandPathW(buffer, szFormatW, MAX_FOLDER_SIZE);
					CreateDirectories(buffer);
					if (showFolder)
						{
							ShellExecuteW(NULL, L"explore", buffer, NULL, NULL, SW_SHOW);
						}
					res = (DirectoryExists(buffer)) ? FOLDER_SUCCESS : FOLDER_FAILURE;
				}
		}
		else{
			char buffer[MAX_FOLDER_SIZE];
			if (szFormat)
				{
					ExpandPath(buffer, szFormat, MAX_FOLDER_SIZE);
					CreateDirectories(buffer);
					if (showFolder)
						{
							ShellExecuteA(NULL, "explore", buffer, NULL, NULL, SW_SHOW);
						}
					res = (DirectoryExists(buffer)) ? FOLDER_SUCCESS : FOLDER_FAILURE;
				}
		}
	return res;
}
예제 #4
0
void SetDefaultName( CTEXTSTR path, CTEXTSTR name, CTEXTSTR extra )
{
	TEXTCHAR *newpath;
	size_t len;
	static CTEXTSTR filepath;// = GetProgramPath();
	static CTEXTSTR filename;// = GetProgramName();
	if( path )
	{
		if( filepath )
         Release( (POINTER)filepath );
		filepath = StrDup( path );
	}
	if( name )
	{
		if( filename )
			Release( (POINTER)filename );
		filename = StrDup( name );
	}
	if( !filepath )
		filepath = ExpandPath( WIDE("*/") );
	if( !filename )
		filename = StrDup( GetProgramName() );
	if( !filename )
      filename = "org.d3x0r.sack";
	// this has to come from C heap.. my init isn't done yet probably and
   // sharemem will just fai(*syslog_local).  (it's probably trying to log... )
	newpath = (TEXTCHAR*)malloc( len = sizeof(TEXTCHAR)*(9 + StrLen( filepath ) + StrLen( filename ) + (extra?StrLen(extra):0) + 5) );
#ifdef __cplusplus_cli
	tnprintf( newpath, len, WIDE("%s/%s%s.cli.log"), filepath, filename, extra?extra:WIDE("") );
#else
	tnprintf( newpath, len, WIDE("%s/%s%s.log"), filepath, filename, extra?extra:WIDE("") );
#endif
	gFilename = newpath;//( newpath ); // use the C heap.
	//free( newpath ); // get rid of this ...
}
예제 #5
0
파일: ff_cmd.c 프로젝트: bicepjai/nanos
/**
 *	@public
 *	@brief	Changes the Current Working Directory
 *
 *	To change the directory, we simply check the provided path, if it exists,
 *	then we change the environment's working directory to that path.
 *
 **/
int cd_cmd(int argc, char **argv, FF_ENVIRONMENT *pEnv) {
	FF_IOMAN *pIoman = pEnv->pIoman;
	FF_T_INT8	path[FF_MAX_PATH];

	int i;

	if(argc == 2) {
		ProcessPath(path, argv[1], pEnv);	// Make path absolute if relative.

		ExpandPath(path);	// Remove any relativity from the path (../ or ..\).
		
		if(FF_FindDir(pIoman, path, (FF_T_UINT16) strlen(path))) {	// Check if path is valid.
			i = strlen(path) - 1;	// Path found, change the directory.

			if(i) {
				if(path[i] == '\\' || path[i] == '/') {
					path[i] = '\0';
				}
			}
			strcpy(pEnv->WorkingDir, path);
			//sprintf(pEnv->WorkingDir, path);
		} else {
			cons_printf("Path \"%s\" not found.\n", path);
		}
	} else {
		cons_printf("Usage: %s [path]\n", argv[0]);
	}
	return 0;
}
예제 #6
0
파일: parse.c 프로젝트: Nehamkin/jwm
/** Parse an include. */
void ParseInclude(const TokenNode *tp, int depth) {

   char *temp;

   Assert(tp);

   if(JUNLIKELY(!tp->value)) {

      ParseError(tp, "no include file specified");

   } else {

      temp = CopyString(tp->value);

      ExpandPath(&temp);

      if(JUNLIKELY(!ParseFile(temp, depth))) {
         ParseError(tp, "could not open included file %s", temp);
      }

      Release(temp);

   }

}
예제 #7
0
파일: view.cpp 프로젝트: mongrelx/efte
int EView::OpenDir(char *Path) {
    char XPath[MAXPATH];
    EDirectory *dir = 0;

    if (ExpandPath(Path, XPath, sizeof(XPath)) == -1)
        return 0;
    {
        EModel *x = Model;
        while (x) {
            if (x->GetContext() == CONTEXT_DIRECTORY) {
                if (filecmp(((EDirectory *)x)->Path, XPath) == 0) {
                    dir = (EDirectory *)x;
                    break;
                }
            }
            x = x->Next;
            if (x == Model)
                break;
        }
    }
    if (dir == 0)
        dir = new EDirectory(0, &ActiveModel, XPath);
    SelectModel(dir);
    return 1;
}
예제 #8
0
static	void
TEST(
	char	*orig,
	char	*base)
{
	printf("[%s] = [%s]\n",orig,ExpandPath(orig,base));
}
예제 #9
0
static void RefreshPreview(HWND hWnd)
{
	TCHAR tmp[MAX_FOLDER_SIZE], res[MAX_FOLDER_SIZE];
	GetEditText(hWnd, tmp, MAX_FOLDER_SIZE);
	ExpandPath(res, tmp, MAX_FOLDER_SIZE);
	SetWindowText(GetDlgItem(hWnd, IDC_PREVIEW_EDIT), res);
}
예제 #10
0
/*
==============
AddScriptToStack
==============
*/
void AddScriptToStack (char *filename, ScriptPathMode_t pathMode = SCRIPT_USE_ABSOLUTE_PATH)
{
	int            size;

	script++;
	if (script == &scriptstack[MAX_INCLUDES])
		Error ("script file exceeded MAX_INCLUDES");
	
	if ( pathMode == SCRIPT_USE_RELATIVE_PATH )
		Q_strncpy( script->filename, filename, sizeof( script->filename ) );
	else
		Q_strncpy (script->filename, ExpandPath (filename), sizeof( script->filename ) );

	size = LoadFile (script->filename, (void **)&script->buffer);

	// printf ("entering %s\n", script->filename);
	if ( g_pfnCallback )
	{
		if ( script == scriptstack + 1 )
			g_pfnCallback( script->filename, NULL, 0 );
		else
			g_pfnCallback( script->filename, script[-1].filename, script[-1].line );
	}

	script->line = 1;

	script->script_p = script->buffer;
	script->end_p = script->buffer + size;
}
예제 #11
0
int EDirectory::FmMkDir() {
    char Dir[MAXPATH];
    char Dir2[MAXPATH];

    strcpy(Dir, Path);
    if (View->MView->Win->GetStr("New directory name", sizeof(Dir), Dir, HIST_PATH) == 0) {
        return 0;
    }

    if (ExpandPath(Dir, Dir2, sizeof(Dir2)) == -1) {
        Msg(S_INFO, "Failed to create directory, path did not expand");
        return 0;
    }

#if defined(MSVC) || defined(BCPP) || defined(WATCOM) || defined(__WATCOM_CPLUSPLUS__)
    int status = mkdir(Dir2);
#else
    int status = mkdir(Dir2, 509);
#endif
    if (status == 0) {
        return RescanDir();
    }

    Msg(S_INFO, "Failed to create directory %s", Dir2);
    return 0;
}
예제 #12
0
void
VisItDataServerPrivate::OpenDatabase(const std::string &filename, int timeState)
{
    // Determine the file and file format.
    if(openFile.empty())
    {
        // Expand the filename.
        std::string expandedFile = ExpandPath(filename);

        // Determine the file format.
        const avtDatabaseMetaData *md = mdserver.GetMDServerMethods()->GetMetaData(expandedFile);
        if(md == NULL)
        {
            EXCEPTION1(VisItException, "Can't get the metadata.");
        }
        openFile = expandedFile;
        openFileFormat = md->GetFileFormat();
    }
    openTimeState = timeState;

    // Set some default arguments.
    bool createMeshQualityExpressions = false;
    bool createTimeDerivativeExpressions = false;
    bool ignoreExtents = true;

    //
    // Open the database on the engine.
    //
    engine.GetEngineMethods()->OpenDatabase(openFileFormat,
                        openFile,
                        openTimeState,
                        createMeshQualityExpressions,
                        createTimeDerivativeExpressions,
                        ignoreExtents);
}
예제 #13
0
int EDirectory::FmMvFile(const char *Name) {
    char FullName[MAXPATH];
    char Dir[MAXPATH];
    char Dir2[MAXPATH];

    strcpy(FullName, Path);
    Slash(FullName, 1);
    strcat(FullName, Name);

    strcpy(Dir, Path);
    if (View->MView->Win->GetStr("New file name", sizeof(Dir), Dir, HIST_PATH) == 0) {
        return 0;
    }

	if (ExpandPath(Dir, Dir2, sizeof(Dir2)) == -1) {
		Msg(S_INFO, "Failed to expand destination %s", Name);
		return 0;
	}

    int status = rename(FullName, Dir2);
    if (status == 0) {
        RescanDir();
        return 1;
    }

    const char *msg = strerror(errno);
    Msg(S_INFO, "Failed to rename %s: %s", FullName, msg);

    return 0;
}
예제 #14
0
파일: lcm.traps.c 프로젝트: 40a/WPSDSCLinux
MI_Result NITS_CALL LCMTest_ExpandPath(_In_z_ const MI_Char * pathIn,
                     _Outptr_result_maybenull_z_ MI_Char **expandedPath, 
                     _Outptr_result_maybenull_ MI_Instance **cimErrorDetails)
{
    return ExpandPath( pathIn, expandedPath, cimErrorDetails);

}
예제 #15
0
파일: scriplib.c 프로젝트: clbr/netradiant
/*
==============
AddScriptToStack
==============
*/
void AddScriptToStack (const char *filename, int index)
{
  int size;

  script++;
  if (script == &scriptstack[MAX_INCLUDES])
    Error ("script file exceeded MAX_INCLUDES");
  strcpy (script->filename, ExpandPath (filename));

  size = vfsLoadFile (script->filename, (void **)&script->buffer, index);

  if (size == -1)
    Sys_Printf ("Script file %s was not found\n", script->filename);
  else
  {
    if (index > 0)
      Sys_Printf ("entering %s (%d)\n", script->filename, index+1);
    else
      Sys_Printf ("entering %s\n", script->filename);
  }

  script->line = 1;
  script->script_p = script->buffer;
  script->end_p = script->buffer + size;
}
예제 #16
0
int FTPCache::AddPathMap(PathMap pathmap) {
	TCHAR * expPath = ExpandPath(pathmap.localpath);
	if (expPath != NULL) {
		pathmap.localpathExpanded = expPath;
	}
	m_vCachePaths.push_back(pathmap);
	return 0;
}
예제 #17
0
static uintptr_t CPROC SetDefaultPath( uintptr_t psv, arg_list args ) {
    PARAM( args, CTEXTSTR, path );
    if( !l.target_path ) { // otherwise it was already set on the commandline
        l.target_path = ExpandPath( path );
        SetCurrentPath( l.target_path );
    }
    return psv;
}
예제 #18
0
void CFolderItem::Expand(char *buffer, int size)
{
	if (IsUnicode())
		{
			ExpandPathW((wchar_t *) buffer, szFormatW, size);
		}
		else{
			ExpandPath(buffer, szFormat, size);
		}
}
예제 #19
0
int FTPCache::ExpandPaths() {
	for(size_t i = 0; i < m_vCachePaths.size(); i++) {
		TCHAR * expPath = ExpandPath(m_vCachePaths[i].localpath);
		if (expPath != NULL) {
			delete [] m_vCachePaths[i].localpathExpanded;
			m_vCachePaths[i].localpathExpanded = expPath;
		}
	}
	return 0;
}
예제 #20
0
파일: dirctrlg.cpp 프로젝트: drvo/wxWidgets
void wxGenericDirCtrl::ExpandRoot()
{
    ExpandDir(m_rootId); // automatically expand first level

    // Expand and select the default path
    if (!m_defaultPath.empty())
    {
        ExpandPath(m_defaultPath);
    }
#ifdef __UNIX__
    else
    {
        // On Unix, there's only one node under the (hidden) root node. It
        // represents the / path, so the user would always have to expand it;
        // let's do it ourselves
        ExpandPath( wxT("/") );
    }
#endif
}
예제 #21
0
파일: qlumpy.c 프로젝트: DeadlyGamer/cs16nd
/*
===========
WriteFile

Save as a seperate file instead of as a wadfile lump
===========
*/
void WriteFile (void)
{
	char	filename[1024];
	char	*exp;

	sprintf (filename,"%s/%s.lmp", destfile, lumpname);
	exp = ExpandPath(filename);
	printf ("saved %s\n", exp);
	SaveFile (exp, lumpbuffer, lump_p-lumpbuffer);		
}
예제 #22
0
파일: stub.c 프로젝트: Epictetus/ocra
void GetCreateProcessInfo(LPVOID* p, LPTSTR* pApplicationName, LPTSTR* pCommandLine)
{
   LPTSTR ImageName = GetString(p);
   LPTSTR CmdLine = GetString(p);

   ExpandPath(pApplicationName, ImageName);

   LPTSTR ExpandedCommandLine;
   ExpandPath(&ExpandedCommandLine, CmdLine);

   LPTSTR MyCmdLine = GetCommandLine();
   LPTSTR MyArgs = SkipArg(MyCmdLine);
   
   *pCommandLine = LocalAlloc(LMEM_FIXED, lstrlen(ExpandedCommandLine) + sizeof(TCHAR) + lstrlen(MyArgs) + sizeof(TCHAR));
   lstrcpy(*pCommandLine, ExpandedCommandLine);
   lstrcat(*pCommandLine, _T(" "));
   lstrcat(*pCommandLine, MyArgs);
   
   LocalFree(ExpandedCommandLine);
}
예제 #23
0
/*************
 * DESCRIPTION:   load texture
 * INPUT:         texture     texture
 * OUTPUT:        FALSE if failed else TRUE
 *************/
BOOL IPREVIEW_TEXTURE::Load(TEXTURE *texture)
{
	/* Load Imagine texture  */
#ifdef __AMIGA__
	IM_TTABLE* (*texture_init)(LONG arg0);

	seglist = LoadSeg(texture->name);
	if(!seglist)
		return FALSE;

	*(ULONG*)(&texture_init) = 4*seglist+4;
#ifdef __PPC__
	ttable = ITextureInit(texture_init);
#else
	ttable = texture_init(0x60FFFF);
#endif
#else
	INQUIRETEXTURE InquireTexture;
	PREFS prefs;
	char szBuffer[256];

	prefs.id = ID_TXTP;
	if (prefs.GetPrefs())
		ExpandPath((char *)prefs.data, texture->name, szBuffer);
	else
		strcpy(szBuffer, texture->name);

	prefs.data = NULL; // VERY important !

	hInst = LoadLibrary(szBuffer);
	if (!hInst)
		return FALSE;

	InquireTexture = (INQUIRETEXTURE)GetProcAddress(hInst, "InquireTexture");
	if (!InquireTexture)
		return FALSE;

	ttable = InquireTexture(0x70, 0x1);
#endif

	if(!ttable)
		return FALSE;

	// copy parameters
	memcpy(params, ((IMAGINE_TEXTURE*)texture)->params, 16*sizeof(float));

	form.pos = pos;
	form.orient_x = orient_x;
	form.orient_y = orient_y;
	form.orient_z = orient_z;
	form.size = size;

	return TRUE;
}
예제 #24
0
EDirectory::EDirectory(int createFlags, EModel **ARoot, char *aPath): EList(createFlags, ARoot, aPath) {
    char XPath[MAXPATH];

    Files = 0;
    FCount = 0;
    SearchLen = 0;
    ExpandPath(aPath, XPath, sizeof(XPath));
    Slash(XPath, 1);
    Path = strdup(XPath);
    RescanList();
}
예제 #25
0
int CFolderItem::FolderCreateDirectory(int showFolder)
{
	if (m_tszFormat == NULL)
		return FOLDER_SUCCESS;

	CMString buffer(ExpandPath(m_tszFormat));
	CreateDirectoryTreeT(buffer);
	if (showFolder)
		ShellExecute(NULL, L"explore", buffer, NULL, NULL, SW_SHOW);

	return (DirectoryExists(buffer)) ? FOLDER_SUCCESS : FOLDER_FAILURE;
}
예제 #26
0
void StartReplay(const std::string &filename, bool reveal)
{
	std::string replay;

	CleanPlayers();
	ExpandPath(replay, filename);
	LoadReplay(replay);

	ReplayRevealMap = reveal;

	StartMap(CurrentMapPath, false);
}
예제 #27
0
void StartSavedGame(const std::string &filename)
{
	std::string path;

	SaveGameLoading = true;
	CleanPlayers();
	ExpandPath(path, filename);
	LoadGame(path);

	StartMap(filename, false);
	//SetDefaultTextColors(nc, rc);
}
예제 #28
0
void ProcessPath(char *dest, const char *src, FF_ENVIRONMENT *pEnv) {
	if(src[0] != '\\' && src[0] != '/') {
		if(strlen(pEnv->WorkingDir) == 1) {
			sprintf(dest, "\\%s", src);
		} else {
			sprintf(dest, "%s\\%s", pEnv->WorkingDir, src);
		}
	} else {
		sprintf(dest, "%s", src);
	}

	ExpandPath(dest);	// Remove all relativity from the path.
}
예제 #29
0
int CFolderItem::FolderCreateDirectory(int showFolder)
{
	if (m_tszFormat == NULL)
		return FOLDER_SUCCESS;

	TCHAR buffer[MAX_FOLDER_SIZE];
	ExpandPath(buffer, m_tszFormat, SIZEOF(buffer));
	CreateDirectoryTreeT(buffer);
	if (showFolder)
		ShellExecute(NULL, L"explore", buffer, NULL, NULL, SW_SHOW);

	return (DirectoryExists(buffer)) ? FOLDER_SUCCESS : FOLDER_FAILURE;
}
예제 #30
0
TupleArcFst* TuneSet::LoadLattice (const Sid s) const {
  boost::iostreams::filtering_streambuf<boost::iostreams::input> in;
  in.push (boost::iostreams::gzip_decompressor() );
  in.push (boost::iostreams::file_source (ExpandPath (m_pattern, s) ) );
  std::istream is (&in);
  TupleArcFst32* fst32 = TupleArcFst32::Read (is, fst::FstReadOptions() );
  TopSort (fst32);
  if (!fst32) {
    cerr << "ERROR: unable to load vector lattice: " << ExpandPath (m_pattern,
         s) << '\n';
    exit (1);
  }
  if (fst32->Properties (fst::kNotTopSorted, true) ) {
    cerr << "ERROR: Input lattices are not topologically sorted: " << '\n';
    exit (1);
  }
  TupleArcFst* fst = new TupleArcFst;
  fst::Expand m;
  fst::Map (*fst32, fst, fst::ExpandMapper (m) );
  delete fst32;
  return fst;
}