#include "abort.h"
#include "chimara-glk.h"
#include "chimara-glk-private.h"
+#include "gi_blorb.h"
ChimaraGlkPrivate *glk_data = NULL;
/* Stop any timers */
glk_request_timer_events(0);
+ /* Close any open resource files */
+ if(glk_data->resource_map != NULL) {
+ giblorb_destroy_map(glk_data->resource_map);
+ glk_stream_close(glk_data->resource_file, NULL);
+ }
+
glk_data = NULL;
g_thread_exit(NULL);
}
--- /dev/null
+#include "resource.h"
+
+extern ChimaraGlkPrivate *glk_data;
+
+/**
+ * giblorb_set_resource_map:
+ * @file The file stream to read the resource map from
+ *
+ * This function tells the library that the file is indeed the Blorby source
+ * of all resource goodness. Whenever your program calls an image or sound
+ * function, such as glk_image_draw(), the library will search this file for
+ * the resource you request.
+ *
+ * Do not close the stream after calling this function. The library is
+ * responsible for closing the stream at shutdown time.
+ */
+giblorb_err_t
+giblorb_set_resource_map(strid_t file)
+{
+ giblorb_map_t *newmap; /* create map allocates memory */
+ giblorb_err_t error = giblorb_create_map(file, &newmap);
+
+ if(error != giblorb_err_None) {
+ g_free(newmap);
+ return error;
+ }
+
+ /* Check if there was already an existing resource map */
+ if(glk_data->resource_map != NULL) {
+ WARNING("Overwriting existing resource map.\n");
+ giblorb_destroy_map(glk_data->resource_map);
+ glk_stream_close(glk_data->resource_file, NULL);
+ }
+
+ glk_data->resource_map = newmap;
+ glk_data->resource_file = file;
+ return giblorb_err_None;
+}
+
+/**
+ * giblorb_get_resource_map:
+ *
+ * This function returns the current resource map being used. Returns NULL
+ * if #giblorb_set_resource_map() has not been called yet.
+ */
+giblorb_map_t*
+giblorb_get_resource_map()
+{
+ if(glk_data->resource_map == NULL) {
+ WARNING("Resource map not set yet.\n");
+ }
+
+ return glk_data->resource_map;
+}