Initial original import from: fuse-2.4.2-2.fc4
[captive.git] / src / libcaptive / io / irp.c
1 /* $Id$
2  * reactos spinlock emulation of libcaptive
3  * Copyright (C) 2002 Jan Kratochvil <project-captive@jankratochvil.net>
4  * 
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
8  * 
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.
13  * 
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
17  */
18
19
20 #include "config.h"
21
22 #include "reactos/ddk/iotypes.h"        /* for PIRP */
23 #include <glib/gmessages.h>
24 #include <glib/gmem.h>
25 #include "captive/macros.h"
26 #include <glib/gmain.h>
27 #include "reactos/internal/io.h"        /* for IoSecondStageCompletion() */
28
29
30 struct IofCompleteRequest_register_APC {
31                 PFILE_OBJECT OriginalFileObject;
32                 IRP *Irp;
33                 CHAR PriorityBoost;
34                 };
35
36 static gboolean IofCompleteRequest_register_APC_idle_func(struct IofCompleteRequest_register_APC *APC /*data*/)
37 {
38         g_return_val_if_fail(APC!=NULL,FALSE);  /* remove-me */
39
40         g_log(G_LOG_DOMAIN,G_LOG_LEVEL_DEBUG,"%s: IoSecondStageCompletion(IRP=%p)...",G_STRLOC,APC->Irp);
41         IoSecondStageCompletion(NULL,NULL,(PVOID)&APC->OriginalFileObject,(PVOID)&APC->Irp,(PVOID)&APC->PriorityBoost);
42         g_log(G_LOG_DOMAIN,G_LOG_LEVEL_DEBUG,"%s: ...IoSecondStageCompletion(IRP=%p) done",G_STRLOC,APC->Irp);
43
44         g_free(APC);
45
46         return FALSE;   /* remove-me */
47 }
48
49
50 void IofCompleteRequest_register_APC(PFILE_OBJECT OriginalFileObject,PIRP Irp,CCHAR PriorityBoost)
51 {
52 struct IofCompleteRequest_register_APC *APC;
53
54         g_return_if_fail(Irp!=NULL);
55
56         captive_new(APC);
57         APC->OriginalFileObject=OriginalFileObject;
58         APC->Irp=Irp;
59         APC->PriorityBoost=PriorityBoost;
60
61         g_idle_add_full(
62                         G_PRIORITY_DEFAULT_IDLE,        /* priority */
63                         (GSourceFunc)IofCompleteRequest_register_APC_idle_func, /* function */
64                         APC,    /* data */
65                         NULL);  /* notify */
66 }