Changeset 11292 for trunk/psModules/src/config
- Timestamp:
- Jan 25, 2007, 2:05:18 PM (19 years ago)
- Location:
- trunk/psModules/src/config
- Files:
-
- 2 edited
-
pmConfig.c (modified) (5 diffs)
-
pmConfig.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/config/pmConfig.c
r11245 r11292 4 4 * @author EAM (IfA) 5 5 * 6 * @version $Revision: 1.7 3$ $Name: not supported by cvs2svn $7 * @date $Date: 2007-01-2 3 03:19:35$6 * @version $Revision: 1.74 $ $Name: not supported by cvs2svn $ 7 * @date $Date: 2007-01-26 00:05:18 $ 8 8 * 9 9 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 24 24 #include <glob.h> 25 25 #include <pslib.h> 26 26 27 #include "pmConfig.h" 28 #include "pmErrorCodes.h" 27 29 #include "pmConfigRecipes.h" 28 30 #include "pmConfigCamera.h" 31 32 #ifdef HAVE_NEBCLIENT 33 #include <nebclient.h> 34 #endif // ifdef HAVE_NEBCLIENT 29 35 30 36 #define PS_SITE "PS_SITE" // Name of the environment variable containing the site config file … … 1047 1053 1048 1054 // convert the supplied name, create a new output psString 1049 psString pmConfigConvertFilename(const char *filename, const pmConfig *config )1055 psString pmConfigConvertFilename(const char *filename, const pmConfig *config, bool create) 1050 1056 { 1051 1057 PS_ASSERT_STRING_NON_EMPTY(filename, NULL); 1052 1058 PS_ASSERT_PTR_NON_NULL(config, NULL); 1053 1059 1054 psString newName = psStringCopy (filename);1055 1056 1060 // strip file:// from front of name 1057 if (!strncasecmp (newName, "file:", strlen("file:"))) { 1061 if (!strncasecmp(filename, "file:", strlen("file:"))) { 1062 psString newName = psStringCopy(filename); 1063 1058 1064 char *point = newName + strlen("file:"); 1059 1065 while (*point == '/') … … 1063 1069 psFree (newName); 1064 1070 newName = tmpName; 1071 1072 return newName; 1065 1073 } 1066 1074 1067 1075 // replace path://PATH with matched datapath 1068 if (!strncasecmp (newName, "path://", strlen("path://"))) {1076 if (!strncasecmp(filename, "path://", strlen("path://"))) { 1069 1077 PS_ASSERT_METADATA_NON_NULL(config->site, NULL); 1078 1079 psString newName = psStringCopy(filename); 1070 1080 1071 1081 // filename should be of the form: path://PATH/rest/of/file … … 1102 1112 psFree(newName); 1103 1113 newName = tmpName; 1114 1115 return newName; 1104 1116 } 1105 1117 1106 1118 // substitute neb://name with matched nebulous name 1107 1108 return newName; 1109 } 1119 if (!strncasecmp(filename, "neb://", strlen("neb://"))) { 1120 #ifdef HAVE_NEBCLIENT 1121 1122 bool status = false; 1123 psString nebulous_server = psMetadataLookupStr(&status, config->site, "NEBULOUS_SERVER"); 1124 if (!status) { 1125 psError(PM_ERR_CONFIG, true, "failed to lookup config value for NEBULOUS_SERVER."); 1126 return NULL; 1127 } 1128 if (!nebulous_server) { 1129 psError(PM_ERR_CONFIG, true, "Could not determine nebulous server URI."); 1130 return NULL; 1131 } 1132 1133 nebServer *server = nebServerAlloc(nebulous_server); 1134 if (!server) { 1135 psError(PM_ERR_SYS, true, "failed to create a nebServer object."); 1136 nebServerFree(server); 1137 return NULL; 1138 } 1139 1140 psString newName = psStringCopy(filename); 1141 1142 // for for the nebulous key 1143 char *foo = nebFind(server, newName); 1144 // if it doesn't exist, create it 1145 if (!foo) { 1146 foo = nebCreate(server, newName, 0, NULL, NULL, NULL); 1147 } 1148 1149 psFree(newName); 1150 psString newFoo = psStringCopy(foo); 1151 psFree(foo); 1152 nebServerFree(server); 1153 1154 return newFoo; 1155 1156 #else // ifdef HAVE_NEBCLIENT 1157 1158 psError(PM_ERR_PROG, true, "psModules was compiled without nebulous support."); 1159 return NULL; 1160 #endif // ifdef HAVE_NEBCLIENT 1161 1162 } 1163 1164 // if we go this far, do nothing 1165 return psStringCopy(filename); 1166 } -
trunk/psModules/src/config/pmConfig.h
r11251 r11292 5 5 * @author Eugene Magnier, IfA 6 6 * 7 * @version $Revision: 1.2 6$ $Name: not supported by cvs2svn $8 * @date $Date: 2007-01-2 4 01:05:41$7 * @version $Revision: 1.27 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2007-01-26 00:05:18 $ 9 9 * Copyright 2005-2006 Institute for Astronomy, University of Hawaii 10 10 */ … … 155 155 156 156 /// Convert the supplied name, create a new output psString 157 psString pmConfigConvertFilename(const char *filename, const pmConfig *config); 157 psString pmConfigConvertFilename( 158 const char *filename, ///< file path/URI 159 const pmConfig *config, ///< configuration 160 bool create ///< create the file if it doesn't exist 161 ); 158 162 159 163 /// Set whether all config parameters are read on startup
Note:
See TracChangeset
for help on using the changeset viewer.
