Exemple #1
0
void InitSearchPaths (void)
/* Initialize the path search list */
{
    /* Always search all stuff in the current directory */
    AddSearchPath ("", SEARCH_LIB | SEARCH_OBJ | SEARCH_CFG);

    /* Add some compiled in search paths if defined at compile time */
#if defined(LD65_LIB)
    AddSearchPath (LD65_LIB, SEARCH_LIB);
#endif
#if defined(LD65_OBJ)
    AddSearchPath (LD65_OBJ, SEARCH_OBJ);
#endif
#if defined(LD65_CFG)
    AddSearchPath (LD65_CFG, SEARCH_CFG);
#endif

    /* Add specific paths from the environment */
    AddSearchPathFromEnv ("LD65_CFG", SEARCH_CFG);
    AddSearchPathFromEnv ("LD65_LIB", SEARCH_LIB);
    AddSearchPathFromEnv ("LD65_OBJ", SEARCH_OBJ);

    /* Add paths relative to a main directory defined in an env var */
    AddSubSearchPathFromEnv ("CC65_HOME", "cfg", SEARCH_CFG);
    AddSubSearchPathFromEnv ("CC65_HOME", "lib", SEARCH_LIB);
    AddSubSearchPathFromEnv ("CC65_HOME", "obj", SEARCH_OBJ);
}
//-----------------------------------------------------------------------------
// Purpose: Tries to add a VPK path to the mount list
//-----------------------------------------------------------------------------
bool TryMountVPKGame( const char *pName, const char *pPath, int id, const char *pMountID, KeyValues *pMountList = NULL )
{
	if( pMountList && pMountList->GetInt( pMountID, 0 ) == 0 )
	{
		return false;
	}

	MountMsg("Adding %s to search path...", pName);

	// Dedicated servers always succeed for now...
#ifdef GAME_DLL
	if( engine->IsDedicatedServer() )
	{
		Msg("succeeded (dedicated server)\n");
		g_AppStatus[id] = AS_AVAILABLE;
		return true;
	}
#endif // GAME_DLL

	if( filesystem->IsDirectory( pPath, "GAME" ) ) 
	{
		AddSearchPath( pPath, "GAME", PATH_ADD_TO_TAIL_ATINDEX );
		g_AppStatus[id] = AS_AVAILABLE;
		MountMsg("succeeded\n");
		return true;
	}
	else
	{
		MountMsg("failed (not installed?)\n");
	}
	return false;
}
Exemple #3
0
void AddSubSearchPathFromEnv (SearchPaths* P, const char* EnvVar, const char* SubDir)
/* Add a search path from an environment variable, adding a subdirectory to
** the environment variable value.
*/
{
    StrBuf Dir = AUTO_STRBUF_INITIALIZER;

    const char* EnvVal = getenv (EnvVar);
    if (EnvVal == 0) {
        /* Not found */
        return;
    }

    /* Copy the environment variable to the buffer */
    SB_CopyStr (&Dir, EnvVal);

    /* Add a path separator if necessary */
    if (SB_NotEmpty (&Dir)) {
        if (SB_LookAtLast (&Dir) != '\\' && SB_LookAtLast (&Dir) != '/') {
            SB_AppendChar (&Dir, '/');
        }
    }

    /* Add the subdirectory and terminate the string */
    SB_AppendStr (&Dir, SubDir);
    SB_Terminate (&Dir);

    /* Add the search path */
    AddSearchPath (P, SB_GetConstBuf (&Dir));

    /* Free the temp buffer */
    SB_Done (&Dir);
}
Exemple #4
0
void AddSearchPathFromEnv (SearchPaths* P, const char* EnvVar)
/* Add a search path from an environment variable to the end of an existing
** list.
*/
{
    AddSearchPath (P, getenv (EnvVar));
}
status_t ArpMultiDir::AddEnvVar(const char* name, const char* leaf)
{
	if( !name ) return B_OK;
	
	int nlen = strlen(name);
	char** e = environ;
	while( e && *e ) {
		ArpD(cdb << ADH << "Looking at var: " << *e << endl);
		if( strncmp(*e,name,nlen) == 0 && (*e)[nlen] == '=' ) {
			ArpD(cdb << ADH << "Found env var: " << *e << endl);
			return AddSearchPath(&((*e)[nlen+1]), leaf);
		}
		e++;
	}
	return B_OK;
}
void CMediaManager::AddSearchPathAndChilds(const std::string& Path)
{
	// Add the root directory
//	Logger::Log() << Path << "\n";
	AddSearchPath(Path);

	// find childs directories to add...
	boost::filesystem::directory_iterator end_itr;
	for (boost::filesystem::directory_iterator itr(Path); itr != end_itr; ++itr)
	{
		if (boost::filesystem::is_directory(itr->status()))
		{
			AddSearchPathAndChilds(itr->path().string());
		}
	}
}
Exemple #7
0
void FinishIncludePaths (void)
/* Finish creating the include path search lists. */
{
    /* Add specific paths from the environment */
    AddSearchPathFromEnv (SysIncSearchPath, "CC65_INC");
    AddSearchPathFromEnv (UsrIncSearchPath, "CC65_INC");

    /* Add paths relative to a main directory defined in an env. var. */
    AddSubSearchPathFromEnv (SysIncSearchPath, "CC65_HOME", "include");

    /* Add some compiled-in search paths if defined at compile time. */
#if defined(CC65_INC) && !defined(_WIN32)
    AddSearchPath (SysIncSearchPath, STRINGIZE (CC65_INC));
#endif

    /* Add paths relative to the parent directory of the Windows binary. */
    AddSubSearchPathFromWinBin (SysIncSearchPath, "include");
}
Exemple #8
0
void AddSubSearchPathFromWinBin (SearchPaths* P, const char* SubDir)
{
/* Windows only:
** Add a search path from the running binary, adding a subdirectory to
** the parent directory of the directory containing the binary.
*/
#if defined(_WIN32)

    char Dir[_MAX_PATH];
    char* Ptr;

    if (GetModuleFileName (NULL, Dir, _MAX_PATH) == 0) {
        return;
    }

    /* Remove binary name */
    Ptr = strrchr (Dir, '\\');
    if (Ptr == 0) {
        return;
    }
    *Ptr = '\0';

    /* Check for 'bin' directory */
    Ptr = strrchr (Dir, '\\');
    if (Ptr == 0) {
        return;
    }
    if (strcmp (Ptr++, "\\bin") != 0) {
        return;
    }

    /* Append SubDir */
    strcpy (Ptr, SubDir);

    /* Add the search path */
    AddSearchPath (P, Dir);

#else

    (void) P;
    (void) SubDir;

#endif
}
Exemple #9
0
void InitSearchPaths (void)
/* Initialize the path search list */
{
    /* Create the search path lists */
    LibSearchPath = NewSearchPath ();
    ObjSearchPath = NewSearchPath ();
    CfgSearchPath = NewSearchPath ();

    LibDefaultPath = NewSearchPath ();
    ObjDefaultPath = NewSearchPath ();
    CfgDefaultPath = NewSearchPath ();

    /* Always search all stuff in the current directory */
    AddSearchPath (LibSearchPath, "");
    AddSearchPath (ObjSearchPath, "");
    AddSearchPath (CfgSearchPath, "");

    /* Add specific paths from the environment. */
    AddSearchPathFromEnv (LibDefaultPath, "LD65_LIB");
    AddSearchPathFromEnv (ObjDefaultPath, "LD65_OBJ");
    AddSearchPathFromEnv (CfgDefaultPath, "LD65_CFG");

    /* Add paths relative to a main directory defined in an env. var. */
    AddSubSearchPathFromEnv (LibDefaultPath, "CC65_HOME", "lib");
    AddSubSearchPathFromEnv (ObjDefaultPath, "CC65_HOME", "lib");
    AddSubSearchPathFromEnv (CfgDefaultPath, "CC65_HOME", "cfg");

    /* Add some compiled-in search paths if defined at compile time. */
#if defined(LD65_LIB) && !defined(_WIN32)
    AddSearchPath (LibDefaultPath, STRINGIZE (LD65_LIB));
#endif
#if defined(LD65_OBJ) && !defined(_WIN32)
    AddSearchPath (ObjDefaultPath, STRINGIZE (LD65_OBJ));
#endif
#if defined(LD65_CFG) && !defined(_WIN32)
    AddSearchPath (CfgDefaultPath, STRINGIZE (LD65_CFG));
#endif

    /* Add paths relative to the parent directory of the Windows binary. */
    AddSubSearchPathFromWinBin (LibDefaultPath, "lib");
    AddSubSearchPathFromWinBin (ObjDefaultPath, "lib");
    AddSubSearchPathFromWinBin (CfgDefaultPath, "cfg");
}
Exemple #10
0
int main( int argc, char * argv[] )
{
  FILE * handl_o;
  char szFileName[ _POSIX_PATH_MAX + 1 ];
  char szPpoName[ _POSIX_PATH_MAX + 1 ];
  int iArg = 1;
  BOOL bOutTable = FALSE;
  BOOL bOutNew = FALSE;
  DEFINES * stdef;
  COMMANDS * stcmd;

  HB_TRACE(HB_TR_DEBUG, ("main(%d, %p)", argc, argv));

  printf( "Harbour Preprocessor (old revision) %d.%d.%d\n",
     HB_VER_MAJOR, HB_VER_MINOR, HB_VER_REVISION );
  printf( "Copyright (c) 1999-2008, http://www.harbour-project.org/\n" );

  hb_pp_Table();
  stdef = hb_pp_topDefine;
  stcmd = hb_pp_topCommand;
  hb_pp_Init();

  while( iArg < argc )
    {
      if( HB_ISOPTSEP(argv[ iArg ][ 0 ]))
        {
          switch( argv[ iArg ][ 1 ] )
            {
            case 'd':
            case 'D':   /* defines a #define from the command line */
              {
                 char *szDefText = hb_strdup( argv[iArg] + 2 ), *pAssign, *sDefLine;
                 unsigned int i = 0;

                 while( i < strlen( szDefText ) && ! HB_ISOPTSEP( szDefText[ i ] ) )
                    i++;

                 szDefText[ i ] = '\0';
                 if( szDefText )
                 {
                    if( ( pAssign = strchr( szDefText, '=' ) ) == NULL )
                    {
                       hb_pp_AddDefine_( szDefText, 0 );
                    }
                    else
                    {
                       szDefText[ pAssign - szDefText ] = '\0';

                       /* hb_pp_AddDefine_( szDefText,  pAssign + 1 ); */
                       sDefLine = hb_xstrcpy( NULL, szDefText, " ", pAssign + 1, NULL );
                       hb_pp_ParseDefine_( sDefLine );
                       hb_xfree( sDefLine );
                    }
                 }

                 hb_xfree( szDefText );
              }
              break;
            case 'i':
            case 'I':
              AddSearchPath( argv[ iArg ]+2, &hb_comp_pIncludePath );
              break;
            case 'o':
            case 'O':
              bOutTable = TRUE;
              break;
            case 'n':
            case 'N':
              bOutNew = TRUE;
              break;
            case 'w':
            case 'W':
              s_iWarnings = 1;
              if( argv[ iArg ][ 2 ] )
                {  /*there is -w<0,1,2,3> probably */
                  s_iWarnings = argv[ iArg ][ 2 ] - '0';
                  if( s_iWarnings < 0 || s_iWarnings > 3 )
                    printf( "\nInvalid command line option: %s\n", argv[ iArg ] );
                }
              break;
            default:
              printf( "\nInvalid command line option: %s\n", &argv[ iArg ][ 1 ] );
              break;
            }
        }
      else  hb_comp_pFileName = hb_fsFNameSplit( argv[ iArg ] );
      iArg++;
    }

  if( hb_comp_pFileName )
    {
      if( ! hb_comp_pFileName->szExtension )
        hb_comp_pFileName->szExtension =".prg";

      hb_fsFNameMerge( szFileName, hb_comp_pFileName );

      if( !hb_pp_fopen( szFileName ) )
        {
          printf("\nCan't open %s\n", szFileName );
          return 1;
        }

      printf( "\nParsing file %s\n", szFileName );
    }
  else
    {
      printf( "\nSyntax:  %s <file[.prg]> [options]"
              "\n"
              "\nOptions:  /d<id>[=<val>]   #define <id>"
              "\n          /i<path>         add #include file search path"
              "\n          /o               creates hbpp.out with all tables"
              "\n          /n               with those only, which defined in your file"
              "\n          /w               enable warnings"
              "\n"
              , argv[ 0 ] );

      if( bOutTable )
        OutTable( NULL, NULL );

      return 1;
    }

  hb_comp_pFileName->szExtension = ".ppo";
  hb_fsFNameMerge( szPpoName, hb_comp_pFileName );

  if( ( handl_o = fopen( szPpoName, "wt" ) ) == NULL )
    {
      printf("\nCan't open %s\n", szPpoName );
      return 1;
    }

  {
    char * szInclude = hb_getenv( "INCLUDE" );

    if( szInclude )
      {
        char * pPath;
        char * pDelim;

        pPath = szInclude;
        while( ( pDelim = strchr( pPath, HB_OS_PATH_LIST_SEP_CHR ) ) != NULL )
          {
            *pDelim = '\0';
            AddSearchPath( pPath, &hb_comp_pIncludePath );
            pPath = pDelim + 1;
          }
        AddSearchPath( pPath, &hb_comp_pIncludePath );
        hb_xfree( szInclude );
      }
  }

  hb_buffer = ( char* ) hb_xgrab( HB_PP_STR_SIZE );
  while( hb_pp_Internal_( handl_o,hb_buffer ) > 0 );
  fclose( hb_comp_files.pLast->handle );
  hb_xfree( hb_comp_files.pLast->pBuffer );
  hb_xfree( hb_comp_files.pLast );
  hb_xfree( hb_buffer );
  fclose( handl_o );

  if( bOutTable )
    OutTable( NULL, NULL );
  else if( bOutNew )
    OutTable( stdef, stcmd );

  printf( "\nOk" );

  return 0;
}