bes Updated for version 3.21.1
The Backend Server (BES) is the lower two tiers of the Hyrax data server
eval_eqn.h
1/*
2 * FILENAME: eval_eqn.h
3 *
4 * PURPOSE: Define equation constants and data structures, and prototype functions
5 *
6 * AUTHOR: Kevin Frender (kbf@ngdc.noaa.gov)
7 *
8 * USAGE: #include <eval_eqn.h>
9 *
10 * COMMENTS:
11 *
12 * CAVEAT:
13 * No claims are made as to the suitability of the accompanying
14 * source code for any purpose. Although this source code has been
15 * used by the NOAA, no warranty, expressed or implied, is made by
16 * NOAA or the United States Government as to the accuracy and
17 * functioning of this source code, nor shall the fact of distribution
18 * constitute any such endorsement, and no responsibility is assumed
19 * by NOAA in connection therewith. The source code contained
20 * within was developed by an agency of the U.S. Government.
21 * NOAA's National Geophysical Data Center has no objection to the
22 * use of this source code for any purpose since it is not subject to
23 * copyright protection in the U.S. If this source code is incorporated
24 * into other software, a statement identifying this source code may be
25 * required under 17 U.S.C. 403 to appear with any copyright notice.
26 */
27
28/* avoid multiple includes */
29#ifndef EE_ERR_UNKNOWN
30
31#define EE_SCRATCH_EQN_LEN 1024
32
33/* Errors occuring in the ee_ functions */
34#define EE_ERR_UNKNOWN 1
35#define EE_ERR_ODD_NUM_PARENS 2
36#define EE_ERR_ODD_NUM_BRACKETS 3
37#define EE_ERR_MEM_LACK 4
38#define EE_ERR_NO_VARS 5
39#define EE_ERR_TOO_MANY_VARS 6
40#define EE_ERR_DOMAIN 7
41#define EE_ERR_MEM_CORRUPT 8
42#define EE_ERR_POUND_SIGN 9
43#define EE_ERR_DOLLAR_SIGN 10
44#define EE_ERR_EQN_BAD 11
45#define EE_ERR_ODD_NUM_QUOTES 12
46#define EE_ERR_VAR_NAME_BAD 13
47#define EE_ERR_BAD_OP_ON_CHAR 14
48#define EE_ERR_BAD_OP_ON_NUM 15
49#define EE_ERR_UNSUPPORTED 16
50#define EE_ERR_EQN_TOO_LONG 17
51
52/* The variable types that ee_ functions can handle */
53#define EE_VAR_TYPE_UNKNOWN 0
54#define EE_VAR_TYPE_NUMERIC 1
55#define EE_VAR_TYPE_CHAR 2
56
57typedef struct eqninfstruct {
58#ifdef FF_CHK_ADDR
59 struct eqninfstruct *check_address;
60#endif
61 unsigned char *equation; /* This is where the step-by-step instructions are */
62 unsigned char *variable_type; /* The type of the various variables */
63 void **variable_ptr; /* Used as a VARIABLE_PTR to VAR structs */
64 char **variable; /* The array of variable names */
65 double *eqn_vars; /* The "workspace" for the ee_ functions */
66 int ee_scratch_int; /* Used internally by the ee_ parsing functions */
67 int eqn_len; /* Length of the instruction set */
68 unsigned char num_vars; /* The number of variables */
69 unsigned char numconst; /* The number of constants (numeric & text) */
70 unsigned char num_work; /* The number of "working" variables */
71 unsigned char result; /* The position in the array where result is found */
72 unsigned char num_strc; /* The number of string constants */
73} EQUATION_INFO, *EQUATION_INFO_PTR;
74
75/* Functions in eval_eqn.c (There are many more, but only these should be called) */
76void ee_show_err_mesg(char *buffer, int error);
77double ee_evaluate_equation(EQUATION_INFO_PTR einfo, int *error);
78EQUATION_INFO_PTR ee_clean_up_equation(char *eqn, int *error);
79
80#ifdef FREEFORM
81/* Functions in eqn_util.c */
82#include <freeform.h>
83
84int ee_check_vars_exist(EQUATION_INFO_PTR einfo, FORMAT_PTR eqn_format);
85int ee_set_var_values(EQUATION_INFO_PTR einfo, void *record, FORMAT_PTR eqn_format);
86int ee_set_var_types(char *eqn, FORMAT_PTR eqn_format);
87int ee_free_einfo(EQUATION_INFO_PTR einfo);
88EQUATION_INFO_PTR ee_make_std_equation(char *equation, FORMAT_PTR eqn_format);
89#endif
90
91#ifndef FF_VALIDATE
92#ifdef FF_CHK_ADDR
93#define FF_VALIDATE(o) assert(o);assert((void *)o == (o)->check_address);
94#else
95#define FF_VALIDATE(o) assert(o);
96#endif
97#endif
98
99#endif /* End of include file */
100