1 /* 2 3 -Procedure lmpool_c ( Load variables from memory into the pool ) 4 5 -Abstract 6 7 Load the variables contained in an internal buffer into the 8 kernel pool. 9 10 -Disclaimer 11 12 THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE 13 CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. 14 GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE 15 ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE 16 PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" 17 TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY 18 WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A 19 PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC 20 SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE 21 SOFTWARE AND RELATED MATERIALS, HOWEVER USED. 22 23 IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA 24 BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT 25 LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, 26 INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, 27 REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE 28 REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. 29 30 RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF 31 THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY 32 CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE 33 ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. 34 35 -Required_Reading 36 37 KERNEL 38 39 -Keywords 40 41 CONSTANTS 42 FILES 43 44 */ 45 46 #include "SpiceUsr.h" 47 #include "SpiceZfc.h" 48 #include "SpiceZst.h" 49 #include "SpiceZmc.h" 50 #include "SpiceZim.h" 51 #undef lmpool_c 52 53 lmpool_c(const void * cvals,SpiceInt lenvals,SpiceInt n)54 void lmpool_c ( const void * cvals, 55 SpiceInt lenvals, 56 SpiceInt n ) 57 58 /* 59 60 -Brief_I/O 61 62 VARIABLE I/O DESCRIPTION 63 -------- --- -------------------------------------------------- 64 cvals I An array that contains a SPICE text kernel. 65 lenvals I Length of strings in cvals. 66 n I The number of entries in cvals. 67 68 -Detailed_Input 69 70 cvals is an array of strings that contains lines of text 71 that could serve as a SPICE text kernel. cvals is 72 declared as follows: 73 74 ConstSpiceChar cvals [n][lenvals] 75 76 Each string in cvals is null-terminated. 77 78 lenvals is the common length of the strings in cvals, 79 including the terminating nulls. 80 81 n is the number of strings in cvals. 82 83 -Detailed_Output 84 85 None. 86 87 -Parameters 88 89 None. 90 91 -Exceptions 92 93 1) If the input string pointer is null, the error SPICE(NULLPOINTER) 94 will be signaled. 95 96 2) If the input string length lenvals is not at least 2, the error 97 SPICE(STRINGTOOLSHORT) will be signaled. 98 99 3) The error 'SPICE(BADVARNAME)' signals if a kernel pool 100 variable name length exceeds 32. 101 102 4) Other exceptions are diagnosed by routines in the call tree of 103 this routine. 104 -Files 105 106 None. 107 108 -Particulars 109 110 This routine allows you to store a text kernel in an internal 111 array of your program and load this array into the kernel pool 112 without first storing its contents as a text kernel. 113 114 Kernel pool variable names are restricted to a length of 32 115 characters or less. 116 117 -Examples 118 119 Suppose that your application is not particularly sensitive 120 to the current number of leapseconds but that you would 121 still like to use a relatively recent leapseconds kernel 122 without requiring users to load a leapseconds kernel into 123 the program. The example below shows how you might set up 124 the initialization portion of your program. 125 126 #include "SpiceUsr.h" 127 128 #define LNSIZE 81 129 #define NLINES 27 130 131 SpiceChar textbuf[NLINES][LNSIZE] = 132 { 133 "DELTET/DELTA_T_A = 32.184", 134 "DELTET/K = 1.657D-3", 135 "DELTET/EB = 1.671D-2", 136 "DELTET/M = ( 6.239996 1.99096871D-7 )", 137 "DELTET/DELTA_AT = ( 10, @1972-JAN-1", 138 " 11, @1972-JUL-1", 139 " 12, @1973-JAN-1", 140 " 13, @1974-JAN-1", 141 " 14, @1975-JAN-1", 142 " 15, @1976-JAN-1", 143 " 16, @1977-JAN-1", 144 " 17, @1978-JAN-1", 145 " 18, @1979-JAN-1", 146 " 19, @1980-JAN-1", 147 " 20, @1981-JUL-1", 148 " 21, @1982-JUL-1", 149 " 22, @1983-JUL-1", 150 " 23, @1985-JUL-1", 151 " 24, @1988-JAN-1", 152 " 25, @1990-JAN-1", 153 " 26, @1991-JAN-1", 154 " 27, @1992-JUL-1", 155 " 28, @1993-JUL-1", 156 " 29, @1994-JUL-1", 157 " 30, @1996-JAN-1", 158 " 31, @1997-JUL-1", 159 " 32, @1999-JAN-1 )" 160 }; 161 162 lmpool_c ( textbuf, LNSIZE, NLINES ); 163 164 165 -Restrictions 166 167 None. 168 169 -Literature_References 170 171 None. 172 173 -Author_and_Institution 174 175 N.J. Bachman (JPL) 176 W.L. Taber (JPL) 177 178 -Version 179 180 -CSPICE Version 1.3.1, 10-FEB-2010 (EDW) 181 182 Added mention of the restriction on kernel pool variable 183 names to 32 characters or less. 184 185 -CSPICE Version 1.3.0, 12-JUL-2002 (NJB) 186 187 Call to C2F_CreateStrArr_Sig replaced with call to C2F_MapStrArr. 188 189 -CSPICE Version 1.2.0, 28-AUG-2001 (NJB) 190 191 Const-qualified input array. 192 193 -CSPICE Version 1.1.0, 14-FEB-2000 (NJB) 194 195 Calls to C2F_CreateStrArr replaced with calls to error-signaling 196 version of this routine: C2F_CreateStrArr_Sig. 197 198 -CSPICE Version 1.0.0, 08-JUN-1999 (NJB) (WLT) 199 200 -Index_Entries 201 202 Load the kernel pool from an internal text buffer 203 204 -& 205 */ 206 207 { /* Begin lmpool_c */ 208 209 210 211 /* 212 Local variables 213 */ 214 215 SpiceChar * fCvalsArr; 216 217 SpiceInt fCvalsLen; 218 219 220 /* 221 Participate in error tracing. 222 */ 223 chkin_c ( "lmpool_c" ); 224 225 /* 226 Make sure the input string pointer is non-null and that the 227 length lenvals is sufficient. 228 */ 229 CHKOSTR ( CHK_STANDARD, "lmpool_c", cvals, lenvals ); 230 231 232 /* 233 Create a Fortran-style string array. 234 */ 235 C2F_MapStrArr ( "lmpool_c", n, lenvals, cvals, &fCvalsLen, &fCvalsArr ); 236 237 if ( failed_c() ) 238 { 239 chkout_c ( "lmpool_c" ); 240 return; 241 } 242 243 244 /* 245 Call the f2c'd routine. 246 */ 247 lmpool_ ( ( char * ) fCvalsArr, 248 ( integer * ) &n, 249 ( ftnlen ) fCvalsLen ); 250 251 252 /* 253 Free the dynamically allocated array. 254 */ 255 free ( fCvalsArr ); 256 257 chkout_c ( "lmpool_c" ); 258 259 } /* End lmpool_c */ 260 261