Changeset 13950
- Timestamp:
- Jun 21, 2007, 4:28:48 PM (19 years ago)
- Location:
- trunk/psLib/src
- Files:
-
- 5 edited
-
astro/psEarthOrientation.c (modified) (2 diffs)
-
astro/psTime.c (modified) (11 diffs)
-
astro/psTime.h (modified) (3 diffs)
-
sys/psConfigure.c (modified) (6 diffs)
-
sys/psConfigure.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/astro/psEarthOrientation.c
r11674 r13950 8 8 * @author Robert Daniel DeSonia, MHPCC 9 9 * 10 * @version $Revision: 1.4 5$ $Name: not supported by cvs2svn $11 * @date $Date: 2007-0 2-07 01:15:49$10 * @version $Revision: 1.46 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2007-06-22 02:28:48 $ 12 12 * 13 13 * Copyright 2005 Maui High Performance Computing Center, University of Hawaii … … 93 93 psMetadata* eocMetadata = psMetadataConfigRead(NULL, 94 94 &nFail, 95 p_psTimeConfigFile Name(),95 p_psTimeConfigFilename(NULL), 96 96 true); 97 97 //Make sure reading of config file worked correctly -
trunk/psLib/src/astro/psTime.c
r13930 r13950 10 10 * @author Ross Harman, MHPCC 11 11 * 12 * @version $Revision: 1.11 2$ $Name: not supported by cvs2svn $13 * @date $Date: 2007-06-2 1 18:46:38 $12 * @version $Revision: 1.113 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2007-06-22 02:28:48 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 68 68 #define NSEC_PER_DAY 86400000000000.0 69 69 70 // Time config file path 71 static char *timeConfig = NULL; 72 70 73 /** Time metadata read from config file */ 71 74 static psMetadata *timeMetadata = NULL; … … 96 99 static psTime* convertTimeUTCUT1(psTime* time); 97 100 101 static bool p_psTimeInit(const char *fileName); 98 102 99 103 /** Removes leading and trailing whitespace and # characters from a string. The cleaned string is a new null … … 164 168 } 165 169 166 // get the pslib.config filename by checking environment variable first, then original installation area. 167 const char* p_psTimeConfigFileName() 168 { 169 const char* filename = getenv("PS_CONFIG_FILE"); 170 171 if (filename == NULL) { // environment variable not found 172 filename = PS_CONFIG_FILE_DEFAULT; // this should come from configure.ac 173 } 174 175 return filename; 170 // get the pslib.config filename by checking environment variable first, then 171 // the possiblity set config file name, then the original installation area. 172 const char *p_psTimeConfigFilename(const char *filename) 173 { 174 // if filename is provided, set timeConfig to this value 175 if (filename) { 176 psFree(timeConfig); 177 timeConfig = psStringCopy(filename); 178 psMemSetPersistent(timeConfig, true); 179 return timeConfig; 180 } 181 182 // check the env var first 183 const char *PS_CONFIG_FILE = getenv("PS_CONFIG_FILE"); 184 if (PS_CONFIG_FILE) { 185 return PS_CONFIG_FILE; 186 } 187 188 // check timeConfig var 2nd 189 if (timeConfig) { 190 return timeConfig; 191 } 192 193 // fall back to the default, this should come from configure.ac 194 return PS_CONFIG_FILE_DEFAULT; 176 195 } 177 196 … … 191 210 192 211 // Check if psTime tables are already loaded 193 if(!p_psTimeInit(p_psTimeConfigFile Name())) {212 if(!p_psTimeInit(p_psTimeConfigFilename(NULL))) { 194 213 *status = PS_LOOKUP_ERROR; 195 214 return NAN; … … 269 288 } 270 289 290 // XXX this is not thread safe as the persistence setting is global 271 291 const bool initialPersistence = 272 292 p_psMemAllocatePersistent(true); // All memory allocated below is "persistent" … … 881 901 if((bulletin != PS_IERS_A) && (bulletin != PS_IERS_B)) { 882 902 psError(PS_ERR_BAD_PARAMETER_VALUE,true,"Invalid bulletin specified %d",bulletin); 903 return NAN; 904 } 905 906 // Check if psTime tables are already loaded 907 if(!p_psTimeInit(p_psTimeConfigFilename(NULL))) { 908 psError(PS_ERR_UNKNOWN, true, "failed to init time tables."); 883 909 return NAN; 884 910 } … … 1065 1091 } 1066 1092 1093 // Check if psTime tables are already loaded 1094 if(!p_psTimeInit(p_psTimeConfigFilename(NULL))) { 1095 psError(PS_ERR_UNKNOWN, true, "failed to init time tables."); 1096 return NULL; 1097 } 1098 1067 1099 // Attempt to find value through table lookup and interpolation 1068 1100 mjd = psTimeToMJD(time); … … 1194 1226 1195 1227 // Check if psTime tables are loaded/loadable 1196 if (!p_psTimeInit(p_psTimeConfigFileName())) {1228 if (!p_psTimeInit(p_psTimeConfigFilename(NULL))) { 1197 1229 psError(PS_ERR_BAD_PARAMETER_VALUE, true, _("Failed to open file %s."), 1198 p_psTimeConfigFile Name());1230 p_psTimeConfigFilename(NULL)); 1199 1231 return NAN; 1200 1232 } … … 1712 1744 // Error checks 1713 1745 PS_ASSERT_PTR_NON_NULL(time,NULL); 1714 PS_ASSERT_INT_WITHIN_RANGE(time->nsec, 0,(psU32)((1e9)-1),NULL);1746 PS_ASSERT_INT_WITHIN_RANGE(time->nsec, (psU32)0, (psU32)((1e9)-1), NULL); 1715 1747 1716 1748 // Convert time to TAI if necessary, but without changing input arguments … … 1796 1828 } 1797 1829 1798 void psTimeInitialize(const char *timeConfig) 1799 { 1800 p_psTimeInit(timeConfig); 1830 // delay actual init until a timefunction is used 1831 bool psTimeInit(const char *filename) 1832 { 1833 // at present, this function can not fail 1834 p_psTimeConfigFilename(filename); 1835 1836 return true; 1801 1837 } 1802 1838 -
trunk/psLib/src/astro/psTime.h
r11668 r13950 11 11 * @author Ross Harman, MHPCC 12 12 * 13 * @version $Revision: 1.5 5$ $Name: not supported by cvs2svn $14 * @date $Date: 2007-0 2-06 21:36:09$13 * @version $Revision: 1.56 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2007-06-22 02:28:48 $ 15 15 * 16 16 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 75 75 76 76 77 // get the pslib.config filename by checking environment variable first, then original installation area.78 const char *p_psTimeConfigFileName();79 80 81 77 /** Initialize time data. 82 78 * 83 * Reads config and data files associated with various time conversions. 84 * 85 * @return bool: True for success, false for failure. 86 */ 87 bool p_psTimeInit( 88 const char *fileName ///< File name containing config/data info 89 ); 90 91 /** Initialize time data. 92 * 93 * Reads the configuration file and sets up the appropriate psTimeTables and predictions. 94 */ 95 void psTimeInitialize( 96 const char *timeConfig ///< psTime configuration file 97 ); 98 99 /** Free memory persistant time data. 100 * 101 * Frees time data to be held in memory until the end of successful program execution. 102 * 103 * @return void: void. 104 */ 79 * Sets the configuration file and sets up the appropriate psTimeTables and predictions. 80 */ 81 bool psTimeInit( 82 const char *filename ///< psTime configuration file 83 ); 84 85 86 /** Frees memory that was allocated by psTime functions. 87 * 88 * Allows a subsequent search for leaked memory. 89 * 90 * @return true on sucess. 91 */ 105 92 bool p_psTimeFinalize(void); 106 93 … … 476 463 ); 477 464 465 // used by p_psEOCInit() 466 const char *p_psTimeConfigFilename(const char *filename); 467 478 468 /// @} 479 469 -
trunk/psLib/src/sys/psConfigure.c
r12757 r13950 13 13 * @author Robert DeSonia, MHPCC 14 14 * 15 * @version $Revision: 1.2 4$ $Name: not supported by cvs2svn $16 * @date $Date: 2007-0 4-06 00:04:15$15 * @version $Revision: 1.25 $ $Name: not supported by cvs2svn $ 16 * @date $Date: 2007-06-22 02:28:48 $ 17 17 * 18 18 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 26 26 #include <stdlib.h> 27 27 #include <string.h> 28 29 #include "psAbort.h" 28 30 #include "psTrace.h" 29 31 #include "psString.h" … … 94 96 95 97 96 voidpsLibInit(const char* timeConfig)98 bool psLibInit(const char* timeConfig) 97 99 { 98 100 // XXX: Still needs error codes to be set 99 101 100 102 if (timeConfig && strlen(timeConfig) > 0) { 101 if (!p _psTimeInit(timeConfig)) {103 if (!psTimeInit(timeConfig)) { 102 104 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 103 105 _("Failed to initialize %s."), "psTime"); 104 return ;106 return false; 105 107 } 106 108 } … … 111 113 atexit(&p_psMemoryCheck); 112 114 } 115 116 return true; 113 117 } 114 118 … … 122 126 // Free the time tables 123 127 if (!p_psTimeFinalize()) { 124 psError(PS_ERR_UNKNOWN, false, 125 _("Failed to finalize %s."), "psTime"); 126 return; 128 psAbort(_("Failed to finalize psTime.")); 127 129 } 128 130 129 131 // Free the precession tables 130 132 if (!p_psEOCFinalize()) { 131 psError(PS_ERR_UNKNOWN, false, 132 _("Failed to finalize %s."), "psEOC"); 133 return; 133 psAbort(_("Failed to finalize psEOC.")); 134 134 } 135 135 … … 139 139 // Free the error system 140 140 psErrorClear(); 141 142 141 } -
trunk/psLib/src/sys/psConfigure.h
r11694 r13950 11 11 * @author Robert DeSonia, MHPCC 12 12 * 13 * @version $Revision: 1.1 1$ $Name: not supported by cvs2svn $14 * @date $Date: 2007-0 2-08 01:59:28 $13 * @version $Revision: 1.12 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2007-06-22 02:28:48 $ 15 15 * 16 16 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 50 50 * 51 51 */ 52 voidpsLibInit(52 bool psLibInit( 53 53 const char* timeConfig ///< Filename of config file for psTime. 54 54 );
Note:
See TracChangeset
for help on using the changeset viewer.
