1 /* dasecu.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 /* Table of constant values */
9 
10 static integer c__22 = 22;
11 
12 /* $Procedure      DASECU ( DAS extract comments to a logical unit ) */
dasecu_(integer * handle,integer * comlun,logical * comnts)13 /* Subroutine */ int dasecu_(integer *handle, integer *comlun, logical *
14 	comnts)
15 {
16     extern /* Subroutine */ int dasec_(integer *, integer *, integer *, char *
17 	    , logical *, ftnlen), chkin_(char *, ftnlen);
18     extern logical failed_(void);
19     char combuf[255*22];
20     extern /* Subroutine */ int dassih_(integer *, char *, ftnlen);
21     integer numcom;
22     extern /* Subroutine */ int chkout_(char *, ftnlen), writla_(integer *,
23 	    char *, integer *, ftnlen);
24     logical gotsom;
25     extern logical return_(void);
26     logical eoc;
27 
28 /* $ Abstract */
29 
30 /*     Extract comments from a previously opened binary DAS file to a */
31 /*     previously opened text file attached to a Fortran logical unit. */
32 
33 /* $ Disclaimer */
34 
35 /*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
36 /*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
37 /*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
38 /*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
39 /*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
40 /*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
41 /*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
42 /*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
43 /*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
44 /*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
45 
46 /*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
47 /*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
48 /*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
49 /*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
50 /*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
51 /*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
52 
53 /*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
54 /*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
55 /*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
56 /*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
57 
58 /* $ Required_Reading */
59 
60 /*     None. */
61 
62 /* $ Keywords */
63 
64 /*     None. */
65 
66 /* $ Declarations */
67 /* $ Brief_I/O */
68 
69 /*     Variable  I/O  Description */
70 /*     --------  ---  -------------------------------------------------- */
71 /*      HANDLE    I   Handle of a DAS file opened with read access. */
72 /*      COMLUN    I   Logical unit of an opened text file. */
73 /*      COMNTS    O   Logical flag, indicating comments were found. */
74 
75 /* $ Detailed_Input */
76 
77 /*     HANDLE   The file handle for a binary DAS file that has been */
78 /*              opened with read access. */
79 
80 /*     COMLUN   The Fortran logical unit of a previously opened text */
81 /*              file to which the comments from a binary DAS file are */
82 /*              to be written. */
83 
84 /*              The comments will be placed into the text file beginning */
85 /*              at the current location in the file, and continuing */
86 /*              until all of the comments have been written. */
87 
88 /* $ Detailed_Output */
89 
90 /*     COMNTS   A logical flag indicating whether or not any comments */
91 /*              were found in the comment area of a DAS file. COMNTS will */
92 /*              have the value .TRUE. if there were some comments, and */
93 /*              the value .FALSE. otherwise. */
94 
95 /* $ Parameters */
96 
97 /*     None. */
98 
99 /* $ Exceptions */
100 
101 /*     1)   If an error occurs while reading from the binary DAS file */
102 /*          attached to HANDLE, a routine called by this routine will */
103 /*          signal an error. */
104 
105 /*     2)   If an error occurs while writing to the text file attached */
106 /*          to COMLUN, a routine called by this routine will signal an */
107 /*          error. */
108 
109 /* $ Files */
110 
111 /*     See parameters COMLUN and HANDLE in the $ Detailed_Inputs section. */
112 
113 /* $ Particulars */
114 
115 /*     This routine will extract all of the comments from the comment */
116 /*     area of a binary DAS file, placing them into a text file */
117 /*     attached to COMLUN, beginning at the current position in the */
118 /*     text file. If there are no comments in the DAS file, nothing is */
119 /*     written to the text file attached to COMLUN. */
120 
121 /* $ Examples */
122 
123 /*      Let */
124 
125 /*         HANDLE   be the DAS file handle of a previously opened binary */
126 /*                  DAS file. */
127 
128 /*         COMLUN   be the Fortran logical unit of a previously opened */
129 /*                  text file that is to accept the comments from the */
130 /*                  DAS comment area. */
131 
132 /*      The subroutine call */
133 
134 /*         CALL DASECU ( HANDLE, COMLUN, COMNTS ) */
135 
136 /*      will extract the comments from the comment area of the binary */
137 /*      DAS file attached to HANDLE, if there are any, and write them */
138 /*      to the logical unit COMLUN. Upun successfur completion, the */
139 /*      value of COMNTS will be .TRUE. if there were some comments */
140 /*      in the comment area and .FALSE. otherwise. */
141 
142 /* $ Restrictions */
143 
144 /*     The maximum length of a single line comment in the comment area is */
145 /*     specified by the parameter LINLEN defined below. Currently this */
146 /*     value is 255 characters. */
147 
148 /* $ Literature_References */
149 
150 /*     None. */
151 
152 /* $ Author_and_Institution */
153 
154 /*     K.R. Gehringer (JPL) */
155 
156 /* $ Version */
157 
158 /* -    Beta Version 1.0.0, 5-JAN-1993 (KRG) */
159 
160 /* -& */
161 /* $ Index_Entries */
162 
163 /*      extract comments from a DAS file to a logical unit */
164 
165 /* -& */
166 
167 /*     SPICELIB functions */
168 
169 
170 /*     Local parameters */
171 
172 /*     Set the value for the maximum length of a text line. */
173 
174 
175 /*     Set the size of the comment buffer. */
176 
177 
178 /*     Local variables */
179 
180 
181 /*     Standard SPICE error handling. */
182 
183     if (return_()) {
184 	return 0;
185     } else {
186 	chkin_("DASECU", (ftnlen)6);
187     }
188 
189 /*     Verify that the DAS file attached to HANDLE is opened for reading. */
190 
191     dassih_(handle, "READ", (ftnlen)4);
192     if (failed_()) {
193 	chkout_("DASECU", (ftnlen)6);
194 	return 0;
195     }
196 
197 /*     Initialize some things before the loop. */
198 
199     numcom = 0;
200     eoc = FALSE_;
201     gotsom = FALSE_;
202     while(! eoc) {
203 
204 /*        While we have not reached the end of the comments, get some */
205 /*        more. */
206 
207 	dasec_(handle, &c__22, &numcom, combuf, &eoc, (ftnlen)255);
208 	if (failed_()) {
209 	    chkout_("DASECU", (ftnlen)6);
210 	    return 0;
211 	}
212 	if (numcom > 0) {
213 
214 /*           If NUMCOM .GT. 0 then we did get some comments, and we need */
215 /*           to write them out, but first, set the flag indicating that */
216 /*           we got some comments. */
217 
218 	    if (! gotsom) {
219 		gotsom = TRUE_;
220 	    }
221 	    writla_(&numcom, combuf, comlun, (ftnlen)255);
222 	    if (failed_()) {
223 		chkout_("DASECU", (ftnlen)6);
224 		return 0;
225 	    }
226 	}
227     }
228 
229 /*     Set the output flag indicating whether or not we got any comments. */
230 
231     *comnts = gotsom;
232     chkout_("DASECU", (ftnlen)6);
233     return 0;
234 } /* dasecu_ */
235 
236