cconfsrv — Common configuration server
This is special XATMI server shipped with Enduro/X in order to provide common-configuration (ini file) parsing facilities to all programming languages which are provided by Enduro/X. The idea behind the configuration server is that it uses XATMI API (exposed as service) in order to get configuration section or list all configuration that is used by application. Configuration service name advertised by this server is @CCONF.
This server is optional and can be used by third party application in oder to read the configuration files via standard XATMI service calls.
cconfsrv engine processes environment variables or special functions variables and $[PARAMETER] for functions. The value can be escaped with
Substitution functions in values for the ini parameters (keys).
Get mode (EX_CC_CMD UBF buffer set to g (default)). In this mode the request for configuration is made for particular section. The config files (or directories) for which to do the lookup can be set in EX_CC_RESOURCE field, you may use multiple occurrences. If field is not set, then lookup is done in all files which are loaded into configuration library. This includes Enduro/X own config files, which are set in NDRX_CCONFIG environment variables (see ex_env(5)). The get request must contain EX_CC_LOOKUPSECTION field, which indicates the section to lookup.
EX_CC_LOOKUPSECTION can be set to lookup the sub-sections, for example if you have in config files:
/paht/to/test1.ini:
[TEST1] PARAM1=value1 PARAM2=value2 [TEST1/SUB1] PARAM3=value3 PARAM5=value5
/path/to/test2.ini:
[TEST1/SUB1/SUB2] PARAM3=value4
Then by doing lookup to TEST1/SUB1/SUB2 section, you will get following result:
Request buffer:
EX_CC_CMD g EX_CC_LOOKUPSECTION TEST1/SUB1/SUB2 EX_CC_RESOURCE /paht/to/test1.ini EX_CC_RESOURCE /paht/to/test2.ini
Response buffer:
EX_CC_SECTION test1 EX_CC_KEY PARAM1 EX_CC_VALUE value1 EX_CC_SECTION test2 EX_CC_KEY PARAM2 EX_CC_VALUE value2 EX_CC_SECTION TEST1/SUB1/SUB2 EX_CC_KEY PARAM3 EX_CC_VALUE value4 EX_CC_SECTION TEST1/SUB1 EX_CC_KEY PARAM5 EX_CC_VALUE value5
Mention that PARAM3 value is set to value4 and not value3, because TEST1/SUB1/SUB2 closer matched the lookup request. The principle is that all parent variables are gathered. If any variable is common between parent and child, then child element will be returned, as it is with higher priority.
When doing requests to configuration server it is possible to request for mandatory field keys checking. The must-have keys are loaded into EX_CC_MANDATORY field occurrences. If during section lookup key is not found, then error 6 is returned.
It is possible request format verification. The key-format fields are used into EX_CC_FORMAT_KEY + EX_CC_FORMAT_FORMAT occurrences. If the format does not match field, error code 7 is returned.
EX_CC_FORMAT_FORMAT field can have following values:
t - Boolean field, valid values starts with on of the following symbols: TtFfYyNn10.
sX..Y or s..Y (e.g. s10..20, s..5) - String field, min length X and max length Y. If X is not set (second format), then X is assumed to be 0.
iX..Y or i..Y (e.g. i1..2, i..3) - Integer field, min len (measured as string) X and max len (measured as string Y.
nX..Y or n..Y (e.g. n2..5, n..3) - Numeric field (can be floating point format). Min length X (measured as string) and max length Y (measured as string).
It is possible to enter in conversational mode in request sections which begins with certain phrase or it is possible to list all sections for given resources. To enter is list mode you need to call the configuration server with EX_CC_CMD UBF buffer field set l. If this is the only field then all sections from default Enduro/X configuration files will be returned.
The sections which starts with phrase can be set in EX_CC_LOOKUPSECTION UBF field occurrences. Resource to lookup can be specified in EX_CC_RESOURCE.
When error occurs, the configuration service returns TPESVCFAIL, and EX_NERROR_CODE is set to corresponding error code. EX_NERROR_MSG have some additional information about error condition.
EX_NERROR_CODE values:
1 Invalid INI file(s).
2 Malloc failed (system have low of memory or some kind of other system related problem).
3 Unix error occurred.
4 Invalid arguments passed.
5 System failure.
6 Mandatory field is missing. EX_NERROR_MSG specifies the exact problematic field.
7 Field value format error. EX_NERROR_MSG specifies the exact problematic field.