Initial creation.

This commit is contained in:
agibert 2001-12-17 01:12:41 +00:00
parent 72db530dbf
commit e22b2d8353
3 changed files with 588 additions and 0 deletions

8
demo/Makefile Normal file
View File

@ -0,0 +1,8 @@
all: demo0
demo0: demo0.c ../lib/opt.h ../lib/libopt.so Makefile
gcc -g -o demo0 -I ../lib -ldl ../lib/libopt.so demo0.c
clean:
rm demo0

290
lib/libopt.h Normal file
View File

@ -0,0 +1,290 @@
/*---------------------------------------------------------------------------------*/
/* $RCSfile: libopt.h,v $ */
/*---------------------------------------------------------------------------------*/
/* $Revision: 1.1 $ */
/* $Name: $ */
/* $Date: 2001/12/17 01:12:41 $ */
/* $Author: agibert $ */
/*---------------------------------------------------------------------------------*/
#ifndef _OPTION_H_
# define _OPTION_H_
# ifdef __cplusplus
extern "C" {
# endif
/*-----------------------------------------------------------------------------------------------------------*/
/* Defines */
/*-----------------------------------------------------------------------------------------------------------*/
#define TIMAD_OPTION_VALUE_LEN (long)64
#define TIMAD_OPTION_VALUE_SIZE (long)(TIMAD_OPTION_VALUE_LEN + 1)
#define TIMAD_OPTION_NAME_TYPE_UNKNOWN (short)0x0
#define TIMAD_OPTION_NAME_TYPE_LONG (short)0x1
#define TIMAD_OPTION_NAME_TYPE_SHORT (short)0x2
#define TIMA_OPTION_NAME_TYPE_ASCII_GET( Type) ( ( Type == TIMAD_OPTION_NAME_TYPE_UNKNOWN) ? "Unknown" : ( ( Type == TIMAD_OPTION_NAME_TYPE_LONG) ? "Long" : ( ( Type == TIMAD_OPTION_NAME_TYPE_SHORT) ? "Short" : "???")))
#define TIMAD_OPTION_ARG_TYPE_UNKNOWN (short)0x0
#define TIMAD_OPTION_ARG_TYPE_MONO (short)0x1
#define TIMAD_OPTION_ARG_TYPE_MULTI (short)0x2
#define TIMA_OPTION_ARG_TYPE_ASCII_GET( Type) ( ( Type == TIMAD_OPTION_ARG_TYPE_UNKNOWN) ? "Unknown" : ( ( Type == TIMAD_OPTION_ARG_TYPE_MONO) ? "Mono" : ( ( Type == TIMAD_OPTION_ARG_TYPE_MULTI) ? "Multi" : "???")))
#define TIMAD_OPTION_VALUE_TYPE_UNKNOWN (short)0x0
#define TIMAD_OPTION_VALUE_TYPE_FLAG (short)0x1
#define TIMAD_OPTION_VALUE_TYPE_LONG (short)0x2
#define TIMAD_OPTION_VALUE_TYPE_STRING (short)0x3
#define TIMA_OPTION_VALUE_TYPE_ASCII_GET( Type) ( ( Type == TIMAD_OPTION_VALUE_TYPE_UNKNOWN) ? "Unknown" : ( ( Type == TIMAD_OPTION_VALUE_TYPE_FLAG) ? "Flag" : ( ( Type == TIMAD_OPTION_VALUE_TYPE_LONG) ? "Long" : ( ( Type == TIMAD_OPTION_VALUE_TYPE_STRING) ? "String" : "???"))))
#define TIMAD_OPTION_ARG_NUMBER_MAX (short)32
#define TIMAD_OPTION_ID_UNKNOWN (short)0
#define TIMAD_OPTION_ID_VERSION (short)1
#define TIMAD_OPTION_ID_HELP (short)2
#define TIMAD_OPTION_ID_VERBOSE (short)3
#define TIMAD_OPTION_ID_TRAN_AUTO (short)4
#define TIMAD_OPTION_ID_ENQ_AUTO (short)5
#define TIMAD_OPTION_ID_DUMP_REPOSITORY (short)6
#define TIMAD_OPTION_ID_DUMP_API (short)7
#define TIMAD_OPTION_ID_DUMP_CSV (short)8
#define TIMAD_OPTION_ID_DUMP_SQL (short)9
#define TIMAD_OPTION_ID_CSCS_DIR (short)10
#define TIMAD_OPTION_ID_CONFIG_FILE (short)11
#define TIMAD_OPTION_ID_DUMP_DIR (short)12
#define TIMAD_OPTION_ID_PORT (short)13
#define TIMAD_OPTION_ID_UNIT_ENABLED (short)14
#define TIMAD_OPTION_ID_UNIT_DISABLED (short)15
#define TIMAD_OPTION_ID_MANAGER_ENABLED (short)16
#define TIMAD_OPTION_ID_MANAGER_DISABLED (short)17
#define TIMAD_OPTION_ID_UNIT_MANAGER_ENABLED (short)18
#define TIMAD_OPTION_ID_UNIT_MANAGER_DISABLED (short)19
#define TIMAD_OPTION_ID_NULL (short)20
#define TIMAD_OPTION_ENV_UNKNOWN (short)0x0
#define TIMAD_OPTION_ENV_DEFAULT (short)0x1
#define TIMAD_OPTION_ENV_CONFIG (short)0x2
#define TIMAD_OPTION_ENV_COMMAND (short)0x3
#define TIMAD_OPTION_ENV_CURRENT (short)0x4
#define TIMAD_OPTION_ENV_NUMBER (short)5
#define TIMA_OPTION_ENV_ASCII_GET( Env) ( ( Env == TIMAD_OPTION_ENV_UNKNOWN) ? "Unknown" : ( ( Env == TIMAD_OPTION_ENV_CURRENT) ? "Current" : ( ( Env == TIMAD_OPTION_ENV_DEFAULT) ? "Default" : ( ( Env == TIMAD_OPTION_ENV_CONFIG) ? "Config" : ( ( Env == TIMAD_OPTION_ENV_COMMAND) ? "Command" : "???")))))
#define TIMAD_OPTION_SWITCH_SHORT_LEN (short)4
#define TIMAD_OPTION_SWITCH_SHORT_SIZE (short)(TIMAD_OPTION_SWITCH_SHORT_LEN + 1)
#define TIMAD_OPTION_SWITCH_LONG_LEN (short)24
#define TIMAD_OPTION_SWITCH_LONG_SIZE (short)(TIMAD_OPTION_SWITCH_LONG_LEN + 1)
#define TIMAD_OPTION_LABEL_LEN (short)32
#define TIMAD_OPTION_LABEL_SIZE (short)(TIMAD_OPTION_LABEL_LEN + 1)
#define TIMAD_OPTION_ARG_LABEL_LEN (short)16
#define TIMAD_OPTION_ARG_LABEL_SIZE (short)(TIMAD_OPTION_ARG_LABEL_LEN + 1)
#define TIMAD_OPTION_DEFAULT \
{ \
{ { "???", "???", "???", "???"}, "Unknown option", "", TIMAD_OPTION_ARG_TYPE_UNKNOWN, 1, { TIMAD_OPTION_VALUE_TYPE_UNKNOWN}, TIMAD_UNKNOWN}, \
\
{ { "version", "V", "", ""}, "Print TIMA version and exit", "", TIMAD_OPTION_ARG_TYPE_MONO, 1, { TIMAD_OPTION_VALUE_TYPE_FLAG}, TIMAD_FALSE}, \
{ { "help", "h", "", ""}, "Print TIMA help and exit", "", TIMAD_OPTION_ARG_TYPE_MONO, 1, { TIMAD_OPTION_VALUE_TYPE_FLAG}, TIMAD_FALSE}, \
\
{ { "verbose", "v", "quiet", "q"}, "verbose output", "", TIMAD_OPTION_ARG_TYPE_MONO, 1, { TIMAD_OPTION_VALUE_TYPE_FLAG}, TIMAD_FALSE}, \
{ { "tran_auto","ta", "tran_man", "tm"},"transaction auto reply", "", TIMAD_OPTION_ARG_TYPE_MONO, 1, { TIMAD_OPTION_VALUE_TYPE_FLAG}, TIMAD_FALSE}, \
{ { "enq_auto", "ea", "enq_man", "em"},"enquery auto reply", "", TIMAD_OPTION_ARG_TYPE_MONO, 1, { TIMAD_OPTION_VALUE_TYPE_FLAG}, TIMAD_FALSE}, \
\
{ { "dump_repository", "dr"}, "Dump Meridian repository", "", TIMAD_OPTION_ARG_TYPE_MONO, 1, { TIMAD_OPTION_VALUE_TYPE_FLAG}, TIMAD_FALSE}, \
{ { "dump_api", "da"}, "Dump messages format in text", "", TIMAD_OPTION_ARG_TYPE_MONO, 1, { TIMAD_OPTION_VALUE_TYPE_FLAG}, TIMAD_FALSE}, \
{ { "dump_csv", "dc"}, "Dump messages format in CSV", "", TIMAD_OPTION_ARG_TYPE_MONO, 1, { TIMAD_OPTION_VALUE_TYPE_FLAG}, TIMAD_FALSE}, \
{ { "dump_sql", "ds"}, "Dump messages format in SQL", "", TIMAD_OPTION_ARG_TYPE_MONO, 1, { TIMAD_OPTION_VALUE_TYPE_FLAG}, TIMAD_FALSE}, \
\
{ { "cscs_dir", "cd"}, "Set CSCS directory name", "<CSCS_Dir>", TIMAD_OPTION_ARG_TYPE_MONO, 2, { TIMAD_OPTION_VALUE_TYPE_STRING}, "%CSCSPATH%"}, \
{ { "config_file", "cf"}, "Set config file name", "<Config_File>", TIMAD_OPTION_ARG_TYPE_MONO, 2, { TIMAD_OPTION_VALUE_TYPE_STRING}, "tima.ini"}, \
{ { "dump_dir", "dd"}, "Set dump directory name", "<Dump_Dir>", TIMAD_OPTION_ARG_TYPE_MONO, 2, { TIMAD_OPTION_VALUE_TYPE_STRING}, "%CSCSPATH%"}, \
\
{ { "port", "p"}, "Set CSCS tcp port", "<CSCS_Port>", TIMAD_OPTION_ARG_TYPE_MONO, 2, { TIMAD_OPTION_VALUE_TYPE_LONG}, "0"}, \
\
{ { "unit_enable", "ue"}, "Enable an unit", "<Unit>", TIMAD_OPTION_ARG_TYPE_MULTI, 2, { TIMAD_OPTION_VALUE_TYPE_STRING}, TIMAD_UNKNOWN}, \
{ { "unit_disable", "ud"}, "Disable an unit", "<Unit>", TIMAD_OPTION_ARG_TYPE_MULTI, 2, { TIMAD_OPTION_VALUE_TYPE_STRING}, TIMAD_UNKNOWN}, \
\
{ { "manager_enable", "me"}, "Enable a manager", "<Manager>", TIMAD_OPTION_ARG_TYPE_MULTI, 2, { TIMAD_OPTION_VALUE_TYPE_STRING}, TIMAD_UNKNOWN}, \
{ { "manager_disable", "md"}, "Disable a manager", "<Manager>", TIMAD_OPTION_ARG_TYPE_MULTI, 2, { TIMAD_OPTION_VALUE_TYPE_STRING}, TIMAD_UNKNOWN}, \
\
{ { "unit_manager_enable", "ume"}, "Enable a unit manager", "<Unit> <Manager>", TIMAD_OPTION_ARG_TYPE_MULTI, 3, { TIMAD_OPTION_VALUE_TYPE_STRING, TIMAD_OPTION_VALUE_TYPE_STRING}, TIMAD_UNKNOWN}, \
{ { "unit_manager_disable", "umd"}, "Disable a unit manager", "<Unit> <Manager>", TIMAD_OPTION_ARG_TYPE_MULTI, 3, { TIMAD_OPTION_VALUE_TYPE_STRING, TIMAD_OPTION_VALUE_TYPE_STRING}, "TIMA Tima"}, \
\
{ { "", "", "", ""}, "Null option", "", TIMAD_OPTION_ARG_TYPE_UNKNOWN, 0, { TIMAD_OPTION_VALUE_TYPE_UNKNOWN}, TIMAD_UNKNOWN}, \
}
#define TIMA_OPT_ENV_FLAG_GET( Option_Tab, Id, Env) ( *(char *)(Option_Tab)[(Id)].OptionValueData_Tab[(Env)].Data)
#define TIMA_OPT_ENV_LONG_GET( Option_Tab, Id, Env) ( *(long *)(Option_Tab)[(Id)].OptionValueData_Tab[(Env)].Data)
#define TIMA_OPT_ENV_STRING_GET( Option_Tab, Id, Env) ( (char *)(Option_Tab)[(Id)].OptionValueData_Tab[(Env)].Data)
#define TIMA_OPT_ENV_GET( Option_Tab, Id, Env) ( ( (Option_Tab)[(Id)].OptionValueData_Tab[(Env)].Type == TIMAD_OPTION_VALUE_TYPE_FLAG) ? (TIMAT_OptionValueData *)TIMA_OPT_ENV_FLAG_GET( (Option_Tab), (Id), (Env)) \
: ( ( (Option_Tab)[(Id)].OptionValueData_Tab[(Env)].Type == TIMAD_OPTION_VALUE_TYPE_LONG) ? (TIMAT_OptionValueData *)TIMA_OPT_ENV_LONG_GET( (Option_Tab), (Id), (Env)) \
: ( ( (Option_Tab)[(Id)].OptionValueData_Tab[(Env)].Type == TIMAD_OPTION_VALUE_TYPE_STRING) ? (TIMAT_OptionValueData *)TIMA_OPT_ENV_STRING_GET( (Option_Tab), (Id), (Env)) : (TIMAT_OptionValueData *)NULL)))
#define TIMA_OPT_CURRENT_FLAG_GET( Id) TIMA_OPT_ENV_FLAG_GET( TIMAG_Option_Tab, (Id), TIMAD_OPTION_ENV_CURRENT)
#define TIMA_OPT_CURRENT_LONG_GET( Id) TIMA_OPT_ENV_LONG_GET( TIMAG_Option_Tab, (Id), TIMAD_OPTION_ENV_CURRENT)
#define TIMA_OPT_CURRENT_STRING_GET( Id) TIMA_OPT_ENV_STRING_GET( TIMAG_Option_Tab, (Id), TIMAD_OPTION_ENV_CURRENT)
#define TIMA_OPT_CURRENT_GET( Id) TIMA_OPT_ENV_GET( TIMAG_Option_Tab, (Id), TIMAD_OPTION_ENV_CURRENT)
#define TIMA_OPT_ENV_FLAG_SET( Option_Tab, Id, Env, Dat) ( *(char *)(Option_Tab)[(Id)].OptionValueData_Tab[(Env)].Data = (char)(Dat))
#define TIMA_OPT_ENV_LONG_SET( Option_Tab, Id, Env, Dat) ( *(long *)(Option_Tab)[(Id)].OptionValueData_Tab[(Env)].Data = (long)(Dat))
#define TIMA_OPT_ENV_STRING_SET( Option_Tab, Id, Env, Dat) if( (short)(Dat) == TIMAD_UNKNOWN) { *((char *)(Option_Tab)[(Id)].OptionValueData_Tab[(Env)].Data) = (char)(Dat);} else { strcpy( (char *)(Option_Tab)[(Id)].OptionValueData_Tab[(Env)].Data, (char *)(Dat));}
#define TIMA_OPT_ENV_SET( Option_Tab, Id, Env, Dat) switch( (Option_Tab)[(Id)].OptionValueData_Tab[(Env)].Type) { \
case TIMAD_OPTION_VALUE_TYPE_FLAG: { TIMA_OPT_ENV_FLAG_SET( (Option_Tab), (Id), (Env), (Dat)); break; } \
case TIMAD_OPTION_VALUE_TYPE_LONG: { TIMA_OPT_ENV_LONG_SET( (Option_Tab), (Id), (Env), (Dat)); break; } \
case TIMAD_OPTION_VALUE_TYPE_STRING: { TIMA_OPT_ENV_STRING_SET( (Option_Tab), (Id), (Env), (Dat)); break; }}
#define TIMA_OPT_CURRENT_FLAG_SET( Id, Data) TIMA_OPT_ENV_FLAG_SET( TIMAG_Option_Tab, TIMAD_OPTION_ENV_CURRENT, (Id), (Data))
#define TIMA_OPT_CURRENT_LONG_SET( Id, Data) TIMA_OPT_ENV_LONG_SET( TIMAG_Option_Tab, TIMAD_OPTION_ENV_CURRENT, (Id), (Data))
#define TIMA_OPT_CURRENT_STRING_SET( Id, Data) TIMA_OPT_ENV_LONG_SET( TIMAG_Option_Tab, TIMAD_OPTION_ENV_CURRENT, (Id), (Data))
#define TIMA_OPT_CURRENT_SET( Id) TIMA_OPT_ENV_SET( TIMAG_Option_Tab, TIMAD_OPTION_ENV_CURRENT, (Id))
/*-----------------------------------------------------------------------------------------------------------*/
/* Types */
/*-----------------------------------------------------------------------------------------------------------*/
typedef char TIMAT_OptionValueData[TIMAD_OPTION_VALUE_SIZE];
typedef struct TIMAT_OptionValue
{
short Type;
TIMAT_OptionValueData Data;
NDT_Node *Node;
} TIMAT_OptionValue;
typedef struct TIMAT_Option
{
union
{
struct
{
char Switch_On_Long[TIMAD_OPTION_SWITCH_LONG_SIZE];
char Switch_On_Short[TIMAD_OPTION_SWITCH_SHORT_SIZE];
char Switch_Off_Long[TIMAD_OPTION_SWITCH_LONG_SIZE];
char Switch_Off_Short[TIMAD_OPTION_SWITCH_SHORT_SIZE];
};
struct
{
char Switch_Long[TIMAD_OPTION_SWITCH_LONG_SIZE];
char Switch_Short[TIMAD_OPTION_SWITCH_SHORT_SIZE];
};
};
char Label[TIMAD_OPTION_LABEL_SIZE];
char Arg_Label[TIMAD_OPTION_ARG_LABEL_SIZE];
short Arg_Type;
short Arg_Number;
short Value_Type_Tab[TIMAD_OPTION_ARG_NUMBER_MAX];
char OptionValueData_Flat_Default[ TIMAD_OPTION_ARG_NUMBER_MAX * ( TIMAD_OPTION_VALUE_SIZE + 1)];
union
{
TIMAT_OptionValue OptionValueData_Tab[TIMAD_OPTION_ENV_NUMBER];
NDT_Root *OptionValueStruct_Tab[TIMAD_OPTION_ENV_NUMBER];
};
} TIMAT_Option;
/*-----------------------------------------------------------------------------------------------------------*/
/* Prototypes */
/*-----------------------------------------------------------------------------------------------------------*/
# ifdef _OPTION_C_
NDT_Status Manager_OptionValueStruct( NDT_Root *, NDT_Index_Id, NDT_Node *, NDT_Command, va_list);
TIMAT_Status TIMA_Opt_Eval( char *, int, char *);
TIMAT_Status Opt_Option_String_Parse( int *, char **, char *);
TIMAT_Status Opt_Option_Value_Copy( TIMAT_Option *, short, short, int *, int, char **, short);
TIMAT_Status Opt_Option_Init( TIMAT_Option *);
TIMAT_Status Opt_Option_DeInit( TIMAT_Option *);
TIMAT_Status TIMA_Opt_Init( void);
TIMAT_Status TIMA_Opt_DeInit( void);
TIMAT_Status Opt_Option_Value_Load( TIMAT_Option *, short, int *, int, char **);
TIMAT_Status Opt_Option_Arg_Parse( TIMAT_Option *, short, int, char **);
TIMAT_Status Opt_Option_File_Parse( TIMAT_Option *, short, char *);
TIMAT_Status Opt_Option_Env_Copy( TIMAT_Option *, short, short);
TIMAT_Status TIMA_Opt_Option_Load( int, char **);
TIMAT_Status TIMA_Opt_OptionValue_Print( FILE *, TIMAT_OptionValue *);
TIMAT_Status TIMA_Opt_Option_Print( FILE *, TIMAT_Option *);
TIMAT_Status TIMA_Opt_Option_Dump( FILE *, TIMAT_Option *);
TIMAT_Status TIMA_Opt_OptionValue_Next( TIMAT_OptionValue **, TIMAT_OptionValue *, TIMAT_Option *, short);
TIMAT_Status TIMA_Opt_Obj_Status_Get( short *, short, short, short, short, TIMAT_OptionValueData *);
# else
extern TIMAT_Status TIMA_Opt_Eval( char *, int, char *);
extern TIMAT_Status TIMA_Opt_Init( void);
extern TIMAT_Status TIMA_Opt_DeInit( void);
extern TIMAT_Status TIMA_Opt_Option_Load( int, char **);
extern TIMAT_Status TIMA_Opt_OptionValue_Print( FILE *, TIMAT_OptionValue *);
extern TIMAT_Status TIMA_Opt_Option_Print( FILE *, TIMAT_Option *);
extern TIMAT_Status TIMA_Opt_Option_Dump( FILE *, TIMAT_Option *);
extern TIMAT_Status TIMA_Opt_OptionValue_Next( TIMAT_OptionValue **, TIMAT_OptionValue *, TIMAT_Option *, short);
extern TIMAT_Status TIMA_Opt_Obj_Status_Get( short *, short, short, short, short, TIMAT_OptionValueData *);
# endif
/*-----------------------------------------------------------------------------------------------------------*/
/* Global Variables */
/*-----------------------------------------------------------------------------------------------------------*/
# ifdef _OPTION_C_
TIMAT_Option TIMAG_Option_Tab[] = TIMAD_OPTION_DEFAULT;
static NDT_Index_Type TIMAG_OptionValue_Type_Initial_Tab[] =
{
( NDD_INDEX_STATUS_OPENED | NDD_INDEX_TYPE_LIST | NDD_INDEX_SUBTYPE_FIFO)
};
static NDT_Index_Type TIMAG_OptionValue_Type_Fitial_Tab[] =
{
( NDD_INDEX_STATUS_OPENED | NDD_INDEX_TYPE_TREE | NDD_INDEX_SUBTYPE_BALANCED)
};
# else
extern TIMAT_Option TIMAG_Option_Tab[];
# endif
/*-----------------------------------------------------------------------------------------------------------*/
# ifdef __cplusplus
}
# endif
#endif

290
lib/opt.h Normal file
View File

@ -0,0 +1,290 @@
/*---------------------------------------------------------------------------------*/
/* $RCSfile: opt.h,v $ */
/*---------------------------------------------------------------------------------*/
/* $Revision: 1.1 $ */
/* $Name: $ */
/* $Date: 2001/12/17 01:12:41 $ */
/* $Author: agibert $ */
/*---------------------------------------------------------------------------------*/
#ifndef _OPTION_H_
# define _OPTION_H_
# ifdef __cplusplus
extern "C" {
# endif
/*-----------------------------------------------------------------------------------------------------------*/
/* Defines */
/*-----------------------------------------------------------------------------------------------------------*/
#define TIMAD_OPTION_VALUE_LEN (long)64
#define TIMAD_OPTION_VALUE_SIZE (long)(TIMAD_OPTION_VALUE_LEN + 1)
#define TIMAD_OPTION_NAME_TYPE_UNKNOWN (short)0x0
#define TIMAD_OPTION_NAME_TYPE_LONG (short)0x1
#define TIMAD_OPTION_NAME_TYPE_SHORT (short)0x2
#define TIMA_OPTION_NAME_TYPE_ASCII_GET( Type) ( ( Type == TIMAD_OPTION_NAME_TYPE_UNKNOWN) ? "Unknown" : ( ( Type == TIMAD_OPTION_NAME_TYPE_LONG) ? "Long" : ( ( Type == TIMAD_OPTION_NAME_TYPE_SHORT) ? "Short" : "???")))
#define TIMAD_OPTION_ARG_TYPE_UNKNOWN (short)0x0
#define TIMAD_OPTION_ARG_TYPE_MONO (short)0x1
#define TIMAD_OPTION_ARG_TYPE_MULTI (short)0x2
#define TIMA_OPTION_ARG_TYPE_ASCII_GET( Type) ( ( Type == TIMAD_OPTION_ARG_TYPE_UNKNOWN) ? "Unknown" : ( ( Type == TIMAD_OPTION_ARG_TYPE_MONO) ? "Mono" : ( ( Type == TIMAD_OPTION_ARG_TYPE_MULTI) ? "Multi" : "???")))
#define TIMAD_OPTION_VALUE_TYPE_UNKNOWN (short)0x0
#define TIMAD_OPTION_VALUE_TYPE_FLAG (short)0x1
#define TIMAD_OPTION_VALUE_TYPE_LONG (short)0x2
#define TIMAD_OPTION_VALUE_TYPE_STRING (short)0x3
#define TIMA_OPTION_VALUE_TYPE_ASCII_GET( Type) ( ( Type == TIMAD_OPTION_VALUE_TYPE_UNKNOWN) ? "Unknown" : ( ( Type == TIMAD_OPTION_VALUE_TYPE_FLAG) ? "Flag" : ( ( Type == TIMAD_OPTION_VALUE_TYPE_LONG) ? "Long" : ( ( Type == TIMAD_OPTION_VALUE_TYPE_STRING) ? "String" : "???"))))
#define TIMAD_OPTION_ARG_NUMBER_MAX (short)32
#define TIMAD_OPTION_ID_UNKNOWN (short)0
#define TIMAD_OPTION_ID_VERSION (short)1
#define TIMAD_OPTION_ID_HELP (short)2
#define TIMAD_OPTION_ID_VERBOSE (short)3
#define TIMAD_OPTION_ID_TRAN_AUTO (short)4
#define TIMAD_OPTION_ID_ENQ_AUTO (short)5
#define TIMAD_OPTION_ID_DUMP_REPOSITORY (short)6
#define TIMAD_OPTION_ID_DUMP_API (short)7
#define TIMAD_OPTION_ID_DUMP_CSV (short)8
#define TIMAD_OPTION_ID_DUMP_SQL (short)9
#define TIMAD_OPTION_ID_CSCS_DIR (short)10
#define TIMAD_OPTION_ID_CONFIG_FILE (short)11
#define TIMAD_OPTION_ID_DUMP_DIR (short)12
#define TIMAD_OPTION_ID_PORT (short)13
#define TIMAD_OPTION_ID_UNIT_ENABLED (short)14
#define TIMAD_OPTION_ID_UNIT_DISABLED (short)15
#define TIMAD_OPTION_ID_MANAGER_ENABLED (short)16
#define TIMAD_OPTION_ID_MANAGER_DISABLED (short)17
#define TIMAD_OPTION_ID_UNIT_MANAGER_ENABLED (short)18
#define TIMAD_OPTION_ID_UNIT_MANAGER_DISABLED (short)19
#define TIMAD_OPTION_ID_NULL (short)20
#define TIMAD_OPTION_ENV_UNKNOWN (short)0x0
#define TIMAD_OPTION_ENV_DEFAULT (short)0x1
#define TIMAD_OPTION_ENV_CONFIG (short)0x2
#define TIMAD_OPTION_ENV_COMMAND (short)0x3
#define TIMAD_OPTION_ENV_CURRENT (short)0x4
#define TIMAD_OPTION_ENV_NUMBER (short)5
#define TIMA_OPTION_ENV_ASCII_GET( Env) ( ( Env == TIMAD_OPTION_ENV_UNKNOWN) ? "Unknown" : ( ( Env == TIMAD_OPTION_ENV_CURRENT) ? "Current" : ( ( Env == TIMAD_OPTION_ENV_DEFAULT) ? "Default" : ( ( Env == TIMAD_OPTION_ENV_CONFIG) ? "Config" : ( ( Env == TIMAD_OPTION_ENV_COMMAND) ? "Command" : "???")))))
#define TIMAD_OPTION_SWITCH_SHORT_LEN (short)4
#define TIMAD_OPTION_SWITCH_SHORT_SIZE (short)(TIMAD_OPTION_SWITCH_SHORT_LEN + 1)
#define TIMAD_OPTION_SWITCH_LONG_LEN (short)24
#define TIMAD_OPTION_SWITCH_LONG_SIZE (short)(TIMAD_OPTION_SWITCH_LONG_LEN + 1)
#define TIMAD_OPTION_LABEL_LEN (short)32
#define TIMAD_OPTION_LABEL_SIZE (short)(TIMAD_OPTION_LABEL_LEN + 1)
#define TIMAD_OPTION_ARG_LABEL_LEN (short)16
#define TIMAD_OPTION_ARG_LABEL_SIZE (short)(TIMAD_OPTION_ARG_LABEL_LEN + 1)
#define TIMAD_OPTION_DEFAULT \
{ \
{ { "???", "???", "???", "???"}, "Unknown option", "", TIMAD_OPTION_ARG_TYPE_UNKNOWN, 1, { TIMAD_OPTION_VALUE_TYPE_UNKNOWN}, TIMAD_UNKNOWN}, \
\
{ { "version", "V", "", ""}, "Print TIMA version and exit", "", TIMAD_OPTION_ARG_TYPE_MONO, 1, { TIMAD_OPTION_VALUE_TYPE_FLAG}, TIMAD_FALSE}, \
{ { "help", "h", "", ""}, "Print TIMA help and exit", "", TIMAD_OPTION_ARG_TYPE_MONO, 1, { TIMAD_OPTION_VALUE_TYPE_FLAG}, TIMAD_FALSE}, \
\
{ { "verbose", "v", "quiet", "q"}, "verbose output", "", TIMAD_OPTION_ARG_TYPE_MONO, 1, { TIMAD_OPTION_VALUE_TYPE_FLAG}, TIMAD_FALSE}, \
{ { "tran_auto","ta", "tran_man", "tm"},"transaction auto reply", "", TIMAD_OPTION_ARG_TYPE_MONO, 1, { TIMAD_OPTION_VALUE_TYPE_FLAG}, TIMAD_FALSE}, \
{ { "enq_auto", "ea", "enq_man", "em"},"enquery auto reply", "", TIMAD_OPTION_ARG_TYPE_MONO, 1, { TIMAD_OPTION_VALUE_TYPE_FLAG}, TIMAD_FALSE}, \
\
{ { "dump_repository", "dr"}, "Dump Meridian repository", "", TIMAD_OPTION_ARG_TYPE_MONO, 1, { TIMAD_OPTION_VALUE_TYPE_FLAG}, TIMAD_FALSE}, \
{ { "dump_api", "da"}, "Dump messages format in text", "", TIMAD_OPTION_ARG_TYPE_MONO, 1, { TIMAD_OPTION_VALUE_TYPE_FLAG}, TIMAD_FALSE}, \
{ { "dump_csv", "dc"}, "Dump messages format in CSV", "", TIMAD_OPTION_ARG_TYPE_MONO, 1, { TIMAD_OPTION_VALUE_TYPE_FLAG}, TIMAD_FALSE}, \
{ { "dump_sql", "ds"}, "Dump messages format in SQL", "", TIMAD_OPTION_ARG_TYPE_MONO, 1, { TIMAD_OPTION_VALUE_TYPE_FLAG}, TIMAD_FALSE}, \
\
{ { "cscs_dir", "cd"}, "Set CSCS directory name", "<CSCS_Dir>", TIMAD_OPTION_ARG_TYPE_MONO, 2, { TIMAD_OPTION_VALUE_TYPE_STRING}, "%CSCSPATH%"}, \
{ { "config_file", "cf"}, "Set config file name", "<Config_File>", TIMAD_OPTION_ARG_TYPE_MONO, 2, { TIMAD_OPTION_VALUE_TYPE_STRING}, "tima.ini"}, \
{ { "dump_dir", "dd"}, "Set dump directory name", "<Dump_Dir>", TIMAD_OPTION_ARG_TYPE_MONO, 2, { TIMAD_OPTION_VALUE_TYPE_STRING}, "%CSCSPATH%"}, \
\
{ { "port", "p"}, "Set CSCS tcp port", "<CSCS_Port>", TIMAD_OPTION_ARG_TYPE_MONO, 2, { TIMAD_OPTION_VALUE_TYPE_LONG}, "0"}, \
\
{ { "unit_enable", "ue"}, "Enable an unit", "<Unit>", TIMAD_OPTION_ARG_TYPE_MULTI, 2, { TIMAD_OPTION_VALUE_TYPE_STRING}, TIMAD_UNKNOWN}, \
{ { "unit_disable", "ud"}, "Disable an unit", "<Unit>", TIMAD_OPTION_ARG_TYPE_MULTI, 2, { TIMAD_OPTION_VALUE_TYPE_STRING}, TIMAD_UNKNOWN}, \
\
{ { "manager_enable", "me"}, "Enable a manager", "<Manager>", TIMAD_OPTION_ARG_TYPE_MULTI, 2, { TIMAD_OPTION_VALUE_TYPE_STRING}, TIMAD_UNKNOWN}, \
{ { "manager_disable", "md"}, "Disable a manager", "<Manager>", TIMAD_OPTION_ARG_TYPE_MULTI, 2, { TIMAD_OPTION_VALUE_TYPE_STRING}, TIMAD_UNKNOWN}, \
\
{ { "unit_manager_enable", "ume"}, "Enable a unit manager", "<Unit> <Manager>", TIMAD_OPTION_ARG_TYPE_MULTI, 3, { TIMAD_OPTION_VALUE_TYPE_STRING, TIMAD_OPTION_VALUE_TYPE_STRING}, TIMAD_UNKNOWN}, \
{ { "unit_manager_disable", "umd"}, "Disable a unit manager", "<Unit> <Manager>", TIMAD_OPTION_ARG_TYPE_MULTI, 3, { TIMAD_OPTION_VALUE_TYPE_STRING, TIMAD_OPTION_VALUE_TYPE_STRING}, "TIMA Tima"}, \
\
{ { "", "", "", ""}, "Null option", "", TIMAD_OPTION_ARG_TYPE_UNKNOWN, 0, { TIMAD_OPTION_VALUE_TYPE_UNKNOWN}, TIMAD_UNKNOWN}, \
}
#define TIMA_OPT_ENV_FLAG_GET( Option_Tab, Id, Env) ( *(char *)(Option_Tab)[(Id)].OptionValueData_Tab[(Env)].Data)
#define TIMA_OPT_ENV_LONG_GET( Option_Tab, Id, Env) ( *(long *)(Option_Tab)[(Id)].OptionValueData_Tab[(Env)].Data)
#define TIMA_OPT_ENV_STRING_GET( Option_Tab, Id, Env) ( (char *)(Option_Tab)[(Id)].OptionValueData_Tab[(Env)].Data)
#define TIMA_OPT_ENV_GET( Option_Tab, Id, Env) ( ( (Option_Tab)[(Id)].OptionValueData_Tab[(Env)].Type == TIMAD_OPTION_VALUE_TYPE_FLAG) ? (TIMAT_OptionValueData *)TIMA_OPT_ENV_FLAG_GET( (Option_Tab), (Id), (Env)) \
: ( ( (Option_Tab)[(Id)].OptionValueData_Tab[(Env)].Type == TIMAD_OPTION_VALUE_TYPE_LONG) ? (TIMAT_OptionValueData *)TIMA_OPT_ENV_LONG_GET( (Option_Tab), (Id), (Env)) \
: ( ( (Option_Tab)[(Id)].OptionValueData_Tab[(Env)].Type == TIMAD_OPTION_VALUE_TYPE_STRING) ? (TIMAT_OptionValueData *)TIMA_OPT_ENV_STRING_GET( (Option_Tab), (Id), (Env)) : (TIMAT_OptionValueData *)NULL)))
#define TIMA_OPT_CURRENT_FLAG_GET( Id) TIMA_OPT_ENV_FLAG_GET( TIMAG_Option_Tab, (Id), TIMAD_OPTION_ENV_CURRENT)
#define TIMA_OPT_CURRENT_LONG_GET( Id) TIMA_OPT_ENV_LONG_GET( TIMAG_Option_Tab, (Id), TIMAD_OPTION_ENV_CURRENT)
#define TIMA_OPT_CURRENT_STRING_GET( Id) TIMA_OPT_ENV_STRING_GET( TIMAG_Option_Tab, (Id), TIMAD_OPTION_ENV_CURRENT)
#define TIMA_OPT_CURRENT_GET( Id) TIMA_OPT_ENV_GET( TIMAG_Option_Tab, (Id), TIMAD_OPTION_ENV_CURRENT)
#define TIMA_OPT_ENV_FLAG_SET( Option_Tab, Id, Env, Dat) ( *(char *)(Option_Tab)[(Id)].OptionValueData_Tab[(Env)].Data = (char)(Dat))
#define TIMA_OPT_ENV_LONG_SET( Option_Tab, Id, Env, Dat) ( *(long *)(Option_Tab)[(Id)].OptionValueData_Tab[(Env)].Data = (long)(Dat))
#define TIMA_OPT_ENV_STRING_SET( Option_Tab, Id, Env, Dat) if( (short)(Dat) == TIMAD_UNKNOWN) { *((char *)(Option_Tab)[(Id)].OptionValueData_Tab[(Env)].Data) = (char)(Dat);} else { strcpy( (char *)(Option_Tab)[(Id)].OptionValueData_Tab[(Env)].Data, (char *)(Dat));}
#define TIMA_OPT_ENV_SET( Option_Tab, Id, Env, Dat) switch( (Option_Tab)[(Id)].OptionValueData_Tab[(Env)].Type) { \
case TIMAD_OPTION_VALUE_TYPE_FLAG: { TIMA_OPT_ENV_FLAG_SET( (Option_Tab), (Id), (Env), (Dat)); break; } \
case TIMAD_OPTION_VALUE_TYPE_LONG: { TIMA_OPT_ENV_LONG_SET( (Option_Tab), (Id), (Env), (Dat)); break; } \
case TIMAD_OPTION_VALUE_TYPE_STRING: { TIMA_OPT_ENV_STRING_SET( (Option_Tab), (Id), (Env), (Dat)); break; }}
#define TIMA_OPT_CURRENT_FLAG_SET( Id, Data) TIMA_OPT_ENV_FLAG_SET( TIMAG_Option_Tab, TIMAD_OPTION_ENV_CURRENT, (Id), (Data))
#define TIMA_OPT_CURRENT_LONG_SET( Id, Data) TIMA_OPT_ENV_LONG_SET( TIMAG_Option_Tab, TIMAD_OPTION_ENV_CURRENT, (Id), (Data))
#define TIMA_OPT_CURRENT_STRING_SET( Id, Data) TIMA_OPT_ENV_LONG_SET( TIMAG_Option_Tab, TIMAD_OPTION_ENV_CURRENT, (Id), (Data))
#define TIMA_OPT_CURRENT_SET( Id) TIMA_OPT_ENV_SET( TIMAG_Option_Tab, TIMAD_OPTION_ENV_CURRENT, (Id))
/*-----------------------------------------------------------------------------------------------------------*/
/* Types */
/*-----------------------------------------------------------------------------------------------------------*/
typedef char TIMAT_OptionValueData[TIMAD_OPTION_VALUE_SIZE];
typedef struct TIMAT_OptionValue
{
short Type;
TIMAT_OptionValueData Data;
NDT_Node *Node;
} TIMAT_OptionValue;
typedef struct TIMAT_Option
{
union
{
struct
{
char Switch_On_Long[TIMAD_OPTION_SWITCH_LONG_SIZE];
char Switch_On_Short[TIMAD_OPTION_SWITCH_SHORT_SIZE];
char Switch_Off_Long[TIMAD_OPTION_SWITCH_LONG_SIZE];
char Switch_Off_Short[TIMAD_OPTION_SWITCH_SHORT_SIZE];
};
struct
{
char Switch_Long[TIMAD_OPTION_SWITCH_LONG_SIZE];
char Switch_Short[TIMAD_OPTION_SWITCH_SHORT_SIZE];
};
};
char Label[TIMAD_OPTION_LABEL_SIZE];
char Arg_Label[TIMAD_OPTION_ARG_LABEL_SIZE];
short Arg_Type;
short Arg_Number;
short Value_Type_Tab[TIMAD_OPTION_ARG_NUMBER_MAX];
char OptionValueData_Flat_Default[ TIMAD_OPTION_ARG_NUMBER_MAX * ( TIMAD_OPTION_VALUE_SIZE + 1)];
union
{
TIMAT_OptionValue OptionValueData_Tab[TIMAD_OPTION_ENV_NUMBER];
NDT_Root *OptionValueStruct_Tab[TIMAD_OPTION_ENV_NUMBER];
};
} TIMAT_Option;
/*-----------------------------------------------------------------------------------------------------------*/
/* Prototypes */
/*-----------------------------------------------------------------------------------------------------------*/
# ifdef _OPTION_C_
NDT_Status Manager_OptionValueStruct( NDT_Root *, NDT_Index_Id, NDT_Node *, NDT_Command, va_list);
TIMAT_Status TIMA_Opt_Eval( char *, int, char *);
TIMAT_Status Opt_Option_String_Parse( int *, char **, char *);
TIMAT_Status Opt_Option_Value_Copy( TIMAT_Option *, short, short, int *, int, char **, short);
TIMAT_Status Opt_Option_Init( TIMAT_Option *);
TIMAT_Status Opt_Option_DeInit( TIMAT_Option *);
TIMAT_Status TIMA_Opt_Init( void);
TIMAT_Status TIMA_Opt_DeInit( void);
TIMAT_Status Opt_Option_Value_Load( TIMAT_Option *, short, int *, int, char **);
TIMAT_Status Opt_Option_Arg_Parse( TIMAT_Option *, short, int, char **);
TIMAT_Status Opt_Option_File_Parse( TIMAT_Option *, short, char *);
TIMAT_Status Opt_Option_Env_Copy( TIMAT_Option *, short, short);
TIMAT_Status TIMA_Opt_Option_Load( int, char **);
TIMAT_Status TIMA_Opt_OptionValue_Print( FILE *, TIMAT_OptionValue *);
TIMAT_Status TIMA_Opt_Option_Print( FILE *, TIMAT_Option *);
TIMAT_Status TIMA_Opt_Option_Dump( FILE *, TIMAT_Option *);
TIMAT_Status TIMA_Opt_OptionValue_Next( TIMAT_OptionValue **, TIMAT_OptionValue *, TIMAT_Option *, short);
TIMAT_Status TIMA_Opt_Obj_Status_Get( short *, short, short, short, short, TIMAT_OptionValueData *);
# else
extern TIMAT_Status TIMA_Opt_Eval( char *, int, char *);
extern TIMAT_Status TIMA_Opt_Init( void);
extern TIMAT_Status TIMA_Opt_DeInit( void);
extern TIMAT_Status TIMA_Opt_Option_Load( int, char **);
extern TIMAT_Status TIMA_Opt_OptionValue_Print( FILE *, TIMAT_OptionValue *);
extern TIMAT_Status TIMA_Opt_Option_Print( FILE *, TIMAT_Option *);
extern TIMAT_Status TIMA_Opt_Option_Dump( FILE *, TIMAT_Option *);
extern TIMAT_Status TIMA_Opt_OptionValue_Next( TIMAT_OptionValue **, TIMAT_OptionValue *, TIMAT_Option *, short);
extern TIMAT_Status TIMA_Opt_Obj_Status_Get( short *, short, short, short, short, TIMAT_OptionValueData *);
# endif
/*-----------------------------------------------------------------------------------------------------------*/
/* Global Variables */
/*-----------------------------------------------------------------------------------------------------------*/
# ifdef _OPTION_C_
TIMAT_Option TIMAG_Option_Tab[] = TIMAD_OPTION_DEFAULT;
static NDT_Index_Type TIMAG_OptionValue_Type_Initial_Tab[] =
{
( NDD_INDEX_STATUS_OPENED | NDD_INDEX_TYPE_LIST | NDD_INDEX_SUBTYPE_FIFO)
};
static NDT_Index_Type TIMAG_OptionValue_Type_Fitial_Tab[] =
{
( NDD_INDEX_STATUS_OPENED | NDD_INDEX_TYPE_TREE | NDD_INDEX_SUBTYPE_BALANCED)
};
# else
extern TIMAT_Option TIMAG_Option_Tab[];
# endif
/*-----------------------------------------------------------------------------------------------------------*/
# ifdef __cplusplus
}
# endif
#endif