#include <popt.h>
#include <glib/gstrfuncs.h>
#include <glib/glist.h>
+#include <glib/gutils.h> /* for g_atexit() */
/* Are we initialized? */
}
+static void captive_shutdown_atexit(void);
+
+
/**
* captive_init:
* @captive_args: String with possible options to parse by popt.
errbool=captive_w32_init();
g_return_val_if_fail(errbool==TRUE,FALSE);
+ g_atexit(captive_shutdown_atexit);
+
active=TRUE;
return TRUE;
}
+
+
+/**
+ * captive_shutdown:
+ *
+ * Closes down %libcaptive. It should flush all pending buffers and successfuly
+ * close the filesystem. Variable #captive_image_iochannel will be set to %NULL,
+ * you should close such channel yourself.
+ *
+ * Returns: %TRUE if successfuly shutdown.
+ */
+gboolean captive_shutdown(void)
+{
+ g_return_val_if_fail(active==TRUE,FALSE);
+ g_return_val_if_fail(captive_image_iochannel!=NULL,FALSE);
+
+ /* FIXME: ntoskrnl/ex/power.c/NtShutdownSystem() does
+ * IoShutdownRegistered{Devices,FileSystems} order; is it correct?
+ */
+ IoShutdownRegisteredFileSystems();
+ IoShutdownRegisteredDevices();
+
+ captive_image_iochannel=NULL;
+
+ active=FALSE;
+ return TRUE;
+}
+
+
+static void captive_shutdown_atexit(void)
+{
+ if (active)
+ captive_shutdown();
+}