MISR Toolkit
1.5.1
odl
wrtsrc.c
Go to the documentation of this file.
1
/*****************************************************************************
2
3
WriteSource: Writes the text of a PDS label to a file with line numbers.
4
5
Input:
6
source_file - Pointer to the file descriptor for the source file
7
containing the label to be printed.
8
output_file - Pointer to the file descriptor for the output file.
9
10
Output: No function value is returned. The text of the label with
11
line numbers is written using output routine ODLWriteStmt.
12
13
Author: Randy Davis, University of Colorado LASP
14
15
Creation Date: 18 May 1991
16
17
History:
18
19
Creation - This routine was introduced in Version 2.1 of the ODLC library.
20
21
Version 2.2 - 18 May 1991 - M. DeMore, Jet Propulsion Laboratory
22
a) Removed include statements that were Unix specific and placed them
23
in odldef.h. Removed prototypes of ODL functions and added include
24
file odlinter.h.
25
b) Corrected argument declarations from FILE to FILE *.
26
27
Version 2.3 - 6 February 1991 - M. DeMore, Jet Propulsion Laboratory
28
a) Changed line number count to long int for PC.
29
****************************************************************************/
30
31
#include "
odldef.h
"
32
#include "
odlinter.h
"
33
34
/* The following define the maximum number of characters in a source line,
35
the width of the line number, and the maximum length of an output line */
36
37
#define MAXSRCLINE 132
38
#define LINOWIDTH 5
39
#define MAXOUTLINE MAXSRCLINE+LINOWIDTH+1
40
41
42
void
WriteSource
(
43
44
/* >>>>>>>>>>>>>>>>>>>>>>>>>> BEGIN CN CHANGES >>>>>>>>>>>>>>>>>>>>>>>>> */
45
/* >>>>> MDD 4/30/91 Changed FILE to FILE * >>>>> */
46
/* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> */
47
48
FILE *source_file,
49
FILE *output_file)
50
51
/* >>>>>>>>>>>>>>>>>>>>>>>>>> END OF CN CHANGES >>>>>>>>>>>>>>>>>>>>>>>> */
52
{
53
char
src_line[
MAXSRCLINE
];
/* Buffer to hold input line of the label */
54
char
out_line[
MAXOUTLINE
];
/* Buffer to hold output line */
55
long
line_no;
/* Line number */
56
57
line_no = 0;
58
59
while
(fgets (src_line,
MAXSRCLINE
, source_file) != NULL)
60
{
61
/* Increment the line number, convert it to a character string
62
representation and place in line buffer */
63
64
line_no++;
65
sprintf (out_line,
"%0*ld %s"
,
LINOWIDTH
, line_no, src_line);
66
ODLWriteStmt
(output_file, out_line);
67
68
/* See if we have hit the END statement yet and if so, stop
69
processing */
70
71
if
(strcmp (src_line,
"END\n"
) == 0)
72
{
73
break
;
74
}
75
}
76
77
return
;
78
}
WriteSource
void WriteSource(FILE *source_file, FILE *output_file)
Definition:
wrtsrc.c:42
MAXOUTLINE
#define MAXOUTLINE
Definition:
wrtsrc.c:39
odldef.h
ODLWriteStmt
void ODLWriteStmt()
odlinter.h
LINOWIDTH
#define LINOWIDTH
Definition:
wrtsrc.c:38
MAXSRCLINE
#define MAXSRCLINE
Definition:
wrtsrc.c:37
MISR Toolkit - Copyright © 2005 - 2020 Jet Propulsion Laboratory
Generated on Fri Jun 19 2020 22:49:51