1 /* dasdc.f -- translated by f2c (version 19980913).
2    You must link the resulting object file with the libraries:
3 	-lf2c -lm   (in that order)
4 */
5 
6 #include "f2c.h"
7 
8 /* $Procedure      DASDC    ( DAS delete comments ) */
dasdc_(integer * handle)9 /* Subroutine */ int dasdc_(integer *handle)
10 {
11     extern /* Subroutine */ int chkin_(char *, ftnlen);
12     integer ncomc, ncomr;
13     extern logical failed_(void);
14     char ifname[60];
15     extern /* Subroutine */ int dassih_(integer *, char *, ftnlen), dasrcr_(
16 	    integer *, integer *), dasrfr_(integer *, char *, char *, integer
17 	    *, integer *, integer *, integer *, ftnlen, ftnlen), daswfr_(
18 	    integer *, char *, char *, integer *, integer *, integer *,
19 	    integer *, ftnlen, ftnlen);
20     char idword[8];
21     extern /* Subroutine */ int chkout_(char *, ftnlen);
22     integer nresvc;
23     extern logical return_(void);
24     integer nresvr;
25 
26 /* $ Abstract */
27 
28 /*     Delete the entire comment area of a previously opened binary */
29 /*     DAS file. */
30 
31 /* $ Disclaimer */
32 
33 /*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
34 /*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
35 /*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
36 /*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
37 /*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
38 /*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
39 /*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
40 /*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
41 /*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
42 /*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
43 
44 /*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
45 /*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
46 /*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
47 /*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
48 /*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
49 /*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
50 
51 /*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
52 /*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
53 /*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
54 /*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
55 
56 /* $ Required_Reading */
57 
58 /*     DAS */
59 
60 /* $ Keywords */
61 
62 /*     None. */
63 
64 /* $ Declarations */
65 /* $ Brief_I/O */
66 
67 /*     Variable  I/O  Description */
68 /*     --------  ---  -------------------------------------------------- */
69 /*     HANDLE     I   The handle of a binary DAS file opened for writing. */
70 
71 /* $ Detailed_Input */
72 
73 /*     HANDLE    The handle of a binary DAS file that is to have its */
74 /*               entire comment area deleted. The DAS file should have */
75 /*               been opened with write access. */
76 
77 /* $ Detailed_Output */
78 
79 /*     None. */
80 
81 /* $ Parameters */
82 
83 /*     None. */
84 
85 /* $ Exceptions */
86 
87 /*     1)   If the binary DAS file attached to HANDLE is not open with */
88 /*          write access, an error will be signalled by a routine called */
89 /*          by this routine. */
90 
91 /* $ Files */
92 
93 /*     See argument HANDLE in $ Detailed_Input. */
94 
95 /* $ Particulars */
96 
97 /*     Binary DAS files contain an area which is reserved for storing */
98 /*     annotations or descriptive textual information about the data */
99 /*     contained in a file. This area is referred to as the ``comment */
100 /*     area'' of the file. The comment area of a DAS file is a line */
101 /*     oriented medium for storing textual information. The comment area */
102 /*     preserves any leading or embedded white space in the line(s) of */
103 /*     text which are stored, so that the appearance of the information */
104 /*     will be unchanged when it is retrieved (extracted) at some other */
105 /*     time. Trailing blanks, however, are NOT preserved, due to the way */
106 /*     that character strings are represented in standard Fortran 77. */
107 
108 /*     This routine will delete the entire comment area from the binary */
109 /*     DAS file attached to HANDLE. The size of the binary DAS file will */
110 /*     remain unchanged. The space that was used by the comment records */
111 /*     is reclaimed. */
112 
113 /* $ Examples */
114 
115 /*     Let */
116 
117 /*           HANDLE   be the handle for a DAS file which has been opened */
118 /*                    with write access. */
119 
120 /*     The call */
121 
122 /*           CALL DASDC ( HANDLE ) */
123 
124 /*     will delete the entire comment area of the binary DAS file */
125 /*     attached to HANDLE. */
126 
127 /* $ Restrictions */
128 
129 /*     None. */
130 
131 /* $ Literature_References */
132 
133 /*     None. */
134 
135 /* $ Author_and_Institution */
136 
137 /*     K.R. Gehringer (JPL) */
138 
139 /* $ Version */
140 
141 /* -    SPICELIB Version 1.0.2, 11-NOV-2016 (NJB) */
142 
143 /*        Fixed typo in Particulars header section. */
144 
145 /* -    SPICELIB Version 1.0.1, 26-OCT-1993 (KRG) */
146 
147 /*        Changed the $Brief_I/O description of handle. It now mentions */
148 /*        that the file must be open for writing. Also added a statement */
149 /*        to the $ Detailed_Input section to the effect that the DAS file */
150 /*        should have been opened with write access. */
151 
152 /* -    SPICELIB Version 1.0.0, 24-NOV-1992 (KRG) */
153 
154 /* -& */
155 /* $ Index_Entries */
156 
157 /*      delete das comment area */
158 
159 /* -& */
160 /* $ Revisions */
161 
162 /* -    SPICELIB Version 1.0.1, 26-OCT-1993 (KRG) */
163 
164 /*        Changed the $Brief_I/O description of handle. It now mentions */
165 /*        that the file must be open for writing. Also added a statement */
166 /*        to the $ Detailed_Input section to the effect that the DAS file */
167 /*        should have been opened with write access. */
168 
169 /* -    SPICELIB Version 1.0.0, 24-NOV-1992 (KRG) */
170 
171 /* -& */
172 
173 /*     SPICELIB functions */
174 
175 
176 /*     Local parameters */
177 
178 /*     Length of a DAS file ID word. */
179 
180 
181 /*     Length of a DAS file internal filename. */
182 
183 
184 /*     Local variables */
185 
186 
187 /*     Standard SPICE error handling. */
188 
189     if (return_()) {
190 	return 0;
191     } else {
192 	chkin_("DASDC", (ftnlen)5);
193     }
194 
195 /*     Verify that the DAS file attached to HANDLE is opened with write */
196 /*     access. */
197 
198     dassih_(handle, "WRITE", (ftnlen)5);
199     if (failed_()) {
200 	chkout_("DASDC", (ftnlen)5);
201 	return 0;
202     }
203 
204 /*     Read the file record to obtain the current number of comment */
205 /*     records in the DAS file attached to HANDLE. We will also get */
206 /*     back some extra stuff that we do not use. */
207 
208     dasrfr_(handle, idword, ifname, &nresvr, &nresvc, &ncomr, &ncomc, (ftnlen)
209 	    8, (ftnlen)60);
210     if (failed_()) {
211 	chkout_("DASDC", (ftnlen)5);
212 	return 0;
213     }
214 
215 /*     Now we will attempt to remove the comment records, if there are */
216 /*     any, otherwise we do nothing. */
217 
218     if (ncomr > 0) {
219 	dasrcr_(handle, &ncomr);
220 	if (failed_()) {
221 	    chkout_("DASDC", (ftnlen)5);
222 	    return 0;
223 	}
224 
225 /*        Now we need to update the DAS file record. */
226 
227 /*        Read in the updated file record since it has been modified: */
228 /*        we deleted all of the comment records. */
229 
230 	dasrfr_(handle, idword, ifname, &nresvr, &nresvc, &ncomr, &ncomc, (
231 		ftnlen)8, (ftnlen)60);
232 	if (failed_()) {
233 	    chkout_("DASDC", (ftnlen)5);
234 	    return 0;
235 	}
236 
237 /*        Zero out the number of comment characters, and write the */
238 /*        updated file record to the file. */
239 
240 	ncomc = 0;
241 	daswfr_(handle, idword, ifname, &nresvr, &nresvc, &ncomr, &ncomc, (
242 		ftnlen)8, (ftnlen)60);
243 	if (failed_()) {
244 	    chkout_("DASDC", (ftnlen)5);
245 	    return 0;
246 	}
247     }
248 
249 /*     We're done now, so goodbye. */
250 
251     chkout_("DASDC", (ftnlen)5);
252     return 0;
253 } /* dasdc_ */
254 
255