#ifdef FIRMWARE_DIR
const char *builtindir;
#endif
- const char *subdir;
+ const char *subdir, *env;
const char *const *datadirs;
- FILE *file;
+ FILE *file = NULL;
(void)cb_data;
return SR_ERR_ARG;
}
- file = try_open_file(g_get_user_data_dir(), subdir, name);
+ env = g_getenv("SIGROK_FIRMWARE_DIR");
+ if (!env)
+ sr_dbg("SIGROK_FIRMWARE_DIR environment variable not set, ignoring.");
+ else
+ file = try_open_file(env, "", name);
+
+ if (!file)
+ file = try_open_file(g_get_user_data_dir(), subdir, name);
+
/*
* Scan the hard-coded directory before the system directories to
* avoid picking up possibly outdated files from a system install.
file = try_open_file(*datadirs++, subdir, name);
}
if (!file) {
- sr_err("Failed to locate '%s'.", name);
+ sr_dbg("Failed to locate '%s'.", name);
return SR_ERR;
}
return SR_ERR_ARG;
}
if (open_cb && close_cb && read_cb) {
- ctx->resource_open_cb = open_cb;
+ ctx->resource_open_cb = open_cb;
ctx->resource_close_cb = close_cb;
- ctx->resource_read_cb = read_cb;
- ctx->resource_cb_data = cb_data;
+ ctx->resource_read_cb = read_cb;
+ ctx->resource_cb_data = cb_data;
} else if (!open_cb && !close_cb && !read_cb) {
- ctx->resource_open_cb = &resource_open_default;
+ ctx->resource_open_cb = &resource_open_default;
ctx->resource_close_cb = &resource_close_default;
- ctx->resource_read_cb = &resource_read_default;
- ctx->resource_cb_data = ctx;
+ ctx->resource_read_cb = &resource_read_default;
+ ctx->resource_cb_data = ctx;
} else {
sr_err("%s: inconsistent callback pointers.", __func__);
return SR_ERR_ARG;
ret = (*ctx->resource_open_cb)(res, name, ctx->resource_cb_data);
if (ret != SR_OK)
- sr_err("Failed to open resource '%s'.", name);
+ sr_err("Failed to open resource '%s' (use loglevel 5/spew for"
+ " details).", name);
return ret;
}
* @param max_size Size limit. Error out if the resource is larger than this.
*
* @return A buffer containing the resource data, or NULL on failure. Must
- * be freed by the caller using g_free().
+ * be freed by the caller using g_free().
*
* @private
*/