1 /*
2 
3 -Procedure pckopn_c ( PCK, open new file )
4 
5 -Abstract
6 
7    Create a new PCK file, returning the handle of the opened file.
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    PCK
37 
38 -Keywords
39 
40    PCK
41 
42 */
43 
44    #include "SpiceUsr.h"
45    #include "SpiceZfc.h"
46    #include "SpiceZmc.h"
47    #include "SpiceZst.h"
48 
pckopn_c(ConstSpiceChar * name,ConstSpiceChar * ifname,SpiceInt ncomch,SpiceInt * handle)49    void pckopn_c ( ConstSpiceChar   * name,
50                    ConstSpiceChar   * ifname,
51                    SpiceInt           ncomch,
52                    SpiceInt         * handle  )
53 
54 /*
55 
56 -Brief_I/O
57 
58    VARIABLE  I/O  DESCRIPTION
59    --------  ---  --------------------------------------------------
60    name       I   The name of the PCK file to be opened.
61    ifname     I   The internal filename for the PCK.
62    ncomch     I   The number of characters to reserve for comments.
63    handle     O   The handle of the opened PCK file.
64 
65 -Detailed_Input
66 
67    name     The name of the PCK file to be created.
68 
69    ifname   The internal filename for the PCK file that is being
70             created. The internal filename may be up to 60 characters
71             long. `ifname' may not contain non-printing characters;
72             otherwise there are no restrictions on its contents.
73 
74    ncomch   This is the space, measured in characters, to be
75             initially set aside for the comment area when a new PCK
76             file is opened. The amount of space actually set aside
77             may be greater than the amount requested, due to the
78             manner in which comment records are allocated in an PCK
79             file. However, the amount of space set aside for comments
80             will always be at least the amount that was requested.
81 
82             The value of ncomch should be greater than or equal to
83             zero, i.e., 0 <= ncomch. A negative value, should one
84             occur, will be assumed to be zero.
85 
86 -Detailed_Output
87 
88    handle   The handle of the opened PCK file. If an error occurs
89             when opening the file, the value of this variable should
90             not be used, as it will not represent a valid handle.
91 
92 -Parameters
93 
94    None.
95 
96 -Exceptions
97 
98    1) If the value of `ncomch' is negative, a value of zero (0) will
99       be used for the number of comment characters to be set aside
100       for comments.
101 
102    2) If an error occurs while attempting to open a CK file the
103       value of `handle' will not represent a valid file handle.
104 
105    3) If any input string pointers are null, the error
106       SPICE(NULLPOINTER) will be signaled.
107 
108    4) If any input strings have length zero, the error
109       SPICE(EMPTYSTRING) will be signaled.
110 
111 -Files
112 
113    See descriptions of `name' and `handle'.
114 
115 -Particulars
116 
117    Open a new PCK file, reserving room for comments if requested.
118 
119 -Examples
120 
121    Suppose that you want to create a new PCK file called 'new.PCK'
122    that contains a single type 2 PCK segment and has room for at
123    least 5000 comment characters. The following code fragment should
124    take care of this for you, assuming that all of the variables
125    passed to the PCK type 2 segment writer have appropriate values.
126 
127 
128       name   = "new.pck";
129       ifname = "Test PCK file";
130 
131       pckopn_c ( name, ifname, 5000, &handle );
132 
133       pckw02_c ( handle, body,   frame_c, first,   last,
134                  segid,  intlen, n,       polydg,  cdata,
135                  btime                                   );
136 
137       pckcls_c ( handle );
138 
139 
140 -Restrictions
141 
142    None.
143 
144 -Literature_References
145 
146     None.
147 
148 -Author_and_Institution
149 
150     N.J. Bachman      (JPL)
151     K.R. Gehringer    (JPL)
152 
153 -Version
154 
155    -CSPICE Version 1.0.0, 16-DEC-2016 (NJB) (KRG)
156 
157 -Index_Entries
158 
159    open a new pck file
160 
161 -&
162 */
163 
164 { /* Begin pckopn_c */
165 
166 
167    /*
168    Participate in error tracing.
169    */
170    chkin_c ( "pckopn_c" );
171 
172    /*
173    Check the input string name to make sure the pointer is non-null
174    and the string length is non-zero.
175    */
176    CHKFSTR ( CHK_STANDARD, "pckopn_c", name );
177 
178    /*
179    Check the input string ifname to make sure the pointer is
180    non-null and the string length is non-zero.
181    */
182    CHKFSTR ( CHK_STANDARD, "pckopn_c", ifname );
183 
184 
185    /*
186    Call the f2c'd Fortran routine.
187    */
188    pckopn_ ( (char       *) name,
189              (char       *) ifname,
190              (integer    *) &ncomch,
191              (integer    *) handle,
192              (ftnlen      ) strlen(name),
193              (ftnlen      ) strlen(ifname) );
194 
195 
196    chkout_c ( "pckopn_c" );
197 
198 } /* End pckopn_c */
199