1 /*
2 
3 -Procedure kdata_c ( Kernel Data )
4 
5 -Abstract
6 
7    Return data for the nth kernel that is among a list of specified
8    kernel types.
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    None.
38 
39 -Keywords
40 
41    KERNEL
42 
43 */
44 
45    #include "SpiceUsr.h"
46    #include "SpiceZfc.h"
47    #include "SpiceZst.h"
48    #include "SpiceZmc.h"
49 
50 
kdata_c(SpiceInt which,ConstSpiceChar * kind,SpiceInt fillen,SpiceInt typlen,SpiceInt srclen,SpiceChar * file,SpiceChar * filtyp,SpiceChar * source,SpiceInt * handle,SpiceBoolean * found)51    void kdata_c ( SpiceInt          which,
52                   ConstSpiceChar  * kind,
53                   SpiceInt          fillen,
54                   SpiceInt          typlen,
55                   SpiceInt          srclen,
56                   SpiceChar       * file,
57                   SpiceChar       * filtyp,
58                   SpiceChar       * source,
59                   SpiceInt        * handle,
60                   SpiceBoolean    * found  )
61 /*
62 
63 -Brief_I/O
64 
65    VARIABLE  I/O  DESCRIPTION
66    --------  ---  --------------------------------------------------
67    which      I   Index of kernel to fetch from the list of kernels.
68    kind       I   The kind of kernel to which fetches are limited.
69    fillen     I   Available space in output file string.
70    typlen     I   Available space in output kernel type string.
71    srclen     I   Available space in output source string.
72    file       O   The name of the kernel file.
73    filtyp     O   The type of the kernel.
74    source     O   Name of the source file used to load file.
75    handle     O   The handle attached to file.
76    found      O   SPICETRUE if the specified file could be located.
77 
78 -Detailed_Input
79 
80    which      is the number of the kernel to fetch (matching the
81               type specified by kind) from the list of kernels that
82               have been loaded through the entry point furnsh_c but
83               that have not been unloaded through the entry point
84               unload_c.
85 
86               The range of which is 0 to count-1, where count is
87               the number of kernels loaded via furnsh_c.  This
88               count may be obtained by calling ktotal_c.  See the
89               Examples section for an illustrative code fragment.
90 
91 
92    kind       is a list of types of kernels to be considered when
93               fetching kernels from the list of loaded kernels. KIND
94               should consist of a list of words of kernels to
95               examine.  Recognized types are
96 
97                  SPK  --- All SPK files are counted in the total.
98                  CK   --- All CK files are counted in the total.
99                  PCK  --- All binary PCK files are counted in the
100                           total.
101                  DSK  --- All DSK files are counted in the total.
102                  EK   --- All EK files are counted in the total.
103                  TEXT --- All text kernels that are not meta-text
104                           kernels are included in the total.
105                  META --- All meta-text kernels are counted in the
106                           total.
107                  ALL  --- Every type of kernel is counted in the
108                           total.
109 
110                kind is case insensitive.  If a word appears in kind
111                that is not one of those listed above it is ignored.
112 
113                See the entry point ktotal_c for examples of the use
114                of kind.
115 
116    fillen      is the amount of available space in the output file
117                string, including room for the terminating null.
118                Normally, this is the declared length of the output
119                string.
120 
121    typlen      is the amount of available space in the output kernel
122                type string.
123 
124    srclen      is the amount of available space in the output kernel
125                source string.
126 
127 
128 -Detailed_Output
129 
130 
131    file        is the name of the file having index which in the
132                sequence of files of type kind currently loaded via
133                furnsh_c.  file will be blank if there is no such kernel
134                is loaded.
135 
136    filtyp      is the type of the kernel specified by file.  filtyp
137                will be empty if there is no file matching the
138                specification of which and kind.
139 
140    source      is the name of the source file that was used to
141                specify file as one to load.  If file was loaded
142                directly via a call to furnsh_c, source will be empty.
143                If there is no file matching the specification of
144                which and kind, source will be empty.
145 
146    handle      is the handle attached to file if it is a binary
147                kernel.  If file is a text kernel or meta-text kernel
148                handle will be zero.  If there is no file matching
149                the specification of which and kind, handle will be
150                set to zero.
151 
152    found       is returned SPICETRUE if a file matching the
153                specification of which and kind exists.  If there is no
154                such file, found will be set to SPICEFALSE.
155 
156 -Parameters
157 
158    None.
159 
160 -Exceptions
161 
162    1) If a file is not loaded matching the specification of which
163       and kind, found will be SPICEFALSE; file, filtyp, and source
164       will be empty and handle will be set to zero.
165 
166    2) If any input or output character argument pointer is null, the
167       error SPICE(NULLPOINTER) will be signaled.
168 
169    3) If any of the output string length arguments are less than 1, the
170       error SPICE(STRINGTOOSHORT) will be signaled.
171 
172    4) If any output string has length at least 1 but is too short to
173       contain the output string, the corresponding is truncated on the
174       right.  The output string is still null-terminated.
175 
176 -Files
177 
178    None.
179 
180 -Particulars
181 
182    This entry point allows you to determine which kernels have
183    been loaded via furnsh_c and to obtain information sufficient
184    to directly query those files.
185 
186 -Examples
187 
188    The following example shows how you could print a summary
189    of SPK files that have been loaded through the interface
190    furnsh_c.
191 
192       #include <stdio.h>
193       #include "SpiceUsr.h"
194 
195       #define  FILLEN   256
196       #define  TYPLEN   33
197       #define  SRCLEN   256
198 
199       SpiceInt        which;
200       SpiceInt        count;
201       SpiceInt        handle;
202 
203       SpiceChar       file  [FILLEN];
204       SpiceChar       filtyp[TYPLEN];
205       SpiceChar       source[SRCLEN];
206 
207       SpiceBoolean    found;
208 
209       int main()
210          {
211          furnsh_c( "standard.tm" );
212 
213          ktotal_c ( "spk", &count );
214 
215          if ( count == 0 )
216             {
217             printf ( "No SPK files loaded at this time.\n" );
218             }
219          else
220             {
221             printf ( "The loaded SPK files are: \n\n" );
222             }
223 
224          for ( which = 0;  which < count;  which++ )
225             {
226             kdata_c ( which,  "spk",    FILLEN,   TYPLEN, SRCLEN,
227                       file,   filtyp,  source,  &handle,  &found );
228             printf ( "%s\n",  file   );
229             }
230 
231          }
232 
233 -Restrictions
234 
235    None.
236 
237 -Literature_References
238 
239    None.
240 
241 -Author_and_Institution
242 
243    N.J. Bachman    (JPL)
244    W.L. Taber      (JPL)
245    E.D. Wright     (JPL)
246 
247 -Version
248 
249    -CSPICE Version 1.1.4, 20-JAN-2016 (NJB)
250 
251       Updated header to reflect support for use of DSKs.
252       Made minor updates to example program. Added
253       Ed Wright as an author of this routine.
254 
255    -CSPICE Version 1.1.3, 02-MAY-2008 (EDW)
256 
257       standard.ker renamed standard.tm
258 
259    -CSPICE Version 1.1.2, 05-SEP-2007 (EDW)
260 
261       Expanded Examples section to a full, compilable program.
262 
263    -CSPICE Version 1.1.1, 29-DEC-2004 (LSE)
264 
265       Corrected example code to match routine's argument list.
266       (2 arguments reversed)
267 
268    -CSPICE Version 1.1.0, 02-FEB-2003 (EDW)
269 
270       Corrected example code to match routine's argument list.
271 
272    -CSPICE Version 1.0.0, 12-SEP-1999 (NJB) (WLT)
273 
274 -Index_Entries
275 
276    Retrieve information on loaded SPICE kernels
277 
278 -&
279 */
280 
281 { /* Begin kdata_c */
282 
283 
284    /*
285    Local variables
286    */
287    logical                 fnd;
288 
289 
290    /*
291    Participate in error tracing.
292    */
293    chkin_c ( "kdata_c" );
294 
295 
296    /*
297    Check the input string kind to make sure the pointer is non-null
298    and the string length is non-zero.
299    */
300    CHKFSTR ( CHK_STANDARD, "kdata_c", kind );
301 
302 
303    /*
304    Make sure the output string file has at least enough room for one
305    output character and a null terminator.  Also check for a null
306    pointer.
307    */
308    CHKOSTR ( CHK_STANDARD, "kdata_c", file, fillen );
309 
310 
311    /*
312    Make sure the output string filtyp has at least enough room for one
313    output character and a null terminator.  Also check for a null
314    pointer.
315    */
316    CHKOSTR ( CHK_STANDARD, "kdata_c", filtyp, typlen );
317 
318 
319    /*
320    Make sure the output string source has at least enough room for one
321    output character and a null terminator.  Also check for a null
322    pointer.
323    */
324    CHKOSTR ( CHK_STANDARD, "kdata_c", source, srclen );
325 
326 
327    /*
328    Map the input index from C to Fortran style.
329    */
330 
331    which++;
332 
333 
334    /*
335    Call the f2c'd routine.
336    */
337    kdata_ (  ( integer   * ) &which,
338              ( char      * ) kind,
339              ( char      * ) file,
340              ( char      * ) filtyp,
341              ( char      * ) source,
342              ( integer   * ) handle,
343              ( logical   * ) &fnd,
344              ( ftnlen      ) strlen(kind),
345              ( ftnlen      ) fillen-1,
346              ( ftnlen      ) typlen-1,
347              ( ftnlen      ) srclen-1     );
348 
349 
350    /*
351    Convert the output strings from Fortran style to C style.  Set
352    the SpiceBoolean output found flag.
353    */
354    F2C_ConvertStr( fillen, file   );
355    F2C_ConvertStr( typlen, filtyp );
356    F2C_ConvertStr( srclen, source );
357 
358    *found = fnd;
359 
360 
361    chkout_c ( "kdata_c" );
362 
363 } /* End kdata_c */
364