char *sr_path;
DAT_OS_FILE *sr_file;
- sr_path = dat_os_getenv (DAT_SR_CONF_ENV);
- if ( sr_path == NULL )
- {
- sr_path = DAT_SR_CONF_DEFAULT;
- }
-
- dat_os_dbg_print (DAT_OS_DBG_TYPE_SR,
- "DAT Registry: static registry file <%s> \n", sr_path);
+ sr_path = dat_os_getenv(DAT_SR_CONF_ENV);
- sr_file = dat_os_fopen (sr_path);
- if ( sr_file == NULL )
+ /* environment override */
+ if ((sr_path != NULL) && ((sr_file = dat_os_fopen(sr_path)) == NULL))
{
- goto bail;
+ dat_os_dbg_print(DAT_OS_DBG_TYPE_ERROR,
+ "DAT Registry: DAT_OVERRIDE, "
+ "bad filename - %s, aborting\n",
+ sr_path);
+ goto bail;
+ }
+
+ if (sr_path == NULL) {
+
+#ifdef DAT_CONF
+ sr_path = DAT_CONF;
+#else
+ sr_path = DAT_SR_CONF_DEFAULT;
+#endif
+ sr_file = dat_os_fopen (sr_path);
+ if (sr_file == NULL)
+ {
+#ifdef DAT_CONF
+ dat_os_dbg_print(DAT_OS_DBG_TYPE_ERROR,
+ "DAT Registry: sysconfdir, "
+ "bad filename - %s, retry default at %s\n",
+ sr_path, DAT_SR_CONF_DEFAULT);
+ /* try default after sysconfdir fails */
+ sr_path = DAT_SR_CONF_DEFAULT;
+ sr_file = dat_os_fopen(sr_path);
+ if (sr_file == NULL) {
+#endif
+ dat_os_dbg_print(DAT_OS_DBG_TYPE_ERROR,
+ "DAT Registry: default, "
+ "bad filename - %s, aborting\n",
+ sr_path);
+ goto bail;
+#ifdef DAT_CONF
+ }
+#endif
+ }
}
+ dat_os_dbg_print(DAT_OS_DBG_TYPE_GENERIC,
+ "DAT Registry: using config file %s\n", sr_path);
+
for (;;)
{
if ( DAT_SUCCESS == dat_sr_parse_eof (sr_file) )
}
else
{
+ dat_os_dbg_print(DAT_OS_DBG_TYPE_ERROR,
+ "DAT Registry: ERROR parsing - %s\n",
+ sr_path);
goto cleanup;
}
}
- if (0 != dat_os_fclose (sr_file))
+ if (0 != dat_os_fclose (sr_file))
+ {
+ dat_os_dbg_print(DAT_OS_DBG_TYPE_ERROR,
+ "DAT Registry: ERROR closing - %s\n",
+ sr_path);
goto bail;
+ }
return DAT_SUCCESS;
cleanup:
dat_os_fclose(sr_file);
bail:
- dat_os_dbg_print(DAT_OS_DBG_TYPE_ERROR,
- "ERROR: unable to parse static registry file, dat.conf\n");
return DAT_INTERNAL_ERROR;
}