예제 #1
0
static void pcf_register_service_parameter(const char *service,
					           const char *suffix,
					           const char *defparam)
{
    char   *name = concatenate(service, suffix, (char *) 0);
    PCF_PARAM_NODE *node;

    /*
     * Skip service parameter names that have built-in definitions. This
     * happens with message delivery transports that have a non-default
     * per-destination concurrency or recipient limit, such as local(8).
     * 
     * Some parameters were tentatively flagged as built-in, but they are
     * service parameters with their own default value. We don't change the
     * default but we correct the parameter class.
     */
    if ((node = PCF_PARAM_TABLE_FIND(pcf_param_table, name)) != 0) {
	PCF_PARAM_CLASS_OVERRIDE(node, PCF_PARAM_FLAG_SERVICE);
    } else {
	PCF_PARAM_TABLE_ENTER(pcf_param_table, name, PCF_PARAM_FLAG_SERVICE,
			  (void *) defparam, pcf_convert_service_parameter);
    }
    myfree(name);
}
예제 #2
0
void    pcf_register_builtin_parameters(const char *procname, pid_t pid)
{
    const char *myname = "pcf_register_builtin_parameters";
    const CONFIG_TIME_TABLE *ctt;
    const CONFIG_BOOL_TABLE *cbt;
    const CONFIG_INT_TABLE *cit;
    const CONFIG_STR_TABLE *cst;
    const CONFIG_STR_FN_TABLE *cft;
    const CONFIG_RAW_TABLE *rst;
    const CONFIG_NINT_TABLE *nst;
    const CONFIG_NBOOL_TABLE *bst;
    const CONFIG_LONG_TABLE *lst;

    /*
     * Sanity checks.
     */
    if (pcf_param_table != 0)
	msg_panic("%s: global parameter table is already initialized", myname);

    /*
     * Initialize the global parameter table.
     */
    pcf_param_table = PCF_PARAM_TABLE_CREATE(1000);

    /*
     * Add the built-in parameters to the global name space. The class
     * (built-in) is tentative; some parameters are actually service-defined,
     * but they have their own default value.
     */
    for (ctt = pcf_time_table; ctt->name; ctt++)
	PCF_PARAM_TABLE_ENTER(pcf_param_table, ctt->name,
			      PCF_PARAM_FLAG_BUILTIN, (void *) ctt,
			      pcf_conv_time_parameter);
    for (cbt = pcf_bool_table; cbt->name; cbt++)
	PCF_PARAM_TABLE_ENTER(pcf_param_table, cbt->name,
			      PCF_PARAM_FLAG_BUILTIN, (void *) cbt,
			      pcf_conv_bool_parameter);
    for (cit = pcf_int_table; cit->name; cit++)
	PCF_PARAM_TABLE_ENTER(pcf_param_table, cit->name,
			      PCF_PARAM_FLAG_BUILTIN, (void *) cit,
			      pcf_conv_int_parameter);
    for (cst = pcf_str_table; cst->name; cst++)
	PCF_PARAM_TABLE_ENTER(pcf_param_table, cst->name,
			      PCF_PARAM_FLAG_BUILTIN, (void *) cst,
			      pcf_conv_str_parameter);
    for (cft = pcf_str_fn_table; cft->name; cft++)
	PCF_PARAM_TABLE_ENTER(pcf_param_table, cft->name,
			      PCF_PARAM_FLAG_BUILTIN, (void *) cft,
			      pcf_conv_str_fn_parameter);
    for (rst = pcf_raw_table; rst->name; rst++)
	PCF_PARAM_TABLE_ENTER(pcf_param_table, rst->name,
			      PCF_PARAM_FLAG_BUILTIN | PCF_PARAM_FLAG_RAW,
			      (void *) rst, pcf_conv_raw_parameter);
    for (nst = pcf_nint_table; nst->name; nst++)
	PCF_PARAM_TABLE_ENTER(pcf_param_table, nst->name,
			      PCF_PARAM_FLAG_BUILTIN, (void *) nst,
			      pcf_conv_nint_parameter);
    for (bst = pcf_nbool_table; bst->name; bst++)
	PCF_PARAM_TABLE_ENTER(pcf_param_table, bst->name,
			      PCF_PARAM_FLAG_BUILTIN, (void *) bst,
			      pcf_conv_nbool_parameter);
    for (lst = pcf_long_table; lst->name; lst++)
	PCF_PARAM_TABLE_ENTER(pcf_param_table, lst->name,
			      PCF_PARAM_FLAG_BUILTIN, (void *) lst,
			      pcf_conv_long_parameter);

    /*
     * Register legacy parameters (used as a backwards-compatible migration
     * aid).
     */
    for (cst = pcf_legacy_str_table; cst->name; cst++)
	PCF_PARAM_TABLE_ENTER(pcf_param_table, cst->name,
			      PCF_PARAM_FLAG_LEGACY, (void *) cst,
			      pcf_conv_str_parameter);

    /*
     * Register parameters whose default value is normally initialized by
     * ad-hoc code.
     */
    pcf_adhoc_procname.defval = mystrdup(procname);
    PCF_PARAM_TABLE_ENTER(pcf_param_table, pcf_adhoc_procname.name,
			  PCF_PARAM_FLAG_BUILTIN | PCF_PARAM_FLAG_READONLY,
		      (void *) &pcf_adhoc_procname, pcf_conv_str_parameter);
    pcf_adhoc_pid.defval = pid;
    PCF_PARAM_TABLE_ENTER(pcf_param_table, pcf_adhoc_pid.name,
			  PCF_PARAM_FLAG_BUILTIN | PCF_PARAM_FLAG_READONLY,
			  (void *) &pcf_adhoc_pid, pcf_conv_int_parameter);
}