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