1 /*
2 
3 -Procedure spkopa_c ( SPK open for addition )
4 
5 -Abstract
6 
7   Open an existing SPK file for subsequent write.
8 
9 -Disclaimer
10 
11    THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
12    CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
13    GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
14    ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
15    PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
16    TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
17    WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
18    PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
19    SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
20    SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
21 
22    IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
23    BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
24    LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
25    INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
26    REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
27    REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
28 
29    RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
30    THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
31    CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
32    ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
33 
34 -Required_Reading
35 
36    SPK
37 
38 -Keywords
39 
40    SPK
41 
42 */
43 
44    #include "SpiceUsr.h"
45    #include "SpiceZfc.h"
46    #include "SpiceZmc.h"
47 
spkopa_c(ConstSpiceChar * file,SpiceInt * handle)48    void spkopa_c ( ConstSpiceChar * file,
49                    SpiceInt       * handle )
50 
51 /*
52 
53 -Brief_I/O
54 
55    VARIABLE  I/O  DESCRIPTION
56    --------  ---  --------------------------------------------------
57    file       I   The name of an existing SPK file.
58    handle     O   A handle attached to the SPK file opened to append.
59 
60 -Detailed_Input
61 
62    file       is the name of an existing SPK file to which
63               you wish to append additional SPK segments.
64 
65 -Detailed_Output
66 
67    handle     is the DAF integer handle that refers to the SPK file
68               opened for appending.
69 
70 -Parameters
71 
72    None.
73 
74 -Files
75 
76    See arguments file and handle.
77 
78 -Exceptions
79 
80    1)  If the file specified does not exist the error
81        SPICE(FILENOTFOUND) will be signalled.
82 
83    2)  If the file specified is not an SPK file, the error
84        SPICE(FILEISNOTSPK) will be signalled.
85 
86    3)  If the string pointer file is null, the error
87        SPICE(NULLPOINTER) will be signaled.
88 
89    4)  If the string file has length zero, the error
90        SPICE(EMPTYSTRING) will be signaled.
91 
92    All other exceptions are determined by routines in the call
93    tree of this routine. If any exceptions arise that prevent
94    opening of the specified file for writing, HANDLE will be
95    returned with the value 0.
96 
97 -Particulars
98 
99    This file provides an interface for opening existing SPK
100    files for the addition of SPK segments.  If you need
101    to open an new SPK file for writing, call the routine SPKOPN.
102 
103 -Examples
104 
105    Suppose you have collected data for a type 05 SPK segment and
106    wish to place the new segment in an existing SPK file.  The
107    code fragment below shows one set of calls that you could perform
108    to make the addition.  (Note that you could add segments of
109    other data types by replacing the call to spkw05_c with a suitably
110    modified call to another spkwXX_c routine.)
111 
112    We assume that the following variables have already been
113    assigned the proper values:
114 
115       body   (integer)  Body code for ephemeris object.
116       center (integer)  body code for the center of motion
117                         of the body.
118       frame  (string)   the reference frame of the states.
119       first  (d.p.)     first valid time for which states can be
120                         computed in seconds past 2000.
121       last   (d.p.)     last valid time for which states can
122                         be computed in seconds past 2000.
123       gm     (d.p.)     gravitational mass of central body.
124       n      (integer)  number of states and epochs.
125       states (d.p.)     array of states (x,y,z,dx,dy,dz).
126       epochs (d.p.)     array of epochs (seconds past 2000.)
127       segid  (string)   segment identifier
128 
129 
130       #include "SpiceUsr.h"
131          .
132          .
133          .
134 
135       /.
136       Begin by opening the file.
137       ./
138       spkopa_c ( file, &handle );
139 
140       /.
141       Now add the collected data as a new segment.
142       ./
143 
144       spkw05_c ( handle, body,  center, frame,  first, last, segid,
145                  gm,     n,     states, epochs                      );
146 
147       /.
148       Finally, close the file.
149       ./
150 
151       spkcls_c ( handle );
152 
153 -Restrictions
154 
155    None.
156 
157 -Author_and_Institution
158 
159    F.S. Turner        (JPL)
160 
161 -Literature_References
162 
163    None.
164 
165 -Version
166 
167    -CSPICE Version 1.0.0, 16-MAR-1999 (FST)
168 
169 -Index_Entries
170 
171    Open an existing SPK file for adding segments
172 
173 -&
174 */
175 
176 {  /* Begin spkopa_c */
177 
178    /*
179    Participate in error tracing.
180    */
181 
182    chkin_c ( "spkopa_c" );
183 
184    /*
185    Check the input string file to make sure the pointer is non-null
186    and the string length is non-zero.
187    */
188    CHKFSTR ( CHK_STANDARD, "spkopa_c", file );
189 
190    /*
191    Call the f2c'd Fortran routine.
192    */
193    spkopa_ ( ( char     * )  file,
194              ( integer  * )  handle,
195              ( ftnlen     )  strlen(file) );
196 
197    chkout_c ( "spkopa_c" );
198 
199 } /* End spkopa_c */
200