2 * reactos I/O streams management of libcaptive
3 * Copyright (C) 2003 Jan Kratochvil <project-captive@jankratochvil.net>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; exactly version 2 of June 1991 is required
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "reactos/ddk/iofuncs.h" /* self */
23 #include <glib/gmessages.h>
24 #include <glib/ghash.h>
27 /* map: (FILE_OBJECT *) -> GINT_TO_POINTER(1) */
28 static GHashTable *captive_stream_file_object_hash;
30 /* initialize 'captive_stream_file_object_hash' */
31 static void captive_stream_file_object_hash_init(void)
33 if (captive_stream_file_object_hash)
35 captive_stream_file_object_hash=g_hash_table_new(g_direct_hash,g_direct_equal);
39 BOOLEAN IoCreateStreamFileObjectLite_is_owner(FILE_OBJECT *FileObject)
41 g_return_val_if_fail(FileObject!=NULL,FALSE);
43 captive_stream_file_object_hash_init();
45 return !!g_hash_table_lookup(captive_stream_file_object_hash,FileObject);
49 void IoCreateStreamFileObjectLite_remove(FILE_OBJECT *FileObject)
53 g_return_if_fail(FileObject!=NULL);
55 captive_stream_file_object_hash_init();
57 errbool=g_hash_table_remove(captive_stream_file_object_hash,FileObject);
58 g_assert(errbool==TRUE);
62 PFILE_OBJECT IoCreateStreamFileObjectLite(IN PFILE_OBJECT FileObject OPTIONAL,IN PDEVICE_OBJECT DeviceObject OPTIONAL)
66 captive_stream_file_object_hash_init();
68 r=IoCreateStreamFileObject(FileObject,DeviceObject);
69 g_return_val_if_fail(r!=NULL,NULL);
71 g_assert(NULL==g_hash_table_lookup(captive_stream_file_object_hash,r)); /* paranoia sanity */
73 g_hash_table_insert(captive_stream_file_object_hash,r,GINT_TO_POINTER(1));