MCPcopy Index your code
hub / github.com/MapServer/MapServer / msSetPROJ_LIB

Function msSetPROJ_LIB

mapproject.c:1058–1116  ·  view source on GitHub ↗

/ msSetPROJ_LIB() */ /

Source from the content-addressed store, hash-verified

1056/* msSetPROJ_LIB() */
1057/************************************************************************/
1058void msSetPROJ_LIB( const char *proj_lib, const char *pszRelToPath )
1059
1060{
1061#ifdef USE_PROJ
1062 static int finder_installed = 0;
1063 char *extended_path = NULL;
1064
1065 /* Handle relative path if applicable */
1066 if( proj_lib && pszRelToPath
1067 && proj_lib[0] != '/'
1068 && proj_lib[0] != '\\'
1069 && !(proj_lib[0] != '\0' && proj_lib[1] == ':') )
1070 {
1071 struct stat stat_buf;
1072 extended_path = (char*) msSmallMalloc(strlen(pszRelToPath)
1073 + strlen(proj_lib) + 10);
1074 sprintf( extended_path, "%s/%s", pszRelToPath, proj_lib );
1075
1076#ifndef S_ISDIR
1077# define S_ISDIR(x) ((x) & S_IFDIR)
1078#endif
1079
1080 if( stat( extended_path, &stat_buf ) == 0
1081 && S_ISDIR(stat_buf.st_mode) )
1082 proj_lib = extended_path;
1083 }
1084
1085
1086 msAcquireLock( TLOCK_PROJ );
1087
1088 if( finder_installed == 0 && proj_lib != NULL)
1089 {
1090 finder_installed = 1;
1091 pj_set_finder( msProjFinder );
1092 }
1093
1094 if (proj_lib == NULL) pj_set_finder(NULL);
1095
1096 if( ms_proj_lib != NULL )
1097 {
1098 free( ms_proj_lib );
1099 ms_proj_lib = NULL;
1100 }
1101
1102 if( last_filename != NULL )
1103 {
1104 free( last_filename );
1105 last_filename = NULL;
1106 }
1107
1108 if( proj_lib != NULL )
1109 ms_proj_lib = msStrdup( proj_lib );
1110
1111 msReleaseLock( TLOCK_PROJ );
1112
1113 if ( extended_path )
1114 msFree( extended_path );
1115#endif

Callers 3

msCleanupFunction · 0.85
msSetConfigOptionFunction · 0.85
msApplyMapConfigOptionsFunction · 0.85

Calls 6

msSmallMallocFunction · 0.85
msAcquireLockFunction · 0.85
msStrdupFunction · 0.85
msReleaseLockFunction · 0.85
msFreeFunction · 0.85
statClass · 0.70

Tested by

no test coverage detected