static char *AddIncludePath( char *old_list, const char *path_list ) { size_t len; size_t old_len; char *new_list; char *p; new_list = old_list; if( path_list != NULL && *path_list != '\0' ) { len = strlen( path_list ); if( old_list == NULL ) { p = new_list = PP_Malloc( len + 1 ); } else { old_len = strlen( old_list ); new_list = PP_Malloc( old_len + 1 + len + 1 ); memcpy( new_list, old_list, old_len ); PP_Free( old_list ); p = new_list + old_len; } while( *path_list != '\0' ) { if( p != new_list ) *p++ = PATH_LIST_SEP; path_list = GetPathElement( path_list, NULL, &p ); } *p = '\0'; } return( new_list ); }
char *AddPath( char *old_list, const char *path_list ) /***************************************************/ { size_t len; size_t old_len; char *new_list; char *p; new_list = old_list; if( path_list != NULL && *path_list != NULLCHAR ) { len = strlen( path_list ); if( old_list == NULL ) { p = new_list = ProfAlloc( len + 1 ); } else { old_len = strlen( old_list ); new_list = ProfAlloc( old_len + 1 + len + 1 ); memcpy( new_list, old_list, old_len ); ProfFree( old_list ); p = new_list + old_len; } while( *path_list != NULLCHAR ) { if( p != new_list ) *p++ = PATH_LIST_SEP; path_list = GetPathElement( path_list, NULL, &p ); } *p = NULLCHAR; } return( new_list ); }
void HFileAppend( // APPEND HFILE TO LIST const char *path_list ) // - list of path names { int old_len; // - length of old H list char *p; // - points into H list char *old_list; // - old H list int len; len = strlen( path_list ); if( len != 0 ) { if( hfile_list != NULL ) { old_list = hfile_list; old_len = strlen( old_list ); hfile_list = CMemAlloc( old_len + 1 + len + 1 ); memcpy( hfile_list, old_list, old_len ); CMemFree( old_list ); p = hfile_list + old_len; } else { p = hfile_list = CMemAlloc( len + 1 ); } while( *path_list != '\0' ) { if( p != hfile_list ) *p++ = PATH_LIST_SEP; path_list = GetPathElement( path_list, NULL, &p ); } *p = '\0'; } }
extern void RcTmpFileName( char *tmpfilename ) /********************************************/ /* uses the TMP env. var. if it is set and puts the result into tmpfilename */ /* which is assumed to be a buffer of at least _MAX_PATH characters */ { char *nextchar; char *tmpdir; tmpdir = RcGetEnv( "TMP" ); nextchar = tmpfilename; if( tmpdir != NULL && *tmpdir != '\0' ) { GetPathElement( tmpdir, NULL, &nextchar ); if( !IS_PATH_SEP( nextchar[-1] ) ) { *nextchar++ = DIR_SEP; } } tmpnam( nextchar ); }
void FIncludePathInit( void ) //============================== { char *env; size_t len; char *p; FIncludePath = NULL; env = getenv( "FINCLUDE" ); if( env != NULL && *env != '\0' ) { len = strlen( env ); p = FIncludePath = FMemAlloc( len + 1 ); while( *env != NULLCHAR ) { if( p != FIncludePath ) *p++ = PATH_LIST_SEP; env = GetPathElement( env, NULL, &p ); } *p = NULLCHAR; } }
static void PathOption( opt_entry *optn, char *ptr ) //============================================================ // Process "INCPATH=" option. { char *p; char *old_list; int old_len; int len; optn = optn; len = strlen( ptr ); // skip quotes if( ptr[0] == '"' && ptr[len - 1] == '"' ) { len -= 2; ++ptr; ptr[len] = NULLCHAR; } if( len == 0 ) return; if( IncludePath == NULL ) { p = IncludePath = FMemAlloc( len + 1 ); } else { old_list = IncludePath; old_len = strlen( old_list ); IncludePath = FMemAlloc( old_len + 1 + len + 1 ); memcpy( IncludePath, old_list, len ); FMemFree( old_list ); p = IncludePath + old_len; } while( *ptr != NULLCHAR ) { if( p != IncludePath ) *p++ = PATH_LIST_SEP; ptr = GetPathElement( ptr, NULL, &p ); } *p = NULLCHAR; }