⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mel.h

📁 C语言多种求最优的程序源代码
💻 H
📖 第 1 页 / 共 2 页
字号:
    char msg[MEL_MAX_ERR_MSG_LEN+1];   /* additional info describing err */
} mel_err;			       /* (not same as messages below). */

#define MEL_MAX_NUM_ERR_MESSAGES 13

#ifdef MEL_INIT

/* the following describes each type of enumerated error: */
char mel_err_msg[MEL_MAX_NUM_ERR_MESSAGES][MEL_MAX_ERR_MSG_LEN+1]
    ={"No errors encountered",
      "Can't read file",
      "Can't write file",
      "Unexpected end of file encountered",
      "End of input data encountered",
      "Descriptor/parameter syntax error",
      "Unknown descriptor name",
      "Unknown parameter name",
      "A (or another) parameter name was expected but is missing",
      "Unable to read parameter value(s) for this descriptor",
      "Missing right parenthesis while reading units",
      "Too many (or duplicate) parameters given for this descriptor",
      "Missing brackets around array data"};

#else

extern char mel_err_msg[MEL_MAX_NUM_ERR_MESSAGES][MEL_MAX_ERR_MSG_LEN+1];

#endif /* MEL_INIT */

/*
------------------------------------------------------------------------
"private" declarations:
------------------------------------------------------------------------
*/

/* hide private declarations from those routines that don't need it: */
#ifdef MEL_PRIVATE

/* the possible different types of data that can be associated with a given 
   descriptor's (i.e., input string's) parameters is important and is common 
   to both input and output structures: */ 
enum mel_data_types { 
    mel_none,	       /* default value */
    mel_bool,	       /* true or false */
    mel_int,           /* integer value */
    mel_real,          /* double floating point */
    mel_str,           /* character string */
    mel_int_array,     /* array of mel_int */
    mel_real_array,    /* array of mel_real */
    mel_str_array,     /* array of mel_str */
};

#ifdef MEL_INPUT

/* the following structure (meli_datum) is used to store information from
   the input descriptor string until the application program calls for it
   via MEL. */

struct {
    int start_line;
    int end_line;
	/* what is this descriptor's position in the input stream? 
	   (useful in telling user about where errors took place.) */
    int descrip_type;
	/* for the descriptor that was input, this is its index into
	   meli_descrip[] array of structures (see below). in other words,
	   which descriptor is it? */
    int num_param;
	/* number of parameters that were input. */
    struct {   /* data for each parameter input */
	int name_index;
	    /* this is the parameter's index into the meli_descrip.param[]
	       array, that is, which parameter is this? (see below) */
	union meli_param_data data;
	    /* data associated with this parameter. */
	char units[MELI_UNITS_STR_LEN+1];
	    /* what units are associated with the data? */
	int array_len;
	    /* if the data was an array, how long was it? */
	int unknown_flag;
	    /* is the value of this parameter "unknown"? */
    } param[MELI_MAX_PARAMS];
} meli_datum;

/* input dictionary manifest constants (all must be CUSTOMIZED): */

#define MELI_NUM_DESCRIP_NAMES 4
    /* how many descriptors there are. */
#define MELI_MAX_DESCRIP_NAME_LEN 15
    /* how many characters are in the longest descriptor name? */
#define MELI_MAX_PARAM_NAME_LEN 15
    /* how many characters in the longest parameter name? */

/* input dictionary declaration: */

/* define the data structure used to describe MEL input data: */
struct meli_descrips {   /* for each descriptor: */
    char name[MELI_MAX_DESCRIP_NAME_LEN+1];   
	/* descriptor's name */
    int min_name_len;   
	/* number of characters required to uniquely identify a 
	   descriptor from all others. */
    int max_num_param;  
	/* total number of parameters associated with this descriptor. */
    struct {   /* for each parameter: */
	char name[MELI_MAX_PARAM_NAME_LEN+1];   
	    /* parameter's name */
	int min_name_len;  
	    /* number of characters required to uniquely this parameter 
	       from all others for this particular descriptor. */
	enum mel_data_types type;
	    /* is it int, real, etc? */
    } param[MELI_MAX_PARAMS];
};

/* note that initialization will be required only in mel.c: */
#ifdef MEL_INIT

struct meli_descrips meli_descrip[MELI_NUM_DESCRIP_NAMES] = { /* CUSTOMIZED */
    {"program_data", 9, 6,
       {{"program", 1, mel_str},
	{"date", 1, mel_str},
	{"input_filename", 1, mel_str},
	{"output_filename", 1, mel_str},
	{"errors_filename", 1, mel_str},
	{"label", 1, mel_str}}},
    {"program_options", 9, 1,
       {{"output_format", 1, mel_str},
	{"", 0, mel_none},
	{"", 0, mel_none},
	{"", 0, mel_none},
	{"", 0, mel_none},
	{"", 0, mel_none}}},
    {"message", 1, 2,
       {{"code", 1, mel_int},
	{"text", 1, mel_str},
	{"", 0, mel_none},
	{"", 0, mel_none},
	{"", 0, mel_none},
	{"", 0, mel_none}}},
    {"end_of_data", 1, 0,
       {{"", 0, mel_none},
	{"", 0, mel_none},
	{"", 0, mel_none},
	{"", 0, mel_none},
	{"", 0, mel_none},
	{"", 0, mel_none}}}};

#else

extern struct meli_descrips meli_descrip[MELI_NUM_DESCRIP_NAMES];

#endif /* MEL_INIT */

#endif /* MEL_INPUT */

#ifdef MEL_OUTPUT

/* the following structure (melo_datum) is used to store information from the
   application program until output as a descriptor using MEL. */

struct {
    int descrip_type;
	/* for the descriptor to be output, this is its index into
	   melo_descrip[] array of structures (see below). in other words,
	   which descriptor is it? */
    int num_param;
	/* number of parameters to be output. */
    struct {   /* data for each parameter to be output */
	int name_index;
	    /* this is the parameter's index into the melo_descrip.param[]
	       array, that is, which parameter is this? (see below) */
	union melo_param_data data;
	    /* data associated with this parameter. */
	char units[MELO_UNITS_STR_LEN+1];
	    /* what units are associated with the data? */
	int array_len;
	    /* if the data was an array, how long was it? */
	int unknown_flag;
	    /* is the value of this parameter "unknown"? */
    } param[MELO_MAX_PARAMS];
} melo_datum;

/* output dictionary manifest constants (all must be CUSTOMIZED):*/

#define MELO_NUM_DESCRIP_NAMES 4
    /* how many descriptors there are: */
#define MELO_MIN_DESCRIP_NAME_LEN 9
    /* how many characters does it take to uniquely define a descriptor name? */
#define MELO_MAX_DESCRIP_NAME_LEN 15
    /* how many characters in the longest descriptor name? */
#define MELO_MIN_PARAM_NAME_LEN 1
    /* how many chars to uniquely define a parameter name? */
#define MELO_MAX_PARAM_NAME_LEN 15
    /* how may characters in the longest parameter name? */
#define MELO_MAX_DESCRIP_STR_LEN 256
    /* how long may the output string be? */

/* define the data structure used to describe MEL output data: */
struct melo_descrips {
    char name[MELO_MAX_DESCRIP_NAME_LEN+1];
    int min_name_len;
    struct {
	char name[MELO_MAX_PARAM_NAME_LEN+1];
	int min_name_len;
	enum mel_data_types type;
    } param[MELO_MAX_PARAMS];
};

#ifdef MEL_INIT

struct melo_descrips melo_descrip[MELO_NUM_DESCRIP_NAMES] = { /* CUSTOMIZED */
    {"program_data", 9,
       {{"program", 1, mel_str},
	{"date", 1, mel_str},
	{"input_filename", 1, mel_str},
	{"output_filename", 1, mel_str},
	{"errors_filename", 1, mel_str},
	{"label", 1, mel_str}}},
    {"program_options", 9,
       {{"output_format", 1, mel_str},
	{"", 0, mel_none},
	{"", 0, mel_none},
	{"", 0, mel_none},
	{"", 0, mel_none},
	{"", 0, mel_none}}},
    {"message", 1,
       {{"code", 1, mel_int},
	{"text", 1, mel_str},
	{"", 0, mel_none},
	{"", 0, mel_none},
	{"", 0, mel_none},
	{"", 0, mel_none}}},
    {"end_of_data", 1,
       {{"", 0, mel_none},
	{"", 0, mel_none},
	{"", 0, mel_none},
	{"", 0, mel_none},
	{"", 0, mel_none},
	{"", 0, mel_none}}}};

#else

extern struct melo_descrips melo_descrip[MELO_NUM_DESCRIP_NAMES];

#endif /* MEL_INIT */

#endif /* MEL_OUTPUT */

#endif /* MEL_PRIVATE */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -