extern fr_table_num_ordered_t const date_precision_table[];
extern size_t date_precision_table_len;
-fr_dict_t *dict_alloc(TALLOC_CTX *ctx, char const *name);
+fr_dict_t *dict_alloc(TALLOC_CTX *ctx);
+
+int dict_dlopen(fr_dict_t *dict, char const *name);
/** Initialise fields in a dictionary attribute structure
*
return 0;
}
- dict = dict_alloc(NULL, argv[0]);
+ dict = dict_alloc(NULL);
+
+ /*
+ * Try to load protocol-specific validation routines.
+ * Some protocols don't need them, so it's OK if the
+ * validation routines don't exist.
+ */
+ if (dict_dlopen(dict, argv[0]) < 0) {
+ talloc_free(dict);
+ return -1;
+ }
/*
* Set the root attribute with the protocol name
memcpy(&tmp, &dict_dir_default, sizeof(tmp));
dict_path = dict_subdir ? talloc_asprintf(NULL, "%s%c%s", dict_dir_default, FR_DIR_SEP, dict_subdir) : tmp;
- dict = dict_alloc(dict_ctx, NULL);
+ dict = dict_alloc(dict_ctx);
if (!dict) {
error:
if (!fr_dict_internal) talloc_free(dict);
return fr_hash_table_finddata(dict->values_by_alias, &find);
}
-static int dict_dlopen(fr_dict_t *dict, char const *name)
+int dict_dlopen(fr_dict_t *dict, char const *name)
{
char *module_name;
char *p, *q;
/** Allocate a new dictionary
*
* @param[in] ctx to allocate dictionary in.
- * @param[in] name the name of the protocol
* @return
* - NULL on memory allocation error.
*/
-fr_dict_t *dict_alloc(TALLOC_CTX *ctx, char const *name)
+fr_dict_t *dict_alloc(TALLOC_CTX *ctx)
{
fr_dict_t *dict;
dict->values_by_da = fr_hash_table_create(dict, dict_enum_value_hash, dict_enum_value_cmp, hash_pool_free);
if (!dict->values_by_da) goto error;
- if (dict_dlopen(dict, name) < 0) goto error;
-
/*
- * Try to load libfreeradius-NAME
+ * Set default type size and length.
*/
+ dict->default_type_size = 1;
+ dict->default_type_length = 1;
return dict;
}