mirror of
https://github.com/samba-team/samba.git
synced 2025-02-23 09:57:40 +03:00
lib:param: Add lpcfg_parse_enum_vals()
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
This commit is contained in:
parent
5a733c3c1b
commit
93e97d5afd
@ -3678,3 +3678,33 @@ char *lpcfg_substituted_string(TALLOC_CTX *mem_ctx,
|
||||
raw_value,
|
||||
lp_sub->private_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Parse a string value of a given parameter to its integer enum value.
|
||||
*
|
||||
* @param[in] param_name The parameter name (e.g. 'client smb encrypt')
|
||||
*
|
||||
* @param[in] param_value The parameter value (e.g. 'required').
|
||||
*
|
||||
* @return The integer value of the enum the param_value matches or INT32_MIN
|
||||
* on error.
|
||||
*/
|
||||
int32_t lpcfg_parse_enum_vals(const char *param_name,
|
||||
const char *param_value)
|
||||
{
|
||||
struct parm_struct *parm = NULL;
|
||||
int32_t ret = INT32_MIN;
|
||||
bool ok;
|
||||
|
||||
parm = lpcfg_parm_struct(NULL, param_name);
|
||||
if (parm == NULL) {
|
||||
return INT32_MIN;
|
||||
}
|
||||
|
||||
ok = lp_set_enum_parm(parm, param_value, &ret);
|
||||
if (!ok) {
|
||||
return INT32_MIN;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -316,6 +316,8 @@ bool lp_do_section(const char *pszSectionName, void *userdata);
|
||||
bool store_lp_set_cmdline(const char *pszParmName, const char *pszParmValue);
|
||||
|
||||
int num_parameters(void);
|
||||
int32_t lpcfg_parse_enum_vals(const char *param_name,
|
||||
const char *param_value);
|
||||
|
||||
struct loadparm_substitution;
|
||||
#ifdef LOADPARM_SUBSTITUTION_INTERNALS
|
||||
|
Loading…
x
Reference in New Issue
Block a user