MISR Toolkit  1.5.1
output.c
Go to the documentation of this file.
1 /*****************************************************************************
2 
3  Description: Routines for writing error messages, warning messages and the
4  statements written by PrintLabel and WriteLabel.
5 
6  Author: Randy Davis, University of Colorado LASP
7 
8  Creation Date: 25 August 1990
9  Last Modified: 18 May, 1991
10 
11  History:
12 
13  Creation - This set of routines was introduced in Version 2 of the
14  ODLC library. These routines are 'standard' versions of output
15  routines for the error and warning messages generated while reading
16  and parsing a label and for the statements written by PrintLabel and
17  WriteLabel. The error and warning routines put out messages to the
18  'stderr' file. ODLPrintStmt writes to the 'stdout' file. ODLWriteStmt
19  writes to a file specified by the first argument to the routine. These
20  routines were introduced in the Version 2.0 release of the ODLC library.
21  Software developers using the ODLC package can customize their
22  program's output by providing their own versions of these routines.
23  For example, user-provided versions of the print routines might be
24  used to place output into special windows on a workstation screen.
25 
26  Version 2.1 - 14 March 1991 - R. Davis, U. of Colorado LASP
27  a) Defined the ODLerror_count and ODLwarning_count global variables in
28  this module rather than in the file with the parser action routines.
29  Also added a new global variable, ODLlinenumber_flag, to make the
30  reporting of line numbers in error/warning messages optional. This
31  allows the error routines to be used for other purposes than
32  printing and writing messages from the label parser.
33  b) Added routine ODLPrintInfo to print information messages.
34 
35  Version 2.2 - 18 May 1991 - M. DeMore, Jet Propulsion Laboratory
36  Removed include statements that were Unix specific and placed them
37  in odldef.h. Added include file odlinter.h.
38 
39  19-Jun-1995 ANS Changed the ODLPrintError, PrintWarning and
40  Print Info functions to write the ouput to
41  the logfile
42 
43 *****************************************************************************/
44 
45 #include "odldef.h"
46 #include "odlinter.h"
47 /*#include "PGS_tk.h"
48 #include "PGS_SMF.h"*/
49 
50 /* The following external variable is defined and set by the lexical
51  analyzer and is used here in error reporting. */
52 
53 extern int yylineno; /* Current source line number */
54 
55 /* The following external variables are defined here and used in other
56  modules */
57 
58 int ODLerror_count; /* Cumulative count of errors */
59 int ODLwarning_count; /* Cumulative count of warnings */
60 int ODLlinenumber_flag; /* TRUE if line number to be reported in message */
61 
62 
63 
64 /*****************************************************************************
65 
66  Routine: ODLPrintError
67 
68  Description: Prints a message reporting an error detected during the
69  parsing of an ODL label.
70 
71  Input:
72  error_msg - Character string with text of error message.
73 
74  Output: The error message string is printed to the stderr output file.
75 
76 *****************************************************************************/
77 
78 #ifndef EOSDIS /* GMS: if we are the EOSDIS project, the
79  * output has been redirected to IK_Syslog */
81  char error_msg[])
82 {
83  char errHead[30];
84 /*
85  if (ODLlinenumber_flag)
86  {
87 */
88  /* Include the line number in the error message */
89 /*
90  fprintf (stderr, "**Error at line %d:\n", yylineno);
91  }
92  else
93  {
94  fprintf (stderr, "**Error:");
95  }
96 */
97  /* Put out the error message text and increment the error count */
98 
99 /* fprintf (stderr, " %s\n", error_msg);
100 */
101 
102  if(ODLlinenumber_flag) sprintf(errHead, "ODL Error at line %d:", yylineno);
103  else
104  {
105  sprintf(errHead, "ODL Error:");
106 
107  }
108  /*(void) PGS_SMF_SetDynamicMsg(PGSMET_E_ODL_ERROR, error_msg, errHead);*/
109  printf("%s\n",errHead);
110  ODLerror_count++;
111 
112  return;
113 }
114 
115 
116 
117 /*****************************************************************************
118 
119  Routine: ODLPrintWarning
120 
121  Description: Prints a message to warn of a non-fatal problem detected
122  during the parsing of an ODL label.
123 
124  Input:
125  warning - Character string with text of warning message.
126 
127  Output: The warning message string is printed to the stderr output file.
128 
129 *****************************************************************************/
130 
132  char warning[])
133 {
134  char warningHead[30];
135 /*
136  if (ODLlinenumber_flag)
137  {
138 */
139  /* Include the line number in the warning message */
140 /*
141  fprintf (stderr, "**Warning at line %d:\n", yylineno);
142  }
143  else
144  {
145  fprintf (stderr, "**Warning:");
146  }
147 */
148 
149  /* Put out the warning message text and increment the warning count */
150 /*
151 
152  fprintf (stderr, " %s\n", warning);
153 */
154  if(ODLlinenumber_flag) sprintf(warningHead, "ODL Warning at line %d:", yylineno);
155  else
156  {
157  sprintf(warningHead, "ODL Warning:");
158 
159  }
160  /* (void) PGS_SMF_SetDynamicMsg(PGSMET_W_ODL_WARNING, warning, warningHead); */
161  printf("%s\n",warningHead);
163 
164  return;
165 }
166 
167 
168 
169 /*****************************************************************************
170 
171  Routine: ODLPrintInfo
172 
173  Description: Prints a message to inform the user of a situation that
174  is important but not an error or warning.
175 
176  Input:
177  info_message - Character string with text of the message.
178 
179  Output: The message string is printed to the stdout output file.
180 
181 *****************************************************************************/
182 
183 
185  char info_message[])
186 {
187 
188  /* Put out the message text */
189 
190  fprintf (stdout, "**Note: %s\n", info_message);
191 
192  /*(void) PGS_SMF_SetDynamicMsg(PGSMET_M_ODL_INFO, info_message, "Note: ");*/
193 
194  return;
195 }
196 
197 #endif
198 
199 
200 
201 /*****************************************************************************
202 
203  Routine: ODLPrintStmt
204 
205  Description: Prints an ODL statement.
206 
207  Input:
208  stmt - Character string with statement to be printed.
209 
210  Output: The statement is printed to the stdout output file.
211 
212 *****************************************************************************/
213 
214 
216  char statement[])
217 {
218 
219  fputs (statement, stdout);
220 
221  return;
222 }
223 
224 
225 
226 
227 /*****************************************************************************
228 
229  Routine: ODLWriteStmt
230 
231  Description: Writes an ODL label statement to the specified file.
232 
233  Input:
234  output_file - Pointer to file to which statement is to be written.
235  statement - Character string with statement to be written.
236 
237  Output: The statement is printed to the output file.
238 
239 *****************************************************************************/
240 
241 
243  FILE *output_file,
244  char statement[])
245 {
246 
247  fputs (statement, output_file);
248  /* len =strlen(statement);
249 fwrite(output_file, len, statement);
250 */
251  return;
252 }
void ODLPrintStmt(char statement[])
Definition: output.c:215
int yylineno
void ODLPrintWarning(char warning[])
Definition: output.c:131
int ODLlinenumber_flag
Definition: output.c:60
void ODLPrintError(char error_msg[])
Definition: output.c:80
void ODLPrintInfo(char info_message[])
Definition: output.c:184
int ODLwarning_count
Definition: output.c:59
void ODLWriteStmt(FILE *output_file, char statement[])
Definition: output.c:242
H5TOOLS_DLL void error_msg(const char *fmt,...)
int ODLerror_count
Definition: output.c:58

MISR Toolkit - Copyright © 2005 - 2020 Jet Propulsion Laboratory
Generated on Fri Jun 19 2020 22:49:51