home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Interactive Guide
/
c-cplusplus-interactive-guide.iso
/
c_ref
/
csource4
/
299_01
/
mel.h
< prev
next >
Wrap
C/C++ Source or Header
|
1989-12-30
|
18KB
|
503 lines
/*
------------------------------------------------------------------------
filename: mel.h
author: g. m. crews
creation date: 25-Jul-1988
date of last revision: 19-Jul-1989
the following defines the input and output interface (called "dictionaries")
between MEL (a generic metalanguage processor) and the engineering analysis
program it is being used for. (see files mel.doc and mel.c for more
information.)
the idea is to use "descriptors" (english-like strings) to make i/o more
readable to an analysis program user or checker. the dictionaries define the
"meanings" of the tokens in the string.
the following data objects form the interface:
input:
char meli_descriptor_string[] input descriptor string
meli_file(...) interpret data from text file
meli(...) interpret data from above string
meli_descrip_type(...) get descriptor type
meli_num_params(...) get number parameters read
meli_param(...) get value of particular parameter
meli_data(...) get parameter data
output:
char melo_descriptor_string[] output descriptor string
melo_init(...) prepare to output descriptor
melo_data(...) put parameter data
melo(...) translate data to above string
melo_file(...) translate and send to text file
errors:
struct {...} mel_err i/o error description
development and testing of any particular set of dictionaries may be
facilitated with a debugging program called test_mel. for more information,
see the file test_mel.c.
NOTE THAT THIS FILE MUST BE CUSTOMIZED FOR EACH TARGET APPLICATION PROGRAM.
APPLICATION DEVELOPERS SHOULD SEARCH FOR THE WORD "CUSTOMIZED" FOR THE
LOCATIONS OF NUMBERS AND OTHER DATA THAT NEED TO CHANGE TO REFLECT
REQUIREMENTS OF THEIR OWN PARTICULAR APPLICATION PROGRAM.
THE PARTICULAR DICTIONARIES CURRENTLY DEFINED ARE SIMPLY A TEST FOR
ILLUSTRATIVE PURPOSES. INPUT AND OUTPUT DICTIONARIES ARE IDENTICAL AND LOOK
LIKE:
program_data,
program = 'sss',
date = 'sss',
input_filename = 'sss',
output_filename = 'sss',
errors_filename = 'sss',
label = 'sss';
program_options,
output_format = 'sss'; "verbose or terse"
message,
code = nnn,
text = 'sss';
end_of_data;
(NOTE THAT nnn STANDS FOR A NUMBER AND 'sss' STANDS FOR A STRING.)
file content: the "public" interface is listed first, followed by the
"private" interface. application programmers should treat MEL as a "black box"
and thus only use the "public" definitions. (note however that manifest
constants, etc., in the "private" area will have to be customized.)
nomemclature: In the following, "meli" is used to label input terms, "melo"
is used to label output terms, and "mel" is used for terms that may apply
to either input or output.
global conditional complilation flags (see mel.doc for more information on
these flags and when to use them) are used to control data hiding and maintain
object oriented approach used for MEL:
MEL_INPUT - define this flag when you wish to use the MEL input object
for your application programs.
MEL_OUTPUT - define this flag when you wish to use MEL for output.
MEL_PRIVATE - users normally should not define this flag when including
mel.h in their application program files. it is used
to define "private" data structures, etc., for internal
MEL routines (see mel.c).
MEL_INIT - developers should also not define this flag for the same
reasons as above.
------------------------------------------------------------------------
*/
/*
------------------------------------------------------------------------
"public" declarations:
------------------------------------------------------------------------
*/
/* if using MEL for input, then must define the MEL input data object: */
#ifdef MEL_INPUT
/* firstly, define input constants (all must be CUSTOMIZED): */
#define MELI_MAX_DESCRIP_STR_LEN 256
/* maximum number of characters in any input descriptor string. */
#define MELI_MAX_PARAMS 6
/* maximum number of parameters for any descriptor (min = 1). */
#define MELI_MAX_PARAM_STR_LEN 80
#define MELI_MAX_PARAM_ARRAY_STR_LEN 1
/* largest allowable parameter string lengths (min = 1) */
#define MELI_MAX_PARAM_INT_ARRAY_LEN 1
#define MELI_MAX_PARAM_REAL_ARRAY_LEN 1
#define MELI_MAX_PARAM_STR_ARRAY_LEN 1
/* maximum number of elements in parameter data arrays (min = 1). */
#define MELI_UNITS_STR_LEN 80
/* maximum length of units associated with any param (min = 1) */
/* secondly, define input data structures: */
union meli_param_data {
int integer;
double real;
char string[MELI_MAX_PARAM_STR_LEN+1];
int integer_array[MELI_MAX_PARAM_INT_ARRAY_LEN];
double real_array[MELI_MAX_PARAM_REAL_ARRAY_LEN];
char string_array[MELI_MAX_PARAM_STR_ARRAY_LEN]
[MELI_MAX_PARAM_ARRAY_STR_LEN+1];
};
/* this is used for input parameter data. it may either be an integer,
real, string, array of integers, array of reals, or an array of
strings. (to save space a union was used.) */
/* thirdly, define input variables: */
char meli_descriptor_string[MELI_MAX_DESCRIP_STR_LEN+1];
/* global storage for the input descriptor string. */
/* lastly, define input functions (typically they return 0 if no error
encountered, else some nonzero error code): */
int meli_file(FILE *meli_file_handle);
/* read a descriptor string from the input stream and call meli().
also, put copy of string read into meli_descriptor_string. */
int meli(void);
/* translate meli_descriptor_string and put information into a private
data structure (meli_datum). */
char *meli_descrip_type(void);
/* return pointer to name of type of descriptor read by meli(). */
int meli_num_params(void);
/* return number of parameters read by meli(). */
int meli_param(int param_num, char *param, union meli_param_data *data,
char *units, int *array_len, int *unknown_flag);
/* fill arguement list with param_num'th parameter read by meli().
(start with param_num = 0.) */
int meli_data(char *param, union meli_param_data *data,
char *units, int *array_len, int *unknown_flag);
/* see if *param was input. if it was, then fill argument list with
data from meli_datum. */
#endif /* MEL_INPUT */
/* if using MEL for output, must define the MEL output data object: */
#ifdef MEL_OUTPUT
/* firstly, define output constants (all must be CUSTOMIZED): */
#define MELO_MAX_DESCRIP_STR_LEN 256
/* how many characters can be in an output descriptor string? */
#define MELO_MAX_PARAMS 6
/* maximum number of parameters for any descriptor. */
#define MELO_MAX_PARAM_STR_LEN 80
#define MELO_MAX_PARAM_ARRAY_STR_LEN 1
/* largest allowable parameter string length. */
#define MELO_MAX_PARAM_INT_ARRAY_LEN 1
#define MELO_MAX_PARAM_REAL_ARRAY_LEN 1
#define MELO_MAX_PARAM_STR_ARRAY_LEN 1
/* maximum number of elements in array of parameter data. */
#define MELO_UNITS_STR_LEN 80
/* maximum string length of any units associated with a param. */
/* secondly, define output data structures: */
union melo_param_data {
int integer;
double real;
char string[MELO_MAX_PARAM_STR_LEN+1];
int integer_array[MELO_MAX_PARAM_INT_ARRAY_LEN];
double real_array[MELO_MAX_PARAM_REAL_ARRAY_LEN];
char string_array[MELO_MAX_PARAM_STR_ARRAY_LEN]
[MELO_MAX_PARAM_ARRAY_STR_LEN+1];
};
/* this is for output parameter data. it may either be an integer, real,
string, array of integers, array of reals, or an array of
strings. (to save space a union was used.) */
/* thirdly, define output variables: */
char melo_descriptor_string[MELO_MAX_DESCRIP_STR_LEN+1];
/* global storage for the output descriptor string. */
/* lastly, define output functions (typically return 0 if no error): */
int melo_init(char *descrip_type);
/* initialize private data structure (melo_datum) to accept parameter
data from following functions. output descriptor type wil