void register_dbms_parameters(const char *param_value, const char *(flag_parameter) (const char *, int, PC_MASTER_ENT *), PC_MASTER_ENT *local_scope) { const PC_DBMS_INFO *dp; char *bufp; char *db_type; char *prefix; static VSTRING *buffer = 0; static VSTRING *candidate = 0; const char **cpp; /* * XXX This does not examine both sides of conditional macro expansion, * and may expand the "wrong" conditional macros. This is the best we can * do for legacy database configuration support. */ if (buffer == 0) buffer = vstring_alloc(100); bufp = expand_parameter_value(buffer, SHOW_EVAL, param_value, local_scope); /* * Naive parsing. We don't really know if the parameter specifies free * text or a list of databases. */ while ((db_type = mystrtok(&bufp, " ,\t\r\n")) != 0) { /* * Skip over "proxy:" maptypes, to emulate the proxymap(8) server's * behavior when opening a local database configuration file. */ while ((prefix = split_at(db_type, ':')) != 0 && strcmp(db_type, DICT_TYPE_PROXY) == 0) db_type = prefix; /* * Look for database:prefix where the prefix is not a pathname and * the database is a known type. Synthesize candidate parameter names * from the user-defined prefix and from the database-defined suffix * list, and see if those parameters have a "name=value" entry in the * local or global namespace. */ if (prefix != 0 && *prefix != '/' && *prefix != '.') { for (dp = dbms_info; dp->db_type != 0; dp++) { if (strcmp(db_type, dp->db_type) == 0) { for (cpp = dp->db_suffixes; *cpp; cpp++) { vstring_sprintf(candidate ? candidate : (candidate = vstring_alloc(30)), "%s_%s", prefix, *cpp); flag_parameter(STR(candidate), PC_PARAM_FLAG_DBMS | PC_PARAM_FLAG_USER, local_scope); } break; } } } } }
void register_dbms_parameters(const char *param_value, const char *(flag_parameter) (const char *, int, char *), PC_MASTER_ENT *local_scope) { const PC_DBMS_INFO *dp; char *bufp; char *db_type; char *prefix; static VSTRING *buffer = 0; static VSTRING *candidate = 0; const char **cpp; /* * Emulate Postfix parameter value expansion, prepending the appropriate * local (master.cf "-o name-value") namespace to the global (main.cf * "name=value") namespace. * * XXX This does not examine both sides of conditional macro expansion, and * may expand the "wrong" conditional macros. This is the best we can do * for legacy database configuration support. */ #define NO_SCAN_FILTER ((char *) 0) (void) mac_expand(buffer ? buffer : (buffer = vstring_alloc(100)), param_value, MAC_EXP_FLAG_RECURSE, NO_SCAN_FILTER, register_dbms_parameters_cb, (char *) local_scope); /* * Naive parsing. We don't really know if the parameter specifies free * text or a list of databases. */ bufp = STR(buffer); while ((db_type = mystrtok(&bufp, " ,\t\r\n")) != 0) { /* * Skip over "proxy:" indirections. */ while ((prefix = split_at(db_type, ':')) != 0 && strcmp(db_type, DICT_TYPE_PROXY) == 0) db_type = prefix; /* * Look for database:prefix where the prefix is not a pathname and * the database is a known type. Synthesize candidate parameter names * from the user-defined prefix and from the database-defined suffix * list, and see if those parameters have a "name=value" entry in the * local or global namespace. */ if (prefix != 0 && *prefix != '/' && *prefix != '.') { for (dp = dbms_info; dp->db_type != 0; dp++) { if (strcmp(db_type, dp->db_type) == 0) { for (cpp = dp->db_suffixes; *cpp; cpp++) { vstring_sprintf(candidate ? candidate : (candidate = vstring_alloc(30)), "%s_%s", prefix, *cpp); flag_parameter(STR(candidate), 0, (char *) local_scope); } break; } } } } }
static void pcf_register_dbms_helper(char *str_value, const char *(flag_parameter) (const char *, int, PCF_MASTER_ENT *), PCF_MASTER_ENT *local_scope) { const PCF_DBMS_INFO *dp; char *db_type; char *prefix; static VSTRING *candidate = 0; const char **cpp; char *err; /* * Naive parsing. We don't really know if this substring specifies a * database or some other text. */ while ((db_type = mystrtokq(&str_value, " ,\t\r\n", "{}")) != 0) { /* * Skip over "proxy:" maptypes, to emulate the proxymap(8) server's * behavior when opening a local database configuration file. */ while ((prefix = split_at(db_type, ':')) != 0 && strcmp(db_type, DICT_TYPE_PROXY) == 0) db_type = prefix; /* * Look for database:prefix where the prefix is not a pathname and * the database is a known type. Synthesize candidate parameter names * from the user-defined prefix and from the database-defined suffix * list, and see if those parameters have a "name=value" entry in the * local or global namespace. */ if (prefix != 0 && *prefix != '/' && *prefix != '.') { if (*prefix == '{') { /* } */ if ((err = extpar(&prefix, "{}", EXTPAR_FLAG_NONE)) != 0) { /* XXX Encapsulate this in pcf_warn() function. */ if (local_scope) msg_warn("%s:%s: %s", MASTER_CONF_FILE, local_scope->name_space, err); else msg_warn("%s: %s", MAIN_CONF_FILE, err); myfree(err); } pcf_register_dbms_helper(prefix, flag_parameter, local_scope); } else { for (dp = pcf_dbms_info; dp->db_type != 0; dp++) { if (strcmp(db_type, dp->db_type) == 0) { for (cpp = dp->db_suffixes; *cpp; cpp++) { vstring_sprintf(candidate ? candidate : (candidate = vstring_alloc(30)), "%s_%s", prefix, *cpp); flag_parameter(STR(candidate), PCF_PARAM_FLAG_DBMS | PCF_PARAM_FLAG_USER, local_scope); } break; } } } } } }