+captive_leave() to replace g_idle*() function calls postponing
authorshort <>
Thu, 1 May 2003 09:13:34 +0000 (09:13 +0000)
committershort <>
Thu, 1 May 2003 09:13:34 +0000 (09:13 +0000)
 - g_idle*() can get executed during KeWaitForSingleObject()

src/libcaptive/client/leave.c [new file with mode: 0644]
src/libcaptive/include/captive/leave.h [new file with mode: 0644]

diff --git a/src/libcaptive/client/leave.c b/src/libcaptive/client/leave.c
new file mode 100644 (file)
index 0000000..1b492f9
--- /dev/null
@@ -0,0 +1,73 @@
+/* $Id$
+ * Code of leaving libcaptive to be called to cleanup W32 fs state
+ * Copyright (C) 2003 Jan Kratochvil <project-captive@jankratochvil.net>
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; exactly version 2 of June 1991 is required
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+
+#include "config.h"
+
+#include "captive/leave.h"     /* self */
+#include <glib/gtypes.h>
+#include <glib/gmessages.h>
+#include "captive/macros.h"
+#include <glib/ghook.h>
+
+
+
+static GHookList captive_leave_hooklist;
+
+
+static void captive_leave_hooklist_init(void)
+{
+       if (captive_leave_hooklist.is_setup)
+               return;
+
+       g_hook_list_init(&captive_leave_hooklist,sizeof(GHook));
+}
+
+
+void captive_leave(void)
+{
+GHookList captive_leave_hooklist_local;
+
+       for (;;) {
+               captive_leave_hooklist_init();
+               if (!captive_leave_hooklist.hooks)
+                       break;
+
+               captive_leave_hooklist_local=captive_leave_hooklist;
+               captive_leave_hooklist.is_setup=FALSE;
+
+               g_hook_list_invoke(&captive_leave_hooklist_local,
+                               FALSE); /* may_recurse */
+               g_hook_list_clear(&captive_leave_hooklist_local);
+               }
+}
+
+
+void captive_leave_register(captive_leave_func func,gpointer data)
+{
+GHook *ghook;
+
+       g_return_if_fail(func!=NULL);
+
+       captive_leave_hooklist_init();
+
+       ghook=g_hook_alloc(&captive_leave_hooklist);
+       ghook->func=func;
+       ghook->data=data;
+       g_hook_append(&captive_leave_hooklist,ghook);
+}
diff --git a/src/libcaptive/include/captive/leave.h b/src/libcaptive/include/captive/leave.h
new file mode 100644 (file)
index 0000000..30eb43a
--- /dev/null
@@ -0,0 +1,36 @@
+/* $Id$
+ * Include file for code of leaving libcaptive to be called to cleanup W32 fs state
+ * Copyright (C) 2003 Jan Kratochvil <project-captive@jankratochvil.net>
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; exactly version 2 of June 1991 is required
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+
+#ifndef _CAPTIVE_LEAVE_H
+#define _CAPTIVE_LEAVE_H 1
+
+
+#include <glib/gtypes.h>
+
+
+G_BEGIN_DECLS
+
+void captive_leave(void);
+typedef void (*captive_leave_func)(gpointer data);
+void captive_leave_register(captive_leave_func func,gpointer data);
+
+G_END_DECLS
+
+
+#endif /* _CAPTIVE_LEAVE_H */