MISR Toolkit
1.5.1
odl
rdlabel.c
Go to the documentation of this file.
1
/*****************************************************************************
2
3
Routine: ReadLabel
4
5
Description: Reads in a PDS label and places the label information
6
into an ODL tree.
7
8
Input:
9
input_file - Pointer to the file containing the label.
10
root - Pointer to the root node on the ODL parse tree.
11
12
Output: A value of one is returned as the function value if parsing was
13
completed successfully; otherwise a value of zero is returned
14
and an summary of errors and warnings is given.
15
16
Author: Randy Davis, University of Colorado LASP
17
18
Creation Date: 20 March 1989
19
Last Modified: 18 May 1991
20
21
History:
22
23
Creation - This routine was part of Version 1 of the ODLC library.
24
25
Version 2.0 - 10 October 1990 - R. Davis, U. of Colorado LASP
26
a) Modified to be compatible with Version 2 data structures.
27
b) Changed to use ODLPrintError for output rather than putting
28
error messages direct to the terminal.
29
c) Moved global variable definitions to the parser action module.
30
31
Version 2.1 - 13 March 1991, R. Davis, U. of Colorado LASP
32
a) Set the new global variable ODLlinenumber_flag to TRUE to
33
indicate that line numbers should be included in any
34
error or warning messages.
35
36
Version 2.2 - 18 May 1991 - M. DeMore, Jet Propulsion Laboratory
37
a) Removed include statements that were Unix specific and placed them
38
in odldef.h. Added include file odlinter.h.
39
b) Added pds_line_offset to line number to account for SFDU skipping.
40
41
*****************************************************************************/
42
43
#include "
odldef.h
"
44
#include "
odlinter.h
"
45
46
/* The following statements duplicate two lexical analyzer constants for
47
use in this module */
48
49
#define YYLMAX BUFSIZ
50
#define YYNEWLINE 10
51
52
/* The following variables are defined in the module containing the
53
parser action routines. */
54
55
extern
AGGREGATE
ODLroot_node
;
/* Pointer to root node of ODL tree */
56
extern
AGGREGATE
ODLcurrent_aggregate
;
/* Pointer to current aggregate node*/
57
58
/* The following variables are defined with the output routines
59
ODLPrintError and ODLPrintWarning */
60
61
extern
int
ODLerror_count
;
/* Cumulative count of errors */
62
extern
int
ODLwarning_count
;
/* Cumulative count of warnings */
63
extern
int
ODLlinenumber_flag
;
/* Controls output of line nos. */
64
65
/* The following variables are defined in the lexical analyzer module */
66
67
extern
FILE *
yyin
;
/* Pointer to file for parser input */
68
extern
FILE *
yyout
;
/* Pointer to file for parser output */
69
70
extern
char
yysbuf
[
YYLMAX
];
/* Lexical analysis rescan buffer */
71
extern
char
*
yysptr
;
/* Pointer into lexical rescan buffer */
72
73
extern
int
yylineno
;
/* Current input line number */
74
extern
int
yyprevious
;
/* Previous lexical analysis state */
75
76
#ifdef PDS_TOOLBOX
77
78
extern
int
pds_line_offset;
/* SFDU offset for PDS toolbox */
79
80
#endif
81
82
int
ReadLabel
(
83
84
FILE *input_file,
85
AGGREGATE
root)
86
87
{
88
char
warning[120];
/* String to contain warning message */
89
90
91
/* Set pointers for the files to be used by the parser */
92
93
yyin
= input_file;
94
yyout
= NULL;
95
96
/* Reset other variables used by the lexical analyzer */
97
98
yyprevious
=
YYNEWLINE
;
99
yysptr
=
yysbuf
;
100
yylineno
= 1;
101
102
#ifdef PDS_TOOLBOX
103
104
yylineno
+= pds_line_offset;
105
106
#endif
107
108
/* Initialize the error and warning counters and indicate that line
109
numbers are to appear in all error and warning messages */
110
111
ODLerror_count
= 0;
112
ODLwarning_count
= 0;
113
ODLlinenumber_flag
= 1;
114
115
/* Initialize the node pointers */
116
117
ODLroot_node = root;
118
ODLcurrent_aggregate = root;
119
120
/* Call the parser to read in and process the label */
121
122
if
(
yyparse
() != 0)
123
{
124
sprintf (warning,
125
"Label reading complete with %d errors, %d warnings."
,
126
ODLerror_count
,
127
ODLwarning_count
);
128
ODLPrintWarning
(warning);
129
return
(0);
130
}
131
else
132
{
133
return
(1);
134
}
135
}
ReadLabel
int ReadLabel(FILE *input_file, AGGREGATE root)
Definition:
rdlabel.c:82
YYLMAX
#define YYLMAX
Definition:
rdlabel.c:49
yyprevious
int yyprevious
Definition:
lexan.c:1960
ODLwarning_count
int ODLwarning_count
Definition:
output.c:59
ODLcurrent_aggregate
AGGREGATE ODLcurrent_aggregate
Definition:
parsact.c:56
odldef.h
yyin
FILE * yyin
Definition:
lexan.c:20
yysbuf
char yysbuf[YYLMAX]
yyparse
int yyparse()
Definition:
parser.c:408
ODLroot_node
AGGREGATE ODLroot_node
Definition:
parsact.c:55
ODLlinenumber_flag
int ODLlinenumber_flag
Definition:
output.c:60
yysptr
char * yysptr
ODLerror_count
int ODLerror_count
Definition:
output.c:58
yylineno
int yylineno
odlinter.h
Aggregate_Node
Definition:
odldef.h:110
ODLPrintWarning
void ODLPrintWarning()
YYNEWLINE
#define YYNEWLINE
Definition:
rdlabel.c:50
yyout
FILE * yyout
Definition:
lexan.c:20
MISR Toolkit - Copyright © 2005 - 2020 Jet Propulsion Laboratory
Generated on Fri Jun 19 2020 22:49:51