/* * rotn_configure -- * WiredTiger no-op encryption configuration. */ static int rotn_configure(ROTN_ENCRYPTOR *rotn_encryptor, WT_CONFIG_ARG *config) { WT_CONFIG_ITEM k, v; WT_CONFIG_PARSER *config_parser; WT_EXTENSION_API *wtext; /* Extension API */ int ret, t_ret; wtext = rotn_encryptor->wtext; /* Get the configuration string. */ if ((ret = wtext->config_get(wtext, NULL, config, "config", &v)) != 0) return (rotn_error(rotn_encryptor, NULL, ret, "WT_EXTENSION_API.config_get")); /* Step through the list of configuration options. */ if ((ret = wtext->config_parser_open( wtext, NULL, v.str, v.len, &config_parser)) != 0) return (rotn_error(rotn_encryptor, NULL, ret, "WT_EXTENSION_API.config_parser_open")); while ((ret = config_parser->next(config_parser, &k, &v)) == 0) { if (strncmp("rotn_force_error", k.str, k.len) == 0 && strlen("rotn_force_error") == k.len) { rotn_encryptor->force_error = v.val == 0 ? 0 : 1; continue; } else { if ((ret = config_parser->close(config_parser)) != 0) return (rotn_error(rotn_encryptor, NULL, ret, "WT_CONFIG_PARSER.close")); return (rotn_error(rotn_encryptor, NULL, EINVAL, "unknown config key")); } } if ((t_ret = config_parser->close(config_parser)) != 0) return (rotn_error(rotn_encryptor, NULL, t_ret, "WT_CONFIG_PARSER.close")); if (ret != WT_NOTFOUND) return (rotn_error(rotn_encryptor, NULL, ret, "WT_CONFIG_PARSER.next")); return (0); }
/* * csv_customize -- * The customize function creates a customized extractor, * needed to save the field number and format. */ static int csv_customize(WT_EXTRACTOR *extractor, WT_SESSION *session, const char *uri, WT_CONFIG_ITEM *appcfg, WT_EXTRACTOR **customp) { const CSV_EXTRACTOR *orig; CSV_EXTRACTOR *csv_extractor; WT_CONFIG_ITEM field, format; WT_CONFIG_PARSER *parser; WT_EXTENSION_API *wtapi; int ret; long field_num; (void)session; /* Unused parameters */ (void)uri; /* Unused parameters */ orig = (const CSV_EXTRACTOR *)extractor; wtapi = orig->wt_api; if ((ret = wtapi->config_parser_open(wtapi, session, appcfg->str, appcfg->len, &parser)) != 0) return (ret); if ((ret = parser->get(parser, "field", &field)) != 0 || (ret = parser->get(parser, "format", &format)) != 0) { if (ret == WT_NOTFOUND) return (EINVAL); return (ret); } field_num = strtol(field.str, NULL, 10); if (field_num < 0 || field_num > INT_MAX) return (EINVAL); if (format.len != 1 || (format.str[0] != 'S' && format.str[0] != 'i')) return (EINVAL); if ((csv_extractor = calloc(1, sizeof(CSV_EXTRACTOR))) == NULL) return (errno); *csv_extractor = *orig; csv_extractor->field = field_num; csv_extractor->format_isnum = (format.str[0] == 'i'); *customp = (WT_EXTRACTOR *)csv_extractor; return (0); }